1
0
Fork 0
forked from len0rd/rockbox

Graphics: Lowlevel block function are in IRAM now as they're called often. Switched the masking logic for better readability. Draw modes and lowlevel function types are now defined for all platforms.

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@6952 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Jens Arnold 2005-06-30 18:42:24 +00:00
parent 3b90707fdd
commit a142d4d79f
4 changed files with 81 additions and 31 deletions

View file

@ -499,41 +499,57 @@ lcd_pixelfunc_type* lcd_remote_pixelfuncs[8] = {
nopixel, clearpixel, nopixel, clearpixel nopixel, clearpixel, nopixel, clearpixel
}; };
static void flipblock(unsigned char *address, unsigned mask, unsigned bits)
__attribute__ ((section(".icode")));
static void flipblock(unsigned char *address, unsigned mask, unsigned bits) static void flipblock(unsigned char *address, unsigned mask, unsigned bits)
{ {
*address ^= (bits & mask); *address ^= (bits & mask);
} }
static void bgblock(unsigned char *address, unsigned mask, unsigned bits)
__attribute__ ((section(".icode")));
static void bgblock(unsigned char *address, unsigned mask, unsigned bits) static void bgblock(unsigned char *address, unsigned mask, unsigned bits)
{ {
*address &= (bits | ~mask); *address &= (bits | ~mask);
} }
static void fgblock(unsigned char *address, unsigned mask, unsigned bits)
__attribute__ ((section(".icode")));
static void fgblock(unsigned char *address, unsigned mask, unsigned bits) static void fgblock(unsigned char *address, unsigned mask, unsigned bits)
{ {
*address |= (bits & mask); *address |= (bits & mask);
} }
static void solidblock(unsigned char *address, unsigned mask, unsigned bits)
__attribute__ ((section(".icode")));
static void solidblock(unsigned char *address, unsigned mask, unsigned bits) static void solidblock(unsigned char *address, unsigned mask, unsigned bits)
{ {
*address = (*address & ~mask) | (bits & mask); *address = (*address & ~mask) | (bits & mask);
} }
static void flipinvblock(unsigned char *address, unsigned mask, unsigned bits)
__attribute__ ((section(".icode")));
static void flipinvblock(unsigned char *address, unsigned mask, unsigned bits) static void flipinvblock(unsigned char *address, unsigned mask, unsigned bits)
{ {
*address ^= (~bits & mask); *address ^= (~bits & mask);
} }
static void bginvblock(unsigned char *address, unsigned mask, unsigned bits)
__attribute__ ((section(".icode")));
static void bginvblock(unsigned char *address, unsigned mask, unsigned bits) static void bginvblock(unsigned char *address, unsigned mask, unsigned bits)
{ {
*address &= ~(bits & mask); *address &= ~(bits & mask);
} }
static void fginvblock(unsigned char *address, unsigned mask, unsigned bits)
__attribute__ ((section(".icode")));
static void fginvblock(unsigned char *address, unsigned mask, unsigned bits) static void fginvblock(unsigned char *address, unsigned mask, unsigned bits)
{ {
*address |= (~bits & mask); *address |= (~bits & mask);
} }
static void solidinvblock(unsigned char *address, unsigned mask, unsigned bits)
__attribute__ ((section(".icode")));
static void solidinvblock(unsigned char *address, unsigned mask, unsigned bits) static void solidinvblock(unsigned char *address, unsigned mask, unsigned bits)
{ {
*address = (*address & ~mask) | (~bits & mask); *address = (*address & ~mask) | (~bits & mask);
@ -707,8 +723,8 @@ void lcd_remote_vline(int x, int y1, int y2)
dst += LCD_REMOTE_WIDTH; dst += LCD_REMOTE_WIDTH;
mask = 0xFFu; mask = 0xFFu;
} }
mask_bottom &= mask; mask &= mask_bottom;
bfunc(dst, mask_bottom, 0xFFu); bfunc(dst, mask, 0xFFu);
} }
/* Draw a rectangular box */ /* Draw a rectangular box */
@ -782,14 +798,14 @@ void lcd_remote_fillrect(int x, int y, int width, int height)
dst += LCD_REMOTE_WIDTH; dst += LCD_REMOTE_WIDTH;
mask = 0xFFu; mask = 0xFFu;
} }
mask_bottom &= mask; mask &= mask_bottom;
if (fillopt && (mask_bottom == 0xFFu)) if (fillopt && (mask == 0xFFu))
memset(dst, bits, width); memset(dst, bits, width);
else else
{ {
for (i = width; i > 0; i--) for (i = width; i > 0; i--)
bfunc(dst++, mask_bottom, 0xFFu); bfunc(dst++, mask, 0xFFu);
} }
} }
@ -871,14 +887,14 @@ void lcd_remote_bitmap_part(const unsigned char *src, int src_x, int src_y,
dst += LCD_REMOTE_WIDTH; dst += LCD_REMOTE_WIDTH;
mask = 0xFFu; mask = 0xFFu;
} }
mask_bottom &= mask; mask &= mask_bottom;
if (copyopt && (mask_bottom == 0xFFu)) if (copyopt && (mask == 0xFFu))
memcpy(dst, src, width); memcpy(dst, src, width);
else else
{ {
for (i = width; i > 0; i--) for (i = width; i > 0; i--)
bfunc(dst++, mask_bottom, *src++); bfunc(dst++, mask, *src++);
} }
} }
else else

