diff options
author | Jonathan Gordon <rockbox@jdgordon.info> | 2011-11-15 14:11:08 +0000 |
---|---|---|
committer | Jonathan Gordon <rockbox@jdgordon.info> | 2011-11-15 14:11:08 +0000 |
commit | 9e07ef2b0adb8fca7e5a9e516397e533653f8836 (patch) | |
tree | 0a283550421917e52ee04068b84a464976f0c4f2 /apps/gui/skin_engine/wps_internals.h | |
parent | 101693fd3047fb64e766580e80635a424fa25c4d (diff) | |
download | rockbox-9e07ef2b0adb8fca7e5a9e516397e533653f8836.tar.gz rockbox-9e07ef2b0adb8fca7e5a9e516397e533653f8836.zip |
Use buflib for all skin engine allocations.
Massive thanks to Michael Chicoine and other testers for finding the early bugs.
This removes all skin memory limitations
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@30991 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/gui/skin_engine/wps_internals.h')
-rw-r--r-- | apps/gui/skin_engine/wps_internals.h | 166 |
1 files changed, 85 insertions, 81 deletions
diff --git a/apps/gui/skin_engine/wps_internals.h b/apps/gui/skin_engine/wps_internals.h index ed09ad0938..65a063592f 100644 --- a/apps/gui/skin_engine/wps_internals.h +++ b/apps/gui/skin_engine/wps_internals.h | |||
@@ -25,6 +25,11 @@ | |||
25 | #ifndef _WPS_ENGINE_INTERNALS_ | 25 | #ifndef _WPS_ENGINE_INTERNALS_ |
26 | #define _WPS_ENGINE_INTERNALS_ | 26 | #define _WPS_ENGINE_INTERNALS_ |
27 | 27 | ||
28 | #include "tag_table.h" | ||
29 | #include "skin_parser.h" | ||
30 | #ifndef __PCTOOL__ | ||
31 | #include "core_alloc.h" | ||
32 | #endif | ||
28 | 33 | ||
29 | /* Timeout unit expressed in HZ. In WPS, all timeouts are given in seconds | 34 | /* Timeout unit expressed in HZ. In WPS, all timeouts are given in seconds |
30 | (possibly with a decimal fraction) but stored as integer values. | 35 | (possibly with a decimal fraction) but stored as integer values. |
@@ -33,52 +38,48 @@ | |||
33 | #define TIMEOUT_UNIT (HZ/10) /* I.e. 0.1 sec */ | 38 | #define TIMEOUT_UNIT (HZ/10) /* I.e. 0.1 sec */ |
34 | #define DEFAULT_SUBLINE_TIME_MULTIPLIER 20 /* In TIMEOUT_UNIT's */ | 39 | #define DEFAULT_SUBLINE_TIME_MULTIPLIER 20 /* In TIMEOUT_UNIT's */ |
35 | 40 | ||
36 | #include "skin_tokens.h" | ||
37 | #include "tag_table.h" | ||
38 | #include "skin_parser.h" | ||
39 | |||
40 | |||
41 | /* TODO: sort this mess out */ | 41 | /* TODO: sort this mess out */ |
42 | 42 | ||
43 | #include "screen_access.h" | 43 | #include "screen_access.h" |
44 | #include "statusbar.h" | 44 | #include "statusbar.h" |
45 | #include "metadata.h" | 45 | #include "metadata.h" |
46 | 46 | ||
47 | /* alignments */ | ||
48 | #define WPS_ALIGN_RIGHT 32 | ||
49 | #define WPS_ALIGN_CENTER 64 | ||
50 | #define WPS_ALIGN_LEFT 128 | ||
51 | |||
52 | 47 | ||
53 | #define TOKEN_VALUE_ONLY 0x0DEADC0D | 48 | #define TOKEN_VALUE_ONLY 0x0DEADC0D |
54 | 49 | ||
55 | #ifdef HAVE_ALBUMART | 50 | /* wps_data*/ |
56 | 51 | struct wps_token { | |
57 | /* albumart definitions */ | 52 | union { |
58 | #define WPS_ALBUMART_NONE 0 /* WPS does not contain AA tag */ | 53 | char c; |
59 | #define WPS_ALBUMART_CHECK 1 /* WPS contains AA conditional tag */ | 54 | unsigned short i; |
60 | #define WPS_ALBUMART_LOAD 2 /* WPS contains AA tag */ | 55 | long l; |
56 | OFFSETTYPE(void*) data; | ||
57 | } value; | ||
58 | |||
59 | enum skin_token_type type; /* enough to store the token type */ | ||
60 | /* Whether the tag (e.g. track name or the album) refers the | ||
61 | current or the next song (false=current, true=next) */ | ||
62 | bool next; | ||
63 | }; | ||
61 | 64 | ||
62 | #define WPS_ALBUMART_ALIGN_RIGHT 1 /* x align: right */ | 65 | char* get_dir(char* buf, int buf_size, const char* path, int level); |
63 | #define WPS_ALBUMART_ALIGN_CENTER 2 /* x/y align: center */ | ||
64 | #define WPS_ALBUMART_ALIGN_LEFT 4 /* x align: left */ | ||
65 | #define WPS_ALBUMART_ALIGN_TOP 1 /* y align: top */ | ||
66 | #define WPS_ALBUMART_ALIGN_BOTTOM 4 /* y align: bottom */ | ||
67 | 66 | ||
68 | #endif /* HAVE_ALBUMART */ | ||
69 | 67 | ||
70 | /* wps_data*/ | 68 | struct skin_token_list { |
69 | OFFSETTYPE(struct wps_token *) token; | ||
70 | OFFSETTYPE(struct skin_token_list *) next; | ||
71 | }; | ||
71 | 72 | ||
72 | #ifdef HAVE_LCD_BITMAP | 73 | #ifdef HAVE_LCD_BITMAP |
73 | struct gui_img { | 74 | struct gui_img { |
74 | struct viewport* vp; /* The viewport to display this image in */ | 75 | OFFSETTYPE(struct viewport*) vp; /* The viewport to display this image in */ |
75 | short int x; /* x-pos */ | 76 | short int x; /* x-pos */ |
76 | short int y; /* y-pos */ | 77 | short int y; /* y-pos */ |
77 | short int num_subimages; /* number of sub-images */ | 78 | short int num_subimages; /* number of sub-images */ |
78 | short int subimage_height; /* height of each sub-image */ | 79 | short int subimage_height; /* height of each sub-image */ |
79 | struct bitmap bm; | 80 | struct bitmap bm; |
80 | int buflib_handle; | 81 | int buflib_handle; |
81 | const char *label; | 82 | OFFSETTYPE(char*) label; |
82 | bool loaded; /* load state */ | 83 | bool loaded; /* load state */ |
83 | bool always_display; /* not using the preload/display mechanism */ | 84 | bool always_display; /* not using the preload/display mechanism */ |
84 | int display; | 85 | int display; |
@@ -86,15 +87,15 @@ struct gui_img { | |||
86 | }; | 87 | }; |
87 | 88 | ||
88 | struct image_display { | 89 | struct image_display { |
89 | const char *label; | 90 | OFFSETTYPE(char*) label; |
90 | int subimage; | 91 | int subimage; |
91 | struct wps_token *token; /* the token to get the subimage number from */ | 92 | OFFSETTYPE(struct wps_token*) token; /* the token to get the subimage number from */ |
92 | int offset; /* offset into the bitmap strip to start */ | 93 | int offset; /* offset into the bitmap strip to start */ |
93 | }; | 94 | }; |
94 | 95 | ||
95 | struct progressbar { | 96 | struct progressbar { |
96 | enum skin_token_type type; | 97 | enum skin_token_type type; |
97 | struct viewport *vp; | 98 | OFFSETTYPE(struct viewport *) vp; |
98 | /* regular pb */ | 99 | /* regular pb */ |
99 | short x; | 100 | short x; |
100 | /* >=0: explicitly set in the tag -> y-coord within the viewport | 101 | /* >=0: explicitly set in the tag -> y-coord within the viewport |
@@ -105,14 +106,14 @@ struct progressbar { | |||
105 | short height; | 106 | short height; |
106 | bool follow_lang_direction; | 107 | bool follow_lang_direction; |
107 | 108 | ||
108 | struct gui_img *image; | 109 | OFFSETTYPE(struct gui_img *) image; |
109 | 110 | ||
110 | bool invert_fill_direction; | 111 | bool invert_fill_direction; |
111 | bool nofill; | 112 | bool nofill; |
112 | bool nobar; | 113 | bool nobar; |
113 | struct gui_img *slider; | 114 | OFFSETTYPE(struct gui_img *) slider; |
114 | bool horizontal; | 115 | bool horizontal; |
115 | struct gui_img *backdrop; | 116 | OFFSETTYPE(struct gui_img *) backdrop; |
116 | }; | 117 | }; |
117 | #endif | 118 | #endif |
118 | 119 | ||
@@ -125,35 +126,11 @@ struct align_pos { | |||
125 | }; | 126 | }; |
126 | 127 | ||
127 | #ifdef HAVE_LCD_BITMAP | 128 | #ifdef HAVE_LCD_BITMAP |
128 | |||
129 | #define MAX_IMAGES (26*2) /* a-z and A-Z */ | ||
130 | #define MAX_PROGRESSBARS 3 | ||
131 | |||
132 | /* The image buffer is big enough to store one full-screen native bitmap, | ||
133 | plus two full-screen mono bitmaps. */ | ||
134 | |||
135 | #define WPS_MAX_VIEWPORTS 24 | ||
136 | #define WPS_MAX_LINES ((LCD_HEIGHT/5+1) * 2) | ||
137 | #define WPS_MAX_SUBLINES (WPS_MAX_LINES*3) | ||
138 | #define WPS_MAX_TOKENS 1150 | 129 | #define WPS_MAX_TOKENS 1150 |
139 | #define WPS_MAX_STRINGS 128 | ||
140 | #define STRING_BUFFER_SIZE 1024 | ||
141 | #define WPS_MAX_COND_LEVEL 10 | ||
142 | |||
143 | #else | 130 | #else |
144 | |||
145 | #define WPS_MAX_VIEWPORTS 2 | ||
146 | #define WPS_MAX_LINES 2 | ||
147 | #define WPS_MAX_SUBLINES 12 | ||
148 | #define WPS_MAX_TOKENS 64 | 131 | #define WPS_MAX_TOKENS 64 |
149 | #define WPS_MAX_STRINGS 32 | ||
150 | #define STRING_BUFFER_SIZE 64 | ||
151 | #define WPS_MAX_COND_LEVEL 5 | ||
152 | |||
153 | #endif | 132 | #endif |
154 | 133 | ||
155 | #define SUBLINE_RESET -1 | ||
156 | |||
157 | enum wps_parse_error { | 134 | enum wps_parse_error { |
158 | PARSE_OK, | 135 | PARSE_OK, |
159 | PARSE_FAIL_UNCLOSED_COND, | 136 | PARSE_FAIL_UNCLOSED_COND, |
@@ -176,12 +153,17 @@ struct gradient_config { | |||
176 | #define VP_DRAW_WASHIDDEN 0x4 | 153 | #define VP_DRAW_WASHIDDEN 0x4 |
177 | /* these are never drawn, nor cleared, i.e. just ignored */ | 154 | /* these are never drawn, nor cleared, i.e. just ignored */ |
178 | #define VP_NEVER_VISIBLE 0x8 | 155 | #define VP_NEVER_VISIBLE 0x8 |
179 | #define VP_DEFAULT_LABEL "|" | 156 | #ifndef __PCTOOL__ |
157 | #define VP_DEFAULT_LABEL -200 | ||
158 | #else | ||
159 | #define VP_DEFAULT_LABEL NULL | ||
160 | #endif | ||
161 | #define VP_DEFAULT_LABEL_STRING "|" | ||
180 | struct skin_viewport { | 162 | struct skin_viewport { |
181 | struct viewport vp; /* The LCD viewport struct */ | 163 | struct viewport vp; /* The LCD viewport struct */ |
182 | char hidden_flags; | 164 | char hidden_flags; |
183 | bool is_infovp; | 165 | bool is_infovp; |
184 | char* label; | 166 | OFFSETTYPE(char*) label; |
185 | int parsed_fontid; | 167 | int parsed_fontid; |
186 | #if LCD_DEPTH > 1 | 168 | #if LCD_DEPTH > 1 |
187 | unsigned start_fgcolour; | 169 | unsigned start_fgcolour; |
@@ -192,14 +174,14 @@ struct skin_viewport { | |||
192 | #endif | 174 | #endif |
193 | }; | 175 | }; |
194 | struct viewport_colour { | 176 | struct viewport_colour { |
195 | struct viewport *vp; | 177 | OFFSETTYPE(struct viewport *) vp; |
196 | unsigned colour; | 178 | unsigned colour; |
197 | }; | 179 | }; |
198 | 180 | ||
199 | #ifdef HAVE_TOUCHSCREEN | 181 | #ifdef HAVE_TOUCHSCREEN |
200 | struct touchregion { | 182 | struct touchregion { |
201 | char* label; /* label to identify this region */ | 183 | OFFSETTYPE(char*) label; /* label to identify this region */ |
202 | struct skin_viewport* wvp;/* The viewport this region is in */ | 184 | OFFSETTYPE(struct skin_viewport*) wvp;/* The viewport this region is in */ |
203 | short int x; /* x-pos */ | 185 | short int x; /* x-pos */ |
204 | short int y; /* y-pos */ | 186 | short int y; /* y-pos */ |
205 | short int width; /* width */ | 187 | short int width; /* width */ |
@@ -219,7 +201,7 @@ struct touchregion { | |||
219 | const struct settings_list *setting; /* setting being controlled */ | 201 | const struct settings_list *setting; /* setting being controlled */ |
220 | union { /* Value to set the setting to for ACTION_SETTING_SET */ | 202 | union { /* Value to set the setting to for ACTION_SETTING_SET */ |
221 | int number; | 203 | int number; |
222 | char* text; | 204 | OFFSETTYPE(char*) text; |
223 | } value; | 205 | } value; |
224 | } setting_data; | 206 | } setting_data; |
225 | int value; | 207 | int value; |
@@ -230,20 +212,32 @@ struct touchregion { | |||
230 | 212 | ||
231 | 213 | ||
232 | struct touchregion_lastpress { | 214 | struct touchregion_lastpress { |
233 | struct touchregion *region; | 215 | OFFSETTYPE(struct touchregion *) region; |
234 | long timeout; | 216 | long timeout; |
235 | }; | 217 | }; |
236 | #endif | 218 | #endif |
237 | 219 | ||
238 | struct playlistviewer { | 220 | struct playlistviewer { |
239 | struct viewport *vp; | 221 | OFFSETTYPE(struct viewport *) vp; |
240 | bool show_icons; | 222 | bool show_icons; |
241 | int start_offset; | 223 | int start_offset; |
242 | struct skin_element *line; | 224 | OFFSETTYPE(struct skin_element *) line; |
243 | }; | 225 | }; |
244 | 226 | ||
245 | 227 | ||
246 | #ifdef HAVE_ALBUMART | 228 | #ifdef HAVE_ALBUMART |
229 | |||
230 | /* albumart definitions */ | ||
231 | #define WPS_ALBUMART_NONE 0 /* WPS does not contain AA tag */ | ||
232 | #define WPS_ALBUMART_CHECK 1 /* WPS contains AA conditional tag */ | ||
233 | #define WPS_ALBUMART_LOAD 2 /* WPS contains AA tag */ | ||
234 | |||
235 | #define WPS_ALBUMART_ALIGN_RIGHT 1 /* x align: right */ | ||
236 | #define WPS_ALBUMART_ALIGN_CENTER 2 /* x/y align: center */ | ||
237 | #define WPS_ALBUMART_ALIGN_LEFT 4 /* x align: left */ | ||
238 | #define WPS_ALBUMART_ALIGN_TOP 1 /* y align: top */ | ||
239 | #define WPS_ALBUMART_ALIGN_BOTTOM 4 /* y align: bottom */ | ||
240 | |||
247 | struct skin_albumart { | 241 | struct skin_albumart { |
248 | /* Album art support */ | 242 | /* Album art support */ |
249 | int x; | 243 | int x; |
@@ -255,7 +249,7 @@ struct skin_albumart { | |||
255 | unsigned char yalign; /* WPS_ALBUMART_ALIGN_TOP, _CENTER, _BOTTOM */ | 249 | unsigned char yalign; /* WPS_ALBUMART_ALIGN_TOP, _CENTER, _BOTTOM */ |
256 | unsigned char state; /* WPS_ALBUMART_NONE, _CHECK, _LOAD */ | 250 | unsigned char state; /* WPS_ALBUMART_NONE, _CHECK, _LOAD */ |
257 | 251 | ||
258 | struct viewport *vp; | 252 | OFFSETTYPE(struct viewport *) vp; |
259 | int draw_handle; | 253 | int draw_handle; |
260 | }; | 254 | }; |
261 | #endif | 255 | #endif |
@@ -272,11 +266,11 @@ struct line_alternator { | |||
272 | 266 | ||
273 | struct conditional { | 267 | struct conditional { |
274 | int last_value; | 268 | int last_value; |
275 | struct wps_token *token; | 269 | OFFSETTYPE(struct wps_token *) token; |
276 | }; | 270 | }; |
277 | 271 | ||
278 | struct logical_if { | 272 | struct logical_if { |
279 | struct wps_token *token; | 273 | OFFSETTYPE(struct wps_token *) token; |
280 | enum { | 274 | enum { |
281 | IF_EQUALS, /* == */ | 275 | IF_EQUALS, /* == */ |
282 | IF_NOTEQUALS, /* != */ | 276 | IF_NOTEQUALS, /* != */ |
@@ -292,7 +286,7 @@ struct logical_if { | |||
292 | struct substring { | 286 | struct substring { |
293 | int start; | 287 | int start; |
294 | int length; | 288 | int length; |
295 | struct wps_token *token; | 289 | OFFSETTYPE(struct wps_token *) token; |
296 | }; | 290 | }; |
297 | 291 | ||
298 | struct listitem { | 292 | struct listitem { |
@@ -302,16 +296,16 @@ struct listitem { | |||
302 | 296 | ||
303 | #ifdef HAVE_SKIN_VARIABLES | 297 | #ifdef HAVE_SKIN_VARIABLES |
304 | struct skin_var { | 298 | struct skin_var { |
305 | const char *label; | 299 | OFFSETTYPE(const char *) label; |
306 | int value; | 300 | int value; |
307 | long last_changed; | 301 | long last_changed; |
308 | }; | 302 | }; |
309 | struct skin_var_lastchange { | 303 | struct skin_var_lastchange { |
310 | struct skin_var *var; | 304 | OFFSETTYPE(struct skin_var *) var; |
311 | long timeout; | 305 | long timeout; |
312 | }; | 306 | }; |
313 | struct skin_var_changer { | 307 | struct skin_var_changer { |
314 | struct skin_var *var; | 308 | OFFSETTYPE(struct skin_var *) var; |
315 | int newval; | 309 | int newval; |
316 | bool direct; /* true to make val=newval, false for val += newval */ | 310 | bool direct; /* true to make val=newval, false for val += newval */ |
317 | int max; | 311 | int max; |
@@ -323,30 +317,29 @@ struct skin_var_changer { | |||
323 | viewable content of a wps */ | 317 | viewable content of a wps */ |
324 | struct wps_data | 318 | struct wps_data |
325 | { | 319 | { |
326 | struct skin_element *tree; | 320 | int buflib_handle; |
321 | |||
322 | OFFSETTYPE(struct skin_element *) tree; | ||
327 | #ifdef HAVE_LCD_BITMAP | 323 | #ifdef HAVE_LCD_BITMAP |
328 | struct skin_token_list *images; | 324 | OFFSETTYPE(struct skin_token_list *) images; |
329 | int *font_ids; | 325 | OFFSETTYPE(int *) font_ids; |
330 | int font_count; | 326 | int font_count; |
331 | #endif | 327 | #endif |
332 | #if LCD_DEPTH > 1 || defined(HAVE_REMOTE_LCD) && LCD_REMOTE_DEPTH > 1 | 328 | #if LCD_DEPTH > 1 || defined(HAVE_REMOTE_LCD) && LCD_REMOTE_DEPTH > 1 |
333 | struct { | 329 | int backdrop_id; |
334 | char *backdrop; | ||
335 | int backdrop_id; | ||
336 | }; | ||
337 | #endif | 330 | #endif |
338 | 331 | ||
339 | #ifdef HAVE_TOUCHSCREEN | 332 | #ifdef HAVE_TOUCHSCREEN |
340 | struct skin_token_list *touchregions; | 333 | OFFSETTYPE(struct skin_token_list *) touchregions; |
341 | bool touchscreen_locked; | 334 | bool touchscreen_locked; |
342 | #endif | 335 | #endif |
343 | #ifdef HAVE_ALBUMART | 336 | #ifdef HAVE_ALBUMART |
344 | struct skin_albumart *albumart; | 337 | OFFSETTYPE(struct skin_albumart *) albumart; |
345 | int playback_aa_slot; | 338 | int playback_aa_slot; |
346 | #endif | 339 | #endif |
347 | 340 | ||
348 | #ifdef HAVE_SKIN_VARIABLES | 341 | #ifdef HAVE_SKIN_VARIABLES |
349 | struct skin_token_list *skinvars; | 342 | OFFSETTYPE(struct skin_token_list *) skinvars; |
350 | #endif | 343 | #endif |
351 | 344 | ||
352 | #ifdef HAVE_LCD_BITMAP | 345 | #ifdef HAVE_LCD_BITMAP |
@@ -360,6 +353,17 @@ struct wps_data | |||
360 | bool wps_loaded; | 353 | bool wps_loaded; |
361 | }; | 354 | }; |
362 | 355 | ||
356 | #ifndef __PCTOOL__ | ||
357 | static inline char* get_skin_buffer(struct wps_data* data) | ||
358 | { | ||
359 | if (data->buflib_handle >= 0) | ||
360 | return core_get_data(data->buflib_handle); | ||
361 | return NULL; | ||
362 | } | ||
363 | #else | ||
364 | #define get_skin_buffer(d) skin_buffer | ||
365 | #endif | ||
366 | |||
363 | /* wps_data end */ | 367 | /* wps_data end */ |
364 | 368 | ||
365 | /* wps_state | 369 | /* wps_state |