From 877d378710337e7b89b015e3901e467fbcff53be Mon Sep 17 00:00:00 2001 From: Jonathan Gordon Date: Tue, 16 Feb 2010 05:24:27 +0000 Subject: Reuse the backdrop buffers if 2 skins use the same backdrop (on the same screen of course) git-svn-id: svn://svn.rockbox.org/rockbox/trunk@24690 a1c6a512-1295-4272-9138-f99709370657 --- apps/gui/skin_engine/skin_backdrops.c | 119 ++++++++++++++++++++++++++++++++++ 1 file changed, 119 insertions(+) create mode 100644 apps/gui/skin_engine/skin_backdrops.c (limited to 'apps/gui/skin_engine/skin_backdrops.c') diff --git a/apps/gui/skin_engine/skin_backdrops.c b/apps/gui/skin_engine/skin_backdrops.c new file mode 100644 index 0000000000..b057935241 --- /dev/null +++ b/apps/gui/skin_engine/skin_backdrops.c @@ -0,0 +1,119 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id: skin_tokens.c 24526 2010-02-05 23:58:53Z jdgordon $ + * + * Copyright (C) 2010 Jonathan Gordon + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ****************************************************************************/ + +#include "config.h" +#include +#include +#include + +#include "settings.h" +#include "skin_buffer.h" +#include "wps_internals.h" +#include "skin_engine.h" + +#if (LCD_DEPTH > 1) || (defined(HAVE_REMOTE_LCD) && (LCD_REMOTE_DEPTH > 1)) + +static struct skin_backdrop { + char name[MAX_FILENAME+1]; + char *buffer; + enum screen_type screen; +} backdrops[SKINNABLE_SCREENS_COUNT*NB_SCREENS]; + +void skin_backdrop_init(void) +{ + int i; + for(i=0;i 1) + if (screen == SCREEN_REMOTE) + buf_size = REMOTE_LCD_BACKDROP_BYTES; + else +#endif + buf_size = LCD_BACKDROP_BYTES; + + if (backdrop[0] == '-') + { +#if NB_SCREENS > 1 + if (screen == SCREEN_REMOTE) + { + return NULL; /* remotes don't have a backdrop setting (yet!) */ + } + else +#endif + { + if (!global_settings.backdrop_file[0]) + { + return NULL; /* backdrop setting not set */ + } + snprintf(filename, sizeof(filename), "%s/%s.bmp", + BACKDROP_DIR, global_settings.backdrop_file); + } + } + else + { + get_image_filename(backdrop, bmpdir, filename, sizeof(filename)); + } + + for(i=0;ibuffer = skin_buffer_alloc(buf_size); + if (!bdrop->buffer) + return NULL; + loaded = screens[screen].backdrop_load(filename, bdrop->buffer); + bdrop->screen = screen; + strlcpy(bdrop->name, backdrop, MAX_FILENAME+1); + bdrop->name[MAX_FILENAME] = '\0'; + + return loaded ? bdrop->buffer : NULL; +} +#else + +void skin_backdrop_init(void) +{ +} +#endif + -- cgit v1.2.3