diff options
Diffstat (limited to 'apps/gui/backdrop.c')
-rw-r--r-- | apps/gui/backdrop.c | 202 |
1 files changed, 21 insertions, 181 deletions
diff --git a/apps/gui/backdrop.c b/apps/gui/backdrop.c index 058eaa5de4..e460b87108 100644 --- a/apps/gui/backdrop.c +++ b/apps/gui/backdrop.c | |||
@@ -27,213 +27,53 @@ | |||
27 | #endif | 27 | #endif |
28 | #include "backdrop.h" | 28 | #include "backdrop.h" |
29 | 29 | ||
30 | static fb_data main_backdrop[LCD_FBHEIGHT][LCD_FBWIDTH] | 30 | bool backdrop_load(const char* filename, char *backdrop_buffer) |
31 | __attribute__ ((aligned (16))); | ||
32 | static fb_data skin_backdrop[LCD_FBHEIGHT][LCD_FBWIDTH] | ||
33 | __attribute__ ((aligned (16))); | ||
34 | |||
35 | #if defined(HAVE_REMOTE_LCD) && LCD_REMOTE_DEPTH > 1 | ||
36 | static fb_remote_data | ||
37 | remote_skin_backdrop[LCD_REMOTE_FBHEIGHT][LCD_REMOTE_FBWIDTH]; | ||
38 | static bool remote_skin_backdrop_valid = false; | ||
39 | #endif | ||
40 | |||
41 | static bool main_backdrop_valid = false; | ||
42 | static bool skin_backdrop_valid = false; | ||
43 | |||
44 | /* load a backdrop into a buffer */ | ||
45 | static bool load_backdrop(const char* filename, fb_data* backdrop_buffer) | ||
46 | { | 31 | { |
47 | struct bitmap bm; | 32 | struct bitmap bm; |
48 | int ret; | 33 | int ret; |
49 | 34 | ||
50 | /* load the image */ | 35 | /* load the image */ |
51 | bm.data=(char*)backdrop_buffer; | 36 | bm.data = backdrop_buffer; |
52 | ret = read_bmp_file(filename, &bm, sizeof(main_backdrop), | 37 | ret = read_bmp_file(filename, &bm, LCD_BACKDROP_BYTES, |
53 | FORMAT_NATIVE | FORMAT_DITHER, NULL); | 38 | FORMAT_NATIVE | FORMAT_DITHER, NULL); |
54 | 39 | ||
55 | return ((ret > 0) | 40 | return ((ret > 0) |
56 | && (bm.width == LCD_WIDTH) && (bm.height == LCD_HEIGHT)); | 41 | && (bm.width == LCD_WIDTH) && (bm.height == LCD_HEIGHT)); |
57 | } | 42 | } |
58 | 43 | ||
59 | static bool load_main_backdrop(const char* filename) | 44 | |
60 | { | 45 | void backdrop_show(char *backdrop_buffer) |
61 | main_backdrop_valid = load_backdrop(filename, &main_backdrop[0][0]); | ||
62 | return main_backdrop_valid; | ||
63 | } | ||
64 | |||
65 | static inline bool load_skin_backdrop(const char* filename) | ||
66 | { | ||
67 | skin_backdrop_valid = load_backdrop(filename, &skin_backdrop[0][0]); | ||
68 | return skin_backdrop_valid; | ||
69 | } | ||
70 | |||
71 | static inline void unload_main_backdrop(void) | ||
72 | { | ||
73 | main_backdrop_valid = false; | ||
74 | } | ||
75 | |||
76 | static inline void unload_skin_backdrop(void) | ||
77 | { | 46 | { |
78 | skin_backdrop_valid = false; | 47 | lcd_set_backdrop((fb_data*)backdrop_buffer); |
79 | } | 48 | } |
49 | |||
80 | 50 | ||
81 | static inline void show_main_backdrop(void) | 51 | #if defined(HAVE_REMOTE_LCD) |
82 | { | ||
83 | lcd_set_backdrop(main_backdrop_valid ? &main_backdrop[0][0] : NULL); | ||
84 | } | ||
85 | |||
86 | static void show_skin_backdrop(void) | ||
87 | { | ||
88 | /* if no wps backdrop, fall back to main backdrop */ | ||
89 | if(skin_backdrop_valid) | ||
90 | { | ||
91 | lcd_set_backdrop(&skin_backdrop[0][0]); | ||
92 | } | ||
93 | else | ||
94 | { | ||
95 | show_main_backdrop(); | ||
96 | } | ||
97 | } | ||
98 | 52 | ||
53 | #if LCD_REMOTE_DEPTH > 1 | ||
99 | /* api functions */ | 54 | /* api functions */ |
100 | 55 | bool remote_backdrop_load(const char *filename, char* backdrop_buffer) | |
101 | bool 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 | |||
111 | void 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 | |||
119 | void 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 | void backdrop_hide(void) | ||
128 | { | ||
129 | lcd_set_backdrop(NULL); | ||
130 | } | ||
131 | |||
132 | |||
133 | |||
134 | #if defined(HAVE_REMOTE_LCD) && LCD_REMOTE_DEPTH > 1 | ||
135 | |||
136 | static bool load_remote_backdrop(const char* filename, | ||
137 | fb_remote_data* backdrop_buffer) | ||
138 | { | 56 | { |
139 | struct bitmap bm; | 57 | struct bitmap bm; |
140 | int ret; | 58 | int ret; |
141 | 59 | ||
142 | /* load the image */ | 60 | /* load the image */ |
143 | bm.data=(char*)backdrop_buffer; | 61 | bm.data = backdrop_buffer; |
144 | ret = read_bmp_file(filename, &bm, sizeof(main_backdrop), | 62 | ret = read_bmp_file(filename, &bm, REMOTE_LCD_BACKDROP_BYTES, |
145 | FORMAT_NATIVE | FORMAT_DITHER | FORMAT_REMOTE, NULL); | 63 | FORMAT_NATIVE | FORMAT_DITHER | FORMAT_REMOTE, NULL); |
146 | |||
147 | return ((ret > 0) | 64 | return ((ret > 0) |
148 | && (bm.width == LCD_REMOTE_WIDTH) | 65 | && (bm.width == REMOTE_LCD_WIDTH) && (bm.height == REMOTE_LCD_HEIGHT)); |
149 | && (bm.height == LCD_REMOTE_HEIGHT)); | ||
150 | } | ||
151 | |||
152 | static inline bool load_remote_skin_backdrop(const char* filename) | ||
153 | { | ||
154 | remote_skin_backdrop_valid = | ||
155 | load_remote_backdrop(filename, &remote_skin_backdrop[0][0]); | ||
156 | return remote_skin_backdrop_valid; | ||
157 | } | ||
158 | |||
159 | static inline void unload_remote_skin_backdrop(void) | ||
160 | { | ||
161 | remote_skin_backdrop_valid = false; | ||
162 | } | ||
163 | |||
164 | static inline void show_remote_main_backdrop(void) | ||
165 | { | ||
166 | lcd_remote_set_backdrop(NULL); | ||
167 | } | ||
168 | |||
169 | static inline void show_remote_skin_backdrop(void) | ||
170 | { | ||
171 | /* if no wps backdrop, fall back to main backdrop */ | ||
172 | if(remote_skin_backdrop_valid) | ||
173 | { | ||
174 | lcd_remote_set_backdrop(&remote_skin_backdrop[0][0]); | ||
175 | } | ||
176 | else | ||
177 | { | ||
178 | show_remote_main_backdrop(); | ||
179 | } | ||
180 | } | ||
181 | |||
182 | |||
183 | /* api functions */ | ||
184 | bool remote_backdrop_load(enum backdrop_type bdrop, | ||
185 | const char *filename) | ||
186 | { | ||
187 | if (bdrop == BACKDROP_SKIN_WPS) | ||
188 | return load_remote_skin_backdrop(filename); | ||
189 | else if (bdrop == BACKDROP_MAIN) | ||
190 | return true; | ||
191 | else | ||
192 | return false; | ||
193 | } | ||
194 | |||
195 | void remote_backdrop_show(enum backdrop_type bdrop) | ||
196 | { | ||
197 | if (bdrop == BACKDROP_MAIN) | ||
198 | show_remote_main_backdrop(); | ||
199 | else if (bdrop == BACKDROP_SKIN_WPS) | ||
200 | show_remote_skin_backdrop(); | ||
201 | } | ||
202 | |||
203 | void remote_backdrop_unload(enum backdrop_type bdrop) | ||
204 | { | ||
205 | if (bdrop != BACKDROP_MAIN) | ||
206 | unload_remote_skin_backdrop(); | ||
207 | } | ||
208 | |||
209 | |||
210 | void remote_backdrop_hide(void) | ||
211 | { | ||
212 | lcd_remote_set_backdrop(NULL); | ||
213 | } | ||
214 | #else | ||
215 | /* api functions */ | ||
216 | bool remote_backdrop_load(enum backdrop_type bdrop, | ||
217 | const char *filename) | ||
218 | { | ||
219 | (void)bdrop; (void)filename; | ||
220 | return true; | ||
221 | } | 66 | } |
67 | #else /* needs stubs */ | ||
222 | 68 | ||
223 | void remote_backdrop_show(enum backdrop_type bdrop) | 69 | bool remote_backdrop_load(const char *filename, char* backdrop_buffer) |
224 | { | 70 | { |
225 | (void)bdrop; | 71 | (void)filename; (void) backdrop_buffer; |
72 | return false; | ||
226 | } | 73 | } |
227 | 74 | void remote_backdrop_show(char* backdrop_buffer) | |
228 | void remote_backdrop_unload(enum backdrop_type bdrop) | ||
229 | { | ||
230 | (void)bdrop; | ||
231 | } | ||
232 | |||
233 | |||
234 | void remote_backdrop_hide(void) | ||
235 | { | 75 | { |
76 | (void)backdrop_buffer; | ||
236 | } | 77 | } |
237 | #endif | 78 | #endif |
238 | 79 | #endif | |
239 | |||