diff options
author | Thomas Martitz <kugel@rockbox.org> | 2011-11-08 21:34:46 +0000 |
---|---|---|
committer | Thomas Martitz <kugel@rockbox.org> | 2011-11-08 21:34:46 +0000 |
commit | 13209604c1512658e729d0bd9f1c54cf3e53568d (patch) | |
tree | 2787f9036b5c40cf79cd324f3d215bb9d48dd34a | |
parent | 6223ad266e556f5b8d749d5f4fe08e27385be66f (diff) | |
download | rockbox-13209604c1512658e729d0bd9f1c54cf3e53568d.tar.gz rockbox-13209604c1512658e729d0bd9f1c54cf3e53568d.zip |
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
-rw-r--r-- | apps/gui/icon.c | 14 | ||||
-rw-r--r-- | apps/gui/scrollbar.c | 13 | ||||
-rw-r--r-- | apps/gui/skin_engine/skin_display.c | 58 | ||||
-rw-r--r-- | apps/plugin.h | 4 | ||||
-rw-r--r-- | apps/screen_access.c | 4 | ||||
-rw-r--r-- | apps/screen_access.h | 3 | ||||
-rw-r--r-- | firmware/drivers/lcd-16bit-common.c | 18 | ||||
-rw-r--r-- | firmware/drivers/lcd-bitmap-common.c | 26 | ||||
-rw-r--r-- | firmware/export/lcd-remote.h | 4 | ||||
-rw-r--r-- | firmware/export/lcd.h | 3 |
10 files changed, 68 insertions, 79 deletions
diff --git a/apps/gui/icon.c b/apps/gui/icon.c index c171da5b44..4c006f947a 100644 --- a/apps/gui/icon.c +++ b/apps/gui/icon.c | |||
@@ -109,14 +109,11 @@ void screen_put_icon_with_offset(struct screen * display, | |||
109 | void screen_put_iconxy(struct screen * display, | 109 | void screen_put_iconxy(struct screen * display, |
110 | int xpos, int ypos, enum themable_icons icon) | 110 | int xpos, int ypos, enum themable_icons icon) |
111 | { | 111 | { |
112 | const void *data; | ||
113 | const int screen = display->screen_type; | 112 | const int screen = display->screen_type; |
114 | const int width = ICON_WIDTH(screen); | 113 | const int width = ICON_WIDTH(screen); |
115 | const int height = ICON_HEIGHT(screen); | 114 | const int height = ICON_HEIGHT(screen); |
116 | const int is_rtl = lang_is_rtl(); | 115 | const int is_rtl = lang_is_rtl(); |
117 | int stride; | ||
118 | const struct bitmap *iconset; | 116 | const struct bitmap *iconset; |
119 | screen_bitmap_part_func *draw_func = NULL; | ||
120 | 117 | ||
121 | if (icon == Icon_NOICON) | 118 | if (icon == Icon_NOICON) |
122 | { | 119 | { |
@@ -145,9 +142,6 @@ void screen_put_iconxy(struct screen * display, | |||
145 | { | 142 | { |
146 | iconset = &inbuilt_iconset[screen]; | 143 | iconset = &inbuilt_iconset[screen]; |
147 | } | 144 | } |
148 | data = iconset->data; | ||
149 | stride = STRIDE(display->screen_type, iconset->width, iconset->height); | ||
150 | |||
151 | /* add some left padding to the icons if they are on the edge */ | 145 | /* add some left padding to the icons if they are on the edge */ |
152 | if (xpos == 0) | 146 | if (xpos == 0) |
153 | xpos++; | 147 | xpos++; |
@@ -155,14 +149,8 @@ void screen_put_iconxy(struct screen * display, | |||
155 | if (is_rtl) | 149 | if (is_rtl) |
156 | xpos = display->getwidth() - xpos - width; | 150 | xpos = display->getwidth() - xpos - width; |
157 | 151 | ||
158 | #if (LCD_DEPTH == 16) || defined(LCD_REMOTE_DEPTH) && (LCD_REMOTE_DEPTH == 16) | ||
159 | if (display->depth == 16) | ||
160 | draw_func = display->transparent_bitmap_part; | ||
161 | else | ||
162 | #endif | ||
163 | draw_func = display->bitmap_part; | ||
164 | 152 | ||
165 | draw_func(data, 0, height * icon, stride, xpos, ypos, width, height); | 153 | display->bmp_part(iconset, 0, height * icon, xpos, ypos, width, height); |
166 | } | 154 | } |
167 | 155 | ||
168 | void screen_put_cursorxy(struct screen * display, int x, int y, bool on) | 156 | void screen_put_cursorxy(struct screen * display, int x, int y, bool on) |
diff --git a/apps/gui/scrollbar.c b/apps/gui/scrollbar.c index 70d34176e1..aafd4b093a 100644 --- a/apps/gui/scrollbar.c +++ b/apps/gui/scrollbar.c | |||
@@ -234,18 +234,7 @@ void gui_bitmap_scrollbar_draw(struct screen * screen, struct bitmap *bm, int x, | |||
234 | else if (bm->height < starty + height) | 234 | else if (bm->height < starty + height) |
235 | height = bm->height - starty; | 235 | height = bm->height - starty; |
236 | 236 | ||
237 | #if LCD_DEPTH > 1 | 237 | screen->bmp_part(bm, startx, starty, x, y, width, height); |
238 | if (bm->format == FORMAT_MONO) | ||
239 | #endif | ||
240 | screen->mono_bitmap_part(bm->data, startx, starty, | ||
241 | bm->width, x, y, width, height); | ||
242 | #if LCD_DEPTH > 1 | ||
243 | else | ||
244 | screen->transparent_bitmap_part((fb_data *)bm->data, startx, starty, | ||
245 | STRIDE(screen->screen_type, | ||
246 | bm->width, bm->height), | ||
247 | x, y, width, height); | ||
248 | #endif | ||
249 | } | 238 | } |
250 | 239 | ||
251 | void show_busy_slider(struct screen *s, int x, int y, int width, int height) | 240 | void show_busy_slider(struct screen *s, int x, int y, int width, int height) |
diff --git a/apps/gui/skin_engine/skin_display.c b/apps/gui/skin_engine/skin_display.c index 95e4310de9..d2dbb56f64 100644 --- a/apps/gui/skin_engine/skin_display.c +++ b/apps/gui/skin_engine/skin_display.c | |||
@@ -248,22 +248,8 @@ void draw_progressbar(struct gui_wps *gwps, int line, struct progressbar *pb) | |||
248 | if (pb->backdrop) | 248 | if (pb->backdrop) |
249 | { | 249 | { |
250 | struct gui_img *img = pb->backdrop; | 250 | struct gui_img *img = pb->backdrop; |
251 | char *img_data = core_get_data(img->buflib_handle); | 251 | img->bm.data = core_get_data(img->buflib_handle); |
252 | #if LCD_DEPTH > 1 | 252 | display->bmp_part(&img->bm, 0, 0, x, y, width, height); |
253 | if(img->bm.format == FORMAT_MONO) { | ||
254 | #endif | ||
255 | display->mono_bitmap_part(img_data, | ||
256 | 0, 0, img->bm.width, | ||
257 | x, y, width, height); | ||
258 | #if LCD_DEPTH > 1 | ||
259 | } else { | ||
260 | display->transparent_bitmap_part((fb_data *)img_data, | ||
261 | 0, 0, | ||
262 | STRIDE(display->screen_type, | ||
263 | img->bm.width, img->bm.height), | ||
264 | x, y, width, height); | ||
265 | } | ||
266 | #endif | ||
267 | flags |= DONT_CLEAR_EXCESS; | 253 | flags |= DONT_CLEAR_EXCESS; |
268 | } | 254 | } |
269 | 255 | ||
@@ -287,7 +273,7 @@ void draw_progressbar(struct gui_wps *gwps, int line, struct progressbar *pb) | |||
287 | int xoff = 0, yoff = 0; | 273 | int xoff = 0, yoff = 0; |
288 | int w = width, h = height; | 274 | int w = width, h = height; |
289 | struct gui_img *img = pb->slider; | 275 | struct gui_img *img = pb->slider; |
290 | char *img_data = core_get_data(img->buflib_handle); | 276 | img->bm.data = core_get_data(img->buflib_handle); |
291 | 277 | ||
292 | if (flags&HORIZONTAL) | 278 | if (flags&HORIZONTAL) |
293 | { | 279 | { |
@@ -305,21 +291,7 @@ void draw_progressbar(struct gui_wps *gwps, int line, struct progressbar *pb) | |||
305 | yoff = height - yoff; | 291 | yoff = height - yoff; |
306 | yoff -= h / 2; | 292 | yoff -= h / 2; |
307 | } | 293 | } |
308 | #if LCD_DEPTH > 1 | 294 | display->bmp_part(&img->bm, 0, 0, x + xoff, y + yoff, w, h); |
309 | if(img->bm.format == FORMAT_MONO) { | ||
310 | #endif | ||
311 | display->mono_bitmap_part(img_data, | ||
312 | 0, 0, img->bm.width, | ||
313 | x + xoff, y + yoff, w, h); | ||
314 | #if LCD_DEPTH > 1 | ||
315 | } else { | ||
316 | display->transparent_bitmap_part((fb_data *)img_data, | ||
317 | 0, 0, | ||
318 | STRIDE(display->screen_type, | ||
319 | img->bm.width, img->bm.height), | ||
320 | x + xoff, y + yoff, w, h); | ||
321 | } | ||
322 | #endif | ||
323 | } | 295 | } |
324 | 296 | ||
325 | if (pb->type == SKIN_TOKEN_PROGRESSBAR) | 297 | if (pb->type == SKIN_TOKEN_PROGRESSBAR) |
@@ -357,30 +329,14 @@ void clear_image_pos(struct gui_wps *gwps, struct gui_img *img) | |||
357 | void wps_draw_image(struct gui_wps *gwps, struct gui_img *img, int subimage) | 329 | void wps_draw_image(struct gui_wps *gwps, struct gui_img *img, int subimage) |
358 | { | 330 | { |
359 | struct screen *display = gwps->display; | 331 | struct screen *display = gwps->display; |
360 | char *img_data = core_get_data(img->buflib_handle); | 332 | img->bm.data = core_get_data(img->buflib_handle); |
361 | if(img->always_display) | 333 | if(img->always_display) |
362 | display->set_drawmode(DRMODE_FG); | 334 | display->set_drawmode(DRMODE_FG); |
363 | else | 335 | else |
364 | display->set_drawmode(DRMODE_SOLID); | 336 | display->set_drawmode(DRMODE_SOLID); |
365 | 337 | ||
366 | #if LCD_DEPTH > 1 | 338 | display->bmp_part(&img->bm, 0, img->subimage_height * subimage, |
367 | if(img->bm.format == FORMAT_MONO) { | 339 | img->x, img->y, img->bm.width, img->subimage_height); |
368 | #endif | ||
369 | display->mono_bitmap_part(img_data, | ||
370 | 0, img->subimage_height * subimage, | ||
371 | img->bm.width, img->x, | ||
372 | img->y, img->bm.width, | ||
373 | img->subimage_height); | ||
374 | #if LCD_DEPTH > 1 | ||
375 | } else { | ||
376 | display->transparent_bitmap_part((fb_data *)img_data, | ||
377 | 0, img->subimage_height * subimage, | ||
378 | STRIDE(display->screen_type, | ||
379 | img->bm.width, img->bm.height), | ||
380 | img->x, img->y, img->bm.width, | ||
381 | img->subimage_height); | ||
382 | } | ||
383 | #endif | ||
384 | } | 340 | } |
385 | 341 | ||
386 | 342 | ||
diff --git a/apps/plugin.h b/apps/plugin.h index fa1259cfe3..0ee37bb4fe 100644 --- a/apps/plugin.h +++ b/apps/plugin.h | |||
@@ -147,12 +147,12 @@ void* plugin_get_buffer(size_t *buffer_size); | |||
147 | #define PLUGIN_MAGIC 0x526F634B /* RocK */ | 147 | #define PLUGIN_MAGIC 0x526F634B /* RocK */ |
148 | 148 | ||
149 | /* increase this every time the api struct changes */ | 149 | /* increase this every time the api struct changes */ |
150 | #define PLUGIN_API_VERSION 213 | 150 | #define PLUGIN_API_VERSION 214 |
151 | 151 | ||
152 | /* update this to latest version if a change to the api struct breaks | 152 | /* update this to latest version if a change to the api struct breaks |
153 | backwards compatibility (and please take the opportunity to sort in any | 153 | backwards compatibility (and please take the opportunity to sort in any |
154 | new function which are "waiting" at the end of the function table) */ | 154 | new function which are "waiting" at the end of the function table) */ |
155 | #define PLUGIN_MIN_API_VERSION 213 | 155 | #define PLUGIN_MIN_API_VERSION 214 |
156 | 156 | ||
157 | /* plugin return codes */ | 157 | /* plugin return codes */ |
158 | /* internal returns start at 0x100 to make exit(1..255) work */ | 158 | /* internal returns start at 0x100 to make exit(1..255) work */ |
diff --git a/apps/screen_access.c b/apps/screen_access.c index 19df13dbc3..b7dc90b5bd 100644 --- a/apps/screen_access.c +++ b/apps/screen_access.c | |||
@@ -197,6 +197,8 @@ struct screen screens[NB_SCREENS] = | |||
197 | .transparent_bitmap=(screen_bitmap_func*)&lcd_bitmap_transparent, | 197 | .transparent_bitmap=(screen_bitmap_func*)&lcd_bitmap_transparent, |
198 | .transparent_bitmap_part=(screen_bitmap_part_func*)&lcd_bitmap_transparent_part, | 198 | .transparent_bitmap_part=(screen_bitmap_part_func*)&lcd_bitmap_transparent_part, |
199 | #endif | 199 | #endif |
200 | .bmp = &lcd_bmp, | ||
201 | .bmp_part = &lcd_bmp_part, | ||
200 | #if LCD_DEPTH > 1 | 202 | #if LCD_DEPTH > 1 |
201 | #if defined(HAVE_LCD_COLOR) && defined(LCD_REMOTE_DEPTH) && LCD_REMOTE_DEPTH > 1 | 203 | #if defined(HAVE_LCD_COLOR) && defined(LCD_REMOTE_DEPTH) && LCD_REMOTE_DEPTH > 1 |
202 | .color_to_native=&lcd_color_to_native, | 204 | .color_to_native=&lcd_color_to_native, |
@@ -296,6 +298,8 @@ struct screen screens[NB_SCREENS] = | |||
296 | .transparent_bitmap_part=(screen_bitmap_part_func*)&lcd_remote_bitmap_part, | 298 | .transparent_bitmap_part=(screen_bitmap_part_func*)&lcd_remote_bitmap_part, |
297 | /* No colour remotes yet */ | 299 | /* No colour remotes yet */ |
298 | #endif | 300 | #endif |
301 | .bmp = &lcd_remote_bmp, | ||
302 | .bmp_part = &lcd_remote_bmp_part, | ||
299 | #if LCD_REMOTE_DEPTH > 1 | 303 | #if LCD_REMOTE_DEPTH > 1 |
300 | #if defined(HAVE_LCD_COLOR) | 304 | #if defined(HAVE_LCD_COLOR) |
301 | .color_to_native=&lcd_remote_color_to_native, | 305 | .color_to_native=&lcd_remote_color_to_native, |
diff --git a/apps/screen_access.h b/apps/screen_access.h index 04cc6f4f90..a9d1408898 100644 --- a/apps/screen_access.h +++ b/apps/screen_access.h | |||
@@ -97,6 +97,9 @@ struct screen | |||
97 | int x, int y, int width, int height); | 97 | int x, int y, int width, int height); |
98 | void (*transparent_bitmap_part)(const void *src, int src_x, int src_y, | 98 | void (*transparent_bitmap_part)(const void *src, int src_x, int src_y, |
99 | int stride, int x, int y, int width, int height); | 99 | int stride, int x, int y, int width, int height); |
100 | void (*bmp)(const struct bitmap *bm, int x, int y); | ||
101 | void (*bmp_part)(const struct bitmap* bm, int src_x, int src_y, | ||
102 | int x, int y, int width, int height); | ||
100 | void (*set_drawmode)(int mode); | 103 | void (*set_drawmode)(int mode); |
101 | #if defined(HAVE_LCD_COLOR) && defined(LCD_REMOTE_DEPTH) && LCD_REMOTE_DEPTH > 1 | 104 | #if defined(HAVE_LCD_COLOR) && defined(LCD_REMOTE_DEPTH) && LCD_REMOTE_DEPTH > 1 |
102 | unsigned (*color_to_native)(unsigned color); | 105 | unsigned (*color_to_native)(unsigned color); |
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, | |||
515 | #endif | 515 | #endif |
516 | } while (--row); | 516 | } while (--row); |
517 | } | 517 | } |
518 | |||
519 | /* Draw a partial bitmap (mono or native) including alpha channel */ | ||
520 | void ICODE_ATTR lcd_bmp_part(const struct bitmap* bm, int src_x, int src_y, | ||
521 | int x, int y, int width, int height) | ||
522 | { | ||
523 | int bitmap_stride = STRIDE_MAIN(bm->width, bm->height); | ||
524 | if (bm->format == FORMAT_MONO) | ||
525 | lcd_mono_bitmap_part(bm->data, src_x, src_y, bitmap_stride, x, y, width, height); | ||
526 | else | ||
527 | lcd_bitmap_transparent_part((fb_data*)bm->data, | ||
528 | src_x, src_y, bitmap_stride, x, y, width, height); | ||
529 | } | ||
530 | |||
531 | /* Draw a native bitmap with alpha channel */ | ||
532 | void ICODE_ATTR lcd_bmp(const struct bitmap *bmp, int x, int y) | ||
533 | { | ||
534 | lcd_bmp_part(bmp, 0, 0, x, y, bmp->width, bmp->height); | ||
535 | } | ||
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, | |||
501 | { | 501 | { |
502 | LCDFN(puts_scroll_style_xyoffset)(x, y, string, style, x_offset, 0); | 502 | LCDFN(puts_scroll_style_xyoffset)(x, y, string, style, x_offset, 0); |
503 | } | 503 | } |
504 | |||
505 | #if !defined(HAVE_LCD_COLOR) || !defined(MAIN_LCD) | ||
506 | /* see lcd-16bit-common.c for others */ | ||
507 | #ifdef MAIN_LCD | ||
508 | #define THIS_STRIDE STRIDE_MAIN | ||
509 | #else | ||
510 | #define THIS_STRIDE STRIDE_REMOTE | ||
511 | #endif | ||
512 | |||
513 | void LCDFN(bmp_part)(const struct bitmap* bm, int src_x, int src_y, | ||
514 | int x, int y, int width, int height) | ||
515 | { | ||
516 | if (bm->format == FORMAT_MONO) | ||
517 | LCDFN(mono_bitmap_part)((FBFN(data)*)(bm->data), | ||
518 | src_x, src_y, THIS_STRIDE(bm->width, bm->height), x, y, width, height); | ||
519 | else | ||
520 | LCDFN(bitmap_part)((FBFN(data)*)(bm->data), | ||
521 | src_x, src_y, THIS_STRIDE(bm->width, bm->height), x, y, width, height); | ||
522 | } | ||
523 | |||
524 | void LCDFN(bmp)(const struct bitmap* bm, int x, int y) | ||
525 | { | ||
526 | LCDFN(bmp_part)(bm, 0, 0, x, y, bm->width, bm->height); | ||
527 | } | ||
528 | |||
529 | #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, | |||
216 | #define lcd_remote_mono_bitmap lcd_remote_bitmap | 216 | #define lcd_remote_mono_bitmap lcd_remote_bitmap |
217 | #define lcd_remote_mono_bitmap_part lcd_remote_bitmap_part | 217 | #define lcd_remote_mono_bitmap_part lcd_remote_bitmap_part |
218 | #endif /* LCD_REMOTE_DEPTH */ | 218 | #endif /* LCD_REMOTE_DEPTH */ |
219 | 219 | extern void lcd_remote_bmp_part(const struct bitmap* bm, int src_x, int src_y, | |
220 | int x, int y, int width, int height); | ||
221 | extern void lcd_remote_bmp(const struct bitmap* bm, int x, int y); | ||
220 | #endif | 222 | #endif |
221 | #endif /* __LCD_REMOTE_H__ */ | 223 | #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, | |||
543 | int height); | 543 | int height); |
544 | extern void lcd_bitmap_transparent(const fb_data *src, int x, int y, | 544 | extern void lcd_bitmap_transparent(const fb_data *src, int x, int y, |
545 | int width, int height); | 545 | int width, int height); |
546 | extern void lcd_bmp_part(const struct bitmap* bm, int src_x, int src_y, | ||
547 | int x, int y, int width, int height); | ||
548 | extern void lcd_bmp(const struct bitmap* bm, int x, int y); | ||
546 | #else /* LCD_DEPTH == 1 */ | 549 | #else /* LCD_DEPTH == 1 */ |
547 | #define lcd_mono_bitmap lcd_bitmap | 550 | #define lcd_mono_bitmap lcd_bitmap |
548 | #define lcd_mono_bitmap_part lcd_bitmap_part | 551 | #define lcd_mono_bitmap_part lcd_bitmap_part |