forked from len0rd/rockbox
Player graphics library: fixed and more robust bounds check, added bitmap drawing.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@6139 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
b0f57cb88e
commit
75640f45eb
2 changed files with 40 additions and 7 deletions
|
@ -28,8 +28,8 @@
|
|||
static struct plugin_api *pgfx_rb = NULL; /* global api struct pointer */
|
||||
static int char_width;
|
||||
static int char_height;
|
||||
static int pixel_height;
|
||||
static int pixel_width;
|
||||
static unsigned pixel_height;
|
||||
static unsigned pixel_width;
|
||||
static unsigned char gfx_chars[8];
|
||||
static unsigned char gfx_buffer[56];
|
||||
|
||||
|
@ -200,14 +200,12 @@ void pgfx_invertrect (int x, int y, int nx, int ny)
|
|||
{
|
||||
int i, j;
|
||||
|
||||
if (x > pixel_width)
|
||||
return;
|
||||
if (y > pixel_height)
|
||||
if (((unsigned) x >= pixel_width) || ((unsigned) y >= pixel_height))
|
||||
return;
|
||||
|
||||
if (x + nx > pixel_width)
|
||||
if ((unsigned)(x + nx) > pixel_width)
|
||||
nx = pixel_width - x;
|
||||
if (y + ny > pixel_height)
|
||||
if ((unsigned)(y + ny) > pixel_height)
|
||||
ny = pixel_height - y;
|
||||
|
||||
for (i = 0; i < nx; i++)
|
||||
|
@ -215,4 +213,37 @@ void pgfx_invertrect (int x, int y, int nx, int ny)
|
|||
pgfx_invertpixel(x + i, y + j);
|
||||
}
|
||||
|
||||
void pgfx_bitmap (const unsigned char *src, int x, int y, int nx, int ny,
|
||||
bool clear)
|
||||
{
|
||||
int stride, i, j;
|
||||
unsigned data;
|
||||
|
||||
if (((unsigned) x >= pixel_width) || ((unsigned) y >= pixel_height))
|
||||
return;
|
||||
|
||||
stride = nx; /* otherwise right-clipping will destroy the image */
|
||||
|
||||
if (((unsigned)(x + nx)) >= pixel_width)
|
||||
nx = pixel_width - x;
|
||||
if (((unsigned)(y + ny)) >= pixel_height)
|
||||
ny = pixel_height - y;
|
||||
|
||||
for (i = 0; i < nx; i++, src++)
|
||||
{
|
||||
data = src[0];
|
||||
if (ny > 8) /* ny is max. 14 */
|
||||
data |= src[stride] << 8;
|
||||
for (j = 0; j < ny; j++)
|
||||
{
|
||||
if (data & 1)
|
||||
pgfx_drawpixel(x + i, y + j);
|
||||
else
|
||||
if (clear)
|
||||
pgfx_clearpixel(x + i, y + j);
|
||||
data >>= 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* HAVE_LCD_CHARCELLS */
|
||||
|
|
|
@ -38,6 +38,8 @@ void pgfx_drawline(int x1, int y1, int x2, int y2);
|
|||
void pgfx_clearline(int x1, int y1, int x2, int y2);
|
||||
void pgfx_invertline(int x1, int y1, int x2, int y2);
|
||||
void pgfx_invertrect (int x, int y, int nx, int ny);
|
||||
void pgfx_bitmap (const unsigned char *src, int x, int y, int nx, int ny,
|
||||
bool clear);
|
||||
|
||||
#endif /* HAVE_LCD_CHARCELLS */
|
||||
#endif /* __PGFX_H__ */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue