3237ae4a4f
I'm currently running up against the limitations of the lcd_draw functions I want these functions to be able to be used on any size buffer not just buffers with a stride matching the underlying device [DONE] allow the framebuffer to be decoupled from the device framebuffer [DONE need examples] allow for some simple blit like transformations [DONE] remove the device framebuffer from the plugin api [DONE}ditto remote framebuffer [DONE] remove _viewport_get_framebuffer you can call struct *vp = lcd_set_viewport(NULL) and vp->buffer->fb_ptr while remote lcds may compile (and work in the sim) its not been tested on targets [FIXED] backdrops need work to be screen agnostic [FIXED] screen statusbar is not being combined into the main viewport correctly yet [FIXED] screen elements are displayed incorrectly after switch to void* [FIXED] core didn't restore proper viewport on splash etc. [NEEDS TESTING] remote lcd garbled data [FIXED] osd lib garbled screen on bmp_part [FIXED] grey_set_vp needs to return old viewport like lcd_set_viewport [FIXED] Viewport update now handles viewports with differing buffers/strides by copying to the main buffer [FIXED] splash on top of WPS leaves old framebuffer data (doesn't redraw) [UPDATE] refined this a bit more to have clear_viewport set the clean bit and have skin_render do its own screen clear scrolling viewports no longer trigger wps refresh also fixed a bug where guisyncyesno was displaying and then disappearing [ADDED!] New LCD macros that allow you to create properly size frame buffers in you desired size without wasting bytes (LCD_ and LCD_REMOTE_) LCD_STRIDE(w, h) same as STRIDE_MAIN LCD_FBSTRIDE(w, h) returns target specific stride for a buffer W x H LCD_NBELEMS(w, h) returns the number of fb_data sized elemenst needed for a buffer W x H LCD_NATIVE_STRIDE(s) conversion between rockbox native vertical and lcd native stride (2bitH) test_viewports.c has an example of usage [FIXED!!] 2bit targets don't respect non-native strides [FIXED] Few define snags Change-Id: I0d04c3834e464eca84a5a715743a297a0cefd0af
230 lines
6.1 KiB
C
230 lines
6.1 KiB
C
/***************************************************************************
|
|
* __________ __ ___.
|
|
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
|
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
|
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
|
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
|
* \/ \/ \/ \/ \/
|
|
* $Id$
|
|
*
|
|
* Copyright (C) 2007 Dave Chapman
|
|
*
|
|
* 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 "plugin.h"
|
|
|
|
#ifdef HAVE_LCD_COLOR
|
|
#define BGCOLOR_1 LCD_RGBPACK(255,255,0)
|
|
#define BGCOLOR_2 LCD_RGBPACK(0,255,0)
|
|
#define FGCOLOR_1 LCD_RGBPACK(0,0,255)
|
|
#elif LCD_DEPTH > 1
|
|
#define BGCOLOR_1 LCD_DARKGRAY
|
|
#define BGCOLOR_2 LCD_LIGHTGRAY
|
|
#define FGCOLOR_1 LCD_WHITE
|
|
#endif
|
|
|
|
static struct viewport vp0 =
|
|
{
|
|
.x = 0,
|
|
.y = 0,
|
|
.width = LCD_WIDTH/ 2 + LCD_WIDTH / 3,
|
|
.height = 20,
|
|
.font = FONT_UI,
|
|
.drawmode = DRMODE_SOLID,
|
|
#if LCD_DEPTH > 1
|
|
.fg_pattern = LCD_DEFAULT_FG,
|
|
.bg_pattern = BGCOLOR_1,
|
|
#endif
|
|
};
|
|
|
|
static struct viewport vp1 =
|
|
{
|
|
.x = LCD_WIDTH / 10,
|
|
.y = 20,
|
|
.width = LCD_WIDTH / 3,
|
|
.height = LCD_HEIGHT / 2,
|
|
.font = FONT_SYSFIXED,
|
|
.drawmode = DRMODE_SOLID,
|
|
#if LCD_DEPTH > 1
|
|
.fg_pattern = LCD_DEFAULT_FG,
|
|
.bg_pattern = LCD_DEFAULT_BG,
|
|
#endif
|
|
};
|
|
|
|
static struct viewport vp2 =
|
|
{
|
|
.x = LCD_WIDTH / 2,
|
|
.y = 40,
|
|
.width = LCD_WIDTH / 3,
|
|
.height = (LCD_HEIGHT / 2),
|
|
.font = FONT_UI,
|
|
.drawmode = DRMODE_SOLID,
|
|
#if LCD_DEPTH > 1
|
|
.fg_pattern = FGCOLOR_1,
|
|
.bg_pattern = BGCOLOR_2,
|
|
#endif
|
|
};
|
|
|
|
|
|
static struct viewport vp3 =
|
|
{
|
|
.x = LCD_WIDTH / 4,
|
|
.y = (5 * LCD_HEIGHT) / 8,
|
|
.width = LCD_WIDTH / 2,
|
|
.height = (LCD_HEIGHT / 4),
|
|
.font = FONT_SYSFIXED,
|
|
.drawmode = DRMODE_SOLID,
|
|
#if LCD_DEPTH > 1
|
|
.fg_pattern = LCD_BLACK,
|
|
.bg_pattern = LCD_WHITE,
|
|
#endif
|
|
};
|
|
|
|
|
|
#ifdef HAVE_REMOTE_LCD
|
|
static struct viewport rvp0 =
|
|
{
|
|
.x = 0,
|
|
.y = 10,
|
|
.width = LCD_REMOTE_WIDTH / 3,
|
|
.height = LCD_REMOTE_HEIGHT - 10,
|
|
.font = FONT_SYSFIXED,
|
|
.drawmode = DRMODE_SOLID,
|
|
#if LCD_REMOTE_DEPTH > 1
|
|
.fg_pattern = LCD_REMOTE_BLACK,
|
|
.bg_pattern = LCD_REMOTE_LIGHTGRAY,
|
|
#endif
|
|
};
|
|
|
|
static struct viewport rvp1 =
|
|
{
|
|
.x = LCD_REMOTE_WIDTH / 2,
|
|
.y = 0,
|
|
.width = LCD_REMOTE_WIDTH / 3,
|
|
.height = LCD_REMOTE_HEIGHT - 10,
|
|
.font = FONT_SYSFIXED,
|
|
.drawmode = DRMODE_SOLID,
|
|
#if LCD_REMOTE_DEPTH > 1
|
|
.fg_pattern = LCD_REMOTE_DEFAULT_FG,
|
|
.bg_pattern = LCD_REMOTE_DEFAULT_BG
|
|
#endif
|
|
};
|
|
|
|
#endif
|
|
|
|
static void *test_address_fn(int x, int y)
|
|
{
|
|
struct frame_buffer_t *fb = vp0.buffer;
|
|
|
|
#if defined(LCD_STRIDEFORMAT) && LCD_STRIDEFORMAT == VERTICAL_STRIDE
|
|
size_t element = (x * LCD_NATIVE_STRIDE(fb->stride)) + y;
|
|
#else
|
|
size_t element = (y * LCD_NATIVE_STRIDE(fb->stride)) + x;
|
|
#endif
|
|
return fb->fb_ptr + (element % fb->elems);
|
|
}
|
|
|
|
enum plugin_status plugin_start(const void* parameter)
|
|
{
|
|
(void)parameter;
|
|
char buf[80];
|
|
int i,y;
|
|
fb_data vp_buffer[LCD_NBELEMS(vp0.width, vp0.height)];
|
|
|
|
struct frame_buffer_t fb;
|
|
|
|
fb.stride = STRIDE_MAIN(vp0.width, vp0.height);
|
|
|
|
fb.fb_ptr = vp_buffer;
|
|
fb.elems = LCD_NBELEMS(vp0.width, vp0.height);
|
|
fb.get_address_fn = &test_address_fn;
|
|
|
|
rb->viewport_set_buffer(&vp0, &fb, SCREEN_MAIN);
|
|
rb->screens[SCREEN_MAIN]->set_viewport(&vp0);
|
|
rb->screens[SCREEN_MAIN]->clear_viewport();
|
|
|
|
rb->screens[SCREEN_MAIN]->puts_scroll(0,0,"Viewport testing plugin - this is a scrolling title");
|
|
|
|
rb->screens[SCREEN_MAIN]->set_viewport(&vp1);
|
|
rb->screens[SCREEN_MAIN]->clear_viewport();
|
|
|
|
for (i = 0 ; i < 3; i++)
|
|
{
|
|
rb->snprintf(buf,sizeof(buf),"Left text, scrolling_line %d",i);
|
|
rb->screens[SCREEN_MAIN]->puts_scroll(0,i,buf);
|
|
}
|
|
|
|
rb->screens[SCREEN_MAIN]->set_viewport(&vp2);
|
|
rb->screens[SCREEN_MAIN]->clear_viewport();
|
|
for (i = 1 ; i < 3; i++)
|
|
{
|
|
rb->snprintf(buf,sizeof(buf),"Right text, scrolling line %d",i);
|
|
rb->screens[SCREEN_MAIN]->puts_scroll(1,i,buf);
|
|
}
|
|
|
|
y = -10;
|
|
for (i = -10; i < vp2.width + 10; i += 5)
|
|
{
|
|
rb->screens[SCREEN_MAIN]->drawline(i, y, i, vp2.height - y);
|
|
}
|
|
|
|
rb->screens[SCREEN_MAIN]->set_viewport(&vp3);
|
|
rb->screens[SCREEN_MAIN]->clear_viewport();
|
|
for (i = 1 ; i < 2; i++)
|
|
{
|
|
rb->snprintf(buf,sizeof(buf),"Bottom text, a scrolling line %d",i);
|
|
rb->screens[SCREEN_MAIN]->puts_scroll(2,i,buf);
|
|
}
|
|
rb->screens[SCREEN_MAIN]->puts_scroll(4,i,"Short line");
|
|
rb->screens[SCREEN_MAIN]->update();
|
|
|
|
|
|
#ifdef HAVE_REMOTE_LCD
|
|
rb->screens[SCREEN_REMOTE]->set_viewport(&rvp0);
|
|
rb->screens[SCREEN_REMOTE]->clear_viewport();
|
|
|
|
for (i = 0 ; i < 5; i++)
|
|
{
|
|
rb->snprintf(buf,sizeof(buf),"Left text, scrolling_line %d",i);
|
|
rb->screens[SCREEN_REMOTE]->puts_scroll(0,i,buf);
|
|
}
|
|
rb->screens[SCREEN_REMOTE]->puts(1,i,"Static");
|
|
|
|
rb->screens[SCREEN_REMOTE]->set_viewport(&rvp1);
|
|
rb->screens[SCREEN_REMOTE]->clear_viewport();
|
|
for (i = 1 ; i < 3; i++)
|
|
{
|
|
rb->snprintf(buf,sizeof(buf),"Right text, scrolling line %d",i);
|
|
rb->screens[SCREEN_REMOTE]->puts_scroll(1,i,buf);
|
|
}
|
|
|
|
y = -10;
|
|
for (i = -10; i < rvp1.width + 10; i += 5)
|
|
{
|
|
rb->screens[SCREEN_REMOTE]->drawline(i, y, i, rvp1.height - y);
|
|
}
|
|
|
|
rb->screens[SCREEN_REMOTE]->update();
|
|
#endif
|
|
rb->button_clear_queue();
|
|
while(rb->button_get(true) <= BUTTON_NONE)
|
|
;;
|
|
|
|
rb->button_get(true);
|
|
|
|
/* Restore the default viewport */
|
|
rb->screens[SCREEN_MAIN]->set_viewport(NULL);
|
|
#ifdef HAVE_REMOTE_LCD
|
|
rb->screens[SCREEN_REMOTE]->set_viewport(NULL);
|
|
#endif
|
|
|
|
return PLUGIN_OK;
|
|
}
|