diff options
author | Andrew Mahone <andrew.mahone@gmail.com> | 2008-12-26 07:03:22 +0000 |
---|---|---|
committer | Andrew Mahone <andrew.mahone@gmail.com> | 2008-12-26 07:03:22 +0000 |
commit | f7fa7e5ad537415f1f75b3a9c1a58eb925e10d04 (patch) | |
tree | ea469e428a756e4f4979be1b6f5a84179a2cc80f /apps/plugins | |
parent | 7428c7cc5b8462ed95683f707fe78609ce8208bf (diff) | |
download | rockbox-f7fa7e5ad537415f1f75b3a9c1a58eb925e10d04.tar.gz rockbox-f7fa7e5ad537415f1f75b3a9c1a58eb925e10d04.zip |
Latest work on the bmp on-load scaler:
Macros for calculating size needed for bitmap load and scaling, so that
these can be compile-time constant when their inputs are.
Reduce size of bayer dither by chopping all but first row of dither
matrix, and replacing 2D lookup with 1D lookup and small calculation.
Move some functions not related to actual bmp file loading out of bmp.c.
A smaller brightness() for mono targets, and a higher-quality one for
greyscale targets, both replacing the division by 10 with a shift.
Port of the linear and area scalers to greyscale targets, this costs
some binsize but produces better output even when dithered to 2bpp.
Move duplicated row output code from inside vertical scalers to a
separate row output function.
Move some multiplies out of the line scaler, for a small speedup and
code size reduction, as well as a small improvement in accuracy for the
upscaling case.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@19592 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/plugins')
-rw-r--r-- | apps/plugins/sliding_puzzle.c | 32 |
1 files changed, 9 insertions, 23 deletions
diff --git a/apps/plugins/sliding_puzzle.c b/apps/plugins/sliding_puzzle.c index 85f4d32f68..fa9e093c3c 100644 --- a/apps/plugins/sliding_puzzle.c +++ b/apps/plugins/sliding_puzzle.c | |||
@@ -19,7 +19,6 @@ | |||
19 | * | 19 | * |
20 | ****************************************************************************/ | 20 | ****************************************************************************/ |
21 | #include "plugin.h" | 21 | #include "plugin.h" |
22 | #include "lib/bmp.h" | ||
23 | 22 | ||
24 | #ifdef HAVE_LCD_BITMAP | 23 | #ifdef HAVE_LCD_BITMAP |
25 | PLUGIN_HEADER | 24 | PLUGIN_HEADER |
@@ -258,13 +257,9 @@ static int num_font = FONT_UI; | |||
258 | static int moves_font = FONT_UI; | 257 | static int moves_font = FONT_UI; |
259 | static int moves_y = 0; | 258 | static int moves_y = 0; |
260 | 259 | ||
261 | #ifdef HAVE_LCD_COLOR | 260 | static unsigned char img_buf |
262 | static unsigned char *img_buf; | 261 | [BM_SCALED_SIZE(IMAGE_WIDTH,IMAGE_HEIGHT,FORMAT_NATIVE,0)] |
263 | static size_t buf_len; | 262 | __attribute__ ((aligned(16))); |
264 | #else | ||
265 | static unsigned char img_buf[IMAGE_WIDTH*IMAGE_HEIGHT*sizeof(fb_data)] | ||
266 | __attribute__ ((aligned(16))); | ||
267 | #endif | ||
268 | #ifdef HAVE_ALBUMART | 263 | #ifdef HAVE_ALBUMART |
269 | static char albumart_path[MAX_PATH+1]; | 264 | static char albumart_path[MAX_PATH+1]; |
270 | #endif | 265 | #endif |
@@ -343,13 +338,9 @@ static bool load_resize_bitmap(void) | |||
343 | main_bitmap.width = IMAGE_WIDTH; | 338 | main_bitmap.width = IMAGE_WIDTH; |
344 | main_bitmap.height = IMAGE_HEIGHT; | 339 | main_bitmap.height = IMAGE_HEIGHT; |
345 | 340 | ||
346 | #ifndef HAVE_LCD_COLOR | ||
347 | size_t buf_len = sizeof(img_buf); | ||
348 | #endif | ||
349 | |||
350 | rc = rb->read_bmp_file( filename, &main_bitmap, | 341 | rc = rb->read_bmp_file( filename, &main_bitmap, |
351 | buf_len, | 342 | sizeof(img_buf), |
352 | FORMAT_NATIVE|FORMAT_RESIZE ); | 343 | FORMAT_NATIVE|FORMAT_RESIZE|FORMAT_DITHER); |
353 | if( rc > 0 ) | 344 | if( rc > 0 ) |
354 | { | 345 | { |
355 | puzzle_bmp_ptr = (const fb_data *)img_buf; | 346 | puzzle_bmp_ptr = (const fb_data *)img_buf; |
@@ -574,7 +565,8 @@ static int puzzle_loop(void) | |||
574 | /* change picture */ | 565 | /* change picture */ |
575 | picmode = (picmode+1)%PICMODE_LAST_XXX; | 566 | picmode = (picmode+1)%PICMODE_LAST_XXX; |
576 | 567 | ||
577 | /* if load_resize_bitmap fails to load bitmap, try next picmode */ | 568 | /* if load_resize_bitmap fails to load bitmap, try next picmode |
569 | */ | ||
578 | do | 570 | do |
579 | { | 571 | { |
580 | load_success = load_resize_bitmap(); | 572 | load_success = load_resize_bitmap(); |
@@ -618,7 +610,8 @@ static int puzzle_loop(void) | |||
618 | } | 610 | } |
619 | } | 611 | } |
620 | 612 | ||
621 | enum plugin_status plugin_start(const struct plugin_api* api, const void* parameter) | 613 | enum plugin_status plugin_start(const struct plugin_api* api, |
614 | const void* parameter) | ||
622 | { | 615 | { |
623 | int i, w, h; | 616 | int i, w, h; |
624 | 617 | ||
@@ -627,13 +620,6 @@ enum plugin_status plugin_start(const struct plugin_api* api, const void* parame | |||
627 | initial_bmp_path=(const char *)parameter; | 620 | initial_bmp_path=(const char *)parameter; |
628 | picmode = PICMODE_INITIAL_PICTURE; | 621 | picmode = PICMODE_INITIAL_PICTURE; |
629 | img_buf_path[0] = '\0'; | 622 | img_buf_path[0] = '\0'; |
630 | #ifdef HAVE_LCD_COLOR | ||
631 | unsigned char *img_buf_end; | ||
632 | img_buf = (unsigned char *)(rb->plugin_get_buffer(&buf_len)); | ||
633 | img_buf_end = img_buf + buf_len; | ||
634 | rb->align_buffer(PUN_PTR(void **,&img_buf), buf_len, 16); | ||
635 | buf_len = img_buf_end - img_buf; | ||
636 | #endif | ||
637 | 623 | ||
638 | /* If launched as a viewer, just go straight to the game without | 624 | /* If launched as a viewer, just go straight to the game without |
639 | bothering with the splash or instructions page */ | 625 | bothering with the splash or instructions page */ |