summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJonathan Gordon <rockbox@jdgordon.info>2014-03-27 18:15:12 +1100
committerJonathan Gordon <rockbox@jdgordon.info>2014-05-14 19:41:55 +1000
commit01cbb795e9a059238f0e39d44d279c1d52874e06 (patch)
treef1aca3081d170a3e5cc92ee4966b6698e1b20232
parent440ff9500bc74cc278e0b66f528cfdf624547240 (diff)
downloadrockbox-01cbb795e9a059238f0e39d44d279c1d52874e06.tar.gz
rockbox-01cbb795e9a059238f0e39d44d279c1d52874e06.tar.bz2
rockbox-01cbb795e9a059238f0e39d44d279c1d52874e06.zip
don't load the same bmp image more than once in a skin
Change-Id: Ie38146a80bb356f40810f017c262b81edac69688
-rw-r--r--apps/gui/skin_engine/skin_parser.c24
1 files changed, 22 insertions, 2 deletions
diff --git a/apps/gui/skin_engine/skin_parser.c b/apps/gui/skin_engine/skin_parser.c
index 57153ed602..cf90ff5eab 100644
--- a/apps/gui/skin_engine/skin_parser.c
+++ b/apps/gui/skin_engine/skin_parser.c
@@ -1826,7 +1826,7 @@ static bool load_skin_bitmaps(struct wps_data *wps_data, char *bmpdir)
{
struct wps_token *token = SKINOFFSETTOPTR(skin_buffer, list->token);
struct gui_img *img = (struct gui_img*)SKINOFFSETTOPTR(skin_buffer, token->value.data);
- if (img->bm.data)
+ if (!img->loaded)
{
if (img->using_preloaded_icons)
{
@@ -1835,10 +1835,30 @@ static bool load_skin_bitmaps(struct wps_data *wps_data, char *bmpdir)
}
else
{
- img->buflib_handle = load_skin_bmp(wps_data, &img->bm, bmpdir);
+ char path[MAX_PATH];
+ int handle;
+ strcpy(path, img->bm.data);
+ handle = load_skin_bmp(wps_data, &img->bm, bmpdir);
+ img->buflib_handle = handle;
img->loaded = img->buflib_handle >= 0;
if (img->loaded)
+ {
+ struct skin_token_list *imglist = SKINOFFSETTOPTR(skin_buffer, list->next);
+
img->subimage_height = img->bm.height / img->num_subimages;
+ while (imglist)
+ {
+ token = SKINOFFSETTOPTR(skin_buffer, imglist->token);
+ img = (struct gui_img*)SKINOFFSETTOPTR(skin_buffer, token->value.data);
+ if (!strcmp(path, img->bm.data))
+ {
+ img->loaded = true;
+ img->buflib_handle = handle;
+ img->subimage_height = img->bm.height / img->num_subimages;
+ }
+ imglist = SKINOFFSETTOPTR(skin_buffer, imglist->next);
+ }
+ }
else
retval = false;
}