diff options
Diffstat (limited to 'apps/plugins/pictureflow.c')
-rw-r--r-- | apps/plugins/pictureflow.c | 81 |
1 files changed, 41 insertions, 40 deletions
diff --git a/apps/plugins/pictureflow.c b/apps/plugins/pictureflow.c index 8ac6032701..48435cdab2 100644 --- a/apps/plugins/pictureflow.c +++ b/apps/plugins/pictureflow.c | |||
@@ -289,7 +289,7 @@ static int track_count; | |||
289 | static int track_index; | 289 | static int track_index; |
290 | static int selected_track; | 290 | static int selected_track; |
291 | static int selected_track_pulse; | 291 | static int selected_track_pulse; |
292 | static void reset_track_list(void); | 292 | void reset_track_list(void); |
293 | 293 | ||
294 | void * buf; | 294 | void * buf; |
295 | size_t buf_size; | 295 | size_t buf_size; |
@@ -340,8 +340,9 @@ static int pf_state; | |||
340 | 340 | ||
341 | /** code */ | 341 | /** code */ |
342 | static inline unsigned fade_color(pix_t c, unsigned a); | 342 | static inline unsigned fade_color(pix_t c, unsigned a); |
343 | static bool save_pfraw(char* filename, struct bitmap *bm); | 343 | bool save_pfraw(char* filename, struct bitmap *bm); |
344 | static bool load_new_slide(void); | 344 | bool load_new_slide(void); |
345 | int load_surface(int); | ||
345 | 346 | ||
346 | static inline PFreal fmul(PFreal a, PFreal b) | 347 | static inline PFreal fmul(PFreal a, PFreal b) |
347 | { | 348 | { |
@@ -562,7 +563,7 @@ const struct custom_format format_transposed = { | |||
562 | }; | 563 | }; |
563 | 564 | ||
564 | /* Create the lookup table with the scaling values for the reflections */ | 565 | /* Create the lookup table with the scaling values for the reflections */ |
565 | static void init_reflect_table(void) | 566 | void init_reflect_table(void) |
566 | { | 567 | { |
567 | int i; | 568 | int i; |
568 | for (i = 0; i < REFLECT_HEIGHT; i++) | 569 | for (i = 0; i < REFLECT_HEIGHT; i++) |
@@ -575,7 +576,7 @@ static void init_reflect_table(void) | |||
575 | Create an index of all albums from the database. | 576 | Create an index of all albums from the database. |
576 | Also store the album names so we can access them later. | 577 | Also store the album names so we can access them later. |
577 | */ | 578 | */ |
578 | static int create_album_index(void) | 579 | int create_album_index(void) |
579 | { | 580 | { |
580 | buf_size -= UNIQBUF_SIZE * sizeof(long); | 581 | buf_size -= UNIQBUF_SIZE * sizeof(long); |
581 | long *uniqbuf = (long *)(buf_size + (char *)buf); | 582 | long *uniqbuf = (long *)(buf_size + (char *)buf); |
@@ -620,7 +621,7 @@ static int create_album_index(void) | |||
620 | /** | 621 | /** |
621 | Return a pointer to the album name of the given slide_index | 622 | Return a pointer to the album name of the given slide_index |
622 | */ | 623 | */ |
623 | static char* get_album_name(const int slide_index) | 624 | char* get_album_name(const int slide_index) |
624 | { | 625 | { |
625 | return album_names + album[slide_index].name_idx; | 626 | return album_names + album[slide_index].name_idx; |
626 | } | 627 | } |
@@ -629,7 +630,7 @@ static char* get_album_name(const int slide_index) | |||
629 | Return a pointer to the track name of the active album | 630 | Return a pointer to the track name of the active album |
630 | create_track_index has to be called first. | 631 | create_track_index has to be called first. |
631 | */ | 632 | */ |
632 | static char* get_track_name(const int track_index) | 633 | char* get_track_name(const int track_index) |
633 | { | 634 | { |
634 | if ( track_index < track_count ) | 635 | if ( track_index < track_count ) |
635 | return track_names + tracks[track_index].name_idx; | 636 | return track_names + tracks[track_index].name_idx; |
@@ -639,7 +640,7 @@ static char* get_track_name(const int track_index) | |||
639 | /** | 640 | /** |
640 | Create the track index of the given slide_index. | 641 | Create the track index of the given slide_index. |
641 | */ | 642 | */ |
642 | static int create_track_index(const int slide_index) | 643 | int create_track_index(const int slide_index) |
643 | { | 644 | { |
644 | if ( slide_index == track_index ) { | 645 | if ( slide_index == track_index ) { |
645 | return -1; | 646 | return -1; |
@@ -712,8 +713,8 @@ static int create_track_index(const int slide_index) | |||
712 | The algorithm looks for the first track of the given album uses | 713 | The algorithm looks for the first track of the given album uses |
713 | find_albumart to find the filename. | 714 | find_albumart to find the filename. |
714 | */ | 715 | */ |
715 | static bool get_albumart_for_index_from_db(const int slide_index, char *buf, | 716 | bool get_albumart_for_index_from_db(const int slide_index, char *buf, |
716 | int buflen) | 717 | int buflen) |
717 | { | 718 | { |
718 | if ( slide_index == -1 ) | 719 | if ( slide_index == -1 ) |
719 | { | 720 | { |
@@ -750,7 +751,7 @@ static bool get_albumart_for_index_from_db(const int slide_index, char *buf, | |||
750 | /** | 751 | /** |
751 | Draw the PictureFlow logo | 752 | Draw the PictureFlow logo |
752 | */ | 753 | */ |
753 | static void draw_splashscreen(void) | 754 | void draw_splashscreen(void) |
754 | { | 755 | { |
755 | struct screen* display = rb->screens[0]; | 756 | struct screen* display = rb->screens[0]; |
756 | const struct picture* logo = &(logos[display->screen_type]); | 757 | const struct picture* logo = &(logos[display->screen_type]); |
@@ -778,7 +779,7 @@ static void draw_splashscreen(void) | |||
778 | /** | 779 | /** |
779 | Draw a simple progress bar | 780 | Draw a simple progress bar |
780 | */ | 781 | */ |
781 | static void draw_progressbar(int step) | 782 | void draw_progressbar(int step) |
782 | { | 783 | { |
783 | int txt_w, txt_h; | 784 | int txt_w, txt_h; |
784 | const int bar_height = 22; | 785 | const int bar_height = 22; |
@@ -811,7 +812,7 @@ static void draw_progressbar(int step) | |||
811 | /** | 812 | /** |
812 | Precomupte the album art images and store them in CACHE_PREFIX. | 813 | Precomupte the album art images and store them in CACHE_PREFIX. |
813 | */ | 814 | */ |
814 | static bool create_albumart_cache(void) | 815 | bool create_albumart_cache(void) |
815 | { | 816 | { |
816 | int ret; | 817 | int ret; |
817 | 818 | ||
@@ -863,7 +864,7 @@ static bool create_albumart_cache(void) | |||
863 | /** | 864 | /** |
864 | Thread used for loading and preparing bitmaps in the background | 865 | Thread used for loading and preparing bitmaps in the background |
865 | */ | 866 | */ |
866 | static void thread(void) | 867 | void thread(void) |
867 | { | 868 | { |
868 | long sleep_time = 5 * HZ; | 869 | long sleep_time = 5 * HZ; |
869 | struct queue_event ev; | 870 | struct queue_event ev; |
@@ -890,7 +891,7 @@ static void thread(void) | |||
890 | /** | 891 | /** |
891 | End the thread by posting the EV_EXIT event | 892 | End the thread by posting the EV_EXIT event |
892 | */ | 893 | */ |
893 | static void end_pf_thread(void) | 894 | void end_pf_thread(void) |
894 | { | 895 | { |
895 | if ( thread_is_running ) { | 896 | if ( thread_is_running ) { |
896 | rb->queue_post(&thread_q, EV_EXIT, 0); | 897 | rb->queue_post(&thread_q, EV_EXIT, 0); |
@@ -906,7 +907,7 @@ static void end_pf_thread(void) | |||
906 | /** | 907 | /** |
907 | Create the thread an setup the event queue | 908 | Create the thread an setup the event queue |
908 | */ | 909 | */ |
909 | static bool create_pf_thread(void) | 910 | bool create_pf_thread(void) |
910 | { | 911 | { |
911 | /* put the thread's queue in the bcast list */ | 912 | /* put the thread's queue in the bcast list */ |
912 | rb->queue_init(&thread_q, true); | 913 | rb->queue_init(&thread_q, true); |
@@ -931,7 +932,7 @@ static bool create_pf_thread(void) | |||
931 | /** | 932 | /** |
932 | Safe the given bitmap as filename in the pfraw format | 933 | Safe the given bitmap as filename in the pfraw format |
933 | */ | 934 | */ |
934 | static bool save_pfraw(char* filename, struct bitmap *bm) | 935 | bool save_pfraw(char* filename, struct bitmap *bm) |
935 | { | 936 | { |
936 | struct pfraw_header bmph; | 937 | struct pfraw_header bmph; |
937 | bmph.width = bm->width; | 938 | bmph.width = bm->width; |
@@ -1114,7 +1115,7 @@ static inline int free_slide_prio(int prio) | |||
1114 | /** | 1115 | /** |
1115 | Read the pfraw image given as filename and return the hid of the buffer | 1116 | Read the pfraw image given as filename and return the hid of the buffer |
1116 | */ | 1117 | */ |
1117 | static int read_pfraw(char* filename, int prio) | 1118 | int read_pfraw(char* filename, int prio) |
1118 | { | 1119 | { |
1119 | struct pfraw_header bmph; | 1120 | struct pfraw_header bmph; |
1120 | int fh = rb->open(filename, O_RDONLY); | 1121 | int fh = rb->open(filename, O_RDONLY); |
@@ -1180,7 +1181,7 @@ static inline bool load_and_prepare_surface(const int slide_index, | |||
1180 | Load the "next" slide that we can load, freeing old slides if needed, provided | 1181 | Load the "next" slide that we can load, freeing old slides if needed, provided |
1181 | that they are further from center_index than the current slide | 1182 | that they are further from center_index than the current slide |
1182 | */ | 1183 | */ |
1183 | static bool load_new_slide(void) | 1184 | bool load_new_slide(void) |
1184 | { | 1185 | { |
1185 | int i = -1; | 1186 | int i = -1; |
1186 | if (cache_center_index != -1) | 1187 | if (cache_center_index != -1) |
@@ -1329,7 +1330,7 @@ static inline struct dim *surface(const int slide_index) | |||
1329 | /** | 1330 | /** |
1330 | adjust slides so that they are in "steady state" position | 1331 | adjust slides so that they are in "steady state" position |
1331 | */ | 1332 | */ |
1332 | static void reset_slides(void) | 1333 | void reset_slides(void) |
1333 | { | 1334 | { |
1334 | center_slide.angle = 0; | 1335 | center_slide.angle = 0; |
1335 | center_slide.cx = 0; | 1336 | center_slide.cx = 0; |
@@ -1370,7 +1371,7 @@ static void reset_slides(void) | |||
1370 | * z | 1371 | * z |
1371 | * TODO: support moving the side slides toward or away from the camera | 1372 | * TODO: support moving the side slides toward or away from the camera |
1372 | */ | 1373 | */ |
1373 | static void recalc_offsets(void) | 1374 | void recalc_offsets(void) |
1374 | { | 1375 | { |
1375 | PFreal xs = PFREAL_HALF - DISPLAY_WIDTH * PFREAL_HALF; | 1376 | PFreal xs = PFREAL_HALF - DISPLAY_WIDTH * PFREAL_HALF; |
1376 | PFreal zo; | 1377 | PFreal zo; |
@@ -1446,7 +1447,7 @@ static inline unsigned fade_color(pix_t c, unsigned a) | |||
1446 | * optimized by saving the numerator and denominator of the fraction, which can | 1447 | * optimized by saving the numerator and denominator of the fraction, which can |
1447 | * then be incremented by (z + zo) and sin(r) respectively. | 1448 | * then be incremented by (z + zo) and sin(r) respectively. |
1448 | */ | 1449 | */ |
1449 | static void render_slide(struct slide_data *slide, const int alpha) | 1450 | void render_slide(struct slide_data *slide, const int alpha) |
1450 | { | 1451 | { |
1451 | struct dim *bmp = surface(slide->slide_index); | 1452 | struct dim *bmp = surface(slide->slide_index); |
1452 | if (!bmp) { | 1453 | if (!bmp) { |
@@ -1593,7 +1594,7 @@ static inline void set_current_slide(const int slide_index) | |||
1593 | /** | 1594 | /** |
1594 | Start the animation for changing slides | 1595 | Start the animation for changing slides |
1595 | */ | 1596 | */ |
1596 | static void start_animation(void) | 1597 | void start_animation(void) |
1597 | { | 1598 | { |
1598 | step = (target < center_slide.slide_index) ? -1 : 1; | 1599 | step = (target < center_slide.slide_index) ? -1 : 1; |
1599 | pf_state = pf_scrolling; | 1600 | pf_state = pf_scrolling; |
@@ -1602,7 +1603,7 @@ static void start_animation(void) | |||
1602 | /** | 1603 | /** |
1603 | Go to the previous slide | 1604 | Go to the previous slide |
1604 | */ | 1605 | */ |
1605 | static void show_previous_slide(void) | 1606 | void show_previous_slide(void) |
1606 | { | 1607 | { |
1607 | if (step == 0) { | 1608 | if (step == 0) { |
1608 | if (center_index > 0) { | 1609 | if (center_index > 0) { |
@@ -1621,7 +1622,7 @@ static void show_previous_slide(void) | |||
1621 | /** | 1622 | /** |
1622 | Go to the next slide | 1623 | Go to the next slide |
1623 | */ | 1624 | */ |
1624 | static void show_next_slide(void) | 1625 | void show_next_slide(void) |
1625 | { | 1626 | { |
1626 | if (step == 0) { | 1627 | if (step == 0) { |
1627 | if (center_index < number_of_slides - 1) { | 1628 | if (center_index < number_of_slides - 1) { |
@@ -1640,7 +1641,7 @@ static void show_next_slide(void) | |||
1640 | /** | 1641 | /** |
1641 | Render the slides. Updates only the offscreen buffer. | 1642 | Render the slides. Updates only the offscreen buffer. |
1642 | */ | 1643 | */ |
1643 | static void render_all_slides(void) | 1644 | void render_all_slides(void) |
1644 | { | 1645 | { |
1645 | MYLCD(set_background)(G_BRIGHT(0)); | 1646 | MYLCD(set_background)(G_BRIGHT(0)); |
1646 | /* TODO: Optimizes this by e.g. invalidating rects */ | 1647 | /* TODO: Optimizes this by e.g. invalidating rects */ |
@@ -1694,7 +1695,7 @@ static void render_all_slides(void) | |||
1694 | /** | 1695 | /** |
1695 | Updates the animation effect. Call this periodically from a timer. | 1696 | Updates the animation effect. Call this periodically from a timer. |
1696 | */ | 1697 | */ |
1697 | static void update_scroll_animation(void) | 1698 | void update_scroll_animation(void) |
1698 | { | 1699 | { |
1699 | if (step == 0) | 1700 | if (step == 0) |
1700 | return; | 1701 | return; |
@@ -1795,7 +1796,7 @@ static void update_scroll_animation(void) | |||
1795 | /** | 1796 | /** |
1796 | Cleanup the plugin | 1797 | Cleanup the plugin |
1797 | */ | 1798 | */ |
1798 | static void cleanup(void *parameter) | 1799 | void cleanup(void *parameter) |
1799 | { | 1800 | { |
1800 | (void) parameter; | 1801 | (void) parameter; |
1801 | /* Turn on backlight timeout (revert to settings) */ | 1802 | /* Turn on backlight timeout (revert to settings) */ |
@@ -1811,7 +1812,7 @@ static void cleanup(void *parameter) | |||
1811 | Create the "?" slide, that is shown while loading | 1812 | Create the "?" slide, that is shown while loading |
1812 | or when no cover was found. | 1813 | or when no cover was found. |
1813 | */ | 1814 | */ |
1814 | static int create_empty_slide(bool force) | 1815 | int create_empty_slide(bool force) |
1815 | { | 1816 | { |
1816 | if ( force || ! rb->file_exists( EMPTY_SLIDE ) ) { | 1817 | if ( force || ! rb->file_exists( EMPTY_SLIDE ) ) { |
1817 | struct bitmap input_bmp; | 1818 | struct bitmap input_bmp; |
@@ -1836,7 +1837,7 @@ static int create_empty_slide(bool force) | |||
1836 | /** | 1837 | /** |
1837 | Shows the album name setting menu | 1838 | Shows the album name setting menu |
1838 | */ | 1839 | */ |
1839 | static int album_name_menu(void) | 1840 | int album_name_menu(void) |
1840 | { | 1841 | { |
1841 | int selection = show_album_name; | 1842 | int selection = show_album_name; |
1842 | 1843 | ||
@@ -1851,7 +1852,7 @@ static int album_name_menu(void) | |||
1851 | /** | 1852 | /** |
1852 | Shows the settings menu | 1853 | Shows the settings menu |
1853 | */ | 1854 | */ |
1854 | static int settings_menu(void) | 1855 | int settings_menu(void) |
1855 | { | 1856 | { |
1856 | int selection = 0; | 1857 | int selection = 0; |
1857 | bool old_val; | 1858 | bool old_val; |
@@ -1926,7 +1927,7 @@ static int settings_menu(void) | |||
1926 | /** | 1927 | /** |
1927 | Show the main menu | 1928 | Show the main menu |
1928 | */ | 1929 | */ |
1929 | static int main_menu(void) | 1930 | int main_menu(void) |
1930 | { | 1931 | { |
1931 | int selection = 0; | 1932 | int selection = 0; |
1932 | int result; | 1933 | int result; |
@@ -1962,7 +1963,7 @@ static int main_menu(void) | |||
1962 | /** | 1963 | /** |
1963 | Animation step for zooming into the current cover | 1964 | Animation step for zooming into the current cover |
1964 | */ | 1965 | */ |
1965 | static void update_cover_in_animation(void) | 1966 | void update_cover_in_animation(void) |
1966 | { | 1967 | { |
1967 | cover_animation_keyframe++; | 1968 | cover_animation_keyframe++; |
1968 | if( cover_animation_keyframe < 20 ) { | 1969 | if( cover_animation_keyframe < 20 ) { |
@@ -1982,7 +1983,7 @@ static void update_cover_in_animation(void) | |||
1982 | /** | 1983 | /** |
1983 | Animation step for zooming out the current cover | 1984 | Animation step for zooming out the current cover |
1984 | */ | 1985 | */ |
1985 | static void update_cover_out_animation(void) | 1986 | void update_cover_out_animation(void) |
1986 | { | 1987 | { |
1987 | cover_animation_keyframe++; | 1988 | cover_animation_keyframe++; |
1988 | if( cover_animation_keyframe <= 15 ) { | 1989 | if( cover_animation_keyframe <= 15 ) { |
@@ -2044,7 +2045,7 @@ static void track_list_yh(int char_height) | |||
2044 | /** | 2045 | /** |
2045 | Reset the track list after a album change | 2046 | Reset the track list after a album change |
2046 | */ | 2047 | */ |
2047 | static void reset_track_list(void) | 2048 | void reset_track_list(void) |
2048 | { | 2049 | { |
2049 | int albumtxt_h = rb->screens[SCREEN_MAIN]->getcharheight(); | 2050 | int albumtxt_h = rb->screens[SCREEN_MAIN]->getcharheight(); |
2050 | track_list_yh(albumtxt_h); | 2051 | track_list_yh(albumtxt_h); |
@@ -2066,7 +2067,7 @@ static void reset_track_list(void) | |||
2066 | /** | 2067 | /** |
2067 | Display the list of tracks | 2068 | Display the list of tracks |
2068 | */ | 2069 | */ |
2069 | static void show_track_list(void) | 2070 | void show_track_list(void) |
2070 | { | 2071 | { |
2071 | MYLCD(clear_display)(); | 2072 | MYLCD(clear_display)(); |
2072 | if ( center_slide.slide_index != track_index ) { | 2073 | if ( center_slide.slide_index != track_index ) { |
@@ -2105,7 +2106,7 @@ static void show_track_list(void) | |||
2105 | } | 2106 | } |
2106 | } | 2107 | } |
2107 | 2108 | ||
2108 | static void select_next_track(void) | 2109 | void select_next_track(void) |
2109 | { | 2110 | { |
2110 | if ( selected_track < track_count - 1 ) { | 2111 | if ( selected_track < track_count - 1 ) { |
2111 | selected_track++; | 2112 | selected_track++; |
@@ -2116,7 +2117,7 @@ static void select_next_track(void) | |||
2116 | } | 2117 | } |
2117 | } | 2118 | } |
2118 | 2119 | ||
2119 | static void select_prev_track(void) | 2120 | void select_prev_track(void) |
2120 | { | 2121 | { |
2121 | if (selected_track > 0 ) { | 2122 | if (selected_track > 0 ) { |
2122 | if (selected_track==start_index_track_list) start_index_track_list--; | 2123 | if (selected_track==start_index_track_list) start_index_track_list--; |
@@ -2129,7 +2130,7 @@ static void select_prev_track(void) | |||
2129 | /** | 2130 | /** |
2130 | Draw the current album name | 2131 | Draw the current album name |
2131 | */ | 2132 | */ |
2132 | static void draw_album_text(void) | 2133 | void draw_album_text(void) |
2133 | { | 2134 | { |
2134 | if (0 == show_album_name) | 2135 | if (0 == show_album_name) |
2135 | return; | 2136 | return; |
@@ -2190,7 +2191,7 @@ static void draw_album_text(void) | |||
2190 | Main function that also contain the main plasma | 2191 | Main function that also contain the main plasma |
2191 | algorithm. | 2192 | algorithm. |
2192 | */ | 2193 | */ |
2193 | static int main(void) | 2194 | int main(void) |
2194 | { | 2195 | { |
2195 | int ret; | 2196 | int ret; |
2196 | 2197 | ||