diff options
Diffstat (limited to 'apps/plugins')
-rw-r--r-- | apps/plugins/pictureflow/pictureflow.c | 76 |
1 files changed, 45 insertions, 31 deletions
diff --git a/apps/plugins/pictureflow/pictureflow.c b/apps/plugins/pictureflow/pictureflow.c index 2ee318ba6a..c2f07b8d70 100644 --- a/apps/plugins/pictureflow/pictureflow.c +++ b/apps/plugins/pictureflow/pictureflow.c | |||
@@ -1174,11 +1174,12 @@ bool save_pfraw(char* filename, struct bitmap *bm) | |||
1174 | int fh = rb->creat( filename , 0666); | 1174 | int fh = rb->creat( filename , 0666); |
1175 | if( fh < 0 ) return false; | 1175 | if( fh < 0 ) return false; |
1176 | rb->write( fh, &bmph, sizeof( struct pfraw_header ) ); | 1176 | rb->write( fh, &bmph, sizeof( struct pfraw_header ) ); |
1177 | pix_t *data = (pix_t*)( bm->data ); | ||
1177 | int y; | 1178 | int y; |
1178 | for( y = 0; y < bm->height; y++ ) | 1179 | for( y = 0; y < bm->height; y++ ) |
1179 | { | 1180 | { |
1180 | pix_t *d = (pix_t*)( bm->data ) + (y*bm->width); | 1181 | rb->write( fh, data , sizeof( pix_t ) * bm->width ); |
1181 | rb->write( fh, d, sizeof( pix_t ) * bm->width ); | 1182 | data += bm->width; |
1182 | } | 1183 | } |
1183 | rb->close( fh ); | 1184 | rb->close( fh ); |
1184 | return true; | 1185 | return true; |
@@ -1199,8 +1200,6 @@ bool create_albumart_cache(void) | |||
1199 | char albumart_file[MAX_PATH]; | 1200 | char albumart_file[MAX_PATH]; |
1200 | unsigned int format = FORMAT_NATIVE; | 1201 | unsigned int format = FORMAT_NATIVE; |
1201 | bool update = (cache_version == CACHE_UPDATE); | 1202 | bool update = (cache_version == CACHE_UPDATE); |
1202 | cache_version = CACHE_REBUILD; | ||
1203 | configfile_save(CONFIG_FILE, config, CONFIG_NUM_ITEMS, CONFIG_VERSION); | ||
1204 | if (resize) | 1203 | if (resize) |
1205 | format |= FORMAT_RESIZE|FORMAT_KEEP_ASPECT; | 1204 | format |= FORMAT_RESIZE|FORMAT_KEEP_ASPECT; |
1206 | for (i=0; i < album_count; i++) | 1205 | for (i=0; i < album_count; i++) |
@@ -1211,8 +1210,10 @@ bool create_albumart_cache(void) | |||
1211 | mfnv(get_album_name(i))); | 1210 | mfnv(get_album_name(i))); |
1212 | /* delete existing cache, so it's a true rebuild */ | 1211 | /* delete existing cache, so it's a true rebuild */ |
1213 | if(rb->file_exists(pfraw_file)) { | 1212 | if(rb->file_exists(pfraw_file)) { |
1214 | if(update) | 1213 | if(update) { |
1214 | slides++; | ||
1215 | continue; | 1215 | continue; |
1216 | } | ||
1216 | rb->remove(pfraw_file); | 1217 | rb->remove(pfraw_file); |
1217 | } | 1218 | } |
1218 | if (!get_albumart_for_index_from_db(i, albumart_file, MAX_PATH)) | 1219 | if (!get_albumart_for_index_from_db(i, albumart_file, MAX_PATH)) |
@@ -1234,10 +1235,12 @@ bool create_albumart_cache(void) | |||
1234 | if (!save_pfraw(pfraw_file, &input_bmp)) | 1235 | if (!save_pfraw(pfraw_file, &input_bmp)) |
1235 | { | 1236 | { |
1236 | rb->splash(HZ, "Could not write bmp"); | 1237 | rb->splash(HZ, "Could not write bmp"); |
1238 | continue; | ||
1237 | } | 1239 | } |
1238 | slides++; | 1240 | slides++; |
1239 | if ( rb->button_get(false) == PF_MENU ) return false; | 1241 | if ( rb->button_get(false) == PF_MENU ) return false; |
1240 | } | 1242 | } |
1243 | draw_progressbar(i); | ||
1241 | if ( slides == 0 ) { | 1244 | if ( slides == 0 ) { |
1242 | /* Warn the user that we couldn't find any albumart */ | 1245 | /* Warn the user that we couldn't find any albumart */ |
1243 | rb->splash(2*HZ, "No album art found"); | 1246 | rb->splash(2*HZ, "No album art found"); |
@@ -1516,8 +1519,8 @@ int read_pfraw(char* filename, int prio) | |||
1516 | else | 1519 | else |
1517 | rb->read(fh, &bmph, sizeof(struct pfraw_header)); | 1520 | rb->read(fh, &bmph, sizeof(struct pfraw_header)); |
1518 | 1521 | ||
1519 | int size = sizeof(struct bitmap) + sizeof( pix_t ) * | 1522 | int size = sizeof(struct dim) + |
1520 | bmph.width * bmph.height; | 1523 | sizeof( pix_t ) * bmph.width * bmph.height; |
1521 | 1524 | ||
1522 | int hid; | 1525 | int hid; |
1523 | while (!(hid = buflib_alloc(&buf_ctx, size)) && free_slide_prio(prio)); | 1526 | while (!(hid = buflib_alloc(&buf_ctx, size)) && free_slide_prio(prio)); |
@@ -1928,6 +1931,7 @@ void render_slide(struct slide_data *slide, const int alpha) | |||
1928 | } | 1931 | } |
1929 | rb->yield(); /* allow audio to play when fast scrolling */ | 1932 | rb->yield(); /* allow audio to play when fast scrolling */ |
1930 | bmp = surface(slide->slide_index); /* resync surface due to yield */ | 1933 | bmp = surface(slide->slide_index); /* resync surface due to yield */ |
1934 | src = (pix_t*)(sizeof(struct dim) + (char *)bmp); | ||
1931 | ptr = &src[column * bmp->height]; | 1935 | ptr = &src[column * bmp->height]; |
1932 | p = (bmp->height-DISPLAY_OFFS) * PFREAL_ONE; | 1936 | p = (bmp->height-DISPLAY_OFFS) * PFREAL_ONE; |
1933 | plim = MIN(sh * PFREAL_ONE, p + (LCD_HEIGHT/2) * dy); | 1937 | plim = MIN(sh * PFREAL_ONE, p + (LCD_HEIGHT/2) * dy); |
@@ -2006,7 +2010,7 @@ void show_previous_slide(void) | |||
2006 | } | 2010 | } |
2007 | } else if ( step > 0 ) { | 2011 | } else if ( step > 0 ) { |
2008 | target = center_index; | 2012 | target = center_index; |
2009 | start_animation(); | 2013 | step = (target <= center_slide.slide_index) ? -1 : 1; |
2010 | } else { | 2014 | } else { |
2011 | target = fmax(0, center_index - 2); | 2015 | target = fmax(0, center_index - 2); |
2012 | } | 2016 | } |
@@ -2025,7 +2029,7 @@ void show_next_slide(void) | |||
2025 | } | 2029 | } |
2026 | } else if ( step < 0 ) { | 2030 | } else if ( step < 0 ) { |
2027 | target = center_index; | 2031 | target = center_index; |
2028 | start_animation(); | 2032 | step = (target < center_slide.slide_index) ? -1 : 1; |
2029 | } else { | 2033 | } else { |
2030 | target = fmin(center_index + 2, number_of_slides - 1); | 2034 | target = fmin(center_index + 2, number_of_slides - 1); |
2031 | } | 2035 | } |
@@ -2044,45 +2048,46 @@ void render_all_slides(void) | |||
2044 | int nleft = num_slides; | 2048 | int nleft = num_slides; |
2045 | int nright = num_slides; | 2049 | int nright = num_slides; |
2046 | 2050 | ||
2051 | int alpha; | ||
2047 | int index; | 2052 | int index; |
2048 | if (step == 0) { | 2053 | if (step == 0) { |
2049 | /* no animation, boring plain rendering */ | 2054 | /* no animation, boring plain rendering */ |
2050 | for (index = nleft - 2; index >= 0; index--) { | 2055 | for (index = nleft - 2; index >= 0; index--) { |
2051 | int alpha = (index < nleft - 2) ? 256 : 128; | 2056 | alpha = (index < nleft - 2) ? 256 : 128; |
2052 | alpha -= extra_fade; | 2057 | alpha -= extra_fade; |
2053 | if (alpha > 0 ) | 2058 | if (alpha > 0 ) |
2054 | render_slide(&left_slides[index], alpha); | 2059 | render_slide(&left_slides[index], alpha); |
2055 | } | 2060 | } |
2056 | for (index = nright - 2; index >= 0; index--) { | 2061 | for (index = nright - 2; index >= 0; index--) { |
2057 | int alpha = (index < nright - 2) ? 256 : 128; | 2062 | alpha = (index < nright - 2) ? 256 : 128; |
2058 | alpha -= extra_fade; | 2063 | alpha -= extra_fade; |
2059 | if (alpha > 0 ) | 2064 | if (alpha > 0 ) |
2060 | render_slide(&right_slides[index], alpha); | 2065 | render_slide(&right_slides[index], alpha); |
2061 | } | 2066 | } |
2062 | } else { | 2067 | } else { |
2063 | /* the first and last slide must fade in/fade out */ | 2068 | /* the first and last slide must fade in/fade out */ |
2069 | |||
2070 | /* if step<0 and nleft==1, left_slides[0] is fading in */ | ||
2071 | alpha = ((step > 0) ? 0 : ((nleft == 1) ? 256 : 128)) - fade / 2; | ||
2064 | for (index = nleft - 1; index >= 0; index--) { | 2072 | for (index = nleft - 1; index >= 0; index--) { |
2065 | int alpha = 256; | 2073 | if (alpha > 0) |
2066 | if (index == nleft - 1) | 2074 | render_slide(&left_slides[index], alpha); |
2067 | alpha = (step > 0) ? 0 : 128 - fade / 2; | 2075 | alpha += 128; |
2068 | if (index == nleft - 2) | 2076 | if (alpha > 256) alpha = 256; |
2069 | alpha = (step > 0) ? 128 - fade / 2 : 256 - fade / 2; | ||
2070 | if (index == nleft - 3) | ||
2071 | alpha = (step > 0) ? 256 - fade / 2 : 256; | ||
2072 | render_slide(&left_slides[index], alpha); | ||
2073 | } | 2077 | } |
2078 | /* if step>0 and nright==1, right_slides[0] is fading in */ | ||
2079 | alpha = ((step > 0) ? ((nright == 1) ? 128 : 0) : -128) + fade / 2; | ||
2074 | for (index = nright - 1; index >= 0; index--) { | 2080 | for (index = nright - 1; index >= 0; index--) { |
2075 | int alpha = (index < nright - 2) ? 256 : 128; | 2081 | if (alpha > 0) |
2076 | if (index == nright - 1) | 2082 | render_slide(&right_slides[index], alpha); |
2077 | alpha = (step > 0) ? fade / 2 : 0; | 2083 | alpha += 128; |
2078 | if (index == nright - 2) | 2084 | if (alpha > 256) alpha = 256; |
2079 | alpha = (step > 0) ? 128 + fade / 2 : fade / 2; | ||
2080 | if (index == nright - 3) | ||
2081 | alpha = (step > 0) ? 256 : 128 + fade / 2; | ||
2082 | render_slide(&right_slides[index], alpha); | ||
2083 | } | 2085 | } |
2084 | } | 2086 | } |
2085 | render_slide(¢er_slide, 256); | 2087 | alpha = 256; |
2088 | if (step != 0 && num_slides <= 2) /* fading out center slide */ | ||
2089 | alpha = (step > 0) ? 256 - fade / 2 : 128 + fade / 2; | ||
2090 | render_slide(¢er_slide, alpha); | ||
2086 | } | 2091 | } |
2087 | 2092 | ||
2088 | 2093 | ||
@@ -2142,6 +2147,7 @@ void update_scroll_animation(void) | |||
2142 | if (center_index == target) { | 2147 | if (center_index == target) { |
2143 | reset_slides(); | 2148 | reset_slides(); |
2144 | pf_state = pf_idle; | 2149 | pf_state = pf_idle; |
2150 | slide_frame = center_index << 16; | ||
2145 | step = 0; | 2151 | step = 0; |
2146 | fade = 256; | 2152 | fade = 256; |
2147 | return; | 2153 | return; |
@@ -2285,6 +2291,8 @@ int settings_menu(void) | |||
2285 | case 7: | 2291 | case 7: |
2286 | cache_version = CACHE_REBUILD; | 2292 | cache_version = CACHE_REBUILD; |
2287 | rb->remove(EMPTY_SLIDE); | 2293 | rb->remove(EMPTY_SLIDE); |
2294 | configfile_save(CONFIG_FILE, config, | ||
2295 | CONFIG_NUM_ITEMS, CONFIG_VERSION); | ||
2288 | rb->splash(HZ, "Cache will be rebuilt on next restart"); | 2296 | rb->splash(HZ, "Cache will be rebuilt on next restart"); |
2289 | break; | 2297 | break; |
2290 | case 8: | 2298 | case 8: |
@@ -2298,7 +2306,6 @@ int settings_menu(void) | |||
2298 | return PLUGIN_USB_CONNECTED; | 2306 | return PLUGIN_USB_CONNECTED; |
2299 | } | 2307 | } |
2300 | } while ( selection >= 0 ); | 2308 | } while ( selection >= 0 ); |
2301 | configfile_save(CONFIG_FILE, config, CONFIG_NUM_ITEMS, CONFIG_VERSION); | ||
2302 | return 0; | 2309 | return 0; |
2303 | } | 2310 | } |
2304 | 2311 | ||
@@ -2678,16 +2685,23 @@ int main(void) | |||
2678 | ALIGN_BUFFER(buf, buf_size, 4); | 2685 | ALIGN_BUFFER(buf, buf_size, 4); |
2679 | number_of_slides = album_count; | 2686 | number_of_slides = album_count; |
2680 | if ((cache_version != CACHE_VERSION) && !create_albumart_cache()) { | 2687 | if ((cache_version != CACHE_VERSION) && !create_albumart_cache()) { |
2688 | cache_version = CACHE_REBUILD; | ||
2689 | configfile_save(CONFIG_FILE, config, CONFIG_NUM_ITEMS, CONFIG_VERSION); | ||
2681 | error_wait("Could not create album art cache"); | 2690 | error_wait("Could not create album art cache"); |
2682 | return PLUGIN_ERROR; | 2691 | return PLUGIN_ERROR; |
2683 | } | 2692 | } |
2684 | 2693 | ||
2685 | if (!create_empty_slide(cache_version != CACHE_VERSION)) { | 2694 | if (!create_empty_slide(cache_version != CACHE_VERSION)) { |
2695 | cache_version = CACHE_REBUILD; | ||
2696 | configfile_save(CONFIG_FILE, config, CONFIG_NUM_ITEMS, CONFIG_VERSION); | ||
2686 | error_wait("Could not load the empty slide"); | 2697 | error_wait("Could not load the empty slide"); |
2687 | return PLUGIN_ERROR; | 2698 | return PLUGIN_ERROR; |
2688 | } | 2699 | } |
2689 | cache_version = CACHE_VERSION; | 2700 | if (cache_version != CACHE_VERSION) |
2690 | configfile_save(CONFIG_FILE, config, CONFIG_NUM_ITEMS, CONFIG_VERSION); | 2701 | { |
2702 | cache_version = CACHE_VERSION; | ||
2703 | configfile_save(CONFIG_FILE, config, CONFIG_NUM_ITEMS, CONFIG_VERSION); | ||
2704 | } | ||
2691 | 2705 | ||
2692 | buflib_init(&buf_ctx, (void *)buf, buf_size); | 2706 | buflib_init(&buf_ctx, (void *)buf, buf_size); |
2693 | 2707 | ||