lcd/skin_engine: Add the ability to draw onto the backdrop layer

The framebuffer the lcd driver uses can now be changed on the fly
which means that regular lcd_* drawing functions can draw onto the
"backdrop" buffer. The skin engine can use this to create layered
effects.

Add the tag %VB to a viewport to draw that viewport onto the
backdrop layer. If you want to draw an image onto the backdrop
framebuffer use %x(backdrop filename) instead of %X() inside
a viewport with %VB.

Change-Id: I741498e2af6d4f2d78932cabe8942317893e7cfc
This commit is contained in:
Jonathan Gordon 2012-02-28 22:26:32 +11:00
parent 13f98df5ed
commit 2c71aa9feb
13 changed files with 87 additions and 10 deletions

View file

@ -95,6 +95,10 @@ int skin_backdrop_assign(char* backdrop, char *bmpdir,
filename[2] = '\0'; /* we check this later to see if we actually have an filename[2] = '\0'; /* we check this later to see if we actually have an
image to load. != '\0' means display the image */ image to load. != '\0' means display the image */
} }
else if (!strcmp(backdrop, BACKDROP_BUFFERNAME))
{
strcpy(filename, backdrop);
}
else else
{ {
get_image_filename(backdrop, bmpdir, filename, sizeof(filename)); get_image_filename(backdrop, bmpdir, filename, sizeof(filename));
@ -156,15 +160,20 @@ bool skin_backdrops_preload(void)
{ {
backdrops[i].buffer = core_get_data(backdrops[i].buflib_handle); backdrops[i].buffer = core_get_data(backdrops[i].buflib_handle);
handle_being_loaded = backdrops[i].buflib_handle; handle_being_loaded = backdrops[i].buflib_handle;
backdrops[i].loaded = if (strcmp(filename, BACKDROP_BUFFERNAME))
screens[screen].backdrop_load(filename, backdrops[i].buffer);
handle_being_loaded = -1;
if (!backdrops[i].loaded)
{ {
core_free(backdrops[i].buflib_handle); backdrops[i].loaded =
backdrops[i].buflib_handle = -1; screens[screen].backdrop_load(filename, backdrops[i].buffer);
retval = false; handle_being_loaded = -1;
if (!backdrops[i].loaded)
{
core_free(backdrops[i].buflib_handle);
backdrops[i].buflib_handle = -1;
retval = false;
}
} }
else
backdrops[i].loaded = true;
} }
else else
retval = false; retval = false;
@ -176,10 +185,21 @@ bool skin_backdrops_preload(void)
return retval; return retval;
} }
void* skin_backdrop_get_buffer(int backdrop_id)
{
if (backdrop_id < 0)
return NULL;
return backdrops[backdrop_id].buffer;
}
void skin_backdrop_show(int backdrop_id) void skin_backdrop_show(int backdrop_id)
{ {
if (backdrop_id < 0) if (backdrop_id < 0)
{
screens[0].backdrop_show(NULL);
current_lcd_backdrop[0] = -1;
return; return;
}
enum screen_type screen = backdrops[backdrop_id].screen; enum screen_type screen = backdrops[backdrop_id].screen;
if ((backdrops[backdrop_id].loaded == false) || if ((backdrops[backdrop_id].loaded == false) ||
(backdrops[backdrop_id].name[0] == '-' && (backdrops[backdrop_id].name[0] == '-' &&

View file

@ -70,6 +70,8 @@ bool skin_backdrops_preload(void);
void skin_backdrop_show(int backdrop_id); void skin_backdrop_show(int backdrop_id);
void skin_backdrop_load_setting(void); void skin_backdrop_load_setting(void);
void skin_backdrop_unload(int backdrop_id); void skin_backdrop_unload(int backdrop_id);
#define BACKDROP_BUFFERNAME "#backdrop_buffer#"
void* skin_backdrop_get_buffer(int backdrop_id);
/* do the button loop as often as required for the peak meters to update /* do the button loop as often as required for the peak meters to update
* with a good refresh rate. * with a good refresh rate.

View file

@ -1832,6 +1832,7 @@ static int convert_viewport(struct wps_data *data, struct skin_element* element)
viewport_set_defaults(&skin_vp->vp, curr_screen); viewport_set_defaults(&skin_vp->vp, curr_screen);
#if (LCD_DEPTH > 1) || (defined(HAVE_REMOTE_LCD) && (LCD_REMOTE_DEPTH > 1)) #if (LCD_DEPTH > 1) || (defined(HAVE_REMOTE_LCD) && (LCD_REMOTE_DEPTH > 1))
skin_vp->output_to_backdrop_buffer = false;
skin_vp->start_fgcolour = skin_vp->vp.fg_pattern; skin_vp->start_fgcolour = skin_vp->vp.fg_pattern;
skin_vp->start_bgcolour = skin_vp->vp.bg_pattern; skin_vp->start_bgcolour = skin_vp->vp.bg_pattern;
#endif #endif
@ -2023,6 +2024,11 @@ static int skin_element_callback(struct skin_element* element, void* data)
case SKIN_TOKEN_VIEWPORT_TEXTSTYLE: case SKIN_TOKEN_VIEWPORT_TEXTSTYLE:
function = parse_viewporttextstyle; function = parse_viewporttextstyle;
break; break;
case SKIN_TOKEN_VIEWPORT_DRAWONBG:
curr_vp->output_to_backdrop_buffer = true;
backdrop_filename = BACKDROP_BUFFERNAME;
wps_data->use_extra_framebuffer = true;
break;
#endif #endif
#ifdef HAVE_LCD_COLOR #ifdef HAVE_LCD_COLOR
case SKIN_TOKEN_VIEWPORT_GRADIENT_SETUP: case SKIN_TOKEN_VIEWPORT_GRADIENT_SETUP:

View file

@ -385,11 +385,22 @@ static void do_tags_in_hidden_conditional(struct skin_element* branch,
skin_viewport->hidden_flags |= VP_DRAW_WASHIDDEN; skin_viewport->hidden_flags |= VP_DRAW_WASHIDDEN;
else else
{ {
if (skin_viewport->output_to_backdrop_buffer)
{
void *backdrop = skin_backdrop_get_buffer(data->backdrop_id);
gwps->display->set_framebuffer(backdrop);
skin_backdrop_show(-1);
}
gwps->display->set_viewport(&skin_viewport->vp); gwps->display->set_viewport(&skin_viewport->vp);
gwps->display->clear_viewport(); gwps->display->clear_viewport();
gwps->display->scroll_stop(&skin_viewport->vp); gwps->display->scroll_stop(&skin_viewport->vp);
gwps->display->set_viewport(&info->skin_vp->vp); gwps->display->set_viewport(&info->skin_vp->vp);
skin_viewport->hidden_flags |= VP_DRAW_HIDDEN; skin_viewport->hidden_flags |= VP_DRAW_HIDDEN;
if (skin_viewport->output_to_backdrop_buffer)
{
gwps->display->set_framebuffer(NULL);
skin_backdrop_show(data->backdrop_id);
}
} }
} }
} }
@ -767,6 +778,7 @@ void skin_render(struct gui_wps *gwps, unsigned refresh_mode)
data->wps_progress_pat[i] = display->get_locked_pattern(); data->wps_progress_pat[i] = display->get_locked_pattern();
} }
#endif #endif
viewport = SKINOFFSETTOPTR(skin_buffer, data->tree); viewport = SKINOFFSETTOPTR(skin_buffer, data->tree);
skin_viewport = SKINOFFSETTOPTR(skin_buffer, viewport->data); skin_viewport = SKINOFFSETTOPTR(skin_buffer, viewport->data);
label = SKINOFFSETTOPTR(skin_buffer, skin_viewport->label); label = SKINOFFSETTOPTR(skin_buffer, skin_viewport->label);
@ -786,6 +798,16 @@ void skin_render(struct gui_wps *gwps, unsigned refresh_mode)
#if (LCD_DEPTH > 1) || (defined(HAVE_REMOTE_LCD) && LCD_REMOTE_DEPTH > 1) #if (LCD_DEPTH > 1) || (defined(HAVE_REMOTE_LCD) && LCD_REMOTE_DEPTH > 1)
skin_viewport->vp.fg_pattern = skin_viewport->start_fgcolour; skin_viewport->vp.fg_pattern = skin_viewport->start_fgcolour;
skin_viewport->vp.bg_pattern = skin_viewport->start_bgcolour; skin_viewport->vp.bg_pattern = skin_viewport->start_bgcolour;
if (skin_viewport->output_to_backdrop_buffer)
{
display->set_framebuffer(skin_backdrop_get_buffer(data->backdrop_id));
skin_backdrop_show(-1);
}
else
{
display->set_framebuffer(NULL);
skin_backdrop_show(data->backdrop_id);
}
#endif #endif
#ifdef HAVE_LCD_COLOR #ifdef HAVE_LCD_COLOR
skin_viewport->vp.lss_pattern = skin_viewport->start_gradient.start; skin_viewport->vp.lss_pattern = skin_viewport->start_gradient.start;
@ -822,7 +844,10 @@ void skin_render(struct gui_wps *gwps, unsigned refresh_mode)
skin_viewport, vp_refresh_mode); skin_viewport, vp_refresh_mode);
refresh_mode = old_refresh_mode; refresh_mode = old_refresh_mode;
} }
#ifdef HAVE_LCD_BITMAP
display->set_framebuffer(NULL);
skin_backdrop_show(data->backdrop_id);
#endif
/* Restore the default viewport */ /* Restore the default viewport */
display->set_viewport(NULL); display->set_viewport(NULL);
display->update(); display->update();

View file

@ -44,7 +44,6 @@
#include "statusbar.h" #include "statusbar.h"
#include "metadata.h" #include "metadata.h"
#define TOKEN_VALUE_ONLY 0x0DEADC0D #define TOKEN_VALUE_ONLY 0x0DEADC0D
/* wps_data*/ /* wps_data*/
@ -166,6 +165,7 @@ struct skin_viewport {
OFFSETTYPE(char*) label; OFFSETTYPE(char*) label;
int parsed_fontid; int parsed_fontid;
#if LCD_DEPTH > 1 #if LCD_DEPTH > 1
bool output_to_backdrop_buffer;
unsigned start_fgcolour; unsigned start_fgcolour;
unsigned start_bgcolour; unsigned start_bgcolour;
#ifdef HAVE_LCD_COLOR #ifdef HAVE_LCD_COLOR
@ -328,6 +328,7 @@ struct wps_data
#endif #endif
#ifdef HAVE_BACKDROP_IMAGE #ifdef HAVE_BACKDROP_IMAGE
int backdrop_id; int backdrop_id;
bool use_extra_framebuffer;
#endif #endif
#ifdef HAVE_TOUCHSCREEN #ifdef HAVE_TOUCHSCREEN

View file

@ -261,6 +261,9 @@ struct screen screens[NB_SCREENS] =
#endif #endif
#ifdef HAVE_BUTTONBAR #ifdef HAVE_BUTTONBAR
.has_buttonbar=false, .has_buttonbar=false,
#endif
#if defined(HAVE_LCD_BITMAP)
.set_framebuffer = (void*)lcd_set_framebuffer,
#endif #endif
}, },
#if NB_SCREENS == 2 #if NB_SCREENS == 2
@ -356,6 +359,9 @@ struct screen screens[NB_SCREENS] =
#endif #endif
#ifdef HAVE_BUTTONBAR #ifdef HAVE_BUTTONBAR
.has_buttonbar=false, .has_buttonbar=false,
#endif
#if defined(HAVE_LCD_BITMAP)
.set_framebuffer = (void*)lcd_remote_set_framebuffer,
#endif #endif
} }
#endif /* NB_SCREENS == 2 */ #endif /* NB_SCREENS == 2 */

View file

@ -160,6 +160,9 @@ struct screen
bool (*backdrop_load)(const char *filename, char* backdrop_buffer); bool (*backdrop_load)(const char *filename, char* backdrop_buffer);
void (*backdrop_show)(char* backdrop_buffer); void (*backdrop_show)(char* backdrop_buffer);
#endif #endif
#if defined(HAVE_LCD_BITMAP)
void (*set_framebuffer)(void *framebuffer);
#endif
}; };
#if defined(HAVE_LCD_BITMAP) || defined(HAVE_REMOTE_LCD) #if defined(HAVE_LCD_BITMAP) || defined(HAVE_REMOTE_LCD)

View file

@ -81,6 +81,14 @@ static void lcd_gradient_rect(int x1, int x2, int y, unsigned h,
} }
#endif #endif
void LCDFN(set_framebuffer)(FBFN(data) *fb)
{
if (fb)
LCDFN(framebuffer) = fb;
else
LCDFN(framebuffer) = &LCDFN(static_framebuffer)[0][0];
}
/* /*
* draws the borders of the current viewport * draws the borders of the current viewport
**/ **/