View file

@ -338,41 +338,57 @@ lcd_pixelfunc_type* lcd_pixelfuncs[8] = {
nopixel, clearpixel, nopixel, clearpixel nopixel, clearpixel, nopixel, clearpixel
}; };
static void flipblock(unsigned char *address, unsigned mask, unsigned bits)
__attribute__ ((section(".icode")));
static void flipblock(unsigned char *address, unsigned mask, unsigned bits) static void flipblock(unsigned char *address, unsigned mask, unsigned bits)
{ {
*address ^= (bits & mask); *address ^= (bits & mask);
} }
static void bgblock(unsigned char *address, unsigned mask, unsigned bits)
__attribute__ ((section(".icode")));
static void bgblock(unsigned char *address, unsigned mask, unsigned bits) static void bgblock(unsigned char *address, unsigned mask, unsigned bits)
{ {
*address &= (bits | ~mask); *address &= (bits | ~mask);
} }
static void fgblock(unsigned char *address, unsigned mask, unsigned bits)
__attribute__ ((section(".icode")));
static void fgblock(unsigned char *address, unsigned mask, unsigned bits) static void fgblock(unsigned char *address, unsigned mask, unsigned bits)
{ {
*address |= (bits & mask); *address |= (bits & mask);
} }
static void solidblock(unsigned char *address, unsigned mask, unsigned bits)
__attribute__ ((section(".icode")));
static void solidblock(unsigned char *address, unsigned mask, unsigned bits) static void solidblock(unsigned char *address, unsigned mask, unsigned bits)
{ {
*address = (*address & ~mask) | (bits & mask); *address = (*address & ~mask) | (bits & mask);
} }
static void flipinvblock(unsigned char *address, unsigned mask, unsigned bits)
__attribute__ ((section(".icode")));
static void flipinvblock(unsigned char *address, unsigned mask, unsigned bits) static void flipinvblock(unsigned char *address, unsigned mask, unsigned bits)
{ {
*address ^= (~bits & mask); *address ^= (~bits & mask);
} }
static void bginvblock(unsigned char *address, unsigned mask, unsigned bits)
__attribute__ ((section(".icode")));
static void bginvblock(unsigned char *address, unsigned mask, unsigned bits) static void bginvblock(unsigned char *address, unsigned mask, unsigned bits)
{ {
*address &= ~(bits & mask); *address &= ~(bits & mask);
} }
static void fginvblock(unsigned char *address, unsigned mask, unsigned bits)
__attribute__ ((section(".icode")));
static void fginvblock(unsigned char *address, unsigned mask, unsigned bits) static void fginvblock(unsigned char *address, unsigned mask, unsigned bits)
{ {
*address |= (~bits & mask); *address |= (~bits & mask);
} }
static void solidinvblock(unsigned char *address, unsigned mask, unsigned bits)
__attribute__ ((section(".icode")));
static void solidinvblock(unsigned char *address, unsigned mask, unsigned bits) static void solidinvblock(unsigned char *address, unsigned mask, unsigned bits)
{ {
*address = (*address & ~mask) | (~bits & mask); *address = (*address & ~mask) | (~bits & mask);
@ -544,8 +560,8 @@ void lcd_vline(int x, int y1, int y2)
dst += LCD_WIDTH; dst += LCD_WIDTH;
mask = 0xFFu; mask = 0xFFu;
} }
mask_bottom &= mask; mask &= mask_bottom;
bfunc(dst, mask_bottom, 0xFFu); bfunc(dst, mask, 0xFFu);
} }
/* Draw a rectangular box */ /* Draw a rectangular box */
@ -619,14 +635,14 @@ void lcd_fillrect(int x, int y, int width, int height)
dst += LCD_WIDTH; dst += LCD_WIDTH;
mask = 0xFFu; mask = 0xFFu;
} }
mask_bottom &= mask; mask &= mask_bottom;
if (fillopt && (mask_bottom == 0xFFu)) if (fillopt && (mask == 0xFFu))
memset(dst, bits, width); memset(dst, bits, width);
else else
{ {
for (i = width; i > 0; i--) for (i = width; i > 0; i--)
bfunc(dst++, mask_bottom, 0xFFu); bfunc(dst++, mask, 0xFFu);
} }
} }
@ -708,14 +724,14 @@ void lcd_bitmap_part(const unsigned char *src, int src_x, int src_y,
dst += LCD_WIDTH; dst += LCD_WIDTH;
mask = 0xFFu; mask = 0xFFu;
} }
mask_bottom &= mask; mask &= mask_bottom;
if (copyopt && (mask_bottom == 0xFFu)) if (copyopt && (mask == 0xFFu))
memcpy(dst, src, width); memcpy(dst, src, width);
else else
{ {
for (i = width; i > 0; i--) for (i = width; i > 0; i--)
bfunc(dst++, mask_bottom, *src++); bfunc(dst++, mask, *src++);
} }
} }
else else

