summaryrefslogtreecommitdiffstats
path: root/apps/plugins/sliding_puzzle.c
diff options
context:
space:
mode:
authorAndrew Mahone <andrew.mahone@gmail.com>2008-12-26 07:03:22 +0000
committerAndrew Mahone <andrew.mahone@gmail.com>2008-12-26 07:03:22 +0000
commitf7fa7e5ad537415f1f75b3a9c1a58eb925e10d04 (patch)
treeea469e428a756e4f4979be1b6f5a84179a2cc80f /apps/plugins/sliding_puzzle.c
parent7428c7cc5b8462ed95683f707fe78609ce8208bf (diff)
downloadrockbox-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/sliding_puzzle.c')
-rw-r--r--apps/plugins/sliding_puzzle.c32
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 @@
*
****************************************************************************/
#include "plugin.h"
-#include "lib/bmp.h"
#ifdef HAVE_LCD_BITMAP
PLUGIN_HEADER
@@ -258,13 +257,9 @@ static int num_font = FONT_UI;
static int moves_font = FONT_UI;
static int moves_y = 0;
-#ifdef HAVE_LCD_COLOR
-static unsigned char *img_buf;
-static size_t buf_len;
-#else
-static unsigned char img_buf[IMAGE_WIDTH*IMAGE_HEIGHT*sizeof(fb_data)]
-__attribute__ ((aligned(16)));
-#endif
+static unsigned char img_buf
+ [BM_SCALED_SIZE(IMAGE_WIDTH,IMAGE_HEIGHT,FORMAT_NATIVE,0)]
+ __attribute__ ((aligned(16)));
#ifdef HAVE_ALBUMART
static char albumart_path[MAX_PATH+1];
#endif
@@ -343,13 +338,9 @@ static bool load_resize_bitmap(void)
main_bitmap.width = IMAGE_WIDTH;
main_bitmap.height = IMAGE_HEIGHT;
-#ifndef HAVE_LCD_COLOR
- size_t buf_len = sizeof(img_buf);
-#endif
-
rc = rb->read_bmp_file( filename, &main_bitmap,
- buf_len,
- FORMAT_NATIVE|FORMAT_RESIZE );
+ sizeof(img_buf),
+ FORMAT_NATIVE|FORMAT_RESIZE|FORMAT_DITHER);
if( rc > 0 )
{
puzzle_bmp_ptr = (const fb_data *)img_buf;
@@ -574,7 +565,8 @@ static int puzzle_loop(void)
/* change picture */
picmode = (picmode+1)%PICMODE_LAST_XXX;
- /* if load_resize_bitmap fails to load bitmap, try next picmode */
+ /* if load_resize_bitmap fails to load bitmap, try next picmode
+ */
do
{
load_success = load_resize_bitmap();
@@ -618,7 +610,8 @@ static int puzzle_loop(void)
}
}
-enum plugin_status plugin_start(const struct plugin_api* api, const void* parameter)
+enum plugin_status plugin_start(const struct plugin_api* api,
+ const void* parameter)
{
int i, w, h;
@@ -627,13 +620,6 @@ enum plugin_status plugin_start(const struct plugin_api* api, const void* parame
initial_bmp_path=(const char *)parameter;
picmode = PICMODE_INITIAL_PICTURE;
img_buf_path[0] = '\0';
-#ifdef HAVE_LCD_COLOR
- unsigned char *img_buf_end;
- img_buf = (unsigned char *)(rb->plugin_get_buffer(&buf_len));
- img_buf_end = img_buf + buf_len;
- rb->align_buffer(PUN_PTR(void **,&img_buf), buf_len, 16);
- buf_len = img_buf_end - img_buf;
-#endif
/* If launched as a viewer, just go straight to the game without
bothering with the splash or instructions page */