diff options
author | William Wilgus <wilgus.william@gmail.com> | 2022-03-21 10:00:04 -0400 |
---|---|---|
committer | William Wilgus <wilgus.william@gmail.com> | 2022-03-21 10:00:04 -0400 |
commit | 60e5786b481a26ca7c0c810d812bf5664a58cb44 (patch) | |
tree | 011f2070f0474c90dd20fe515ba741e7895dd620 | |
parent | 64c577a0c55fe23d266d06517a85da9c6feb01c6 (diff) | |
download | rockbox-60e5786b48.tar.gz rockbox-60e5786b48.zip |
lcd-bitmap-common optimize a few viewport functions
Change-Id: I71cd61f66e875280d07f17a9e828fbecc305bad2
-rw-r--r-- | firmware/drivers/lcd-bitmap-common.c | 18 |
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) { vp = &default_vp; vp->buffer = fb_default; + return vp; } /* use defaults if no buffer is provided */ @@ -132,8 +133,9 @@ struct viewport* LCDFN(set_viewport_ex)(struct viewport* vp, int flags) * expected. */ - if((unsigned) vp->x > (unsigned) LCDM(WIDTH) - || (unsigned) vp->y > (unsigned) LCDM(HEIGHT) + if( vp->x < 0 || vp->y < 0 + || vp->x > LCDM(WIDTH) + || vp->y > LCDM(HEIGHT) || vp->x + vp->width > LCDM(WIDTH) || vp->y + vp->height > LCDM(HEIGHT)) { @@ -177,12 +179,18 @@ struct viewport *LCDFN(get_viewport)(bool *is_default) void LCDFN(update_viewport)(void) { struct viewport* vp = LCDFN(current_viewport); + int x, y; if (vp->buffer->stride != LCDFN(framebuffer_default.stride)) { - LCDFN(update_viewport_rect)(0,0, vp->width, vp->height); - return; + x = 0; + y = 0; + } + else + { + x = vp->x; + y = vp->y; } - LCDFN(update_rect)(vp->x, vp->y, vp->width, vp->height); + LCDFN(update_rect)(x, y, vp->width, vp->height); } void LCDFN(update_viewport_rect)(int x, int y, int width, int height) |