View file

@ -395,41 +395,57 @@ lcd_pixelfunc_type* lcd_pixelfuncs[8] = {
nopixel, clearpixel, nopixel, clearpixel nopixel, clearpixel, nopixel, clearpixel
}; };
static void flipblock(unsigned char *address, unsigned mask, unsigned bits)
__attribute__ ((section(".icode")));
static void flipblock(unsigned char *address, unsigned mask, unsigned bits) static void flipblock(unsigned char *address, unsigned mask, unsigned bits)
{ {
*address ^= (bits & mask); *address ^= (bits & mask);
} }
static void bgblock(unsigned char *address, unsigned mask, unsigned bits)
__attribute__ ((section(".icode")));
static void bgblock(unsigned char *address, unsigned mask, unsigned bits) static void bgblock(unsigned char *address, unsigned mask, unsigned bits)
{ {
*address &= (bits | ~mask); *address &= (bits | ~mask);
} }
static void fgblock(unsigned char *address, unsigned mask, unsigned bits)
__attribute__ ((section(".icode")));
static void fgblock(unsigned char *address, unsigned mask, unsigned bits) static void fgblock(unsigned char *address, unsigned mask, unsigned bits)
{ {
*address |= (bits & mask); *address |= (bits & mask);
} }
static void solidblock(unsigned char *address, unsigned mask, unsigned bits)
__attribute__ ((section(".icode")));
static void solidblock(unsigned char *address, unsigned mask, unsigned bits) static void solidblock(unsigned char *address, unsigned mask, unsigned bits)
{ {
*address = (*address & ~mask) | (bits & mask); *address = (*address & ~mask) | (bits & mask);
} }
static void flipinvblock(unsigned char *address, unsigned mask, unsigned bits)
__attribute__ ((section(".icode")));
static void flipinvblock(unsigned char *address, unsigned mask, unsigned bits) static void flipinvblock(unsigned char *address, unsigned mask, unsigned bits)
{ {
*address ^= (~bits & mask); *address ^= (~bits & mask);
} }
static void bginvblock(unsigned char *address, unsigned mask, unsigned bits)
__attribute__ ((section(".icode")));
static void bginvblock(unsigned char *address, unsigned mask, unsigned bits) static void bginvblock(unsigned char *address, unsigned mask, unsigned bits)
{ {
*address &= ~(bits & mask); *address &= ~(bits & mask);
} }
static void fginvblock(unsigned char *address, unsigned mask, unsigned bits)
__attribute__ ((section(".icode")));
static void fginvblock(unsigned char *address, unsigned mask, unsigned bits) static void fginvblock(unsigned char *address, unsigned mask, unsigned bits)
{ {
*address |= (~bits & mask); *address |= (~bits & mask);
} }
static void solidinvblock(unsigned char *address, unsigned mask, unsigned bits)
__attribute__ ((section(".icode")));
static void solidinvblock(unsigned char *address, unsigned mask, unsigned bits) static void solidinvblock(unsigned char *address, unsigned mask, unsigned bits)
{ {
*address = (*address & ~mask) | (~bits & mask); *address = (*address & ~mask) | (~bits & mask);
@ -601,8 +617,8 @@ void lcd_vline(int x, int y1, int y2)
dst += LCD_WIDTH; dst += LCD_WIDTH;
mask = 0xFFu; mask = 0xFFu;
} }
mask_bottom &= mask; mask &= mask_bottom;
bfunc(dst, mask_bottom, 0xFFu); bfunc(dst, mask, 0xFFu);
} }
/* Draw a rectangular box */ /* Draw a rectangular box */
@ -676,14 +692,14 @@ void lcd_fillrect(int x, int y, int width, int height)
dst += LCD_WIDTH; dst += LCD_WIDTH;
mask = 0xFFu; mask = 0xFFu;
} }
mask_bottom &= mask; mask &= mask_bottom;
if (fillopt && (mask_bottom == 0xFFu)) if (fillopt && (mask == 0xFFu))
memset(dst, bits, width); memset(dst, bits, width);
else else
{ {
for (i = width; i > 0; i--) for (i = width; i > 0; i--)
bfunc(dst++, mask_bottom, 0xFFu); bfunc(dst++, mask, 0xFFu);
} }
} }
@ -765,14 +781,14 @@ void lcd_bitmap_part(const unsigned char *src, int src_x, int src_y,
dst += LCD_WIDTH; dst += LCD_WIDTH;
mask = 0xFFu; mask = 0xFFu;
} }
mask_bottom &= mask; mask &= mask_bottom;
if (copyopt && (mask_bottom == 0xFFu)) if (copyopt && (mask == 0xFFu))
memcpy(dst, src, width); memcpy(dst, src, width);
else else
{ {
for (i = width; i > 0; i--) for (i = width; i > 0; i--)
bfunc(dst++, mask_bottom, *src++); bfunc(dst++, mask, *src++);
} }
} }
else else

