summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWilliam Wilgus <wilgus.william@gmail.com>2022-03-21 10:00:04 -0400
committerWilliam Wilgus <wilgus.william@gmail.com>2022-03-21 10:00:04 -0400
commit60e5786b481a26ca7c0c810d812bf5664a58cb44 (patch)
tree011f2070f0474c90dd20fe515ba741e7895dd620
parent64c577a0c55fe23d266d06517a85da9c6feb01c6 (diff)
downloadrockbox-60e5786b481a26ca7c0c810d812bf5664a58cb44.tar.gz
rockbox-60e5786b481a26ca7c0c810d812bf5664a58cb44.zip
lcd-bitmap-common optimize a few viewport functions
Change-Id: I71cd61f66e875280d07f17a9e828fbecc305bad2
-rw-r--r--firmware/drivers/lcd-bitmap-common.c18
1 files changed, 13 insertions, 5 deletions
diff --git a/firmware/drivers/lcd-bitmap-common.c b/firmware/drivers/lcd-bitmap-common.c
index 9a5f865f2a..48710df49b 100644
--- a/firmware/drivers/lcd-bitmap-common.c
+++ b/firmware/drivers/lcd-bitmap-common.c
@@ -84,6 +84,7 @@ struct viewport* LCDFN(init_viewport)(struct viewport* vp)
84 { 84 {
85 vp = &default_vp; 85 vp = &default_vp;
86 vp->buffer = fb_default; 86 vp->buffer = fb_default;
87 return vp;
87 } 88 }
88 89
89 /* use defaults if no buffer is provided */ 90 /* use defaults if no buffer is provided */
@@ -132,8 +133,9 @@ struct viewport* LCDFN(set_viewport_ex)(struct viewport* vp, int flags)
132 * expected. 133 * expected.
133 */ 134 */
134 135
135 if((unsigned) vp->x > (unsigned) LCDM(WIDTH) 136 if( vp->x < 0 || vp->y < 0
136 || (unsigned) vp->y > (unsigned) LCDM(HEIGHT) 137 || vp->x > LCDM(WIDTH)
138 || vp->y > LCDM(HEIGHT)
137 || vp->x + vp->width > LCDM(WIDTH) 139 || vp->x + vp->width > LCDM(WIDTH)
138 || vp->y + vp->height > LCDM(HEIGHT)) 140 || vp->y + vp->height > LCDM(HEIGHT))
139 { 141 {
@@ -177,12 +179,18 @@ struct viewport *LCDFN(get_viewport)(bool *is_default)
177void LCDFN(update_viewport)(void) 179void LCDFN(update_viewport)(void)
178{ 180{
179 struct viewport* vp = LCDFN(current_viewport); 181 struct viewport* vp = LCDFN(current_viewport);
182 int x, y;
180 if (vp->buffer->stride != LCDFN(framebuffer_default.stride)) 183 if (vp->buffer->stride != LCDFN(framebuffer_default.stride))
181 { 184 {
182 LCDFN(update_viewport_rect)(0,0, vp->width, vp->height); 185 x = 0;
183 return; 186 y = 0;
187 }
188 else
189 {
190 x = vp->x;
191 y = vp->y;
184 } 192 }
185 LCDFN(update_rect)(vp->x, vp->y, vp->width, vp->height); 193 LCDFN(update_rect)(x, y, vp->width, vp->height);
186} 194}
187 195
188void LCDFN(update_viewport_rect)(int x, int y, int width, int height) 196void LCDFN(update_viewport_rect)(int x, int y, int width, int height)