From d9e5b67b71cf246c11da8a9083af21752ac7bd15 Mon Sep 17 00:00:00 2001 From: Dave Chapman Date: Thu, 2 Feb 2006 20:42:56 +0000 Subject: Patch #1421422 - Backdrop image patch started by Linus, finished by me. Adds ability to set backdrop images for file browser and menus (store full-screen bitmaps in /.rockbox/backdrops/) and also the ability to set a full-screen background image in a WPS using the %X|filename.bmp| WPS tag. Currently only implemented for targets with colour LCDs. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@8536 a1c6a512-1295-4272-9138-f99709370657 --- firmware/drivers/lcd-16bit.c | 75 ++++++++++++++++++++++++++++++++++++-------- firmware/export/lcd.h | 4 +++ 2 files changed, 66 insertions(+), 13 deletions(-) (limited to 'firmware') diff --git a/firmware/drivers/lcd-16bit.c b/firmware/drivers/lcd-16bit.c index bf5cdbcdd0..aaf7bde1aa 100644 --- a/firmware/drivers/lcd-16bit.c +++ b/firmware/drivers/lcd-16bit.c @@ -38,6 +38,9 @@ /*** globals ***/ fb_data lcd_framebuffer[LCD_HEIGHT][LCD_WIDTH] __attribute__ ((aligned (16))); +fb_data* lcd_backdrop IDATA_ATTR = NULL; +int lcd_backdrop_offset = NULL; + static unsigned fg_pattern IDATA_ATTR = LCD_DEFAULT_FG; static unsigned bg_pattern IDATA_ATTR = LCD_DEFAULT_BG; static int drawmode = DRMODE_SOLID; @@ -105,6 +108,17 @@ void lcd_set_background(unsigned color) bg_pattern = color; } +void lcd_set_backdrop(fb_data* backdrop) +{ + lcd_backdrop = backdrop; + if (backdrop) + lcd_backdrop_offset = (int)backdrop - (int)&lcd_framebuffer[0][0]; +} + +fb_data* lcd_get_backdrop(void) +{ + return lcd_backdrop; +} unsigned lcd_get_background(void) { @@ -160,6 +174,12 @@ static void clearpixel(fb_data *address) *address = bg_pattern; } +static void clearimgpixel(fb_data *address) ICODE_ATTR; +static void clearimgpixel(fb_data *address) +{ + *address = *(fb_data *)((int)address + lcd_backdrop_offset); +} + static void flippixel(fb_data *address) ICODE_ATTR; static void flippixel(fb_data *address) { @@ -177,26 +197,41 @@ lcd_fastpixelfunc_type* const lcd_fastpixelfuncs[8] = { nopixel, clearpixel, nopixel, clearpixel }; +lcd_fastpixelfunc_type* const lcd_fastimgpixelfuncs[8] = { + flippixel, nopixel, setpixel, setpixel, + nopixel, clearimgpixel, nopixel, clearimgpixel +}; + /*** drawing functions ***/ /* Clear the whole display */ void lcd_clear_display(void) { - fb_data bits = (drawmode & DRMODE_INVERSEVID) ? fg_pattern : bg_pattern; fb_data *dst = LCDADDR(0, 0); fb_data *dst_end = dst + LCD_HEIGHT*LCD_WIDTH; - - do - *dst++ = bits; - while (dst < dst_end); + + if (lcd_backdrop) { + do + clearimgpixel(dst++); + while (dst < dst_end); + } else { + do + clearpixel(dst++); + while (dst < dst_end); + } scrolling_lines = 0; } /* Set a single pixel */ void lcd_drawpixel(int x, int y) { - if (((unsigned)x < LCD_WIDTH) && ((unsigned)y < LCD_HEIGHT)) - lcd_fastpixelfuncs[drawmode](LCDADDR(x, y)); + if (((unsigned)x < LCD_WIDTH) && ((unsigned)y < LCD_HEIGHT)) { + if (lcd_backdrop) { + lcd_fastimgpixelfuncs[drawmode](LCDADDR(x, y)); + } else { + lcd_fastpixelfuncs[drawmode](LCDADDR(x, y)); + } + } } /* Draw a line */ @@ -208,7 +243,10 @@ void lcd_drawline(int x1, int y1, int x2, int y2) int d, dinc1, dinc2; int x, xinc1, xinc2; int y, yinc1, yinc2; - lcd_fastpixelfunc_type *pfunc = lcd_fastpixelfuncs[drawmode]; + lcd_fastpixelfunc_type *pfunc = (lcd_backdrop ? + lcd_fastimgpixelfuncs[drawmode] : + lcd_fastpixelfuncs[drawmode]); + deltax = abs(x2 - x1); deltay = abs(y2 - y1); @@ -275,7 +313,9 @@ void lcd_hline(int x1, int x2, int y) { int x; fb_data *dst, *dst_end; - lcd_fastpixelfunc_type *pfunc = lcd_fastpixelfuncs[drawmode]; + lcd_fastpixelfunc_type *pfunc = (lcd_backdrop ? + lcd_fastimgpixelfuncs[drawmode] : + lcd_fastpixelfuncs[drawmode]); /* direction flip */ if (x2 < x1) @@ -308,7 +348,9 @@ void lcd_vline(int x, int y1, int y2) { int y; fb_data *dst, *dst_end; - lcd_fastpixelfunc_type *pfunc = lcd_fastpixelfuncs[drawmode]; + lcd_fastpixelfunc_type *pfunc = (lcd_backdrop ? + lcd_fastimgpixelfuncs[drawmode] : + lcd_fastpixelfuncs[drawmode]); /* direction flip */ if (y2 < y1) @@ -358,7 +400,9 @@ void lcd_drawrect(int x, int y, int width, int height) void lcd_fillrect(int x, int y, int width, int height) { fb_data *dst, *dst_end; - lcd_fastpixelfunc_type *pfunc = lcd_fastpixelfuncs[drawmode]; + lcd_fastpixelfunc_type *pfunc = (lcd_backdrop ? + lcd_fastimgpixelfuncs[drawmode] : + lcd_fastpixelfuncs[drawmode]); /* nothing to draw? */ if ((width <= 0) || (height <= 0) || (x >= LCD_WIDTH) || (y >= LCD_HEIGHT) @@ -450,8 +494,13 @@ void lcd_mono_bitmap_part(const unsigned char *src, int src_x, int src_y, src_end = src + width; dst = LCDADDR(x, y); - fgfunc = lcd_fastpixelfuncs[drawmode]; - bgfunc = lcd_fastpixelfuncs[drawmode ^ DRMODE_INVERSEVID]; + if (lcd_backdrop) { + fgfunc = lcd_fastimgpixelfuncs[drawmode]; + bgfunc = lcd_fastimgpixelfuncs[drawmode ^ DRMODE_INVERSEVID]; + } else { + fgfunc = lcd_fastpixelfuncs[drawmode]; + bgfunc = lcd_fastpixelfuncs[drawmode ^ DRMODE_INVERSEVID]; + } do { diff --git a/firmware/export/lcd.h b/firmware/export/lcd.h index f4c40fb88c..55a51b3176 100644 --- a/firmware/export/lcd.h +++ b/firmware/export/lcd.h @@ -265,6 +265,10 @@ extern void lcd_set_background(unsigned background); extern unsigned lcd_get_background(void); extern void lcd_set_drawinfo(int mode, unsigned foreground, unsigned background); +#ifdef HAVE_LCD_COLOR +void lcd_set_backdrop(fb_data* backdrop); +fb_data* lcd_get_backdrop(void); +#endif extern 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); -- cgit v1.2.3