diff options
author | Thomas Martitz <kugel@rockbox.org> | 2014-01-12 01:30:26 +0100 |
---|---|---|
committer | Thomas Martitz <kugel@rockbox.org> | 2014-01-12 01:34:06 +0100 |
commit | 488a1b983e1c2fac14de25aa781caf12628e53c8 (patch) | |
tree | 8d5b5b33e0c7eb9e5222b843f84c6b2d65d1a352 /firmware/drivers/lcd-scroll.c | |
parent | 656261bde1122612d1bf8ffc3c992c75a7fbc52e (diff) | |
download | rockbox-488a1b983e1c2fac14de25aa781caf12628e53c8.tar.gz rockbox-488a1b983e1c2fac14de25aa781caf12628e53c8.zip |
put_line/scrolling: Make the scroll engine inform custom scrollers about start/stop of scrolling.
With the new lcd_putsxy_scroll_func() code can register custom scroll functions
(put_line() makes use of that). In order for the custom scroller to be able
to properly manage its userdata pointer (set via struct scrollinfo::userdata)
the scroll engine must inform the scroller about start and stop of scrolling.
To inform about start the lcd_scroll_* functions now return true when
the line will scroll. To inform about stop the scroll engine calls into the
scroller one last time, with the text set to NULL.
put_line() can use this to release the userdata registered per scrolling line
so that it can be recycled.
This fixes that some scrolling lines became glitchy after some time because
the userdata was recycled too early.
Change-Id: Iff0a6ce2a4f9ae2bada1b8e62f4f5950224942a9
Diffstat (limited to 'firmware/drivers/lcd-scroll.c')
-rw-r--r-- | firmware/drivers/lcd-scroll.c | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/firmware/drivers/lcd-scroll.c b/firmware/drivers/lcd-scroll.c index a1bde9fe12..5162f9a100 100644 --- a/firmware/drivers/lcd-scroll.c +++ b/firmware/drivers/lcd-scroll.c | |||
@@ -30,7 +30,7 @@ | |||
30 | #define MAIN_LCD | 30 | #define MAIN_LCD |
31 | #endif | 31 | #endif |
32 | 32 | ||
33 | static struct scrollinfo LCDFN(scroll)[LCD_SCROLLABLE_LINES]; | 33 | static struct scrollinfo LCDFN(scroll)[LCDM(SCROLLABLE_LINES)]; |
34 | 34 | ||
35 | struct scroll_screen_info LCDFN(scroll_info) = | 35 | struct scroll_screen_info LCDFN(scroll_info) = |
36 | { | 36 | { |
@@ -51,6 +51,13 @@ struct scroll_screen_info LCDFN(scroll_info) = | |||
51 | 51 | ||
52 | void LCDFN(scroll_stop)(void) | 52 | void LCDFN(scroll_stop)(void) |
53 | { | 53 | { |
54 | for (int i = 0; i < LCDFN(scroll_info).lines; i++) | ||
55 | { | ||
56 | /* inform scroller about end of scrolling */ | ||
57 | struct scrollinfo *s = &LCDFN(scroll_info).scroll[i]; | ||
58 | s->line = NULL; | ||
59 | s->scroll_func(s); | ||
60 | } | ||
54 | LCDFN(scroll_info).lines = 0; | 61 | LCDFN(scroll_info).lines = 0; |
55 | } | 62 | } |
56 | 63 | ||
@@ -66,6 +73,9 @@ void LCDFN(scroll_stop_viewport_rect)(const struct viewport *vp, int x, int y, i | |||
66 | && (x < (s->x+s->width) && (x+width) >= s->x) | 73 | && (x < (s->x+s->width) && (x+width) >= s->x) |
67 | && (y < (s->y+s->height) && (y+height) >= s->y)) | 74 | && (y < (s->y+s->height) && (y+height) >= s->y)) |
68 | { | 75 | { |
76 | /* inform scroller about end of scrolling */ | ||
77 | s->line = NULL; | ||
78 | s->scroll_func(s); | ||
69 | /* If i is not the last active line in the array, then move | 79 | /* If i is not the last active line in the array, then move |
70 | the last item to position i. This compacts | 80 | the last item to position i. This compacts |
71 | the scroll array at the same time of removing the line */ | 81 | the scroll array at the same time of removing the line */ |