View file

@ -132,6 +132,7 @@ void lcd_remote_init(void);
void lcd_remote_write_command(int cmd); void lcd_remote_write_command(int cmd);
void lcd_remote_write_command_ex(int cmd, int data); void lcd_remote_write_command_ex(int cmd, int data);
void lcd_remote_write_data(const fb_remote_data *data, int count); void lcd_remote_write_data(const fb_remote_data *data, int count);
extern void lcd_remote_set_framebuffer(fb_remote_data *fb);
extern void lcd_remote_bitmap_part(const fb_remote_data *src, int src_x, extern void lcd_remote_bitmap_part(const fb_remote_data *src, int src_x,
int src_y, int stride, int x, int y, int src_y, int stride, int x, int y,

View file

@ -529,6 +529,7 @@ extern void lcd_bitmap_part(const fb_data *src, int src_x, int src_y,
int stride, int x, int y, int width, int height); int stride, int x, int y, int width, int height);
extern void lcd_bitmap(const fb_data *src, int x, int y, int width, extern void lcd_bitmap(const fb_data *src, int x, int y, int width,
int height); int height);
extern void lcd_set_framebuffer(fb_data *fb);
extern void lcd_scroll_step(int pixels); extern void lcd_scroll_step(int pixels);

View file

@ -204,6 +204,7 @@ static const struct tag_info legal_tags[] =
{ SKIN_TOKEN_VIEWPORT_BGCOLOUR, "Vb" , "s", SKIN_REFRESH_STATIC|NOBREAK }, { SKIN_TOKEN_VIEWPORT_BGCOLOUR, "Vb" , "s", SKIN_REFRESH_STATIC|NOBREAK },
{ SKIN_TOKEN_VIEWPORT_TEXTSTYLE, "Vs" , "S|s", SKIN_REFRESH_STATIC }, { SKIN_TOKEN_VIEWPORT_TEXTSTYLE, "Vs" , "S|s", SKIN_REFRESH_STATIC },
{ SKIN_TOKEN_VIEWPORT_GRADIENT_SETUP, "Vg" , "SS|s", SKIN_REFRESH_STATIC|NOBREAK }, { SKIN_TOKEN_VIEWPORT_GRADIENT_SETUP, "Vg" , "SS|s", SKIN_REFRESH_STATIC|NOBREAK },
{ SKIN_TOKEN_VIEWPORT_DRAWONBG, "VB" , "", SKIN_REFRESH_STATIC|NOBREAK },
{ SKIN_TOKEN_VIEWPORT_CONDITIONAL, "Vl" , "SIIiii", 0 }, { SKIN_TOKEN_VIEWPORT_CONDITIONAL, "Vl" , "SIIiii", 0 },
{ SKIN_TOKEN_UIVIEWPORT_LOAD, "Vi" , "sIIiii", 0 }, { SKIN_TOKEN_UIVIEWPORT_LOAD, "Vi" , "sIIiii", 0 },

View file

@ -92,7 +92,8 @@ enum skin_token_type {
SKIN_TOKEN_VIEWPORT_BGCOLOUR, SKIN_TOKEN_VIEWPORT_BGCOLOUR,
SKIN_TOKEN_VIEWPORT_TEXTSTYLE, SKIN_TOKEN_VIEWPORT_TEXTSTYLE,
SKIN_TOKEN_VIEWPORT_GRADIENT_SETUP, SKIN_TOKEN_VIEWPORT_GRADIENT_SETUP,
SKIN_TOKEN_VIEWPORT_DRAWONBG,
/* Battery */ /* Battery */
SKIN_TOKEN_BATTERY_PERCENT, SKIN_TOKEN_BATTERY_PERCENT,
SKIN_TOKEN_BATTERY_PERCENTBAR, SKIN_TOKEN_BATTERY_PERCENTBAR,

View file

@ -91,6 +91,8 @@ show the information for the next song to be played.
\config{\%VI('label')} & Set the Info Viewport to use the viewport called \config{\%VI('label')} & Set the Info Viewport to use the viewport called
label, as declared with the previous tag.\\ label, as declared with the previous tag.\\
\config{\%VB} & Draw this viewport on the backdrop layer.
\end{tagmap} \end{tagmap}
\section{Additional Fonts} \section{Additional Fonts}