skin_engine.c settings_apply_skins cleanup

just some cleanup and removal of ifdefs in favor of dummy functions

Change-Id: I03a1d351344afcc428dedb67aab915184f99bd23
This commit is contained in:
William Wilgus 2022-03-15 20:17:11 -04:00
parent a5c16d2990
commit b3e0d18f7d
5 changed files with 40 additions and 22 deletions

View file

@ -81,8 +81,9 @@ static int buflib_move_callback(int handle, void* current, void* new)
}
static struct buflib_callbacks buflib_ops = {buflib_move_callback, NULL, NULL};
static bool first_go = true;
void skin_backdrop_init(void)
bool skin_backdrop_init(void)
{
bool go_status = first_go;
if (first_go)
{
for (int i=0; i<NB_BDROPS; i++)
@ -98,6 +99,7 @@ void skin_backdrop_init(void)
handle_being_loaded = -1;
first_go = false;
}
return go_status;
}
int skin_backdrop_assign(char* backdrop, char *bmpdir,
@ -331,8 +333,20 @@ void skin_backdrop_unload(int backdrop_id)
(void)backdrop_id;
}
#else
static bool first_go = true;
bool skin_backdrop_init(void)
{
bool go_status = first_go;
first_go = false;
return go_status;
}
void skin_backdrop_init(void)
void skin_backdrop_load_setting(void)
{
}
void skin_backdrop_show(int backdrop_id)
{
(void) backdrop_id;
}
#endif

View file

@ -149,16 +149,28 @@ void skin_unload_all(void)
gui_sync_skin_init();
}
static void skin_reset_buffers(int item, int screen)
{
skin_data_free_buflib_allocs(&skins[item][screen].data);
#ifdef HAVE_ALBUMART
if (skins[item][screen].data.playback_aa_slot >= 0)
playback_release_aa_slot(skins[item][screen].data.playback_aa_slot);
#endif
#ifdef HAVE_BACKDROP_IMAGE
if (skins[item][screen].data.backdrop_id >= 0)
skin_backdrop_unload(skins[item][screen].data.backdrop_id);
#endif
}
void settings_apply_skins(void)
{
int i;
char filename[MAX_PATH];
static bool first_run = true;
if (audio_status() & AUDIO_STATUS_PLAY)
audio_stop();
skin_backdrop_init();
bool first_run = skin_backdrop_init();
skins_initialised = true;
/* Make sure each skin is loaded */
@ -170,15 +182,7 @@ void settings_apply_skins(void)
if (!first_run)
{
skin_data_free_buflib_allocs(&skins[i][j].data);
#ifdef HAVE_ALBUMART
if (skins[i][j].data.playback_aa_slot >= 0)
playback_release_aa_slot(skins[i][j].data.playback_aa_slot);
#endif
#ifdef HAVE_BACKDROP_IMAGE
if (skins[i][j].data.backdrop_id >= 0)
skin_backdrop_unload(skins[i][j].data.backdrop_id);
#endif
skin_reset_buffers(i, j);
}
gui_skin_reset(&skins[i][j]);
skins[i][j].gui_wps.display = &screens[j];
@ -186,17 +190,14 @@ void settings_apply_skins(void)
skin_get_gwps(i, j);
}
}
first_run = false;
#ifdef HAVE_BACKDROP_IMAGE
/* any backdrop that was loaded with "-" has to be reloaded because
* the setting may have changed */
skin_backdrop_load_setting();
#endif
viewportmanager_theme_changed(THEME_STATUSBAR);
#ifdef HAVE_BACKDROP_IMAGE
FOR_NB_SCREENS(i)
skin_backdrop_show(sb_get_backdrop(i));
#endif
}
void skin_load(enum skinnable_screens skin, enum screen_type screen,

View file

@ -62,7 +62,7 @@ bool skin_has_sbs(enum screen_type screen, struct wps_data *data);
/* load a backdrop into the skin buffer.
* reuse buffers if the file is already loaded */
char* skin_backdrop_load(char* backdrop, char *bmpdir, enum screen_type screen);
void skin_backdrop_init(void);
bool skin_backdrop_init(void);
int skin_backdrop_assign(char* backdrop, char *bmpdir,
enum screen_type screen);
bool skin_backdrops_preload(void);

View file

@ -156,7 +156,12 @@ int sb_get_backdrop(enum screen_type screen)
else
return -1;
}
#else
int sb_get_backdrop(enum screen_type screen)
{
(void) screen;
return -1;
}
#endif
static bool force_waiting = false;
void sb_skin_update(enum screen_type screen, bool force)

View file

@ -49,9 +49,7 @@ void sb_bypass_touchregions(bool enable);
int sb_touch_to_button(int context);
#endif
#if (LCD_DEPTH > 1) || (defined(HAVE_REMOTE_LCD) && LCD_REMOTE_DEPTH > 1)
int sb_get_backdrop(enum screen_type screen);
#endif
int sb_preproccess(enum screen_type screen, struct wps_data *data);
int sb_postproccess(enum screen_type screen, struct wps_data *data);