diff options
Diffstat (limited to 'apps/plugins')
-rw-r--r-- | apps/plugins/pictureflow.c | 67 |
1 files changed, 50 insertions, 17 deletions
diff --git a/apps/plugins/pictureflow.c b/apps/plugins/pictureflow.c index 320e39c842..b6c63c4561 100644 --- a/apps/plugins/pictureflow.c +++ b/apps/plugins/pictureflow.c | |||
@@ -43,7 +43,6 @@ const struct button_mapping *plugin_contexts[] | |||
43 | #if LCD_DEPTH < 8 | 43 | #if LCD_DEPTH < 8 |
44 | #define USEGSLIB | 44 | #define USEGSLIB |
45 | GREY_INFO_STRUCT | 45 | GREY_INFO_STRUCT |
46 | #define FPLUGIN &format_grey | ||
47 | #define LCD_BUF _grey_info.buffer | 46 | #define LCD_BUF _grey_info.buffer |
48 | #define MYLCD(fn) grey_ ## fn | 47 | #define MYLCD(fn) grey_ ## fn |
49 | #define G_PIX(r,g,b) \ | 48 | #define G_PIX(r,g,b) \ |
@@ -55,7 +54,6 @@ GREY_INFO_STRUCT | |||
55 | #define BUFFER_HEIGHT _grey_info.height | 54 | #define BUFFER_HEIGHT _grey_info.height |
56 | typedef unsigned char pix_t; | 55 | typedef unsigned char pix_t; |
57 | #else | 56 | #else |
58 | #define FPLUGIN NULL | ||
59 | #define LCD_BUF rb->lcd_framebuffer | 57 | #define LCD_BUF rb->lcd_framebuffer |
60 | #define MYLCD(fn) rb->lcd_ ## fn | 58 | #define MYLCD(fn) rb->lcd_ ## fn |
61 | #define G_PIX LCD_RGBPACK | 59 | #define G_PIX LCD_RGBPACK |
@@ -136,7 +134,7 @@ typedef fb_data pix_t; | |||
136 | #define ERROR_BUFFER_FULL -2 | 134 | #define ERROR_BUFFER_FULL -2 |
137 | 135 | ||
138 | /* current version for cover cache */ | 136 | /* current version for cover cache */ |
139 | #define CACHE_VERSION 1 | 137 | #define CACHE_VERSION 2 |
140 | #define CONFIG_VERSION 1 | 138 | #define CONFIG_VERSION 1 |
141 | #define CONFIG_FILE "pictureflow.cfg" | 139 | #define CONFIG_FILE "pictureflow.cfg" |
142 | 140 | ||
@@ -396,6 +394,43 @@ static inline PFreal fcos(int iangle) | |||
396 | return fsin(iangle + (IANGLE_MAX >> 2)); | 394 | return fsin(iangle + (IANGLE_MAX >> 2)); |
397 | } | 395 | } |
398 | 396 | ||
397 | static void output_row_transposed(uint32_t row, void * row_in, | ||
398 | struct scaler_context *ctx) | ||
399 | { | ||
400 | pix_t *dest = (pix_t*)ctx->bm->data + row; | ||
401 | pix_t *end = dest + ctx->bm->height * ctx->bm->width; | ||
402 | #ifdef USEGSLIB | ||
403 | uint32_t *qp = (uint32_t*)row_in; | ||
404 | for (; dest < end; dest += ctx->bm->height) | ||
405 | *dest = ((*qp++) + ctx->round) * (uint64_t)ctx->divisor >> 32; | ||
406 | #else | ||
407 | struct uint32_rgb *qp = (struct uint32_rgb*)row_in; | ||
408 | uint32_t rb_mul = ((uint64_t)ctx->divisor * 31 + 127) / 255, | ||
409 | rb_rnd = ((uint64_t)ctx->round * 31 + 127) / 255, | ||
410 | g_mul = ((uint64_t)ctx->divisor * 63 + 127) / 255, | ||
411 | g_rnd = ((uint64_t)ctx->round * 63 + 127) / 255; | ||
412 | unsigned int r, g, b; | ||
413 | for (; dest < end; dest += ctx->bm->height) | ||
414 | { | ||
415 | r = (qp->r + rb_rnd) * (uint64_t)rb_mul >> 32; | ||
416 | g = (qp->g + g_rnd) * (uint64_t)g_mul >> 32; | ||
417 | b = (qp->b + rb_rnd) * (uint64_t)rb_mul >> 32; | ||
418 | qp++; | ||
419 | *dest = LCD_RGBPACK_LCD(r,g,b); | ||
420 | } | ||
421 | #endif | ||
422 | } | ||
423 | |||
424 | static unsigned int get_size(struct bitmap *bm) | ||
425 | { | ||
426 | return bm->width * bm->height * sizeof(pix_t); | ||
427 | } | ||
428 | |||
429 | const struct custom_format format_transposed = { | ||
430 | .output_row = output_row_transposed, | ||
431 | .get_size = get_size | ||
432 | }; | ||
433 | |||
399 | /* Create the lookup table with the scaling values for the reflections */ | 434 | /* Create the lookup table with the scaling values for the reflections */ |
400 | void init_reflect_table(void) | 435 | void init_reflect_table(void) |
401 | { | 436 | { |
@@ -647,7 +682,7 @@ bool create_albumart_cache(void) | |||
647 | input_bmp.width = DISPLAY_WIDTH; | 682 | input_bmp.width = DISPLAY_WIDTH; |
648 | input_bmp.height = DISPLAY_HEIGHT; | 683 | input_bmp.height = DISPLAY_HEIGHT; |
649 | ret = rb->read_bmp_file(albumart_file, &input_bmp, | 684 | ret = rb->read_bmp_file(albumart_file, &input_bmp, |
650 | plugin_buf_size, format, FPLUGIN); | 685 | plugin_buf_size, format, &format_transposed); |
651 | if (ret <= 0) { | 686 | if (ret <= 0) { |
652 | rb->splash(HZ, "Could not read bmp"); | 687 | rb->splash(HZ, "Could not read bmp"); |
653 | continue; /* skip missing/broken files */ | 688 | continue; /* skip missing/broken files */ |
@@ -664,8 +699,6 @@ bool create_albumart_cache(void) | |||
664 | rb->splash(2*HZ, "No album art found"); | 699 | rb->splash(2*HZ, "No album art found"); |
665 | return false; | 700 | return false; |
666 | } | 701 | } |
667 | cache_version = CACHE_VERSION; | ||
668 | configfile_save(CONFIG_FILE, config, CONFIG_NUM_ITEMS, CONFIG_VERSION); | ||
669 | return true; | 702 | return true; |
670 | } | 703 | } |
671 | 704 | ||
@@ -1167,20 +1200,20 @@ void render_slide(struct slide_data *slide, const int alpha) | |||
1167 | int dy = dist / h; | 1200 | int dy = dist / h; |
1168 | int p1 = (bmp->height - 1 - (DISPLAY_OFFS)) * PFREAL_ONE; | 1201 | int p1 = (bmp->height - 1 - (DISPLAY_OFFS)) * PFREAL_ONE; |
1169 | int p2 = p1 + dy; | 1202 | int p2 = p1 + dy; |
1170 | const pix_t *ptr = &src[column]; | 1203 | const pix_t *ptr = &src[column * bmp->height]; |
1171 | 1204 | ||
1172 | if (alpha == 256) | 1205 | if (alpha == 256) |
1173 | { | 1206 | { |
1174 | while ((y1 >= 0) && (p1 >= 0)) | 1207 | while ((y1 >= 0) && (p1 >= 0)) |
1175 | { | 1208 | { |
1176 | *pixel1 = ptr[bmp->width * (p1 >> PFREAL_SHIFT)]; | 1209 | *pixel1 = ptr[p1 >> PFREAL_SHIFT]; |
1177 | p1 -= dy; | 1210 | p1 -= dy; |
1178 | y1--; | 1211 | y1--; |
1179 | pixel1 -= pixelstep; | 1212 | pixel1 -= pixelstep; |
1180 | } | 1213 | } |
1181 | while ((p2 < sh * PFREAL_ONE) && (y2 < h)) | 1214 | while ((p2 < sh * PFREAL_ONE) && (y2 < h)) |
1182 | { | 1215 | { |
1183 | *pixel2 = ptr[bmp->width * (p2 >> PFREAL_SHIFT)]; | 1216 | *pixel2 = ptr[p2 >> PFREAL_SHIFT]; |
1184 | p2 += dy; | 1217 | p2 += dy; |
1185 | y2++; | 1218 | y2++; |
1186 | pixel2 += pixelstep; | 1219 | pixel2 += pixelstep; |
@@ -1190,7 +1223,7 @@ void render_slide(struct slide_data *slide, const int alpha) | |||
1190 | { | 1223 | { |
1191 | int ty = (p2 >> PFREAL_SHIFT) - sh; | 1224 | int ty = (p2 >> PFREAL_SHIFT) - sh; |
1192 | int lalpha = reflect_table[ty]; | 1225 | int lalpha = reflect_table[ty]; |
1193 | *pixel2 = fade_color(ptr[bmp->width * (sh - 1 - ty)],lalpha); | 1226 | *pixel2 = fade_color(ptr[sh - 1 - ty],lalpha); |
1194 | p2 += dy; | 1227 | p2 += dy; |
1195 | y2++; | 1228 | y2++; |
1196 | pixel2 += pixelstep; | 1229 | pixel2 += pixelstep; |
@@ -1199,16 +1232,14 @@ void render_slide(struct slide_data *slide, const int alpha) | |||
1199 | else | 1232 | else |
1200 | while ((y1 >= 0) && (p1 >= 0)) | 1233 | while ((y1 >= 0) && (p1 >= 0)) |
1201 | { | 1234 | { |
1202 | *pixel1 = fade_color(ptr[bmp->width * | 1235 | *pixel1 = fade_color(ptr[p1 >> PFREAL_SHIFT],alpha); |
1203 | (p1 >> PFREAL_SHIFT)],alpha); | ||
1204 | p1 -= dy; | 1236 | p1 -= dy; |
1205 | y1--; | 1237 | y1--; |
1206 | pixel1 -= pixelstep; | 1238 | pixel1 -= pixelstep; |
1207 | } | 1239 | } |
1208 | while ((p2 < sh * PFREAL_ONE) && (y2 < h)) | 1240 | while ((p2 < sh * PFREAL_ONE) && (y2 < h)) |
1209 | { | 1241 | { |
1210 | *pixel2 = fade_color(ptr[bmp->width * | 1242 | *pixel2 = fade_color(ptr[p2 >> PFREAL_SHIFT],alpha); |
1211 | (p2 >> PFREAL_SHIFT)],alpha); | ||
1212 | p2 += dy; | 1243 | p2 += dy; |
1213 | y2++; | 1244 | y2++; |
1214 | pixel2 += pixelstep; | 1245 | pixel2 += pixelstep; |
@@ -1218,7 +1249,7 @@ void render_slide(struct slide_data *slide, const int alpha) | |||
1218 | { | 1249 | { |
1219 | int ty = (p2 >> PFREAL_SHIFT) - sh; | 1250 | int ty = (p2 >> PFREAL_SHIFT) - sh; |
1220 | int lalpha = (reflect_table[ty] * alpha + 128) >> 8; | 1251 | int lalpha = (reflect_table[ty] * alpha + 128) >> 8; |
1221 | *pixel2 = fade_color(ptr[bmp->width * (sh - 1 - ty)],lalpha); | 1252 | *pixel2 = fade_color(ptr[sh - 1 - ty],lalpha); |
1222 | p2 += dy; | 1253 | p2 += dy; |
1223 | y2++; | 1254 | y2++; |
1224 | pixel2 += pixelstep; | 1255 | pixel2 += pixelstep; |
@@ -1491,7 +1522,7 @@ int create_empty_slide(bool force) | |||
1491 | ret = rb->read_bmp_file(EMPTY_SLIDE_BMP, &input_bmp, | 1522 | ret = rb->read_bmp_file(EMPTY_SLIDE_BMP, &input_bmp, |
1492 | plugin_buf_size, | 1523 | plugin_buf_size, |
1493 | FORMAT_NATIVE|FORMAT_RESIZE|FORMAT_KEEP_ASPECT, | 1524 | FORMAT_NATIVE|FORMAT_RESIZE|FORMAT_KEEP_ASPECT, |
1494 | FPLUGIN); | 1525 | &format_transposed); |
1495 | if (!save_pfraw(EMPTY_SLIDE, &input_bmp)) | 1526 | if (!save_pfraw(EMPTY_SLIDE, &input_bmp)) |
1496 | return false; | 1527 | return false; |
1497 | } | 1528 | } |
@@ -1890,9 +1921,11 @@ int main(void) | |||
1890 | return PLUGIN_ERROR; | 1921 | return PLUGIN_ERROR; |
1891 | } | 1922 | } |
1892 | 1923 | ||
1893 | if (!create_empty_slide(false)) { | 1924 | if (!create_empty_slide(cache_version != CACHE_VERSION)) { |
1894 | rb->splash(HZ, "Could not load the empty slide"); | 1925 | rb->splash(HZ, "Could not load the empty slide"); |
1895 | return PLUGIN_ERROR; | 1926 | return PLUGIN_ERROR; |
1927 | cache_version = CACHE_VERSION; | ||
1928 | configfile_save(CONFIG_FILE, config, CONFIG_NUM_ITEMS, CONFIG_VERSION); | ||
1896 | } | 1929 | } |
1897 | 1930 | ||
1898 | if (!create_pf_thread()) { | 1931 | if (!create_pf_thread()) { |