summaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorThomas Martitz <kugel@rockbox.org>2009-10-14 15:49:11 +0000
committerThomas Martitz <kugel@rockbox.org>2009-10-14 15:49:11 +0000
commit0f0d9064c5e7add982d4b62850375985d79c1168 (patch)
tree432ace6da9deb1723e65851fd86a17c621c90405 /apps
parentef53cc099e1a04442230967a755bf8850afef619 (diff)
downloadrockbox-0f0d9064c5e7add982d4b62850375985d79c1168.tar.gz
rockbox-0f0d9064c5e7add982d4b62850375985d79c1168.tar.bz2
rockbox-0f0d9064c5e7add982d4b62850375985d79c1168.zip
Remove wps_reset(), and rename skin_data_init to skin_data_reset() and extend it to zero most of the wps_data members.
As these are called when parsing a skin it doesn't need to be called by the wps or settings, so make it local to skin_parser.c. Reorder the members of struct wps_data for more effecient alignment. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@23171 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps')
-rw-r--r--apps/gui/skin_engine/skin_display.c25
-rw-r--r--apps/gui/skin_engine/skin_parser.c51
-rw-r--r--apps/gui/skin_engine/wps_internals.h43
-rw-r--r--apps/gui/wps.c18
-rw-r--r--apps/gui/wps.h1
-rw-r--r--apps/settings.c8
6 files changed, 68 insertions, 78 deletions
diff --git a/apps/gui/skin_engine/skin_display.c b/apps/gui/skin_engine/skin_display.c
index cf1dbaa771..7d75b48506 100644
--- a/apps/gui/skin_engine/skin_display.c
+++ b/apps/gui/skin_engine/skin_display.c
@@ -68,31 +68,6 @@
static bool skin_redraw(struct gui_wps *gwps, unsigned refresh_mode);
-/* initial setup of wps_data */
-void skin_data_init(struct wps_data *wps_data)
-{
-#ifdef HAVE_LCD_BITMAP
- wps_data->wps_sb_tag = false;
- wps_data->show_sb_on_wps = false;
- wps_data->peak_meter_enabled = false;
- wps_data->images = NULL;
- wps_data->progressbars = NULL;
-#ifdef HAVE_ALBUMART
- wps_data->albumart = NULL;
-#endif
- /* progress bars */
-#else /* HAVE_LCD_CHARCELLS */
- int i;
- for (i = 0; i < 8; i++)
- {
- wps_data->wps_progress_pat[i] = 0;
- }
- wps_data->full_line_progressbar = false;
-#endif
- wps_data->button_time_volume = 0;
- wps_data->wps_loaded = false;
-}
-
/* TODO: maybe move this whole function into wps.c instead ? */
bool gui_wps_display(struct gui_wps *gwps)
{
diff --git a/apps/gui/skin_engine/skin_parser.c b/apps/gui/skin_engine/skin_parser.c
index bd6199c5e9..dbbdc32730 100644
--- a/apps/gui/skin_engine/skin_parser.c
+++ b/apps/gui/skin_engine/skin_parser.c
@@ -104,8 +104,6 @@ extern void print_debug_info(struct wps_data *data, int fail, int line);
extern void debug_skin_usage(void);
#endif
-static void wps_reset(struct wps_data *data);
-
/* Function for parsing of details for a token. At the moment the
function is called, the token type has already been set. The
function must fill in the details and possibly add more tokens
@@ -1582,16 +1580,45 @@ static bool wps_parse(struct wps_data *data, const char *wps_bufptr, bool debug)
return (fail == 0);
}
-static void wps_reset(struct wps_data *data)
+
+/*
+ * initial setup of wps_data; does reset everything
+ * except fields which need to survive, i.e.
+ *
+ * wps_data->remote_wps
+ **/
+void skin_data_reset(struct wps_data *wps_data)
{
-#ifdef HAVE_REMOTE_LCD
- bool rwps = data->remote_wps; /* remember whether the data is for a RWPS */
+#ifdef HAVE_LCD_BITMAP
+ wps_data->images = NULL;
+ wps_data->progressbars = NULL;
#endif
- memset(data, 0, sizeof(*data));
- skin_data_init(data);
-#ifdef HAVE_REMOTE_LCD
- data->remote_wps = rwps;
+#ifdef HAVE_TOUCHSCREEN
+ wps_data->touchregions = NULL;
+#endif
+ wps_data->viewports = NULL;
+ wps_data->strings = NULL;
+#ifdef HAVE_ALBUMART
+ wps_data->albumart = NULL;
+#endif
+ wps_data->tokens = NULL;
+ wps_data->num_tokens = 0;
+ wps_data->button_time_volume = 0;
+
+#ifdef HAVE_LCD_BITMAP
+ wps_data->peak_meter_enabled = false;
+ wps_data->wps_sb_tag = false;
+ wps_data->show_sb_on_wps = false;
+#else /* HAVE_LCD_CHARCELLS */
+ /* progress bars */
+ int i;
+ for (i = 0; i < 8; i++)
+ {
+ wps_data->wps_progress_pat[i] = 0;
+ }
+ wps_data->full_line_progressbar = false;
#endif
+ wps_data->wps_loaded = false;
}
#ifdef HAVE_LCD_BITMAP
@@ -1704,7 +1731,7 @@ bool skin_data_load(struct wps_data *wps_data,
}
#endif
- wps_reset(wps_data);
+ skin_data_reset(wps_data);
curr_vp = skin_buffer_alloc(sizeof(struct skin_viewport));
if (!curr_vp)
@@ -1796,7 +1823,7 @@ bool skin_data_load(struct wps_data *wps_data,
/* parse the WPS source */
if (!wps_parse(wps_data, wps_buffer, true)) {
- wps_reset(wps_data);
+ skin_data_reset(wps_data);
return false;
}
@@ -1811,7 +1838,7 @@ bool skin_data_load(struct wps_data *wps_data,
/* load the bitmaps that were found by the parsing */
if (!load_skin_bitmaps(wps_data, bmpdir)) {
- wps_reset(wps_data);
+ skin_data_reset(wps_data);
return false;
}
#endif
diff --git a/apps/gui/skin_engine/wps_internals.h b/apps/gui/skin_engine/wps_internals.h
index 177a376008..7a4fdddc7c 100644
--- a/apps/gui/skin_engine/wps_internals.h
+++ b/apps/gui/skin_engine/wps_internals.h
@@ -244,43 +244,38 @@ struct skin_albumart {
struct wps_data
{
#ifdef HAVE_LCD_BITMAP
- bool wps_sb_tag;
- bool show_sb_on_wps;
-
struct skin_token_list *images;
struct skin_token_list *progressbars;
-
- bool peak_meter_enabled;
-#ifdef HAVE_ALBUMART
- struct skin_albumart *albumart;
-#endif
-
-#else /*HAVE_LCD_CHARCELLS */
- unsigned short wps_progress_pat[8];
- bool full_line_progressbar;
#endif
#ifdef HAVE_TOUCHSCREEN
struct skin_token_list *touchregions;
#endif
-
-#ifdef HAVE_REMOTE_LCD
- bool remote_wps;
-#endif
-
struct skin_token_list *viewports;
-
+ struct skin_token_list *strings;
+#ifdef HAVE_ALBUMART
+ struct skin_albumart *albumart;
+#endif
+ struct wps_token *tokens;
/* Total number of tokens in the WPS. During WPS parsing, this is
the index of the token being parsed. */
int num_tokens;
- struct wps_token *tokens;
-
- struct skin_token_list *strings;
-
- bool wps_loaded;
-
/* tick the volume button was last pressed */
unsigned int button_time_volume;
+
+#ifdef HAVE_LCD_BITMAP
+ bool peak_meter_enabled;
+ bool wps_sb_tag;
+ bool show_sb_on_wps;
+#else /*HAVE_LCD_CHARCELLS */
+ unsigned short wps_progress_pat[8];
+ bool full_line_progressbar;
+#endif
+ bool wps_loaded;
+#ifdef HAVE_REMOTE_LCD
+ /* this must not be reset on skin loading */
+ bool remote_wps;
+#endif
};
/* wps_data end */
diff --git a/apps/gui/wps.c b/apps/gui/wps.c
index 2529686e3e..3524ba34b7 100644
--- a/apps/gui/wps.c
+++ b/apps/gui/wps.c
@@ -79,11 +79,12 @@
#define MIN_FF_REWIND_STEP 500
/* this is for the viewportmanager */
-static int wpsbars;
-/* currently only one wps_state is needed */
-static struct wps_state wps_state;
-static struct gui_wps gui_wps[NB_SCREENS];
-static struct wps_data wps_datas[NB_SCREENS];
+static int wpsbars = 0;
+
+/* currently only one wps_state is needed, initialize to 0 */
+static struct wps_state wps_state = { .id3 = NULL};
+static struct gui_wps gui_wps[NB_SCREENS] = {{ 0 }};
+static struct wps_data wps_datas[NB_SCREENS] = {{ 0 }};
/* initial setup of wps_data */
static void wps_state_init(void);
@@ -160,12 +161,6 @@ void wps_data_load(enum screen_type screen, const char *buf, bool isfile)
#endif
}
-void wps_data_init(enum screen_type screen)
-{
- skin_data_init(gui_wps[screen].data);
-}
-
-
static bool wps_fading_out = false;
void fade(bool fade_in, bool updatewps)
{
@@ -1288,7 +1283,6 @@ void gui_sync_wps_init(void)
int i;
FOR_NB_SCREENS(i)
{
- skin_data_init(&wps_datas[i]);
#ifdef HAVE_ALBUMART
wps_datas[i].albumart = NULL;
#endif
diff --git a/apps/gui/wps.h b/apps/gui/wps.h
index f2f44859ca..6affcee698 100644
--- a/apps/gui/wps.h
+++ b/apps/gui/wps.h
@@ -27,7 +27,6 @@ long gui_wps_show(void);
/* wrapper for the wps to load the skin (.wps/.rwps) files */
void wps_data_load(enum screen_type, const char *, bool);
-void wps_data_init(enum screen_type);
void gui_sync_wps_init(void);
diff --git a/apps/settings.c b/apps/settings.c
index ce888c44c5..2a5e31824f 100644
--- a/apps/settings.c
+++ b/apps/settings.c
@@ -741,25 +741,25 @@ void settings_apply_skins(void)
/* re-initialize the skin buffer before we start reloading skins */
skin_buffer_init();
if ( global_settings.wps_file[0] &&
- global_settings.wps_file[0] != 0xff ) {
+ global_settings.wps_file[0] != 0xff )
+ {
snprintf(buf, sizeof buf, WPS_DIR "/%s.wps",
global_settings.wps_file);
wps_data_load(SCREEN_MAIN, buf, true);
}
else
{
- wps_data_init(SCREEN_MAIN);
wps_data_load(SCREEN_MAIN, NULL, true);
}
#if defined(HAVE_REMOTE_LCD) && (NB_SCREENS > 1)
- if ( global_settings.rwps_file[0]) {
+ if ( global_settings.rwps_file[0])
+ {
snprintf(buf, sizeof buf, WPS_DIR "/%s.rwps",
global_settings.rwps_file);
wps_data_load(SCREEN_REMOTE, buf, true);
}
else
{
- wps_data_init(SCREEN_REMOTE);
wps_data_load(SCREEN_REMOTE, NULL, true);
}
#endif