summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAidan MacDonald <amachronic@protonmail.com>2022-10-02 00:54:11 +0100
committerAidan MacDonald <amachronic@protonmail.com>2022-10-12 07:34:15 -0400
commit6acc8a81a73114b614102beaaaf732b92f4e6ddd (patch)
treea04c7065ea1893fec08ae60910532ab578348391
parent726673c638f5ecc8928ee66bb2e10b651e60e325 (diff)
downloadrockbox-6acc8a81a7.tar.gz
rockbox-6acc8a81a7.zip
lcd: Cosmetic variable renaming
Assign lcd_current_viewport to a local variable for easier typing. Change-Id: Ib5d4283fd1c5a21c94d3bd3c2c28ce206383fb96
-rw-r--r--firmware/drivers/lcd-16bit-common.c64
-rw-r--r--firmware/drivers/lcd-16bit-vert.c26
-rw-r--r--firmware/drivers/lcd-16bit.c26
-rw-r--r--firmware/drivers/lcd-1bit-vert.c26
-rw-r--r--firmware/drivers/lcd-24bit.c71
-rw-r--r--firmware/drivers/lcd-2bit-horz.c21
-rw-r--r--firmware/drivers/lcd-2bit-vert.c27
-rw-r--r--firmware/drivers/lcd-2bit-vi.c27
8 files changed, 163 insertions, 125 deletions
diff --git a/firmware/drivers/lcd-16bit-common.c b/firmware/drivers/lcd-16bit-common.c
index ad41485dfe..a3a6dc6663 100644
--- a/firmware/drivers/lcd-16bit-common.c
+++ b/firmware/drivers/lcd-16bit-common.c
@@ -31,14 +31,15 @@
/* Clear the current viewport */
void lcd_clear_viewport(void)
{
+ struct viewport *vp = lcd_current_viewport;
fb_data *dst, *dst_end;
int x, y, width, height;
int len, step;
- x = lcd_current_viewport->x;
- y = lcd_current_viewport->y;
- width = lcd_current_viewport->width;
- height = lcd_current_viewport->height;
+ x = vp->x;
+ y = vp->y;
+ width = vp->width;
+ height = vp->height;
len = STRIDE_MAIN(width, height);
step = STRIDE_MAIN(ROW_INC, COL_INC);
@@ -46,18 +47,18 @@ void lcd_clear_viewport(void)
dst = FBADDR(x, y);
dst_end = FBADDR(x + width - 1 , y + height - 1);
- if (lcd_current_viewport->drawmode & DRMODE_INVERSEVID)
+ if (vp->drawmode & DRMODE_INVERSEVID)
{
do
{
- memset16(dst, lcd_current_viewport->fg_pattern, len);
+ memset16(dst, vp->fg_pattern, len);
dst += step;
}
while (dst <= dst_end);
}
else
{
- if (lcd_backdrop && lcd_current_viewport->buffer == &lcd_framebuffer_default)
+ if (lcd_backdrop && vp->buffer == &lcd_framebuffer_default)
{
do
{
@@ -71,19 +72,19 @@ void lcd_clear_viewport(void)
{
do
{
- memset16(dst, lcd_current_viewport->bg_pattern, len);
+ memset16(dst, vp->bg_pattern, len);
dst += step;
}
while (dst <= dst_end);
}
}
- if (lcd_current_viewport == &default_vp)
+ if (vp == &default_vp)
lcd_scroll_stop();
else
- lcd_scroll_stop_viewport(lcd_current_viewport);
+ lcd_scroll_stop_viewport(vp);
- lcd_current_viewport->flags &= ~(VP_FLAG_VP_SET_CLEAN);
+ vp->flags &= ~(VP_FLAG_VP_SET_CLEAN);
}
/*** low-level drawing functions ***/
@@ -128,6 +129,7 @@ lcd_fastpixelfunc_type* const * lcd_fastpixelfuncs = lcd_fastpixelfuncs_bgcolor;
/* Fill a rectangular area */
void lcd_fillrect(int x, int y, int width, int height)
{
+ struct viewport *vp = lcd_current_viewport;
unsigned bits = 0;
enum fill_opt fillopt = OPT_NONE;
fb_data *dst, *dst_end;
@@ -137,14 +139,14 @@ void lcd_fillrect(int x, int y, int width, int height)
return;
/* drawmode and optimisation */
- if (lcd_current_viewport->drawmode & DRMODE_INVERSEVID)
+ if (vp->drawmode & DRMODE_INVERSEVID)
{
- if (lcd_current_viewport->drawmode & DRMODE_BG)
+ if (vp->drawmode & DRMODE_BG)
{
if (!lcd_backdrop)
{
fillopt = OPT_SET;
- bits = lcd_current_viewport->bg_pattern;
+ bits = vp->bg_pattern;
}
else
fillopt = OPT_COPY;
@@ -152,13 +154,13 @@ void lcd_fillrect(int x, int y, int width, int height)
}
else
{
- if (lcd_current_viewport->drawmode & DRMODE_FG)
+ if (vp->drawmode & DRMODE_FG)
{
fillopt = OPT_SET;
- bits = lcd_current_viewport->fg_pattern;
+ bits = vp->fg_pattern;
}
}
- if (fillopt == OPT_NONE && lcd_current_viewport->drawmode != DRMODE_COMPLEMENT)
+ if (fillopt == OPT_NONE && vp->drawmode != DRMODE_COMPLEMENT)
return;
dst = FBADDR(x, y);
@@ -213,6 +215,7 @@ void ICODE_ATTR lcd_mono_bitmap_part(const unsigned char *src, int src_x,
int src_y, int stride, int x, int y,
int width, int height)
{
+ struct viewport *vp = lcd_current_viewport;
if (!lcd_clip_viewport_rect(&x, &y, &width, &height, &src_x, &src_y))
return;
@@ -221,7 +224,7 @@ void ICODE_ATTR lcd_mono_bitmap_part(const unsigned char *src, int src_x,
src_y &= 7;
unsigned dmask = 0;
- int drmode = lcd_current_viewport->drawmode;
+ int drmode = vp->drawmode;
if (drmode & DRMODE_INVERSEVID)
{
@@ -267,7 +270,7 @@ void ICODE_ATTR lcd_mono_bitmap_part(const unsigned char *src, int src_x,
break;
case DRMODE_BG:
- bg = lcd_current_viewport->bg_pattern;
+ bg = vp->bg_pattern;
do {
data = (*src_col++ ^ dmask) >> src_y;
if(!(data & 0x01))
@@ -278,7 +281,7 @@ void ICODE_ATTR lcd_mono_bitmap_part(const unsigned char *src, int src_x,
break;
case DRMODE_FG:
- fg = lcd_current_viewport->fg_pattern;
+ fg = vp->fg_pattern;
do {
data = (*src_col++ ^ dmask) >> src_y;
if(data & 0x01)
@@ -289,7 +292,7 @@ void ICODE_ATTR lcd_mono_bitmap_part(const unsigned char *src, int src_x,
break;
case DRMODE_SOLID|DRMODE_INT_BD:
- fg = lcd_current_viewport->fg_pattern;
+ fg = vp->fg_pattern;
bo = lcd_backdrop_offset;
do {
data = (*src_col++ ^ dmask) >> src_y;
@@ -303,8 +306,8 @@ void ICODE_ATTR lcd_mono_bitmap_part(const unsigned char *src, int src_x,
break;
case DRMODE_SOLID:
- fg = lcd_current_viewport->fg_pattern;
- bg = lcd_current_viewport->bg_pattern;
+ fg = vp->fg_pattern;
+ bg = vp->bg_pattern;
do {
data = (*src_col++ ^ dmask) >> src_y;
if(data & 0x01)
@@ -416,9 +419,10 @@ static void ICODE_ATTR lcd_alpha_bitmap_part_mix(const fb_data* image,
int width, int height,
int stride_image, int stride_src)
{
+ struct viewport *vp = lcd_current_viewport;
fb_data *dst, *dst_row;
unsigned dmask = 0x00000000;
- int drmode = lcd_current_viewport->drawmode;
+ int drmode = vp->drawmode;
if (!lcd_clip_viewport_rect(&x, &y, &width, &height, &src_x, &src_y))
return;
@@ -545,7 +549,7 @@ static void ICODE_ATTR lcd_alpha_bitmap_part_mix(const fb_data* image,
while (--col);
break;
case DRMODE_BG:
- bg = lcd_current_viewport->bg_pattern;
+ bg = vp->bg_pattern;
do
{
*dst = blend_two_colors(bg, *dst, data & ALPHA_COLOR_LOOKUP_SIZE );
@@ -565,7 +569,7 @@ static void ICODE_ATTR lcd_alpha_bitmap_part_mix(const fb_data* image,
while (--col);
break;
case DRMODE_FG:
- fg = lcd_current_viewport->fg_pattern;
+ fg = vp->fg_pattern;
do
{
*dst = blend_two_colors(*dst, fg, data & ALPHA_COLOR_LOOKUP_SIZE );
@@ -576,7 +580,7 @@ static void ICODE_ATTR lcd_alpha_bitmap_part_mix(const fb_data* image,
break;
case DRMODE_SOLID|DRMODE_INT_BD:
bo = lcd_backdrop_offset;
- fg = lcd_current_viewport->fg_pattern;
+ fg = vp->fg_pattern;
do
{
fb_data *c = (fb_data *)((uintptr_t)dst + bo);
@@ -587,7 +591,7 @@ static void ICODE_ATTR lcd_alpha_bitmap_part_mix(const fb_data* image,
while (--col);
break;
case DRMODE_SOLID|DRMODE_INT_IMG:
- bg = lcd_current_viewport->bg_pattern;
+ bg = vp->bg_pattern;
img_offset = image - dst;
do
{
@@ -610,8 +614,8 @@ static void ICODE_ATTR lcd_alpha_bitmap_part_mix(const fb_data* image,
while (--col);
break;
case DRMODE_SOLID:
- bg = lcd_current_viewport->bg_pattern;
- fg = lcd_current_viewport->fg_pattern;
+ bg = vp->bg_pattern;
+ fg = vp->fg_pattern;
do
{
*dst = blend_two_colors(bg, fg, data & ALPHA_COLOR_LOOKUP_SIZE );
diff --git a/firmware/drivers/lcd-16bit-vert.c b/firmware/drivers/lcd-16bit-vert.c
index c721ef6302..1c0d441af4 100644
--- a/firmware/drivers/lcd-16bit-vert.c
+++ b/firmware/drivers/lcd-16bit-vert.c
@@ -62,16 +62,17 @@ static void ICODE_ATTR lcd_alpha_bitmap_part_mix(const fb_data* image,
/* Draw a horizontal line (optimised) */
void lcd_hline(int x1, int x2, int y)
{
+ struct viewport *vp = lcd_current_viewport;
fb_data *dst, *dst_end;
int stride_dst;
- lcd_fastpixelfunc_type *pfunc = lcd_fastpixelfuncs[lcd_current_viewport->drawmode];
+ lcd_fastpixelfunc_type *pfunc = lcd_fastpixelfuncs[vp->drawmode];
if (!lcd_clip_viewport_hline(&x1, &x2, &y))
return;
dst = FBADDR(x1, y);
- stride_dst = lcd_current_viewport->buffer->stride;
+ stride_dst = vp->buffer->stride;
dst_end = dst + (x2 - x1) * stride_dst;
do
@@ -85,6 +86,7 @@ void lcd_hline(int x1, int x2, int y)
/* Draw a vertical line (optimised) */
void lcd_vline(int x, int y1, int y2)
{
+ struct viewport *vp = lcd_current_viewport;
int height;
unsigned bits = 0;
enum fill_opt fillopt = OPT_NONE;
@@ -96,14 +98,14 @@ void lcd_vline(int x, int y1, int y2)
height = y2 - y1 + 1;
/* drawmode and optimisation */
- if (lcd_current_viewport->drawmode & DRMODE_INVERSEVID)
+ if (vp->drawmode & DRMODE_INVERSEVID)
{
- if (lcd_current_viewport->drawmode & DRMODE_BG)
+ if (vp->drawmode & DRMODE_BG)
{
if (!lcd_backdrop)
{
fillopt = OPT_SET;
- bits = lcd_current_viewport->bg_pattern;
+ bits = vp->bg_pattern;
}
else
fillopt = OPT_COPY;
@@ -111,13 +113,13 @@ void lcd_vline(int x, int y1, int y2)
}
else
{
- if (lcd_current_viewport->drawmode & DRMODE_FG)
+ if (vp->drawmode & DRMODE_FG)
{
fillopt = OPT_SET;
- bits = lcd_current_viewport->fg_pattern;
+ bits = vp->fg_pattern;
}
}
- if (fillopt == OPT_NONE && lcd_current_viewport->drawmode != DRMODE_COMPLEMENT)
+ if (fillopt == OPT_NONE && vp->drawmode != DRMODE_COMPLEMENT)
return;
dst = FBADDR(x, y1);
@@ -147,6 +149,7 @@ void ICODE_ATTR lcd_bitmap_part(const fb_data *src, int src_x, int src_y,
int stride, int x, int y, int width,
int height)
{
+ struct viewport *vp = lcd_current_viewport;
fb_data *dst;
int stride_dst;
@@ -155,7 +158,7 @@ void ICODE_ATTR lcd_bitmap_part(const fb_data *src, int src_x, int src_y,
src += stride * src_x + src_y; /* move starting point */
dst = FBADDR(x, y);
- stride_dst = lcd_current_viewport->buffer->stride;
+ stride_dst = vp->buffer->stride;
fb_data *dst_end = dst + width * stride_dst;
do
@@ -172,6 +175,7 @@ void ICODE_ATTR lcd_bitmap_transparent_part(const fb_data *src, int src_x,
int src_y, int stride, int x,
int y, int width, int height)
{
+ struct viewport *vp = lcd_current_viewport;
fb_data *dst, *dst_end;
int stride_dst;
@@ -180,7 +184,7 @@ void ICODE_ATTR lcd_bitmap_transparent_part(const fb_data *src, int src_x,
src += stride * src_x + src_y; /* move starting point */
dst = FBADDR(x, y);
- stride_dst = lcd_current_viewport->buffer->stride;
+ stride_dst = vp->buffer->stride;
dst_end = dst + width * stride_dst;
do
@@ -189,7 +193,7 @@ void ICODE_ATTR lcd_bitmap_transparent_part(const fb_data *src, int src_x,
for(i = 0;i < height;i++)
{
if (src[i] == REPLACEWITHFG_COLOR)
- dst[i] = lcd_current_viewport->fg_pattern;
+ dst[i] = vp->fg_pattern;
else if(src[i] != TRANSPARENT_COLOR)
dst[i] = src[i];
}
diff --git a/firmware/drivers/lcd-16bit.c b/firmware/drivers/lcd-16bit.c
index fd032c0956..f802a1bfbb 100644
--- a/firmware/drivers/lcd-16bit.c
+++ b/firmware/drivers/lcd-16bit.c
@@ -62,6 +62,7 @@ static void ICODE_ATTR lcd_alpha_bitmap_part_mix(const fb_data* image,
/* Draw a horizontal line (optimised) */
void lcd_hline(int x1, int x2, int y)
{
+ struct viewport *vp = lcd_current_viewport;
int width;
unsigned bits = 0;
enum fill_opt fillopt = OPT_NONE;
@@ -73,14 +74,14 @@ void lcd_hline(int x1, int x2, int y)
width = x2 - x1 + 1;
/* drawmode and optimisation */
- if (lcd_current_viewport->drawmode & DRMODE_INVERSEVID)
+ if (vp->drawmode & DRMODE_INVERSEVID)
{
- if (lcd_current_viewport->drawmode & DRMODE_BG)
+ if (vp->drawmode & DRMODE_BG)
{
if (!lcd_backdrop)
{
fillopt = OPT_SET;
- bits = lcd_current_viewport->bg_pattern;
+ bits = vp->bg_pattern;
}
else
fillopt = OPT_COPY;
@@ -88,13 +89,13 @@ void lcd_hline(int x1, int x2, int y)
}
else
{
- if (lcd_current_viewport->drawmode & DRMODE_FG)
+ if (vp->drawmode & DRMODE_FG)
{
fillopt = OPT_SET;
- bits = lcd_current_viewport->fg_pattern;
+ bits = vp->fg_pattern;
}
}
- if (fillopt == OPT_NONE && lcd_current_viewport->drawmode != DRMODE_COMPLEMENT)
+ if (fillopt == OPT_NONE && vp->drawmode != DRMODE_COMPLEMENT)
return;
dst = FBADDR(x1, y);
@@ -122,15 +123,16 @@ void lcd_hline(int x1, int x2, int y)
/* Draw a vertical line (optimised) */
void lcd_vline(int x, int y1, int y2)
{
+ struct viewport *vp = lcd_current_viewport;
fb_data *dst, *dst_end;
int stride_dst;
- lcd_fastpixelfunc_type *pfunc = lcd_fastpixelfuncs[lcd_current_viewport->drawmode];
+ lcd_fastpixelfunc_type *pfunc = lcd_fastpixelfuncs[vp->drawmode];
if (!lcd_clip_viewport_vline(&x, &y1, &y2))
return;
dst = FBADDR(x, y1);
- stride_dst = lcd_current_viewport->buffer->stride;
+ stride_dst = vp->buffer->stride;
dst_end = dst + (y2 - y1) * stride_dst;
do
@@ -146,6 +148,7 @@ void ICODE_ATTR lcd_bitmap_part(const fb_data *src, int src_x, int src_y,
int stride, int x, int y, int width,
int height)
{
+ struct viewport *vp = lcd_current_viewport;
fb_data *dst;
int stride_dst;
@@ -154,7 +157,7 @@ void ICODE_ATTR lcd_bitmap_part(const fb_data *src, int src_x, int src_y,
src += stride * src_y + src_x; /* move starting point */
dst = FBADDR(x, y);
- stride_dst = lcd_current_viewport->buffer->stride;
+ stride_dst = vp->buffer->stride;
do
{
@@ -170,9 +173,10 @@ void ICODE_ATTR lcd_bitmap_transparent_part(const fb_data *src, int src_x,
int src_y, int stride, int x,
int y, int width, int height)
{
+ struct viewport *vp = lcd_current_viewport;
fb_data *dst;
- unsigned fg = lcd_current_viewport->fg_pattern;
- int stride_dst = lcd_current_viewport->buffer->stride;
+ unsigned fg = vp->fg_pattern;
+ int stride_dst = vp->buffer->stride;
if (!lcd_clip_viewport_rect(&x, &y, &width, &height, &src_x, &src_y))
return;
diff --git a/firmware/drivers/lcd-1bit-vert.c b/firmware/drivers/lcd-1bit-vert.c
index 9c69b82e51..548dd96994 100644
--- a/firmware/drivers/lcd-1bit-vert.c
+++ b/firmware/drivers/lcd-1bit-vert.c
@@ -237,6 +237,7 @@ void LCDFN(clear_viewport)(void)
/* Draw a horizontal line (optimised) */
void LCDFN(hline)(int x1, int x2, int y)
{
+ struct viewport *vp = CURRENT_VP;
int width;
unsigned char *dst, *dst_end;
unsigned mask;
@@ -247,7 +248,7 @@ void LCDFN(hline)(int x1, int x2, int y)
width = x2 - x1 + 1;
- bfunc = LCDFN(blockfuncs)[CURRENT_VP->drawmode];
+ bfunc = LCDFN(blockfuncs)[vp->drawmode];
dst = LCDFB(x1,y>>3);
mask = BIT_N(y & 7);
@@ -260,6 +261,7 @@ void LCDFN(hline)(int x1, int x2, int y)
/* Draw a vertical line (optimised) */
void LCDFN(vline)(int x, int y1, int y2)
{
+ struct viewport *vp = CURRENT_VP;
int ny;
FBFN(data) *dst;
int stride_dst;
@@ -269,12 +271,12 @@ void LCDFN(vline)(int x, int y1, int y2)
if (!LCDFN(clip_viewport_vline)(&x, &y1, &y2))
return;
- bfunc = LCDFN(blockfuncs)[CURRENT_VP->drawmode];
+ bfunc = LCDFN(blockfuncs)[vp->drawmode];
dst = LCDFB(x,y1>>3);
ny = y2 - (y1 & ~7);
mask = 0xFFu << (y1 & 7);
mask_bottom = 0xFFu >> (~ny & 7);
- stride_dst = CURRENT_VP->buffer->stride;
+ stride_dst = vp->buffer->stride;
for (; ny >= 8; ny -= 8)
{
@@ -289,6 +291,7 @@ void LCDFN(vline)(int x, int y1, int y2)
/* Fill a rectangular area */
void LCDFN(fillrect)(int x, int y, int width, int height)
{
+ struct viewport *vp = CURRENT_VP;
int ny;
FBFN(data) *dst, *dst_end;
int stride_dst;
@@ -300,27 +303,27 @@ void LCDFN(fillrect)(int x, int y, int width, int height)
if (!LCDFN(clip_viewport_rect)(&x, &y, &width, &height, NULL, NULL))
return;
- if (CURRENT_VP->drawmode & DRMODE_INVERSEVID)
+ if (vp->drawmode & DRMODE_INVERSEVID)
{
- if (CURRENT_VP->drawmode & DRMODE_BG)
+ if (vp->drawmode & DRMODE_BG)
{
fillopt = true;
}
}
else
{
- if (CURRENT_VP->drawmode & DRMODE_FG)
+ if (vp->drawmode & DRMODE_FG)
{
fillopt = true;
bits = 0xFFu;
}
}
- bfunc = LCDFN(blockfuncs)[CURRENT_VP->drawmode];
+ bfunc = LCDFN(blockfuncs)[vp->drawmode];
dst = LCDFB(x,y>>3);
ny = height - 1 + (y & 7);
mask = 0xFFu << (y & 7);
mask_bottom = 0xFFu >> (~ny & 7);
- stride_dst = CURRENT_VP->buffer->stride;
+ stride_dst = vp->buffer->stride;
for (; ny >= 8; ny -= 8)
{
@@ -368,6 +371,7 @@ void ICODE_ATTR LCDFN(bitmap_part)(const unsigned char *src, int src_x,
int src_y, int stride, int x, int y,
int width, int height)
{
+ struct viewport *vp = CURRENT_VP;
int shift, ny;
FBFN(data) *dst, *dst_end;
int stride_dst;
@@ -381,17 +385,17 @@ void ICODE_ATTR LCDFN(bitmap_part)(const unsigned char *src, int src_x,
src_y &= 7;
y -= src_y;
dst = LCDFB(x,y>>3);
- stride_dst = CURRENT_VP->buffer->stride;
+ stride_dst = vp->buffer->stride;
shift = y & 7;
ny = height - 1 + shift + src_y;
- bfunc = LCDFN(blockfuncs)[CURRENT_VP->drawmode];
+ bfunc = LCDFN(blockfuncs)[vp->drawmode];
mask = 0xFFu << (shift + src_y);
mask_bottom = 0xFFu >> (~ny & 7);
if (shift == 0)
{
- bool copyopt = (CURRENT_VP->drawmode == DRMODE_SOLID);
+ bool copyopt = (vp->drawmode == DRMODE_SOLID);
for (; ny >= 8; ny -= 8)
{
diff --git a/firmware/drivers/lcd-24bit.c b/firmware/drivers/lcd-24bit.c
index d95415e957..be0d3e239c 100644
--- a/firmware/drivers/lcd-24bit.c
+++ b/firmware/drivers/lcd-24bit.c
@@ -61,14 +61,15 @@ static void ICODE_ATTR lcd_alpha_bitmap_part_mix(const fb_data* image,
/* Clear the current viewport */
void lcd_clear_viewport(void)
{
+ struct viewport *vp = lcd_current_viewport;
fb_data *dst, *dst_end;
int x, y, width, height;
int len, step;
- x = lcd_current_viewport->x;
- y = lcd_current_viewport->y;
- width = lcd_current_viewport->width;
- height = lcd_current_viewport->height;
+ x = vp->x;
+ y = vp->y;
+ width = vp->width;
+ height = vp->height;
len = STRIDE_MAIN(width, height);
step = STRIDE_MAIN(ROW_INC, COL_INC);
@@ -76,9 +77,9 @@ void lcd_clear_viewport(void)
dst = FBADDR(x, y);
dst_end = FBADDR(x + width - 1 , y + height - 1);
- if (lcd_current_viewport->drawmode & DRMODE_INVERSEVID)
+ if (vp->drawmode & DRMODE_INVERSEVID)
{
- fb_data px = FB_SCALARPACK(lcd_current_viewport->fg_pattern);
+ fb_data px = FB_SCALARPACK(vp->fg_pattern);
do
{
fb_data *end = dst + len;
@@ -93,7 +94,7 @@ void lcd_clear_viewport(void)
{
if (!lcd_backdrop)
{
- fb_data px = FB_SCALARPACK(lcd_current_viewport->bg_pattern);
+ fb_data px = FB_SCALARPACK(vp->bg_pattern);
do
{
fb_data *end = dst + len;
@@ -116,12 +117,12 @@ void lcd_clear_viewport(void)
}
}
- if (lcd_current_viewport == &default_vp)
+ if (vp == &default_vp)
lcd_scroll_stop();
else
- lcd_scroll_stop_viewport(lcd_current_viewport);
+ lcd_scroll_stop_viewport(vp);
- lcd_current_viewport->flags &= ~(VP_FLAG_VP_SET_CLEAN);
+ vp->flags &= ~(VP_FLAG_VP_SET_CLEAN);
}
/*** low-level drawing functions ***/
@@ -167,6 +168,7 @@ lcd_fastpixelfunc_type* const * lcd_fastpixelfuncs = lcd_fastpixelfuncs_bgcolor;
/* Fill a rectangular area */
void lcd_fillrect(int x, int y, int width, int height)
{
+ struct viewport *vp = lcd_current_viewport;
enum fill_opt fillopt = OPT_NONE;
fb_data *dst, *dst_end;
int len, step;
@@ -177,14 +179,14 @@ void lcd_fillrect(int x, int y, int width, int height)
return;
/* drawmode and optimisation */
- if (lcd_current_viewport->drawmode & DRMODE_INVERSEVID)
+ if (vp->drawmode & DRMODE_INVERSEVID)
{
- if (lcd_current_viewport->drawmode & DRMODE_BG)
+ if (vp->drawmode & DRMODE_BG)
{
if (!lcd_backdrop)
{
fillopt = OPT_SET;
- bits = FB_SCALARPACK(lcd_current_viewport->bg_pattern);
+ bits = FB_SCALARPACK(vp->bg_pattern);
}
else
fillopt = OPT_COPY;
@@ -192,13 +194,13 @@ void lcd_fillrect(int x, int y, int width, int height)
}
else
{
- if (lcd_current_viewport->drawmode & DRMODE_FG)
+ if (vp->drawmode & DRMODE_FG)
{
fillopt = OPT_SET;
- bits = FB_SCALARPACK(lcd_current_viewport->fg_pattern);
+ bits = FB_SCALARPACK(vp->fg_pattern);
}
}
- if (fillopt == OPT_NONE && lcd_current_viewport->drawmode != DRMODE_COMPLEMENT)
+ if (fillopt == OPT_NONE && vp->drawmode != DRMODE_COMPLEMENT)
return;
dst = FBADDR(x, y);
@@ -259,10 +261,11 @@ void ICODE_ATTR lcd_mono_bitmap_part(const unsigned char *src, int src_x,
int src_y, int stride, int x, int y,
int width, int height)
{
+ struct viewport *vp = lcd_current_viewport;
const unsigned char *src_end;
fb_data *dst, *dst_col;
unsigned dmask = 0x100; /* bit 8 == sentinel */
- int drmode = lcd_current_viewport->drawmode;
+ int drmode = vp->drawmode;
int row;
if (!lcd_clip_viewport_rect(&x, &y, &width, &height, &src_x, &src_y))
@@ -332,7 +335,7 @@ void ICODE_ATTR lcd_mono_bitmap_part(const unsigned char *src, int src_x,
break;
case DRMODE_BG:
- bg = FB_SCALARPACK(lcd_current_viewport->bg_pattern);
+ bg = FB_SCALARPACK(vp->bg_pattern);
do
{
if (!(data & 0x01))
@@ -345,7 +348,7 @@ void ICODE_ATTR lcd_mono_bitmap_part(const unsigned char *src, int src_x,
break;
case DRMODE_FG:
- fg = FB_SCALARPACK(lcd_current_viewport->fg_pattern);
+ fg = FB_SCALARPACK(vp->fg_pattern);
do
{
if (data & 0x01)
@@ -358,7 +361,7 @@ void ICODE_ATTR lcd_mono_bitmap_part(const unsigned char *src, int src_x,
break;
case DRMODE_SOLID|DRMODE_INT_BD:
- fg = FB_SCALARPACK(lcd_current_viewport->fg_pattern);
+ fg = FB_SCALARPACK(vp->fg_pattern);
bo = lcd_backdrop_offset;
do
{
@@ -371,8 +374,8 @@ void ICODE_ATTR lcd_mono_bitmap_part(const unsigned char *src, int src_x,
break;
case DRMODE_SOLID:
- fg = FB_SCALARPACK(lcd_current_viewport->fg_pattern);
- bg = FB_SCALARPACK(lcd_current_viewport->bg_pattern);
+ fg = FB_SCALARPACK(vp->fg_pattern);
+ bg = FB_SCALARPACK(vp->bg_pattern);
do
{
*dst = (data & 0x01) ? fg : bg;
@@ -442,9 +445,10 @@ static void ICODE_ATTR lcd_alpha_bitmap_part_mix(const fb_data* image,
int width, int height,
int stride_image, int stride_src)
{
+ struct viewport *vp = lcd_current_viewport;
fb_data *dst, *dst_row;
unsigned dmask = 0x00000000;
- int drmode = lcd_current_viewport->drawmode;
+ int drmode = vp->drawmode;
if (!lcd_clip_viewport_rect(&x, &y, &width, &height, &src_x, &src_y))
return;
@@ -570,7 +574,7 @@ static void ICODE_ATTR lcd_alpha_bitmap_part_mix(const fb_data* image,
while (--col);
break;
case DRMODE_BG:
- bg = lcd_current_viewport->bg_pattern;
+ bg = vp->bg_pattern;
do
{
unsigned px = FB_UNPACK_SCALAR_LCD(*dst);
@@ -593,7 +597,7 @@ static void ICODE_ATTR lcd_alpha_bitmap_part_mix(const fb_data* image,
while (--col);
break;
case DRMODE_FG:
- fg = lcd_current_viewport->fg_pattern;
+ fg = vp->fg_pattern;
do
{
unsigned px = FB_UNPACK_SCALAR_LCD(*dst);
@@ -605,7 +609,7 @@ static void ICODE_ATTR lcd_alpha_bitmap_part_mix(const fb_data* image,
break;
case DRMODE_SOLID|DRMODE_INT_BD:
bo = lcd_backdrop_offset;
- fg = lcd_current_viewport->fg_pattern;
+ fg = vp->fg_pattern;
do
{
unsigned c = FB_UNPACK_SCALAR_LCD(*(fb_data *)((uintptr_t)dst + bo));
@@ -616,7 +620,7 @@ static void ICODE_ATTR lcd_alpha_bitmap_part_mix(const fb_data* image,
while (--col);
break;
case DRMODE_SOLID|DRMODE_INT_IMG:
- bg = lcd_current_viewport->bg_pattern;
+ bg = vp->bg_pattern;
img_offset = image - dst;
do
{
@@ -641,8 +645,8 @@ static void ICODE_ATTR lcd_alpha_bitmap_part_mix(const fb_data* image,
while (--col);
break;
case DRMODE_SOLID:
- bg = lcd_current_viewport->bg_pattern;
- fg = lcd_current_viewport->fg_pattern;
+ bg = vp->bg_pattern;
+ fg = vp->fg_pattern;
do
{
*dst = blend_two_colors(bg, fg, data & ALPHA_COLOR_LOOKUP_SIZE );
@@ -689,9 +693,10 @@ static void ICODE_ATTR lcd_alpha_bitmap_part_mix(const fb_data* image,
/* Draw a horizontal line (optimised) */
void lcd_hline(int x1, int x2, int y)
{
+ struct viewport *vp = lcd_current_viewport;
int width;
fb_data *dst, *dst_end;
- lcd_fastpixelfunc_type *pfunc = lcd_fastpixelfuncs[lcd_current_viewport->drawmode];
+ lcd_fastpixelfunc_type *pfunc = lcd_fastpixelfuncs[vp->drawmode];
if (!lcd_clip_viewport_hline(&x1, &x2, &y))
return;
@@ -710,8 +715,9 @@ void lcd_hline(int x1, int x2, int y)
/* Draw a vertical line (optimised) */
void lcd_vline(int x, int y1, int y2)
{
+ struct viewport *vp = lcd_current_viewport;
fb_data *dst, *dst_end;
- lcd_fastpixelfunc_type *pfunc = lcd_fastpixelfuncs[lcd_current_viewport->drawmode];
+ lcd_fastpixelfunc_type *pfunc = lcd_fastpixelfuncs[vp->drawmode];
if (!lcd_clip_viewport_vline(&x, &y1, &y2))
return;
@@ -754,6 +760,7 @@ void ICODE_ATTR lcd_bitmap_transparent_part(const fb_data *src, int src_x,
int src_y, int stride, int x,
int y, int width, int height)
{
+ struct viewport *vp = lcd_current_viewport;
fb_data *dst;
fb_data fg, transparent, replacewithfg;
@@ -765,7 +772,7 @@ void ICODE_ATTR lcd_bitmap_transparent_part(const fb_data *src, int src_x,
transparent = FB_SCALARPACK(TRANSPARENT_COLOR);
replacewithfg = FB_SCALARPACK(REPLACEWITHFG_COLOR);
- fg = FB_SCALARPACK(lcd_current_viewport->fg_pattern);
+ fg = FB_SCALARPACK(vp->fg_pattern);
#define CMP(c1, c2) (c1.r == c2.r && c1.g == c2.g && c1.b == c2.b)
do
diff --git a/firmware/drivers/lcd-2bit-horz.c b/firmware/drivers/lcd-2bit-horz.c
index cf7e20d4a8..e5d683be9e 100644
--- a/firmware/drivers/lcd-2bit-horz.c
+++ b/firmware/drivers/lcd-2bit-horz.c
@@ -378,6 +378,7 @@ void lcd_clear_viewport(void)
/* Draw a horizontal line (optimised) */
void lcd_hline(int x1, int x2, int y)
{
+ struct viewport *vp = lcd_current_viewport;
int nx;
unsigned char *dst;
unsigned mask, mask_right;
@@ -386,7 +387,7 @@ void lcd_hline(int x1, int x2, int y)
if (!lcd_clip_viewport_hline(&x1, &x2, &y))
return;
- bfunc = lcd_blockfuncs[lcd_current_viewport->drawmode];
+ bfunc = lcd_blockfuncs[vp->drawmode];
dst = FBADDR(x1>>2,y);
nx = x2 - (x1 & ~3);
mask = 0xFFu >> (2 * (x1 & 3));
@@ -404,6 +405,7 @@ void lcd_hline(int x1, int x2, int y)
/* Draw a vertical line (optimised) */
void lcd_vline(int x, int y1, int y2)
{
+ struct viewport *vp = lcd_current_viewport;
unsigned char *dst, *dst_end;
int stride_dst;
unsigned mask;
@@ -412,9 +414,9 @@ void lcd_vline(int x, int y1, int y2)
if (!lcd_clip_viewport_vline(&x, &y1, &y2))
return;
- bfunc = lcd_blockfuncs[lcd_current_viewport->drawmode];
+ bfunc = lcd_blockfuncs[vp->drawmode];
dst = FBADDR(x>>2,y1);
- stride_dst = LCD_FBSTRIDE(lcd_current_viewport->buffer->stride, 0);
+ stride_dst = LCD_FBSTRIDE(vp->buffer->stride, 0);
mask = pixmask[x & 3];
dst_end = dst + (y2 - y1) * stride_dst;
@@ -429,6 +431,7 @@ void lcd_vline(int x, int y1, int y2)
/* Fill a rectangular area */
void lcd_fillrect(int x, int y, int width, int height)
{
+ struct viewport *vp = lcd_current_viewport;
int nx;
unsigned char *dst, *dst_end;
int stride_dst;
@@ -438,9 +441,9 @@ void lcd_fillrect(int x, int y, int width, int height)
if (!lcd_clip_viewport_rect(&x, &y, &width, &height, NULL, NULL))
return;
- bfunc = lcd_blockfuncs[lcd_current_viewport->drawmode];
+ bfunc = lcd_blockfuncs[vp->drawmode];
dst = FBADDR(x>>2,y);
- stride_dst = LCD_FBSTRIDE(lcd_current_viewport->buffer->stride, 0);
+ stride_dst = LCD_FBSTRIDE(vp->buffer->stride, 0);
nx = width - 1 + (x & 3);
mask = 0xFFu >> (2 * (x & 3));
mask_right = 0xFFu << (2 * (~nx & 3));
@@ -485,12 +488,13 @@ void ICODE_ATTR lcd_mono_bitmap_part(const unsigned char *src, int src_x,
int src_y, int stride, int x, int y,
int width, int height)
{
+ struct viewport *vp = lcd_current_viewport;
const unsigned char *src_end;
fb_data *dst, *dst_end;
int stride_dst;
unsigned dmask = 0x100; /* bit 8 == sentinel */
unsigned dst_mask;
- int drmode = lcd_current_viewport->drawmode;
+ int drmode = vp->drawmode;
if (!lcd_clip_viewport_rect(&x, &y, &width, &height, &src_x, &src_y))
return;
@@ -500,7 +504,7 @@ void ICODE_ATTR lcd_mono_bitmap_part(const unsigned char *src, int src_x,
src_end = src + width;
dst = FBADDR(x >> 2,y);
- stride_dst = LCD_FBSTRIDE(lcd_current_viewport->buffer->stride, 0);
+ stride_dst = LCD_FBSTRIDE(vp->buffer->stride, 0);
dst_end = dst + height * stride_dst;
dst_mask = pixmask[x & 3];
@@ -652,6 +656,7 @@ void ICODE_ATTR lcd_bitmap_part(const unsigned char *src, int src_x,
int src_y, int stride, int x, int y,
int width, int height)
{
+ struct viewport *vp = lcd_current_viewport;
int shift, nx;
unsigned char *dst, *dst_end;
int stride_dst;
@@ -666,7 +671,7 @@ void ICODE_ATTR lcd_bitmap_part(const unsigned char *src, int src_x,
src_x &= 3;
x -= src_x;
dst = FBADDR(x>>2,y);
- stride_dst = LCD_FBSTRIDE(lcd_current_viewport->buffer->stride, 0);
+ stride_dst = LCD_FBSTRIDE(vp->buffer->stride, 0);
shift = x & 3;
nx = width - 1 + shift + src_x;
diff --git a/firmware/drivers/lcd-2bit-vert.c b/firmware/drivers/lcd-2bit-vert.c
index c4bdba67cb..354c8802fc 100644
--- a/firmware/drivers/lcd-2bit-vert.c
+++ b/firmware/drivers/lcd-2bit-vert.c
@@ -380,6 +380,7 @@ void lcd_clear_viewport(void)
/* Draw a horizontal line (optimised) */
void lcd_hline(int x1, int x2, int y)
{
+ struct viewport *vp = lcd_current_viewport;
int width;
fb_data *dst, *dst_end;
unsigned mask;
@@ -390,7 +391,7 @@ void lcd_hline(int x1, int x2, int y)
width = x2 - x1 + 1;
- bfunc = lcd_blockfuncs[lcd_current_viewport->drawmode];
+ bfunc = lcd_blockfuncs[vp->drawmode];
dst = FBADDR(x1,y>>2);
mask = pixmask[y & 3];
@@ -403,6 +404,7 @@ void lcd_hline(int x1, int x2, int y)
/* Draw a vertical line (optimised) */
void lcd_vline(int x, int y1, int y2)
{
+ struct viewport *vp = lcd_current_viewport;
int ny;
fb_data *dst;
int stride_dst;
@@ -412,9 +414,9 @@ void lcd_vline(int x, int y1, int y2)
if (!lcd_clip_viewport_vline(&x, &y1, &y2))
return;
- bfunc = lcd_blockfuncs[lcd_current_viewport->drawmode];
+ bfunc = lcd_blockfuncs[vp->drawmode];
dst = FBADDR(x,y1>>2);
- stride_dst = lcd_current_viewport->buffer->stride;
+ stride_dst = vp->buffer->stride;
ny = y2 - (y1 & ~3);
mask = 0xFFu << (2 * (y1 & 3));
mask_bottom = 0xFFu >> (2 * (~ny & 3));
@@ -432,6 +434,7 @@ void lcd_vline(int x, int y1, int y2)
/* Fill a rectangular area */
void lcd_fillrect(int x, int y, int width, int height)
{
+ struct viewport *vp = lcd_current_viewport;
int ny;
fb_data *dst, *dst_end;
int stride_dst;
@@ -443,9 +446,9 @@ void lcd_fillrect(int x, int y, int width, int height)
if (!lcd_clip_viewport_rect(&x, &y, &width, &height, NULL, NULL))
return;
- if (lcd_current_viewport->drawmode & DRMODE_INVERSEVID)
+ if (vp->drawmode & DRMODE_INVERSEVID)
{
- if ((lcd_current_viewport->drawmode & DRMODE_BG) && !lcd_backdrop)
+ if ((vp->drawmode & DRMODE_BG) && !lcd_backdrop)
{
fillopt = true;
bits = bg_pattern;
@@ -453,15 +456,15 @@ void lcd_fillrect(int x, int y, int width, int height)
}
else
{
- if (lcd_current_viewport->drawmode & DRMODE_FG)
+ if (vp->drawmode & DRMODE_FG)
{
fillopt = true;
bits = fg_pattern;
}
}
- bfunc = lcd_blockfuncs[lcd_current_viewport->drawmode];
+ bfunc = lcd_blockfuncs[vp->drawmode];
dst = FBADDR(x,y>>2);
- stride_dst = lcd_current_viewport->buffer->stride;
+ stride_dst = vp->buffer->stride;
ny = height - 1 + (y & 3);
mask = 0xFFu << (2 * (y & 3));
mask_bottom = 0xFFu >> (2 * (~ny & 3));
@@ -512,6 +515,7 @@ void ICODE_ATTR lcd_mono_bitmap_part(const unsigned char *src, int src_x,
int src_y, int stride, int x, int y,
int width, int height)
{
+ struct viewport *vp = lcd_current_viewport;
int shift, ny;
fb_data *dst, *dst_end;
int stride_dst;
@@ -525,14 +529,14 @@ void ICODE_ATTR lcd_mono_bitmap_part(const unsigned char *src, int src_x,
src_y &= 7;
y -= src_y;
dst = FBADDR(x,y>>2);
- stride_dst = lcd_current_viewport->buffer->stride;
+ stride_dst = vp->buffer->stride;
shift = y & 3;
ny = height - 1 + shift + src_y;
mask = 0xFFFFu << (2 * (shift + src_y));
/* Overflowing bits aren't important. */
mask_bottom = 0xFFFFu >> (2 * (~ny & 7));
- bfunc = lcd_blockfuncs[lcd_current_viewport->drawmode];
+ bfunc = lcd_blockfuncs[vp->drawmode];
if (shift == 0)
{
@@ -662,6 +666,7 @@ void ICODE_ATTR lcd_bitmap_part(const fb_data *src, int src_x, int src_y,
int stride, int x, int y, int width,
int height)
{
+ struct viewport *vp = lcd_current_viewport;
int shift, ny;
fb_data *dst, *dst_end;
int stride_dst;
@@ -674,7 +679,7 @@ void ICODE_ATTR lcd_bitmap_part(const fb_data *src, int src_x, int src_y,
src_y &= 3;
y -= src_y;
dst = FBADDR(x,y>>2);
- stride_dst = lcd_current_viewport->buffer->stride;
+ stride_dst = vp->buffer->stride;
shift = y & 3;
ny = height - 1 + shift + src_y;
diff --git a/firmware/drivers/lcd-2bit-vi.c b/firmware/drivers/lcd-2bit-vi.c
index 99bd32c77b..7de4a57577 100644
--- a/firmware/drivers/lcd-2bit-vi.c
+++ b/firmware/drivers/lcd-2bit-vi.c
@@ -413,6 +413,7 @@ void LCDFN(clear_viewport)(void)
/* Draw a horizontal line (optimised) */
void LCDFN(hline)(int x1, int x2, int y)
{
+ struct viewport *vp = CURRENT_VP;
int width;
FBFN(data) *dst, *dst_end;
unsigned mask;
@@ -423,7 +424,7 @@ void LCDFN(hline)(int x1, int x2, int y)
width = x2 - x1 + 1;
- bfunc = LCDFN(blockfuncs)[CURRENT_VP->drawmode];
+ bfunc = LCDFN(blockfuncs)[vp->drawmode];
dst = LCDFB(x1,y>>3);
mask = 0x0101 << (y & 7);
@@ -436,6 +437,7 @@ void LCDFN(hline)(int x1, int x2, int y)
/* Draw a vertical line (optimised) */
void LCDFN(vline)(int x, int y1, int y2)
{
+ struct viewport *vp = CURRENT_VP;
int ny;
FBFN(data) *dst;
int stride_dst;
@@ -445,9 +447,9 @@ void LCDFN(vline)(int x, int y1, int y2)
if (!LCDFN(clip_viewport_vline)(&x, &y1, &y2))
return;
- bfunc = LCDFN(blockfuncs)[CURRENT_VP->drawmode];
+ bfunc = LCDFN(blockfuncs)[vp->drawmode];
dst = LCDFB(x,y1>>3);
- stride_dst = CURRENT_VP->buffer->stride;
+ stride_dst = vp->buffer->stride;
ny = y2 - (y1 & ~7);
mask = (0xFFu << (y1 & 7)) & 0xFFu;
mask |= mask << 8;
@@ -467,6 +469,7 @@ void LCDFN(vline)(int x, int y1, int y2)
/* Fill a rectangular area */
void LCDFN(fillrect)(int x, int y, int width, int height)
{
+ struct viewport *vp = CURRENT_VP;
int ny;
FBFN(data) *dst, *dst_end;
int stride_dst;
@@ -478,9 +481,9 @@ void LCDFN(fillrect)(int x, int y, int width, int height)
if (!LCDFN(clip_viewport_rect)(&x, &y, &width, &height, NULL, NULL))
return;
- if (CURRENT_VP->drawmode & DRMODE_INVERSEVID)
+ if (vp->drawmode & DRMODE_INVERSEVID)
{
- if ((CURRENT_VP->drawmode & DRMODE_BG) && !backdrop)
+ if ((vp->drawmode & DRMODE_BG) && !backdrop)
{
fillopt = true;
bits = bg_pattern;
@@ -488,15 +491,15 @@ void LCDFN(fillrect)(int x, int y, int width, int height)
}
else
{
- if (CURRENT_VP->drawmode & DRMODE_FG)
+ if (vp->drawmode & DRMODE_FG)
{
fillopt = true;
bits = fg_pattern;
}
}
- bfunc = LCDFN(blockfuncs)[CURRENT_VP->drawmode];
+ bfunc = LCDFN(blockfuncs)[vp->drawmode];
dst = LCDFB(x,y>>3);
- stride_dst = CURRENT_VP->buffer->stride;
+ stride_dst = vp->buffer->stride;
ny = height - 1 + (y & 7);
mask = (0xFFu << (y & 7)) & 0xFFu;
mask |= mask << 8;
@@ -549,6 +552,7 @@ void ICODE_ATTR LCDFN(mono_bitmap_part)(const unsigned char *src, int src_x,
int src_y, int stride, int x, int y,
int width, int height)
{
+ struct viewport *vp = CURRENT_VP;
int shift, ny;
FBFN(data) *dst, *dst_end;
int stride_dst;
@@ -562,11 +566,11 @@ void ICODE_ATTR LCDFN(mono_bitmap_part)(const unsigned char *src, int src_x,
src_y &= 7;
y -= src_y;
dst = LCDFB(x,y>>3);
- stride_dst = CURRENT_VP->buffer->stride;
+ stride_dst = vp->buffer->stride;
shift = y & 7;
ny = height - 1 + shift + src_y;
- bfunc = LCDFN(blockfuncs)[CURRENT_VP->drawmode];
+ bfunc = LCDFN(blockfuncs)[vp->drawmode];
mask = 0xFFu << (shift + src_y);
/* not byte-doubled here because shift+src_y can be > 7 */
mask_bottom = 0xFFu >> (~ny & 7);
@@ -670,6 +674,7 @@ void ICODE_ATTR LCDFN(bitmap_part)(const FBFN(data) *src, int src_x,
int src_y, int stride, int x, int y,
int width, int height)
{
+ struct viewport *vp = CURRENT_VP;
int shift, ny;
FBFN(data) *dst, *dst_end;
int stride_dst;
@@ -682,7 +687,7 @@ void ICODE_ATTR LCDFN(bitmap_part)(const FBFN(data) *src, int src_x,
src_y &= 7;
y -= src_y;
dst = LCDFB(x,y>>3);
- stride_dst = CURRENT_VP->buffer->stride;
+ stride_dst = vp->buffer->stride;
shift = y & 7;
ny = height - 1 + shift + src_y;