summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Martitz <kugel@rockbox.org>2014-01-11 19:17:58 +0100
committerThomas Martitz <kugel@rockbox.org>2014-01-11 19:17:58 +0100
commit26b317e094a37c43d23e661cf99fe858c159f1b2 (patch)
tree7e0cfbb80fee1b15435a6a261d99186dac2e0455
parent2a471c9e84ddc4f6f407d4fe3ad2a21a1d0e3723 (diff)
downloadrockbox-26b317e.tar.gz
rockbox-26b317e.zip
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
-rw-r--r--firmware/drivers/lcd-bitmap-common.c3
-rw-r--r--firmware/drivers/lcd-scroll.c125
-rw-r--r--firmware/export/scroll_engine.h5
3 files changed, 80 insertions, 53 deletions
diff --git a/firmware/drivers/lcd-bitmap-common.c b/firmware/drivers/lcd-bitmap-common.c
index a102eaea66..a71f5b2862 100644
--- a/firmware/drivers/lcd-bitmap-common.c
+++ b/firmware/drivers/lcd-bitmap-common.c
@@ -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));
}
}
diff --git a/firmware/drivers/lcd-scroll.c b/firmware/drivers/lcd-scroll.c
index d524ce81c8..a1bde9fe12 100644
--- a/firmware/drivers/lcd-scroll.c
+++ b/firmware/drivers/lcd-scroll.c
@@ -123,11 +123,78 @@ void LCDFN(jump_scroll_delay)(int ms)
}
#endif
+/* 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 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];
+
+ if (s->bidir)
+ { /* scroll bidirectional */
+ s->line = s->linebuffer;
+ if (s->offset <= 0) {
+ /* at beginning of line */
+ s->offset = 0;
+ s->backward = false;
+ ended = true;
+ }
+ else if (s->offset >= width - s->width) {
+ /* at end of line */
+ s->offset = width - s->width;
+ s->backward = true;
+ ended = true;
+ }
+ }
+ else
+ {
+ snprintf(line_buf, sizeof(line_buf)-1, "%s%s%s",
+ s->linebuffer, " ", s->linebuffer);
+ s->line = line_buf;
+ width += LCDFN(getstringsize)(" ", NULL, NULL);
+ /* scroll forward the whole time */
+ if (s->offset >= width) {
+ s->offset = 0;
+ ended = true;
+ }
+ }
+
+ /* Stash and restore these three, so that the scroll_func
+ * can do whatever it likes without destroying the state */
+#ifdef HAVE_LCD_BITMAP
+ unsigned drawmode;
+#if LCD_DEPTH > 1
+ unsigned fg_pattern, bg_pattern;
+ fg_pattern = s->vp->fg_pattern;
+ bg_pattern = s->vp->bg_pattern;
+#endif
+ drawmode = s->vp->drawmode;
+#endif
+ s->scroll_func(s);
+
+ LCDFN(update_viewport_rect)(s->x, s->y, s->width, s->height);
+
+#ifdef HAVE_LCD_BITMAP
+#if LCD_DEPTH > 1
+ s->vp->fg_pattern = fg_pattern;
+ s->vp->bg_pattern = bg_pattern;
+#endif
+ s->vp->drawmode = drawmode;
+#endif
+
+ return ended;
+}
+
static void LCDFN(scroll_worker)(void)
{
- int index, width;
+ int index;
bool makedelay;
- static char line_buf[SCROLL_LINE_SIZE];
bool is_default;
struct scroll_screen_info *si = &LCDFN(scroll_info);
struct scrollinfo *s;
@@ -152,7 +219,6 @@ static void LCDFN(scroll_worker)(void)
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;
@@ -160,62 +226,15 @@ static void LCDFN(scroll_worker)(void)
step = 1;
#endif
+
if (s->backward)
s->offset -= step;
else
s->offset += step;
- if (s->bidir)
- { /* scroll bidirectional */
- s->line = s->linebuffer;
- if (s->offset <= 0) {
- /* at beginning of line */
- s->offset = 0;
- s->backward = false;
- makedelay = true;
- }
- else if (s->offset >= width - s->width) {
- /* at end of line */
- s->offset = width - s->width;
- s->backward = true;
- makedelay = true;
- }
- }
- else
- {
- snprintf(line_buf, sizeof(line_buf)-1, "%s%s%s",
- s->linebuffer, " ", s->linebuffer);
- s->line = line_buf;
- width += LCDFN(getstringsize)(" ", NULL, NULL);
- /* scroll forward the whole time */
- if (s->offset >= width) {
- s->offset = 0;
- makedelay = true;
- }
- }
+ /* put the line onto the display now */
+ makedelay = LCDFN(scroll_now(s));
- /* Stash and restore these three, so that the scroll_func
- * can do whatever it likes without destroying the state */
-#ifdef HAVE_LCD_BITMAP
- unsigned drawmode;
-#if LCD_DEPTH > 1
- unsigned fg_pattern, bg_pattern;
- fg_pattern = s->vp->fg_pattern;
- bg_pattern = s->vp->bg_pattern;
-#endif
- drawmode = s->vp->drawmode;
-#endif
- s->scroll_func(s);
-
- LCDFN(update_viewport_rect)(s->x, s->y, s->width, s->height);
-
-#ifdef HAVE_LCD_BITMAP
-#if LCD_DEPTH > 1
- s->vp->fg_pattern = fg_pattern;
- s->vp->bg_pattern = bg_pattern;
-#endif
- s->vp->drawmode = drawmode;
-#endif
LCDFN(set_viewport)(vp);
if (makedelay)
diff --git a/firmware/export/scroll_engine.h b/firmware/export/scroll_engine.h
index 19a2bc4cca..64e1d6d6ae 100644
--- a/firmware/export/scroll_engine.h
+++ b/firmware/export/scroll_engine.h
@@ -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 */