forked from len0rd/rockbox
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
This commit is contained in:
parent
ef53cc099e
commit
0f0d9064c5
6 changed files with 68 additions and 78 deletions
|
|
@ -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)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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 */
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue