mirror of
https://github.com/tuxbox-neutrino/neutrino.git
synced 2025-08-29 16:31:11 +02:00
driver/framebuffer.cpp: paintBoxRel with solid fill for nevis
This commit is contained in:
@@ -59,6 +59,9 @@ extern CPictureViewer * g_PicViewer;
|
||||
#define FB_HW_ACCELERATION
|
||||
#endif
|
||||
#endif
|
||||
#if defined(FB_HW_ACCELERATION) && defined(USE_NEVIS_GXA)
|
||||
#error
|
||||
#endif
|
||||
//#undef USE_NEVIS_GXA //FIXME
|
||||
/*******************************************************************************/
|
||||
#ifdef USE_NEVIS_GXA
|
||||
@@ -92,6 +95,7 @@ extern CPictureViewer * g_PicViewer;
|
||||
#define GXA_BMP2_ADDR_REG 0x0054
|
||||
#define GXA_DEPTH_REG 0x00F4
|
||||
#define GXA_CONTENT_ID_REG 0x0144
|
||||
#define GXA_BLT_CONTROL_REG 0x0034
|
||||
|
||||
#define GXA_CMD_BLT 0x00010800
|
||||
#define GXA_CMD_NOT_ALPHA 0x00011000
|
||||
@@ -100,6 +104,7 @@ extern CPictureViewer * g_PicViewer;
|
||||
|
||||
#define GXA_BMP1_TYPE_REG 0x0048
|
||||
#define GXA_BMP1_ADDR_REG 0x004C
|
||||
#define GXA_BMP7_TYPE_REG 0x0078
|
||||
|
||||
#define GXA_BLEND_CFG_REG 0x003C
|
||||
#define GXA_CFG_REG 0x0030
|
||||
@@ -218,6 +223,7 @@ void CFrameBuffer::setupGXA(void)
|
||||
_write_gxa(gxa_base, GXA_CFG_REG, 0x100 | (1 << 12) | (1 << 29));
|
||||
_write_gxa(gxa_base, GXA_CFG2_REG, 0x1FF);
|
||||
_write_gxa(gxa_base, GXA_BG_COLOR_REG, (unsigned int) backgroundColor);
|
||||
_write_gxa(gxa_base, GXA_BMP7_TYPE_REG, (3 << 16) | screeninfo.xres | (1 << 27));
|
||||
}
|
||||
#endif
|
||||
void CFrameBuffer::init(const char * const fbDevice)
|
||||
@@ -620,15 +626,21 @@ void CFrameBuffer::paintBoxRel(const int x, const int y, const int dx, const int
|
||||
if (!getActive())
|
||||
return;
|
||||
|
||||
#if defined(USE_NEVIS_GXA)
|
||||
if (dx == 0 || dy == 0) {
|
||||
printf("paintBoxRel: radius %d, start x %d y %d end x %d y %d\n", radius, x, y, x+dx, x+dy);
|
||||
return;
|
||||
}
|
||||
#if defined(FB_HW_ACCELERATION)
|
||||
fb_fillrect fillrect;
|
||||
fillrect.color = col;
|
||||
fillrect.rop = ROP_COPY;
|
||||
#elif defined(USE_NEVIS_GXA)
|
||||
OpenThreads::ScopedLock<OpenThreads::Mutex> m_lock(mutex);
|
||||
/* solid fill with background color */
|
||||
unsigned int cmd = GXA_CMD_BLT | GXA_CMD_NOT_TEXT | GXA_SRC_BMP_SEL(7) | GXA_DST_BMP_SEL(2) | GXA_PARAM_COUNT(2) | GXA_CMD_NOT_ALPHA;
|
||||
_write_gxa(gxa_base, GXA_BG_COLOR_REG, (unsigned int) col); /* setup the drawing color */
|
||||
#endif
|
||||
|
||||
bool corner_tl = (type & CORNER_TOP_LEFT) == CORNER_TOP_LEFT;
|
||||
bool corner_tr = (type & CORNER_TOP_RIGHT) == CORNER_TOP_RIGHT;
|
||||
bool corner_bl = (type & CORNER_BOTTOM_LEFT) == CORNER_BOTTOM_LEFT;
|
||||
bool corner_br = (type & CORNER_BOTTOM_RIGHT)== CORNER_BOTTOM_RIGHT;
|
||||
|
||||
/* 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
|
||||
ca draw boxes with round corners and als circles by just setting dx = dy = radius (max 540). */
|
||||
@@ -665,6 +677,10 @@ void CFrameBuffer::paintBoxRel(const int x, const int y, const int dx, const int
|
||||
int line = 0;
|
||||
|
||||
if (type && radius) {
|
||||
bool corner_tl = (type & CORNER_TOP_LEFT) == CORNER_TOP_LEFT;
|
||||
bool corner_tr = (type & CORNER_TOP_RIGHT) == CORNER_TOP_RIGHT;
|
||||
bool corner_bl = (type & CORNER_BOTTOM_LEFT) == CORNER_BOTTOM_LEFT;
|
||||
bool corner_br = (type & CORNER_BOTTOM_RIGHT)== CORNER_BOTTOM_RIGHT;
|
||||
int ofs, scf, scl, ofl, ofr;
|
||||
/* just an multiplicator for all math to reduce rounding errors */
|
||||
#define MUL 32768
|
||||
@@ -703,63 +719,66 @@ void CFrameBuffer::paintBoxRel(const int x, const int y, const int dx, const int
|
||||
ofr = corner_br ? ofs : 0;
|
||||
} else {
|
||||
//printf("3: x %d y %d dx %d dy %d rad %d line %d\n", x, y, dx, dy, radius, line);
|
||||
#ifdef FB_HW_ACCELERATION
|
||||
/* FIXME small size faster to do by software */
|
||||
fb_fillrect fillrect;
|
||||
#if defined(FB_HW_ACCELERATION) || defined(USE_NEVIS_GXA)
|
||||
int rect_height_mult = (((type & (CORNER_BOTTOM | CORNER_TOP)) == (CORNER_BOTTOM | CORNER_TOP)) ? 2 : 1);
|
||||
|
||||
#if defined(FB_HW_ACCELERATION)
|
||||
fillrect.dx = x;
|
||||
fillrect.dy = y + line;
|
||||
fillrect.width = dx;
|
||||
fillrect.height = dy - (radius * rect_height_mult);
|
||||
fillrect.color = col;
|
||||
fillrect.rop = ROP_COPY;
|
||||
if (dx == 0 || dy == 0) {
|
||||
printf("paintBoxRel: radius %d, start x %d y %d end x %d y %d\n", radius, x, y, x+dx, x+dy);
|
||||
return;
|
||||
}
|
||||
|
||||
ioctl(fd, FBIO_FILL_RECT, &fillrect);
|
||||
#elif defined(USE_NEVIS_GXA)
|
||||
_write_gxa(gxa_base, GXA_BLT_CONTROL_REG, 0);
|
||||
_write_gxa(gxa_base, cmd, GXA_POINT(x, y + line)); /* destination x/y */
|
||||
_write_gxa(gxa_base, cmd, GXA_POINT(dx, dy - (radius * rect_height_mult))); /* width/height */
|
||||
#endif
|
||||
line += dy - (radius * rect_height_mult);
|
||||
continue;
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
if (dx-ofr-ofl == 0)
|
||||
printf("paintBoxRel: radius %d, start x %d y %d end x %d y %d\n", radius, x, y, dx-ofr-ofl, y+line);
|
||||
|
||||
#ifdef USE_NEVIS_GXA
|
||||
_write_gxa(gxa_base, GXA_BLT_CONTROL_REG, 0);
|
||||
_write_gxa(gxa_base, cmd, GXA_POINT(x + ofl, y + line)); /* destination x/y */
|
||||
_write_gxa(gxa_base, cmd, GXA_POINT(dx-ofr-ofr, 1)); /* width/height */
|
||||
#else
|
||||
paintHLineRelInternal(x+ofl, dx-ofl-ofr, y+line, col);
|
||||
#endif
|
||||
line++;
|
||||
}
|
||||
} else {
|
||||
#ifdef FB_HW_ACCELERATION
|
||||
#if defined(FB_HW_ACCELERATION)
|
||||
/* FIXME small size faster to do by software */
|
||||
if (dx > 10 || dy > 10) {
|
||||
fb_fillrect fillrect;
|
||||
|
||||
fillrect.dx = x;
|
||||
fillrect.dy = y;
|
||||
fillrect.width = dx;
|
||||
fillrect.height = dy;
|
||||
fillrect.color = col;
|
||||
fillrect.rop = ROP_COPY;
|
||||
if (dx == 0 || dy == 0) {
|
||||
printf("paintBoxRel: radius %d, start x %d y %d end x %d y %d\n", radius, x, y, x+dx, x+dy);
|
||||
return;
|
||||
}
|
||||
|
||||
ioctl(fd, FBIO_FILL_RECT, &fillrect);
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
#if defined(USE_NEVIS_GXA)
|
||||
_write_gxa(gxa_base, GXA_BLT_CONTROL_REG, 0);
|
||||
_write_gxa(gxa_base, cmd, GXA_POINT(x, y)); /* destination x/y */
|
||||
_write_gxa(gxa_base, cmd, GXA_POINT(dx, dy)); /* width/height */
|
||||
#else
|
||||
int swidth = stride / sizeof(fb_pixel_t);
|
||||
fb_pixel_t *fbp = getFrameBufferPointer() + (swidth * y);
|
||||
while (line < dy) {
|
||||
paintHLineRelInternal(x, dx, y+line, col);
|
||||
for (int pos = x; pos < x + dx; pos++)
|
||||
*(fbp + pos) = col;
|
||||
|
||||
fbp += swidth;
|
||||
line++;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef USE_NEVIS_GXA
|
||||
_write_gxa(gxa_base, GXA_BG_COLOR_REG, (unsigned int) backgroundColor); //FIXME needed ?
|
||||
/* the GXA seems to do asynchronous rendering, so we add a sync marker
|
||||
* to which the fontrenderer code can synchronize
|
||||
*/
|
||||
@@ -769,6 +788,7 @@ void CFrameBuffer::paintBoxRel(const int x, const int y, const int dx, const int
|
||||
|
||||
void CFrameBuffer::paintVLineRelInternal(int x, int y, int dy, const fb_pixel_t col)
|
||||
{
|
||||
|
||||
#if defined(FB_HW_ACCELERATION)
|
||||
fb_fillrect fillrect;
|
||||
fillrect.dx = x;
|
||||
@@ -819,14 +839,10 @@ void CFrameBuffer::paintHLineRelInternal(int x, int dx, int y, const fb_pixel_t
|
||||
fillrect.color = col;
|
||||
fillrect.rop = ROP_COPY;
|
||||
ioctl(fd, FBIO_FILL_RECT, &fillrect);
|
||||
} else {
|
||||
uint8_t * pos = ((uint8_t *)getFrameBufferPointer()) + x * sizeof(fb_pixel_t) + stride * y;
|
||||
|
||||
fb_pixel_t * dest = (fb_pixel_t *)pos;
|
||||
for (int i = 0; i < dx; i++)
|
||||
*(dest++) = col;
|
||||
return;
|
||||
}
|
||||
#elif defined(USE_NEVIS_GXA)
|
||||
#endif
|
||||
#if defined(USE_NEVIS_GXA)
|
||||
/* draw a single horizontal line from point x/y with width dx */
|
||||
unsigned int cmd = GXA_CMD_NOT_TEXT | GXA_SRC_BMP_SEL(2) | GXA_DST_BMP_SEL(2) | GXA_PARAM_COUNT(2) | GXA_CMD_NOT_ALPHA;
|
||||
|
||||
|
Reference in New Issue
Block a user