diff options
author | Jens Arnold <amiconn@rockbox.org> | 2007-01-21 10:10:23 +0000 |
---|---|---|
committer | Jens Arnold <amiconn@rockbox.org> | 2007-01-21 10:10:23 +0000 |
commit | a3a303e440d751fbbb8c2532640098bfc969b75f (patch) | |
tree | 19849fd1d97ec809694a3e10a1105c0d9326e586 /firmware | |
parent | d88de046e7e26d12c8483975070985a6ed1fb32b (diff) |
The code police strikes back, and some minor optimisations.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@12086 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware')
-rw-r--r-- | firmware/drivers/lcd-16bit.c | 164 |
1 files changed, 85 insertions, 79 deletions
diff --git a/firmware/drivers/lcd-16bit.c b/firmware/drivers/lcd-16bit.c index a035ea2d3a..16037f149d 100644 --- a/firmware/drivers/lcd-16bit.c +++ b/firmware/drivers/lcd-16bit.c @@ -552,85 +552,91 @@ void lcd_mono_bitmap_part(const unsigned char *src, int src_x, int src_y, void lcd_mono_bitmap_part(const unsigned char *src, int src_x, int src_y, int stride, int x, int y, int width, int height) { - const unsigned char *src_end; - fb_data *dst, *dst_end; - - /* nothing to draw? */ - if ((width <= 0) || (height <= 0) || (x >= LCD_WIDTH) || (y >= LCD_HEIGHT) - || (x + width <= 0) || (y + height <= 0)) - return; - - /* clipping */ - if (x < 0) - { - width += x; - src_x -= x; - x = 0; - } - if (y < 0) - { - height += y; - src_y -= y; - y = 0; - } - if (x + width > LCD_WIDTH) - width = LCD_WIDTH - x; - if (y + height > LCD_HEIGHT) - height = LCD_HEIGHT - y; - - src += stride * (src_y >> 3) + src_x; /* move starting point */ - src_y &= 7; - src_end = src + width; - - dst = LCDADDR(x, y); - int drawmode = lcd_get_drawmode(); - fb_data *backdrop = lcd_get_backdrop(); - bool has_backdrop = backdrop ? true : false; - backdrop = backdrop + y * LCD_WIDTH + x; - lcd_fastpixelfunc_type *fgfunc = lcd_fastpixelfuncs[drawmode];; - lcd_fastpixelfunc_type *bgfunc = lcd_fastpixelfuncs[drawmode ^ DRMODE_INVERSEVID];; - do { - const unsigned char *src_col = src++; - unsigned data = *src_col >> src_y; - fb_data *dst_col = dst++; - int numbits = 8 - src_y; - fb_data *backdrop_col = backdrop++; - dst_end = dst_col + height * LCD_WIDTH; - do { - switch(drawmode) { - case DRMODE_SOLID: - if (data & 0x01) - *dst_col = fg_pattern; - else - *dst_col = has_backdrop ? *backdrop_col : bg_pattern; - break; - case DRMODE_FG: - if (data & 0x01) - *dst_col = fg_pattern; - break; - case (DRMODE_SOLID|DRMODE_INVERSEVID): - if(data & 0x01) - *dst_col = has_backdrop ? *backdrop_col : bg_pattern; - else - *dst_col = fg_pattern; - break; - default: - if (data & 0x01) - fgfunc(dst_col); - else - bgfunc(dst_col); - break; - }; - dst_col += LCD_WIDTH; - backdrop_col += LCD_WIDTH; - data >>= 1; - if (--numbits == 0) { - src_col += stride; - data = *src_col; - numbits = 8; - } - } while (dst_col < dst_end); - } while (src < src_end); + const unsigned char *src_end; + bool has_backdrop; + fb_data *dst, *dst_end, *backdrop; + lcd_fastpixelfunc_type *fgfunc, *bgfunc; + + /* nothing to draw? */ + if ((width <= 0) || (height <= 0) || (x >= LCD_WIDTH) || (y >= LCD_HEIGHT) + || (x + width <= 0) || (y + height <= 0)) + return; + + /* clipping */ + if (x < 0) + { + width += x; + src_x -= x; + x = 0; + } + if (y < 0) + { + height += y; + src_y -= y; + y = 0; + } + if (x + width > LCD_WIDTH) + width = LCD_WIDTH - x; + if (y + height > LCD_HEIGHT) + height = LCD_HEIGHT - y; + + src += stride * (src_y >> 3) + src_x; /* move starting point */ + src_y &= 7; + src_end = src + width; + + dst = LCDADDR(x, y); + has_backdrop = (lcd_backdrop != NULL); + backdrop = lcd_backdrop + y * LCD_WIDTH + x; + fgfunc = lcd_fastpixelfuncs[drawmode]; + bgfunc = lcd_fastpixelfuncs[drawmode ^ DRMODE_INVERSEVID]; + do + { + const unsigned char *src_col = src++; + unsigned data = *src_col >> src_y; + fb_data *dst_col = dst++; + int numbits = 8 - src_y; + fb_data *backdrop_col = backdrop++; + dst_end = dst_col + height * LCD_WIDTH; + do + { + switch (drawmode) + { + case DRMODE_SOLID: + if (data & 0x01) + *dst_col = fg_pattern; + else + *dst_col = has_backdrop ? *backdrop_col : bg_pattern; + break; + case DRMODE_FG: + if (data & 0x01) + *dst_col = fg_pattern; + break; + case (DRMODE_SOLID|DRMODE_INVERSEVID): + if (data & 0x01) + *dst_col = has_backdrop ? *backdrop_col : bg_pattern; + else + *dst_col = fg_pattern; + break; + default: + if (data & 0x01) + fgfunc(dst_col); + else + bgfunc(dst_col); + break; + } + dst_col += LCD_WIDTH; + backdrop_col += LCD_WIDTH; + data >>= 1; + if (--numbits == 0) + { + src_col += stride; + data = *src_col; + numbits = 8; + } + } + while (dst_col < dst_end); + } + while (src < src_end); } /* Draw a full monochrome bitmap */ void lcd_mono_bitmap(const unsigned char *src, int x, int y, int width, int height) |