From 13209604c1512658e729d0bd9f1c54cf3e53568d Mon Sep 17 00:00:00 2001 From: Thomas Martitz Date: Tue, 8 Nov 2011 21:34:46 +0000 Subject: Add new lcd_bmp and lcd_bmp_part APIs. This new APIs wrap around lcd_[mono|transparent]_bitmap/_part calls and handle all kinds bitmaps. The intended use is to draw bitmaps that come from read_bmp_fd/_file. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@30936 a1c6a512-1295-4272-9138-f99709370657 --- firmware/drivers/lcd-16bit-common.c | 18 ++++++++++++++++++ firmware/drivers/lcd-bitmap-common.c | 26 ++++++++++++++++++++++++++ firmware/export/lcd-remote.h | 4 +++- firmware/export/lcd.h | 3 +++ 4 files changed, 50 insertions(+), 1 deletion(-) (limited to 'firmware') diff --git a/firmware/drivers/lcd-16bit-common.c b/firmware/drivers/lcd-16bit-common.c index 1e1548e997..bbac2b295a 100644 --- a/firmware/drivers/lcd-16bit-common.c +++ b/firmware/drivers/lcd-16bit-common.c @@ -515,3 +515,21 @@ void ICODE_ATTR lcd_alpha_bitmap_part(const unsigned char *src, int src_x, #endif } while (--row); } + +/* Draw a partial bitmap (mono or native) including alpha channel */ +void ICODE_ATTR lcd_bmp_part(const struct bitmap* bm, int src_x, int src_y, + int x, int y, int width, int height) +{ + int bitmap_stride = STRIDE_MAIN(bm->width, bm->height); + if (bm->format == FORMAT_MONO) + lcd_mono_bitmap_part(bm->data, src_x, src_y, bitmap_stride, x, y, width, height); + else + lcd_bitmap_transparent_part((fb_data*)bm->data, + src_x, src_y, bitmap_stride, x, y, width, height); +} + +/* Draw a native bitmap with alpha channel */ +void ICODE_ATTR lcd_bmp(const struct bitmap *bmp, int x, int y) +{ + lcd_bmp_part(bmp, 0, 0, x, y, bmp->width, bmp->height); +} diff --git a/firmware/drivers/lcd-bitmap-common.c b/firmware/drivers/lcd-bitmap-common.c index 878c08863b..3aa833d6a1 100644 --- a/firmware/drivers/lcd-bitmap-common.c +++ b/firmware/drivers/lcd-bitmap-common.c @@ -501,3 +501,29 @@ void LCDFN(puts_scroll_style_offset)(int x, int y, const unsigned char *string, { LCDFN(puts_scroll_style_xyoffset)(x, y, string, style, x_offset, 0); } + +#if !defined(HAVE_LCD_COLOR) || !defined(MAIN_LCD) +/* see lcd-16bit-common.c for others */ +#ifdef MAIN_LCD +#define THIS_STRIDE STRIDE_MAIN +#else +#define THIS_STRIDE STRIDE_REMOTE +#endif + +void LCDFN(bmp_part)(const struct bitmap* bm, int src_x, int src_y, + int x, int y, int width, int height) +{ + if (bm->format == FORMAT_MONO) + LCDFN(mono_bitmap_part)((FBFN(data)*)(bm->data), + src_x, src_y, THIS_STRIDE(bm->width, bm->height), x, y, width, height); + else + LCDFN(bitmap_part)((FBFN(data)*)(bm->data), + src_x, src_y, THIS_STRIDE(bm->width, bm->height), x, y, width, height); +} + +void LCDFN(bmp)(const struct bitmap* bm, int x, int y) +{ + LCDFN(bmp_part)(bm, 0, 0, x, y, bm->width, bm->height); +} + +#endif diff --git a/firmware/export/lcd-remote.h b/firmware/export/lcd-remote.h index e2f2ab16ec..46ec2a949a 100644 --- a/firmware/export/lcd-remote.h +++ b/firmware/export/lcd-remote.h @@ -216,6 +216,8 @@ extern void lcd_bitmap_remote_transparent(const fb_remote_data *src, int x, #define lcd_remote_mono_bitmap lcd_remote_bitmap #define lcd_remote_mono_bitmap_part lcd_remote_bitmap_part #endif /* LCD_REMOTE_DEPTH */ - +extern void lcd_remote_bmp_part(const struct bitmap* bm, int src_x, int src_y, + int x, int y, int width, int height); +extern void lcd_remote_bmp(const struct bitmap* bm, int x, int y); #endif #endif /* __LCD_REMOTE_H__ */ diff --git a/firmware/export/lcd.h b/firmware/export/lcd.h index f4336233ab..47ea94bca9 100644 --- a/firmware/export/lcd.h +++ b/firmware/export/lcd.h @@ -543,6 +543,9 @@ extern void lcd_bitmap_transparent_part(const fb_data *src, int height); extern void lcd_bitmap_transparent(const fb_data *src, int x, int y, int width, int height); +extern void lcd_bmp_part(const struct bitmap* bm, int src_x, int src_y, + int x, int y, int width, int height); +extern void lcd_bmp(const struct bitmap* bm, int x, int y); #else /* LCD_DEPTH == 1 */ #define lcd_mono_bitmap lcd_bitmap #define lcd_mono_bitmap_part lcd_bitmap_part -- cgit v1.2.3