merge neutrino-apollo

This commit is contained in:
[CST] Bas
2013-01-18 14:21:41 +08:00
committed by [CST] Focus
parent 5d7406831a
commit e7833b099f
2 changed files with 262 additions and 266 deletions

View File

@@ -537,12 +537,13 @@ void CFrameBuffer::setBlendLevel(int level)
if (ioctl(fd, FBIO_SETOPACITY, value))
printf("FBIO_SETOPACITY failed.\n");
#if 1
#ifndef ISAPOLLO
if(level == 100) // TODO: sucks.
usleep(20000);
#endif
#endif
}
#if 0
//never used
void CFrameBuffer::setAlphaFade(int in, int num, int tr)
@@ -557,6 +558,7 @@ void CFrameBuffer::paletteFade(int i, __u32 rgb1, __u32 rgb2, int level)
__u16 *r = cmap.red+i;
__u16 *g = cmap.green+i;
__u16 *b = cmap.blue+i;
*r= ((rgb2&0xFF0000)>>16)*level;
*g= ((rgb2&0x00FF00)>>8 )*level;
*b= ((rgb2&0x0000FF) )*level;
@@ -591,10 +593,12 @@ void CFrameBuffer::paletteSet(struct fb_cmap *map)
map = &cmap;
if(bpp == 8) {
//printf("Set palette for %dbit\n", bpp);
//printf("Set palette for %dbit\n", bpp);
ioctl(fd, FBIOPUTCMAP, map);
}
uint32_t rl, ro, gl, go, bl, bo, tl, to;
rl = screeninfo.red.length;
ro = screeninfo.red.offset;
gl = screeninfo.green.length;
@@ -609,22 +613,6 @@ void CFrameBuffer::paletteSet(struct fb_cmap *map)
}
}
#if 0
void CFrameBuffer::paintBoxRel(const int x, const int y, const int dx, const int dy, const fb_pixel_t col)
{
if (!getActive())
return;
uint8_t * pos = ((uint8_t *)getFrameBufferPointer()) + x * sizeof(fb_pixel_t) + stride * y;
for (int count = 0; count < dy; count++) {
fb_pixel_t * dest = (fb_pixel_t *)pos;
for (int i = 0; i < dx; i++)
*(dest++) = col;
pos += stride;
}
}
#endif
void CFrameBuffer::paintBoxRel(const int x, const int y, const int dx, const int dy, const fb_pixel_t col, int radius, int type)
{
/* draw a filled rectangle (with additional round corners) */
@@ -632,18 +620,15 @@ 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
#if defined(USE_NEVIS_GXA)
OpenThreads::ScopedLock<OpenThreads::Mutex> m_lock(mutex);
#else
int swidth = stride / sizeof(fb_pixel_t);
fb_pixel_t *fbp = getFrameBufferPointer() + (swidth * y);
#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). */
@@ -678,17 +663,11 @@ void CFrameBuffer::paintBoxRel(const int x, const int y, const int dx, const int
23};
int line = 0;
#ifdef USE_NEVIS_GXA
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;
_write_gxa(gxa_base, GXA_FG_COLOR_REG, (unsigned int) col); /* setup the drawing color */
_write_gxa(gxa_base, GXA_LINE_CONTROL_REG, 0x00000404); /* X is major axis, skip last pixel */
#endif
if ((type) && (radius))
{
#define MUL 32768 /* just an multiplicator for all math to reduce rounding errors */
if (type && radius) {
int ofs, scf, scl, ofl, ofr;
/* just an multiplicator for all math to reduce rounding errors */
#define MUL 32768
/* limit the radius */
if (radius > dx)
@@ -697,17 +676,14 @@ void CFrameBuffer::paintBoxRel(const int x, const int y, const int dx, const int
radius = dy;
if (radius > 540)
radius = 540;
if (radius < 1) /* dx or dy = 0... */
radius = 1; /* avoid div by zero below */
scf = (540 * MUL) / radius;
scf = (540 * MUL) / ((radius < 1) ? 1 : radius);
while (line < dy)
{
while (line < dy) {
ofl = ofr = 0;
if (line < radius && (type & CORNER_TOP)) /* one of the top corners */
{
if (line < radius && (type & CORNER_TOP)) {/* one of the top corners */
//printf("1: x %d y %d dx %d dy %d rad %d line %d\n", x, y, dx, dy, radius, line);
/* uper round corners */
scl = scf * (radius - line) / MUL;
if ((scf * (radius - line) % MUL) >= (MUL / 2)) /* round up */
@@ -716,9 +692,8 @@ void CFrameBuffer::paintBoxRel(const int x, const int y, const int dx, const int
// 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 & CORNER_BOTTOM)) /* one of the bottom corners */
{
} else if ((line >= dy - radius) && (type & CORNER_BOTTOM)) { /* one of the bottom corners */
//printf("2: x %d y %d dx %d dy %d rad %d line %d\n", x, y, dx, dy, radius, line);
/* lower round corners */
scl = scf * (radius - (dy - (line + 1))) / MUL;
if ((scf * (radius - (dy - (line + 1))) % MUL) >= (MUL / 2)) /* round up */
@@ -726,31 +701,43 @@ void CFrameBuffer::paintBoxRel(const int x, const int y, const int dx, const int
ofs = radius - (q_circle[scl] * MUL / scf);
ofl = corner_bl ? ofs : 0;
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;
int rect_height_mult = (((type & (CORNER_BOTTOM | CORNER_TOP)) == (CORNER_BOTTOM | CORNER_TOP)) ? 2 : 1);
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;
}
#if defined(FB_HW_ACCELERATION)
ioctl(fd, FBIO_FILL_RECT, &fillrect);
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);
paintHLine(x+ofl, x+dx-ofr, y+line, col);
#elif defined(USE_NEVIS_GXA)
_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 */
#else
for (int pos = x + ofl; pos < x + dx - ofr; pos++)
{
*(fbp + pos) = col;
}
fbp += swidth;
#endif
paintHLineRelInternal(x+ofl, dx-ofl-ofr, y+line, col);
line++;
}
}
else
{
} else {
#ifdef 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;
@@ -761,37 +748,27 @@ void CFrameBuffer::paintBoxRel(const int x, const int y, const int dx, const int
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);
paintHLine(x, x+dx, y+line, col);
return;
}
#endif
while (line < dy)
{
#ifdef USE_NEVIS_GXA
_write_gxa(gxa_base, cmd, GXA_POINT(x + dx, y + line)); /* endig point */
_write_gxa(gxa_base, cmd, GXA_POINT(x, y + line)); /* start point */
}
#else
for (int pos = x; pos < x + dx; pos++)
{
*(fbp + pos) = col;
}
fbp += swidth;
#endif
while (line < dy) {
paintHLineRelInternal(x+ofl, dx-ofl-ofr, y+line col);
line++;
}
}
#ifdef USE_NEVIS_GXA
/* the GXA seems to do asynchronous rendering, so we add a sync marker
to which the fontrenderer code can synchronize */
* to which the fontrenderer code can synchronize
*/
add_gxa_sync_marker();
#endif
#endif
}
void CFrameBuffer::paintVLineRel(int x, int y, int dy, const fb_pixel_t col)
void CFrameBuffer::paintVLineRelInternal(int x, int y, int dy, const fb_pixel_t col)
{
if (!getActive())
return;
#if defined(FB_HW_ACCELERATION)
fb_fillrect fillrect;
@@ -803,7 +780,6 @@ void CFrameBuffer::paintVLineRel(int x, int y, int dy, const fb_pixel_t col)
fillrect.rop = ROP_COPY;
ioctl(fd, FBIO_FILL_RECT, &fillrect);
#elif defined(USE_NEVIS_GXA)
OpenThreads::ScopedLock<OpenThreads::Mutex> m_lock(mutex);
/* draw a single vertical line from point x/y with hight 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;
@@ -821,11 +797,19 @@ void CFrameBuffer::paintVLineRel(int x, int y, int dy, const fb_pixel_t col)
#endif /* USE_NEVIS_GXA */
}
void CFrameBuffer::paintHLineRel(int x, int dx, int y, const fb_pixel_t col)
void CFrameBuffer::paintVLineRel(int x, int y, int dy, const fb_pixel_t col)
{
if (!getActive())
return;
#if defined(USE_NEVIS_GXA)
OpenThreads::ScopedLock<OpenThreads::Mutex> m_lock(mutex);
#endif
paintVLineRelInternal(x, y, dy, col);
}
void CFrameBuffer::paintHLineRelInternal(int x, int dx, int y, const fb_pixel_t col)
{
#if defined(FB_HW_ACCELERATION)
fb_fillrect fillrect;
fillrect.dx = x;
@@ -836,7 +820,6 @@ void CFrameBuffer::paintHLineRel(int x, int dx, int y, const fb_pixel_t col)
fillrect.rop = ROP_COPY;
ioctl(fd, FBIO_FILL_RECT, &fillrect);
#elif defined(USE_NEVIS_GXA)
OpenThreads::ScopedLock<OpenThreads::Mutex> m_lock(mutex);
/* 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;
@@ -853,6 +836,17 @@ void CFrameBuffer::paintHLineRel(int x, int dx, int y, const fb_pixel_t col)
#endif /* USE_NEVIS_GXA */
}
void CFrameBuffer::paintHLineRel(int x, int dx, int y, const fb_pixel_t col)
{
if (!getActive())
return;
#if defined(USE_NEVIS_GXA)
OpenThreads::ScopedLock<OpenThreads::Mutex> m_lock(mutex);
#endif
paintHLineRelInternal(x, dx, y, col);
}
void CFrameBuffer::setIconBasePath(const std::string & iconPath)
{
iconBasePath = iconPath;

View File

@@ -118,6 +118,9 @@ class CFrameBuffer
int cache_size;
void * int_convertRGB2FB(unsigned char *rgbbuff, unsigned long x, unsigned long y, int transp, bool alpha);
int m_transparent_default, m_transparent;
// Unlocked versions (no mutex)
void paintHLineRelInternal(int x, int dx, int y, const fb_pixel_t col);
void paintVLineRelInternal(int x, int y, int dy, const fb_pixel_t col);
public:
fb_pixel_t realcolor[256];
@@ -176,7 +179,6 @@ class CFrameBuffer
inline void paintHLine(int xa, int xb, int y, const fb_pixel_t col) { paintHLineRel(xa, xb - xa, y, col); }
void paintHLineRel(int x, int dx, int y, const fb_pixel_t col);
void setIconBasePath(const std::string & iconPath);
void getIconSize(const char * const filename, int* width, int *height);