neutrino: port rounded corner code from tuxbox CVS

This allows to set all four corners separately. The default is
now to have all four corners rounded if radius is > 0 in paintBoxRel.
It also places hard coded integer numbers for CORNER_TOP and
CORNER_BOTTOM with the respective #defines.
This should make it much easier to port over code parts from tuxbox.org.
However, there are probably bugs and oversights in that I did not find
yet. Reports are welcome.

git-svn-id: file:///home/bas/coolstream_public_svn/THIRDPARTY/applications/neutrino-experimental@45 e54a6e83-5905-42d5-8d5c-058d10e6a962
This commit is contained in:
seife
2009-12-13 22:23:23 +00:00
parent af169c19ff
commit b0b471210f
31 changed files with 126 additions and 114 deletions

View File

@@ -44,7 +44,7 @@ class CFBWindow
CFBWindow(const int _x, const int _y, const int _dx, const int _dy);
~CFBWindow();
void paintBoxRel(const int _x, const int _y, const int _dx, const int _dy, const color_t _col, int radius = 0, int type = 0);
void paintBoxRel(const int _x, const int _y, const int _dx, const int _dy, const color_t _col, int radius = 0, int type = 0xF);
bool paintIcon(const char * const _filename, const int _x, const int _y, const color_t _offset = 1);
void RenderString(const font_t _font, const int _x, const int _y, const int _width, const char * const _text, const color_t _color, const int _boxheight = 0, const bool _utf8_encoded = false);
};

View File

@@ -500,6 +500,10 @@ void CFrameBuffer::paintBoxRel(const int x, const int y, const int dx, const int
if (!getActive())
return;
int corner_tl = (type & CORNER_TOP_LEFT) ? 1 : 0;
int corner_tr = (type & CORNER_TOP_RIGHT) ? 1 : 0;
int corner_bl = (type & CORNER_BOTTOM_LEFT) ? 1 : 0;
int corner_br = (type & CORNER_BOTTOM_RIGHT) ? 1 : 0;
#ifdef USE_NEVIS_GXA
/* this table contains the x coordinates for a quarter circle (the bottom right quarter) with fixed
radius of 540 px which is the half of the max HD graphics size of 1080 px. So with that table we
@@ -543,7 +547,7 @@ void CFrameBuffer::paintBoxRel(const int x, const int y, const int dx, const int
if ((type) && (radius))
{
#define MUL 32768 /* just an multiplicator for all math to reduce rounding errors */
int ofs, scf, scl;
int ofs, scf, scl, ofl, ofr;
/* limit the radius */
if (radius > dx)
@@ -559,26 +563,31 @@ void CFrameBuffer::paintBoxRel(const int x, const int y, const int dx, const int
while (line < dy)
{
ofs = 0;
ofl = ofr = 0;
if ((line < radius) && (type & 1))
if (line < radius && (type & CORNER_TOP)) /* one of the top corners */
{
/* uper round corners */
scl = scf * (radius - line) / MUL;
if ((scf * (radius - line) % MUL) >= (MUL / 2)) /* round up */
scl++;
ofs = radius - (q_circle[scl] * MUL / scf);
// ofl = corner_tl * ofs; // might depend on the arch if multiply is faster or not
ofl = corner_tl ? ofs : 0;
ofr = corner_tr ? ofs : 0;
}
else if ((line >= (dy - radius)) && (type & 2))
else if ((line >= dy - radius) && (type & CORNER_BOTTOM)) /* one of the bottom corners */
{
/* lower round corners */
scl = scf * (radius - (dy - (line + 1))) / MUL;
if ((scf * (radius - (dy - (line + 1))) % MUL) >= (MUL / 2)) /* round up */
scl++;
ofs = radius - (q_circle[scl] * MUL / scf);
ofl = corner_bl ? ofs : 0;
ofr = corner_br ? ofs : 0;
}
_write_gxa(gxa_base, cmd, GXA_POINT(x + dx - ofs, y + line)); /* endig point */
_write_gxa(gxa_base, cmd, GXA_POINT(x + ofs, y + line)); /* start point */
_write_gxa(gxa_base, cmd, GXA_POINT(x + dx - ofr, y + line)); /* endig point */
_write_gxa(gxa_base, cmd, GXA_POINT(x + ofl, y + line)); /* start point */
line++;
}
@@ -594,6 +603,7 @@ void CFrameBuffer::paintBoxRel(const int x, const int y, const int dx, const int
}
#else
#error TODO: please fix the rounded corner code for !USE_NEVIS_GXA case
int F,R=radius,sx,sy,dxx=dx,dyy=dy,rx,ry,wx,wy;
if (!getActive())

View File

@@ -36,22 +36,24 @@
typedef struct fb_var_screeninfo t_fb_var_screeninfo;
#if 0
#define CORNER_TOP_LEFT 0x1
#define CORNER_TOP_RIGHT 0x2
#define CORNER_TOP 0x3
#define CORNER_BOTTOM_RIGHT 0x4
#define CORNER_RIGHT 0x6
#define CORNER_BOTTOM_LEFT 0x8
#define CORNER_LEFT 0x9
#define CORNER_BOTTOM 0xC
#endif
#if 1
#define CORNER_TOP_LEFT 0x1
#define CORNER_TOP_RIGHT 0x2
#define CORNER_TOP 0x3
#define CORNER_BOTTOM_RIGHT 0x4
#define CORNER_RIGHT 0x6
#define CORNER_BOTTOM_LEFT 0x8
#define CORNER_LEFT 0x9
#define CORNER_BOTTOM 0xC
#define CORNER_ALL 0xF
#define SHADOW_OFFSET 6
#else
#define CORNER_TOP 0x1
#define CORNER_BOTTOM 0x2
#define CORNER_BOTH 0x3
#endif
/** Ausf<EFBFBD>hrung als Singleton */
/** Ausfuehrung als Singleton */
class CFrameBuffer
{
private:
@@ -150,7 +152,7 @@ class CFrameBuffer
};
void paintPixel(int x, int y, const fb_pixel_t col);
void paintBoxRel(const int x, const int y, const int dx, const int dy, const fb_pixel_t col, int radius = 0, int type = 0);
void paintBoxRel(const int x, const int y, const int dx, const int dy, const fb_pixel_t col, int radius = 0, int type = CORNER_ALL);
inline void paintBox(int xa, int ya, int xb, int yb, const fb_pixel_t col) { paintBoxRel(xa, ya, xb - xa, yb - ya, col); }
inline void paintBox(int xa, int ya, int xb, int yb, const fb_pixel_t col, int radius, int type) { paintBoxRel(xa, ya, xb - xa, yb - ya, col, radius, type); }