summaryrefslogtreecommitdiffstats
path: root/firmware/drivers/lcd-16bit-vert.c
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/drivers/lcd-16bit-vert.c')
-rw-r--r--firmware/drivers/lcd-16bit-vert.c98
1 files changed, 52 insertions, 46 deletions
diff --git a/firmware/drivers/lcd-16bit-vert.c b/firmware/drivers/lcd-16bit-vert.c
index ffe2b85b3c..b336e78c78 100644
--- a/firmware/drivers/lcd-16bit-vert.c
+++ b/firmware/drivers/lcd-16bit-vert.c
@@ -39,7 +39,7 @@
#include "scroll_engine.h"
#define ROW_INC 1
-#define COL_INC LCD_HEIGHT
+#define COL_INC lcd_current_viewport->buffer->stride
extern lcd_fastpixelfunc_type* const lcd_fastpixelfuncs_backdrop[];
extern lcd_fastpixelfunc_type* const lcd_fastpixelfuncs_bgcolor[];
@@ -61,7 +61,9 @@ void lcd_hline(int x1, int x2, int y)
{
int x;
fb_data *dst, *dst_end;
- lcd_fastpixelfunc_type *pfunc = lcd_fastpixelfuncs[current_vp->drawmode];
+ int stride_dst;
+
+ lcd_fastpixelfunc_type *pfunc = lcd_fastpixelfuncs[lcd_current_viewport->drawmode];
/* direction flip */
if (x2 < x1)
@@ -73,20 +75,20 @@ void lcd_hline(int x1, int x2, int y)
/******************** In viewport clipping **********************/
/* nothing to draw? */
- if (((unsigned)y >= (unsigned)current_vp->height) ||
- (x1 >= current_vp->width) ||
+ if (((unsigned)y >= (unsigned)lcd_current_viewport->height) ||
+ (x1 >= lcd_current_viewport->width) ||
(x2 < 0))
return;
if (x1 < 0)
x1 = 0;
- if (x2 >= current_vp->width)
- x2 = current_vp->width-1;
+ if (x2 >= lcd_current_viewport->width)
+ x2 = lcd_current_viewport->width-1;
/* Adjust x1 and y to viewport */
- x1 += current_vp->x;
- x2 += current_vp->x;
- y += current_vp->y;
+ x1 += lcd_current_viewport->x;
+ x2 += lcd_current_viewport->x;
+ y += lcd_current_viewport->y;
#if defined(HAVE_VIEWPORT_CLIP)
/********************* Viewport on screen clipping ********************/
@@ -103,12 +105,13 @@ void lcd_hline(int x1, int x2, int y)
#endif
dst = FBADDR(x1 , y );
- dst_end = dst + (x2 - x1) * LCD_HEIGHT;
+ stride_dst = lcd_current_viewport->buffer->stride;
+ dst_end = dst + (x2 - x1) * stride_dst;
do
{
pfunc(dst);
- dst += LCD_HEIGHT;
+ dst += stride_dst;
}
while (dst <= dst_end);
}
@@ -131,20 +134,20 @@ void lcd_vline(int x, int y1, int y2)
/******************** In viewport clipping **********************/
/* nothing to draw? */
- if (((unsigned)x >= (unsigned)current_vp->width) ||
- (y1 >= current_vp->height) ||
+ if (((unsigned)x >= (unsigned)lcd_current_viewport->width) ||
+ (y1 >= lcd_current_viewport->height) ||
(y2 < 0))
return;
if (y1 < 0)
y1 = 0;
- if (y2 >= current_vp->height)
- y2 = current_vp->height-1;
+ if (y2 >= lcd_current_viewport->height)
+ y2 = lcd_current_viewport->height-1;
/* adjust for viewport */
- x += current_vp->x;
- y1 += current_vp->y;
- y2 += current_vp->y;
+ x += lcd_current_viewport->x;
+ y1 += lcd_current_viewport->y;
+ y2 += lcd_current_viewport->y;
#if defined(HAVE_VIEWPORT_CLIP)
/********************* Viewport on screen clipping ********************/
@@ -163,14 +166,14 @@ void lcd_vline(int x, int y1, int y2)
height = y2 - y1 + 1;
/* drawmode and optimisation */
- if (current_vp->drawmode & DRMODE_INVERSEVID)
+ if (lcd_current_viewport->drawmode & DRMODE_INVERSEVID)
{
- if (current_vp->drawmode & DRMODE_BG)
+ if (lcd_current_viewport->drawmode & DRMODE_BG)
{
if (!lcd_backdrop)
{
fillopt = OPT_SET;
- bits = current_vp->bg_pattern;
+ bits = lcd_current_viewport->bg_pattern;
}
else
fillopt = OPT_COPY;
@@ -178,13 +181,13 @@ void lcd_vline(int x, int y1, int y2)
}
else
{
- if (current_vp->drawmode & DRMODE_FG)
+ if (lcd_current_viewport->drawmode & DRMODE_FG)
{
fillopt = OPT_SET;
- bits = current_vp->fg_pattern;
+ bits = lcd_current_viewport->fg_pattern;
}
}
- if (fillopt == OPT_NONE && current_vp->drawmode != DRMODE_COMPLEMENT)
+ if (fillopt == OPT_NONE && lcd_current_viewport->drawmode != DRMODE_COMPLEMENT)
return;
dst = FBADDR(x, y1);
@@ -215,11 +218,11 @@ void ICODE_ATTR lcd_bitmap_part(const fb_data *src, int src_x, int src_y,
int height)
{
fb_data *dst;
-
+ int stride_dst;
/******************** Image in viewport clipping **********************/
/* nothing to draw? */
- if ((width <= 0) || (height <= 0) || (x >= current_vp->width) ||
- (y >= current_vp->height) || (x + width <= 0) || (y + height <= 0))
+ if ((width <= 0) || (height <= 0) || (x >= lcd_current_viewport->width) ||
+ (y >= lcd_current_viewport->height) || (x + width <= 0) || (y + height <= 0))
return;
if (x < 0)
@@ -235,14 +238,14 @@ void ICODE_ATTR lcd_bitmap_part(const fb_data *src, int src_x, int src_y,
y = 0;
}
- if (x + width > current_vp->width)
- width = current_vp->width - x;
- if (y + height > current_vp->height)
- height = current_vp->height - y;
+ if (x + width > lcd_current_viewport->width)
+ width = lcd_current_viewport->width - x;
+ if (y + height > lcd_current_viewport->height)
+ height = lcd_current_viewport->height - y;
/* adjust for viewport */
- x += current_vp->x;
- y += current_vp->y;
+ x += lcd_current_viewport->x;
+ y += lcd_current_viewport->y;
#if defined(HAVE_VIEWPORT_CLIP)
/********************* Viewport on screen clipping ********************/
@@ -272,13 +275,14 @@ 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);
- fb_data *dst_end = dst + width * LCD_HEIGHT;
+ stride_dst = lcd_current_viewport->buffer->stride;
+ fb_data *dst_end = dst + width * stride_dst;
do
{
memcpy(dst, src, height * sizeof(fb_data));
src += stride;
- dst += LCD_HEIGHT;
+ dst += stride_dst;
}
while (dst < dst_end);
}
@@ -289,11 +293,12 @@ void ICODE_ATTR lcd_bitmap_transparent_part(const fb_data *src, int src_x,
int y, int width, int height)
{
fb_data *dst, *dst_end;
+ int stride_dst;
/******************** Image in viewport clipping **********************/
/* nothing to draw? */
- if ((width <= 0) || (height <= 0) || (x >= current_vp->width) ||
- (y >= current_vp->height) || (x + width <= 0) || (y + height <= 0))
+ if ((width <= 0) || (height <= 0) || (x >= lcd_current_viewport->width) ||
+ (y >= lcd_current_viewport->height) || (x + width <= 0) || (y + height <= 0))
return;
if (x < 0)
@@ -309,14 +314,14 @@ void ICODE_ATTR lcd_bitmap_transparent_part(const fb_data *src, int src_x,
y = 0;
}
- if (x + width > current_vp->width)
- width = current_vp->width - x;
- if (y + height > current_vp->height)
- height = current_vp->height - y;
+ if (x + width > lcd_current_viewport->width)
+ width = lcd_current_viewport->width - x;
+ if (y + height > lcd_current_viewport->height)
+ height = lcd_current_viewport->height - y;
/* adjust for viewport */
- x += current_vp->x;
- y += current_vp->y;
+ x += lcd_current_viewport->x;
+ y += lcd_current_viewport->y;
#if defined(HAVE_VIEWPORT_CLIP)
/********************* Viewport on screen clipping ********************/
@@ -346,7 +351,8 @@ 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);
- dst_end = dst + width * LCD_HEIGHT;
+ stride_dst = lcd_current_viewport->buffer->stride;
+ dst_end = dst + width * stride_dst;
do
{
@@ -354,12 +360,12 @@ 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] = current_vp->fg_pattern;
+ dst[i] = lcd_current_viewport->fg_pattern;
else if(src[i] != TRANSPARENT_COLOR)
dst[i] = src[i];
}
src += stride;
- dst += LCD_HEIGHT;
+ dst += stride_dst;
}
while (dst < dst_end);
}