View file

@ -113,22 +113,23 @@ extern void lcd_jump_scroll(int mode); /* 0=off, 1=once, ..., ALWAYS */
extern void lcd_jump_scroll_delay(int ms); extern void lcd_jump_scroll_delay(int ms);
#endif #endif
#if defined(HAVE_LCD_BITMAP) || defined(SIMULATOR) /* Draw modes */
/* draw modes */
#define DRMODE_COMPLEMENT 0 #define DRMODE_COMPLEMENT 0
#define DRMODE_BG 1 #define DRMODE_BG 1
#define DRMODE_FG 2 #define DRMODE_FG 2
#define DRMODE_SOLID 3 #define DRMODE_SOLID 3
#define DRMODE_INVERSEVID 4 /* used as bit modifier for basic modes */ #define DRMODE_INVERSEVID 4 /* used as bit modifier for basic modes */
/* Low-level drawing function types */
typedef void lcd_pixelfunc_type(int x, int y); /* for b&w */
typedef void lcd_blockfunc_type(unsigned char *address, unsigned mask, unsigned bits);
#if defined(HAVE_LCD_BITMAP) || defined(SIMULATOR)
#define DRAW_PIXEL(x,y) lcd_framebuffer[(y)>>3][(x)] |= (1<<((y)&7)) #define DRAW_PIXEL(x,y) lcd_framebuffer[(y)>>3][(x)] |= (1<<((y)&7))
#define CLEAR_PIXEL(x,y) lcd_framebuffer[(y)>>3][(x)] &= ~(1<<((y)&7)) #define CLEAR_PIXEL(x,y) lcd_framebuffer[(y)>>3][(x)] &= ~(1<<((y)&7))
#define INVERT_PIXEL(x,y) lcd_framebuffer[(y)>>3][(x)] ^= (1<<((y)&7)) #define INVERT_PIXEL(x,y) lcd_framebuffer[(y)>>3][(x)] ^= (1<<((y)&7))
typedef void lcd_pixelfunc_type(int x, int y); /* for b&w */
typedef void lcd_blockfunc_type(unsigned char *address, unsigned mask, unsigned bits);
/* Memory copy of display bitmap */ /* Memory copy of display bitmap */
extern unsigned char lcd_framebuffer[LCD_HEIGHT/8][LCD_WIDTH]; extern unsigned char lcd_framebuffer[LCD_HEIGHT/8][LCD_WIDTH];
@ -156,7 +157,8 @@ extern void lcd_drawrect(int x, int y, int width, int height);
extern void lcd_fillrect(int x, int y, int width, int height); extern void lcd_fillrect(int x, int y, int width, int height);
extern void lcd_bitmap_part(const unsigned char *src, int src_x, int src_y, extern void lcd_bitmap_part(const unsigned char *src, int src_x, int src_y,
int stride, int x, int y, int width, int height); int stride, int x, int y, int width, int height);
extern void lcd_bitmap(const unsigned char *src, int x, int y, int nx, int ny); extern void lcd_bitmap(const unsigned char *src, int x, int y, int width,
int height);
extern void lcd_putsxy(int x, int y, const unsigned char *string); extern void lcd_putsxy(int x, int y, const unsigned char *string);
extern void lcd_invertscroll(int x, int y); extern void lcd_invertscroll(int x, int y);