forked from len0rd/rockbox
scroll engine: Factor out renderer function so it can be called by lcd code.
This is used by lcd_puts_scroll_worker() to render the line immediately instead of waiting for the next scroll tick when only the text was updated. Previously lcd_puts_scroll_worker() did not render anything in this case which could lead to visible blinking. This fixes blinking scrolling lines with dynamic text in the skin engine. Change-Id: I475bde8c8eb7c92f505e3c5ecf4d32bb90690536
This commit is contained in:
parent
2a471c9e84
commit
26b317e094
3 changed files with 80 additions and 53 deletions
|
@ -398,6 +398,9 @@ static void LCDFN(puts_scroll_worker)(int x, int y, const unsigned char *string,
|
|||
s->height = height;
|
||||
s->vp = current_vp;
|
||||
LCDFN(scroll_info).lines++;
|
||||
} else {
|
||||
/* if only the text was updated render immediately */
|
||||
LCDFN(scroll_now(s));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -123,47 +123,18 @@ void LCDFN(jump_scroll_delay)(int ms)
|
|||
}
|
||||
#endif
|
||||
|
||||
static void LCDFN(scroll_worker)(void)
|
||||
/* This renders the scrolling line described by s immediatly.
|
||||
* This can be called to update a scrolling line if the text has changed
|
||||
* without waiting for the next scroll tick
|
||||
*
|
||||
* Returns true if the text scrolled to the end */
|
||||
bool LCDFN(scroll_now)(struct scrollinfo *s)
|
||||
{
|
||||
int index, width;
|
||||
bool makedelay;
|
||||
int width = LCDFN(getstringsize)(s->linebuffer, NULL, NULL);
|
||||
bool ended = false;
|
||||
/* assume s->scroll_func() don't yield; otherwise this buffer might need
|
||||
* to be mutex'd (the worst case would be minor glitches though) */
|
||||
static char line_buf[SCROLL_LINE_SIZE];
|
||||
bool is_default;
|
||||
struct scroll_screen_info *si = &LCDFN(scroll_info);
|
||||
struct scrollinfo *s;
|
||||
struct viewport *vp;
|
||||
int step;
|
||||
|
||||
for ( index = 0; index < si->lines; index++ )
|
||||
{
|
||||
s = &si->scroll[index];
|
||||
|
||||
/* check pause */
|
||||
if (TIME_BEFORE(current_tick, s->start_tick))
|
||||
continue;
|
||||
|
||||
s->start_tick = current_tick;
|
||||
|
||||
/* this runs out of the ui thread, thus we need to
|
||||
* save and restore the current viewport since the ui thread
|
||||
* is unaware of the swapped viewports. the vp must
|
||||
* be switched early so that lcd_getstringsize() picks the
|
||||
* correct font */
|
||||
vp = LCDFN(get_viewport)(&is_default);
|
||||
LCDFN(set_viewport)(s->vp);
|
||||
|
||||
width = LCDFN(getstringsize)(s->linebuffer, NULL, NULL);
|
||||
makedelay = false;
|
||||
#ifdef HAVE_LCD_BITMAP
|
||||
step = si->step;
|
||||
#else
|
||||
step = 1;
|
||||
#endif
|
||||
|
||||
if (s->backward)
|
||||
s->offset -= step;
|
||||
else
|
||||
s->offset += step;
|
||||
|
||||
if (s->bidir)
|
||||
{ /* scroll bidirectional */
|
||||
|
@ -172,13 +143,13 @@ static void LCDFN(scroll_worker)(void)
|
|||
/* at beginning of line */
|
||||
s->offset = 0;
|
||||
s->backward = false;
|
||||
makedelay = true;
|
||||
ended = true;
|
||||
}
|
||||
else if (s->offset >= width - s->width) {
|
||||
/* at end of line */
|
||||
s->offset = width - s->width;
|
||||
s->backward = true;
|
||||
makedelay = true;
|
||||
ended = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -190,7 +161,7 @@ static void LCDFN(scroll_worker)(void)
|
|||
/* scroll forward the whole time */
|
||||
if (s->offset >= width) {
|
||||
s->offset = 0;
|
||||
makedelay = true;
|
||||
ended = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -216,6 +187,54 @@ static void LCDFN(scroll_worker)(void)
|
|||
#endif
|
||||
s->vp->drawmode = drawmode;
|
||||
#endif
|
||||
|
||||
return ended;
|
||||
}
|
||||
|
||||
static void LCDFN(scroll_worker)(void)
|
||||
{
|
||||
int index;
|
||||
bool makedelay;
|
||||
bool is_default;
|
||||
struct scroll_screen_info *si = &LCDFN(scroll_info);
|
||||
struct scrollinfo *s;
|
||||
struct viewport *vp;
|
||||
int step;
|
||||
|
||||
for ( index = 0; index < si->lines; index++ )
|
||||
{
|
||||
s = &si->scroll[index];
|
||||
|
||||
/* check pause */
|
||||
if (TIME_BEFORE(current_tick, s->start_tick))
|
||||
continue;
|
||||
|
||||
s->start_tick = current_tick;
|
||||
|
||||
/* this runs out of the ui thread, thus we need to
|
||||
* save and restore the current viewport since the ui thread
|
||||
* is unaware of the swapped viewports. the vp must
|
||||
* be switched early so that lcd_getstringsize() picks the
|
||||
* correct font */
|
||||
vp = LCDFN(get_viewport)(&is_default);
|
||||
LCDFN(set_viewport)(s->vp);
|
||||
|
||||
makedelay = false;
|
||||
#ifdef HAVE_LCD_BITMAP
|
||||
step = si->step;
|
||||
#else
|
||||
step = 1;
|
||||
#endif
|
||||
|
||||
|
||||
if (s->backward)
|
||||
s->offset -= step;
|
||||
else
|
||||
s->offset += step;
|
||||
|
||||
/* put the line onto the display now */
|
||||
makedelay = LCDFN(scroll_now(s));
|
||||
|
||||
LCDFN(set_viewport)(vp);
|
||||
|
||||
if (makedelay)
|
||||
|
|
|
@ -30,6 +30,7 @@
|
|||
#include "file.h"
|
||||
|
||||
struct viewport;
|
||||
struct scrollinfo;
|
||||
|
||||
extern void scroll_init(void) INIT_ATTR;
|
||||
|
||||
|
@ -40,6 +41,7 @@ extern void lcd_scroll_delay(int ms);
|
|||
extern void lcd_scroll_stop(void);
|
||||
extern void lcd_scroll_stop_viewport(const struct viewport *vp);
|
||||
extern void lcd_scroll_stop_viewport_rect(const struct viewport *vp, int x, int y, int width, int height);
|
||||
extern bool lcd_scroll_now(struct scrollinfo *scroll);
|
||||
#ifdef HAVE_REMOTE_LCD
|
||||
extern void lcd_remote_scroll_speed(int speed);
|
||||
extern void lcd_remote_scroll_delay(int ms);
|
||||
|
@ -47,8 +49,11 @@ extern void lcd_remote_scroll_delay(int ms);
|
|||
extern void lcd_remote_scroll_stop(void);
|
||||
extern void lcd_remote_scroll_stop_viewport(const struct viewport *vp);
|
||||
extern void lcd_remote_scroll_stop_viewport_rect(const struct viewport *vp, int x, int y, int width, int height);
|
||||
extern bool lcd_remote_scroll_now(struct scrollinfo *scroll);
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
/* internal usage, but in multiple drivers
|
||||
* larger than the normal linebuffer since it holds the line a second
|
||||
* time (+3 spaces) for non-bidir scrolling */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue