summaryrefslogtreecommitdiff
path: root/apps/gui/backdrop.c
diff options
context:
space:
mode:
authorThomas Martitz <kugel@rockbox.org>2009-08-06 00:14:40 +0000
committerThomas Martitz <kugel@rockbox.org>2009-08-06 00:14:40 +0000
commit4764ee04c9c6432ad3cada25a8e87be056815815 (patch)
tree490154e71180349bb1991bd04445ddc0287a5db3 /apps/gui/backdrop.c
parent4632fc0682cfc3e2490435d616c7fa0b48088125 (diff)
downloadrockbox-4764ee04c9c6432ad3cada25a8e87be056815815.tar.gz
rockbox-4764ee04c9c6432ad3cada25a8e87be056815815.zip
Add backdrop functions to the multiscreen api and add a enum backdrop_type parameter for different backdrops (main, wps), symplifying calls and removing dozens of #ifdefs (stubs added for non-backdrop displays that can't do backdrops).
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@22176 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/gui/backdrop.c')
-rw-r--r--apps/gui/backdrop.c141
1 files changed, 94 insertions, 47 deletions
diff --git a/apps/gui/backdrop.c b/apps/gui/backdrop.c
index c95fda9022..28216da4e0 100644
--- a/apps/gui/backdrop.c
+++ b/apps/gui/backdrop.c
@@ -27,21 +27,19 @@
27#endif 27#endif
28#include "backdrop.h" 28#include "backdrop.h"
29 29
30#if LCD_DEPTH >= 8 30static fb_data main_backdrop[LCD_FBHEIGHT][LCD_FBHEIGHT]
31static fb_data main_backdrop[LCD_HEIGHT][LCD_WIDTH] __attribute__ ((aligned (16))); 31 __attribute__ ((aligned (16)));
32static fb_data wps_backdrop[LCD_HEIGHT][LCD_WIDTH] __attribute__ ((aligned (16))); 32static fb_data skin_backdrop[LCD_FBHEIGHT][LCD_FBHEIGHT]
33#elif LCD_DEPTH == 2 33 __attribute__ ((aligned (16)));
34static fb_data main_backdrop[LCD_FBHEIGHT][LCD_FBWIDTH];
35static fb_data wps_backdrop[LCD_FBHEIGHT][LCD_FBWIDTH];
36#endif
37 34
38#if defined(HAVE_REMOTE_LCD) && LCD_REMOTE_DEPTH > 1 35#if defined(HAVE_REMOTE_LCD) && LCD_REMOTE_DEPTH > 1
39static fb_remote_data remote_wps_backdrop[LCD_REMOTE_FBHEIGHT][LCD_REMOTE_FBWIDTH]; 36static fb_remote_data
40static bool remote_wps_backdrop_valid = false; 37remote_skin_backdrop[LCD_REMOTE_FBHEIGHT][LCD_REMOTE_FBWIDTH];
38static bool remote_skin_backdrop_valid = false;
41#endif 39#endif
42 40
43static bool main_backdrop_valid = false; 41static bool main_backdrop_valid = false;
44static bool wps_backdrop_valid = false; 42static bool skin_backdrop_valid = false;
45 43
46/* load a backdrop into a buffer */ 44/* load a backdrop into a buffer */
47static bool load_backdrop(const char* filename, fb_data* backdrop_buffer) 45static bool load_backdrop(const char* filename, fb_data* backdrop_buffer)
@@ -54,49 +52,43 @@ static bool load_backdrop(const char* filename, fb_data* backdrop_buffer)
54 ret = read_bmp_file(filename, &bm, sizeof(main_backdrop), 52 ret = read_bmp_file(filename, &bm, sizeof(main_backdrop),
55 FORMAT_NATIVE | FORMAT_DITHER, NULL); 53 FORMAT_NATIVE | FORMAT_DITHER, NULL);
56 54
57 if ((ret > 0) && (bm.width == LCD_WIDTH) && (bm.height == LCD_HEIGHT)) 55 return ((ret > 0)
58 { 56 && (bm.width == LCD_WIDTH) && (bm.height == LCD_HEIGHT));
59 return true;
60 }
61 else
62 {
63 return false;
64 }
65} 57}
66 58
67bool load_main_backdrop(const char* filename) 59static bool load_main_backdrop(const char* filename)
68{ 60{
69 main_backdrop_valid = load_backdrop(filename, &main_backdrop[0][0]); 61 main_backdrop_valid = load_backdrop(filename, &main_backdrop[0][0]);
70 return main_backdrop_valid; 62 return main_backdrop_valid;
71} 63}
72 64
73bool load_wps_backdrop(const char* filename) 65static inline bool load_skin_backdrop(const char* filename)
74{ 66{
75 wps_backdrop_valid = load_backdrop(filename, &wps_backdrop[0][0]); 67 skin_backdrop_valid = load_backdrop(filename, &skin_backdrop[0][0]);
76 return wps_backdrop_valid; 68 return skin_backdrop_valid;
77} 69}
78 70
79void unload_main_backdrop(void) 71static inline void unload_main_backdrop(void)
80{ 72{
81 main_backdrop_valid = false; 73 main_backdrop_valid = false;
82} 74}
83 75
84void unload_wps_backdrop(void) 76static inline void unload_skin_backdrop(void)
85{ 77{
86 wps_backdrop_valid = false; 78 skin_backdrop_valid = false;
87} 79}
88 80
89void show_main_backdrop(void) 81static inline void show_main_backdrop(void)
90{ 82{
91 lcd_set_backdrop(main_backdrop_valid ? &main_backdrop[0][0] : NULL); 83 lcd_set_backdrop(main_backdrop_valid ? &main_backdrop[0][0] : NULL);
92} 84}
93 85
94void show_wps_backdrop(void) 86static void show_skin_backdrop(void)
95{ 87{
96 /* if no wps backdrop, fall back to main backdrop */ 88 /* if no wps backdrop, fall back to main backdrop */
97 if(wps_backdrop_valid) 89 if(skin_backdrop_valid)
98 { 90 {
99 lcd_set_backdrop(&wps_backdrop[0][0]); 91 lcd_set_backdrop(&skin_backdrop[0][0]);
100 } 92 }
101 else 93 else
102 { 94 {
@@ -104,9 +96,39 @@ void show_wps_backdrop(void)
104 } 96 }
105} 97}
106 98
99/* api functions */
100
101bool backdrop_load(enum backdrop_type bdrop, const char* filename)
102{
103 if (bdrop == BACKDROP_MAIN)
104 return load_main_backdrop(filename);
105 else if (bdrop == BACKDROP_SKIN_WPS)
106 return load_skin_backdrop(filename);
107 else
108 return false;
109}
110
111void backdrop_unload(enum backdrop_type bdrop)
112{
113 if (bdrop == BACKDROP_MAIN)
114 unload_main_backdrop();
115 else if (bdrop == BACKDROP_SKIN_WPS)
116 unload_skin_backdrop();
117}
118
119void backdrop_show(enum backdrop_type bdrop)
120{
121 if (bdrop == BACKDROP_MAIN)
122 show_main_backdrop();
123 else if (bdrop == BACKDROP_SKIN_WPS)
124 show_skin_backdrop();
125}
126
127
107#if defined(HAVE_REMOTE_LCD) && LCD_REMOTE_DEPTH > 1 128#if defined(HAVE_REMOTE_LCD) && LCD_REMOTE_DEPTH > 1
108 129
109static bool load_remote_backdrop(const char* filename, fb_remote_data* backdrop_buffer) 130static bool load_remote_backdrop(const char* filename,
131 fb_remote_data* backdrop_buffer)
110{ 132{
111 struct bitmap bm; 133 struct bitmap bm;
112 int ret; 134 int ret;
@@ -116,33 +138,29 @@ static bool load_remote_backdrop(const char* filename, fb_remote_data* backdrop_
116 ret = read_bmp_file(filename, &bm, sizeof(main_backdrop), 138 ret = read_bmp_file(filename, &bm, sizeof(main_backdrop),
117 FORMAT_NATIVE | FORMAT_DITHER | FORMAT_REMOTE, NULL); 139 FORMAT_NATIVE | FORMAT_DITHER | FORMAT_REMOTE, NULL);
118 140
119 if ((ret > 0) && (bm.width == LCD_REMOTE_WIDTH) && (bm.height == LCD_REMOTE_HEIGHT)) 141 return ((ret > 0)
120 { 142 && (bm.width == LCD_REMOTE_WIDTH)
121 return true; 143 && (bm.height == LCD_REMOTE_HEIGHT));
122 }
123 else
124 {
125 return false;
126 }
127} 144}
128 145
129bool load_remote_wps_backdrop(const char* filename) 146static inline bool load_remote_skin_backdrop(const char* filename)
130{ 147{
131 remote_wps_backdrop_valid = load_remote_backdrop(filename, &remote_wps_backdrop[0][0]); 148 remote_skin_backdrop_valid =
132 return remote_wps_backdrop_valid; 149 load_remote_backdrop(filename, &remote_skin_backdrop[0][0]);
150 return remote_skin_backdrop_valid;
133} 151}
134 152
135void unload_remote_wps_backdrop(void) 153static inline void unload_remote_skin_backdrop(void)
136{ 154{
137 remote_wps_backdrop_valid = false; 155 remote_skin_backdrop_valid = false;
138} 156}
139 157
140void show_remote_wps_backdrop(void) 158static inline void show_remote_skin_backdrop(void)
141{ 159{
142 /* if no wps backdrop, fall back to main backdrop */ 160 /* if no wps backdrop, fall back to main backdrop */
143 if(remote_wps_backdrop_valid) 161 if(remote_skin_backdrop_valid)
144 { 162 {
145 lcd_remote_set_backdrop(&remote_wps_backdrop[0][0]); 163 lcd_remote_set_backdrop(&remote_skin_backdrop[0][0]);
146 } 164 }
147 else 165 else
148 { 166 {
@@ -150,8 +168,37 @@ void show_remote_wps_backdrop(void)
150 } 168 }
151} 169}
152 170
153void show_remote_main_backdrop(void) 171static line void show_remote_main_backdrop(void)
154{ 172{
155 lcd_remote_set_backdrop(NULL); 173 lcd_remote_set_backdrop(NULL);
156} 174}
175
176
177/* api functions */
178bool remote_backdrop_load(enum backdrop_type bdrop,
179 const char *filename)
180{
181 if (bdrop == BACKDROP_SKIN_WPS)
182 return load_remote_skin_backdrop(filename);
183 else if (bdrop == BACKDROP_MAIN)
184 return true;
185 else
186 return false;
187}
188
189void remote_backrop_show(enum backdrop_type bdrop)
190{
191 if (bdrop == BACKDROP_MAIN)
192 show_remote_main_backdrop();
193 else if (bdrop == BACKDROP_SKIN_WPS)
194 show_remote_skin_backdrop();
195}
196
197void remote_backdrop_unload(enum backdrop_type bdrop)
198{
199 if (bdrop != BACKDROP_MAIN)
200 unload_remote_skin_backdrop();
201}
202
203
157#endif 204#endif