summaryrefslogtreecommitdiffstats
path: root/firmware/drivers/lcd-16bit.c
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/drivers/lcd-16bit.c')
-rw-r--r--firmware/drivers/lcd-16bit.c107
1 files changed, 6 insertions, 101 deletions
diff --git a/firmware/drivers/lcd-16bit.c b/firmware/drivers/lcd-16bit.c
index 6dff6f3b50..fd032c0956 100644
--- a/firmware/drivers/lcd-16bit.c
+++ b/firmware/drivers/lcd-16bit.c
@@ -62,36 +62,14 @@ 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)
{
- int x, width;
+ int width;
unsigned bits = 0;
enum fill_opt fillopt = OPT_NONE;
fb_data *dst, *dst_end;
- /* direction flip */
- if (x2 < x1)
- {
- x = x1;
- x1 = x2;
- x2 = x;
- }
-
- /******************** In viewport clipping **********************/
- /* nothing to draw? */
- if (((unsigned)y >= (unsigned)lcd_current_viewport->height) ||
- (x1 >= lcd_current_viewport->width) ||
- (x2 < 0))
+ if (!lcd_clip_viewport_hline(&x1, &x2, &y))
return;
- if (x1 < 0)
- x1 = 0;
- if (x2 >= lcd_current_viewport->width)
- x2 = lcd_current_viewport->width-1;
-
- /* Adjust x1 and y to viewport */
- x1 += lcd_current_viewport->x;
- x2 += lcd_current_viewport->x;
- y += lcd_current_viewport->y;
-
width = x2 - x1 + 1;
/* drawmode and optimisation */
@@ -144,37 +122,14 @@ void lcd_hline(int x1, int x2, int y)
/* Draw a vertical line (optimised) */
void lcd_vline(int x, int y1, int y2)
{
- int y;
fb_data *dst, *dst_end;
int stride_dst;
lcd_fastpixelfunc_type *pfunc = lcd_fastpixelfuncs[lcd_current_viewport->drawmode];
- /* direction flip */
- if (y2 < y1)
- {
- y = y1;
- y1 = y2;
- y2 = y;
- }
-
- /******************** In viewport clipping **********************/
- /* nothing to draw? */
- if (((unsigned)x >= (unsigned)lcd_current_viewport->width) ||
- (y1 >= lcd_current_viewport->height) ||
- (y2 < 0))
+ if (!lcd_clip_viewport_vline(&x, &y1, &y2))
return;
- if (y1 < 0)
- y1 = 0;
- if (y2 >= lcd_current_viewport->height)
- y2 = lcd_current_viewport->height-1;
-
- /* adjust for viewport */
- x += lcd_current_viewport->x;
- y1 += lcd_current_viewport->y;
- y2 += lcd_current_viewport->y;
-
- dst = FBADDR(x , y1);
+ dst = FBADDR(x, y1);
stride_dst = lcd_current_viewport->buffer->stride;
dst_end = dst + (y2 - y1) * stride_dst;
@@ -194,34 +149,9 @@ void ICODE_ATTR lcd_bitmap_part(const fb_data *src, int src_x, int src_y,
fb_data *dst;
int stride_dst;
- /******************** Image in viewport clipping **********************/
- /* nothing to draw? */
- if ((width <= 0) || (height <= 0) || (x >= lcd_current_viewport->width) ||
- (y >= lcd_current_viewport->height) || (x + width <= 0) || (y + height <= 0))
+ if (!lcd_clip_viewport_rect(&x, &y, &width, &height, &src_x, &src_y))
return;
- if (x < 0)
- {
- width += x;
- src_x -= x;
- x = 0;
- }
- if (y < 0)
- {
- height += y;
- src_y -= y;
- y = 0;
- }
-
- 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 += lcd_current_viewport->x;
- y += lcd_current_viewport->y;
-
src += stride * src_y + src_x; /* move starting point */
dst = FBADDR(x, y);
stride_dst = lcd_current_viewport->buffer->stride;
@@ -244,34 +174,9 @@ void ICODE_ATTR lcd_bitmap_transparent_part(const fb_data *src, int src_x,
unsigned fg = lcd_current_viewport->fg_pattern;
int stride_dst = lcd_current_viewport->buffer->stride;
- /******************** Image in viewport clipping **********************/
- /* nothing to draw? */
- if ((width <= 0) || (height <= 0) || (x >= lcd_current_viewport->width) ||
- (y >= lcd_current_viewport->height) || (x + width <= 0) || (y + height <= 0))
+ if (!lcd_clip_viewport_rect(&x, &y, &width, &height, &src_x, &src_y))
return;
- if (x < 0)
- {
- width += x;
- src_x -= x;
- x = 0;
- }
- if (y < 0)
- {
- height += y;
- src_y -= y;
- y = 0;
- }
-
- 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 += lcd_current_viewport->x;
- y += lcd_current_viewport->y;
-
src += stride * src_y + src_x; /* move starting point */
dst = FBADDR(x, y);