From 40e98a2e4915464b9306ab7b0f6feb173de095c5 Mon Sep 17 00:00:00 2001 From: William Wilgus Date: Mon, 26 Oct 2020 12:38:22 -0400 Subject: Whitespace cleanup on fb_viewport Rewrite Change-Id: I24aac41c8abecf7b78a44d7f59e842b791be4563 --- firmware/drivers/lcd-16bit-vert.c | 46 ++++++++++---------- firmware/drivers/lcd-16bit.c | 48 ++++++++++----------- firmware/drivers/lcd-1bit-vert.c | 56 ++++++++++++------------ firmware/drivers/lcd-24bit.c | 48 ++++++++++----------- firmware/drivers/lcd-2bit-horz.c | 84 ++++++++++++++++++------------------ firmware/drivers/lcd-2bit-vert.c | 76 ++++++++++++++++---------------- firmware/drivers/lcd-2bit-vi.c | 38 ++++++++-------- firmware/drivers/lcd-bitmap-common.c | 2 +- firmware/drivers/lcd-color-common.c | 2 +- firmware/export/config/mrobe500.h | 2 +- firmware/export/lcd.h | 6 +-- 11 files changed, 204 insertions(+), 204 deletions(-) (limited to 'firmware') diff --git a/firmware/drivers/lcd-16bit-vert.c b/firmware/drivers/lcd-16bit-vert.c index b336e78c78..8631271482 100644 --- a/firmware/drivers/lcd-16bit-vert.c +++ b/firmware/drivers/lcd-16bit-vert.c @@ -84,19 +84,19 @@ void lcd_hline(int x1, int x2, int y) 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; - + #if defined(HAVE_VIEWPORT_CLIP) /********************* Viewport on screen clipping ********************/ /* nothing to draw? */ if (((unsigned)y >= (unsigned) LCD_HEIGHT) || (x1 >= LCD_WIDTH) || (x2 < 0)) - return; - + return; + /* clipping */ if (x1 < 0) x1 = 0; @@ -143,19 +143,19 @@ void lcd_vline(int x, int y1, int y2) 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; - + #if defined(HAVE_VIEWPORT_CLIP) /********************* Viewport on screen clipping ********************/ /* nothing to draw? */ - if (( (unsigned) x >= (unsigned)LCD_WIDTH) || (y1 >= LCD_HEIGHT) + if (( (unsigned) x >= (unsigned)LCD_WIDTH) || (y1 >= LCD_HEIGHT) || (y2 < 0)) return; - + /* clipping */ if (y1 < 0) y1 = 0; @@ -224,7 +224,7 @@ void ICODE_ATTR lcd_bitmap_part(const fb_data *src, int src_x, int src_y, 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) { width += x; @@ -237,23 +237,23 @@ void ICODE_ATTR lcd_bitmap_part(const fb_data *src, int src_x, int src_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; - + height = lcd_current_viewport->height - y; + /* adjust for viewport */ x += lcd_current_viewport->x; y += lcd_current_viewport->y; - + #if defined(HAVE_VIEWPORT_CLIP) /********************* Viewport on screen clipping ********************/ /* nothing to draw? */ - if ((x >= LCD_WIDTH) || (y >= LCD_HEIGHT) + if ((x >= LCD_WIDTH) || (y >= LCD_HEIGHT) || (x + width <= 0) || (y + height <= 0)) return; - + /* clip image in viewport in screen */ if (x < 0) { @@ -294,13 +294,13 @@ void ICODE_ATTR lcd_bitmap_transparent_part(const fb_data *src, int src_x, { fb_data *dst, *dst_end; 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)) return; - + if (x < 0) { width += x; @@ -313,23 +313,23 @@ void ICODE_ATTR lcd_bitmap_transparent_part(const fb_data *src, int src_x, 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; - + height = lcd_current_viewport->height - y; + /* adjust for viewport */ x += lcd_current_viewport->x; y += lcd_current_viewport->y; - + #if defined(HAVE_VIEWPORT_CLIP) /********************* Viewport on screen clipping ********************/ /* nothing to draw? */ - if ((x >= LCD_WIDTH) || (y >= LCD_HEIGHT) + if ((x >= LCD_WIDTH) || (y >= LCD_HEIGHT) || (x + width <= 0) || (y + height <= 0)) return; - + /* clip image in viewport in screen */ if (x < 0) { diff --git a/firmware/drivers/lcd-16bit.c b/firmware/drivers/lcd-16bit.c index 03c50f8ebf..6a76ba48ab 100644 --- a/firmware/drivers/lcd-16bit.c +++ b/firmware/drivers/lcd-16bit.c @@ -74,11 +74,11 @@ void lcd_hline(int x1, int x2, int y) /******************** In viewport clipping **********************/ /* nothing to draw? */ - if (((unsigned)y >= (unsigned)lcd_current_viewport->height) || + if (((unsigned)y >= (unsigned)lcd_current_viewport->height) || (x1 >= lcd_current_viewport->width) || (x2 < 0)) return; - + if (x1 < 0) x1 = 0; if (x2 >= lcd_current_viewport->width) @@ -88,14 +88,14 @@ void lcd_hline(int x1, int x2, int 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 ********************/ /* nothing to draw? */ if (((unsigned)y >= (unsigned) LCD_HEIGHT) || (x1 >= LCD_WIDTH) || (x2 < 0)) - return; - + return; + /* clipping */ if (x1 < 0) x1 = 0; @@ -179,19 +179,19 @@ void lcd_vline(int x, int y1, int y2) 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; - + #if defined(HAVE_VIEWPORT_CLIP) /********************* Viewport on screen clipping ********************/ /* nothing to draw? */ - if (( (unsigned) x >= (unsigned)LCD_WIDTH) || (y1 >= LCD_HEIGHT) + if (( (unsigned) x >= (unsigned)LCD_WIDTH) || (y1 >= LCD_HEIGHT) || (y2 < 0)) return; - + /* clipping */ if (y1 < 0) y1 = 0; @@ -224,7 +224,7 @@ void ICODE_ATTR lcd_bitmap_part(const fb_data *src, int src_x, int src_y, 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) { width += x; @@ -237,23 +237,23 @@ void ICODE_ATTR lcd_bitmap_part(const fb_data *src, int src_x, int src_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; - + height = lcd_current_viewport->height - y; + /* adjust for viewport */ x += lcd_current_viewport->x; y += lcd_current_viewport->y; - + #if defined(HAVE_VIEWPORT_CLIP) /********************* Viewport on screen clipping ********************/ /* nothing to draw? */ - if ((x >= LCD_WIDTH) || (y >= LCD_HEIGHT) + if ((x >= LCD_WIDTH) || (y >= LCD_HEIGHT) || (x + width <= 0) || (y + height <= 0)) return; - + /* clip image in viewport in screen */ if (x < 0) { @@ -272,7 +272,7 @@ void ICODE_ATTR lcd_bitmap_part(const fb_data *src, int src_x, int src_y, if (y + height > LCD_HEIGHT) height = LCD_HEIGHT - y; #endif - + src += stride * src_y + src_x; /* move starting point */ dst = FBADDR(x, y); stride_dst = lcd_current_viewport->buffer->stride; @@ -300,7 +300,7 @@ void ICODE_ATTR lcd_bitmap_transparent_part(const fb_data *src, int src_x, 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) { width += x; @@ -313,23 +313,23 @@ void ICODE_ATTR lcd_bitmap_transparent_part(const fb_data *src, int src_x, 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; - + height = lcd_current_viewport->height - y; + /* adjust for viewport */ x += lcd_current_viewport->x; y += lcd_current_viewport->y; - + #if defined(HAVE_VIEWPORT_CLIP) /********************* Viewport on screen clipping ********************/ /* nothing to draw? */ - if ((x >= LCD_WIDTH) || (y >= LCD_HEIGHT) + if ((x >= LCD_WIDTH) || (y >= LCD_HEIGHT) || (x + width <= 0) || (y + height <= 0)) return; - + /* clip image in viewport in screen */ if (x < 0) { diff --git a/firmware/drivers/lcd-1bit-vert.c b/firmware/drivers/lcd-1bit-vert.c index 57abdb91a6..c86ced9b6c 100644 --- a/firmware/drivers/lcd-1bit-vert.c +++ b/firmware/drivers/lcd-1bit-vert.c @@ -219,7 +219,7 @@ static void ICODE_ATTR solidinvblock(FBFN(data) *address, unsigned mask, unsigned bits) { unsigned data = *(char *)address; - + bits = ~bits ^ data; *address = data ^ (bits & mask); } @@ -255,7 +255,7 @@ void LCDFN(clear_viewport)(void) oldmode = CURRENT_VP->drawmode; /* Invert the INVERSEVID bit and set basic mode to SOLID */ - CURRENT_VP->drawmode = (~CURRENT_VP->drawmode & DRMODE_INVERSEVID) | + CURRENT_VP->drawmode = (~CURRENT_VP->drawmode & DRMODE_INVERSEVID) | DRMODE_SOLID; LCDFN(fillrect)(0, 0, CURRENT_VP->width, CURRENT_VP->height); @@ -271,7 +271,7 @@ void LCDFN(clear_viewport)(void) /* Set a single pixel */ void LCDFN(drawpixel)(int x, int y) { - if ( ((unsigned)x < (unsigned)CURRENT_VP->width) + if ( ((unsigned)x < (unsigned)CURRENT_VP->width) && ((unsigned)y < (unsigned)CURRENT_VP->height) #if defined(HAVE_VIEWPORT_CLIP) && ((unsigned)x < (unsigned)LCDM(WIDTH)) @@ -385,30 +385,30 @@ void LCDFN(hline)(int x1, int x2, int y) x1 = x2; x2 = x; } - + /******************** In viewport clipping **********************/ /* nothing to draw? */ if (((unsigned)y >= (unsigned)CURRENT_VP->height) || (x1 >= CURRENT_VP->width) || (x2 < 0)) - return; - + return; + if (x1 < 0) x1 = 0; if (x2 >= CURRENT_VP->width) x2 = CURRENT_VP->width-1; - + /* adjust to viewport */ x1 += CURRENT_VP->x; x2 += CURRENT_VP->x; y += CURRENT_VP->y; - + #if defined(HAVE_VIEWPORT_CLIP) /********************* Viewport on screen clipping ********************/ /* nothing to draw? */ if (((unsigned)y >= (unsigned) LCDM(HEIGHT)) || (x1 >= LCDM(WIDTH)) || (x2 < 0)) - return; - + return; + /* clipping */ if (x1 < 0) x1 = 0; @@ -449,25 +449,25 @@ void LCDFN(vline)(int x, int y1, int y2) /* nothing to draw? */ if (((unsigned)x >= (unsigned)CURRENT_VP->width) || (y1 >= CURRENT_VP->height) || (y2 < 0)) - return; - + return; + if (y1 < 0) y1 = 0; if (y2 >= CURRENT_VP->height) y2 = CURRENT_VP->height-1; - + /* adjust for viewport */ y1 += CURRENT_VP->y; y2 += CURRENT_VP->y; x += CURRENT_VP->x; - + #if defined(HAVE_VIEWPORT_CLIP) /********************* Viewport on screen clipping ********************/ /* nothing to draw? */ - if (( (unsigned) x >= (unsigned)LCDM(WIDTH)) || (y1 >= LCDM(HEIGHT)) + if (( (unsigned) x >= (unsigned)LCDM(WIDTH)) || (y1 >= LCDM(HEIGHT)) || (y2 < 0)) return; - + /* clipping */ if (y1 < 0) y1 = 0; @@ -538,18 +538,18 @@ void LCDFN(fillrect)(int x, int y, int width, int height) width = CURRENT_VP->width - x; if (y + height > CURRENT_VP->height) height = CURRENT_VP->height - y; - + /* adjust for viewport */ x += CURRENT_VP->x; y += CURRENT_VP->y; - + #if defined(HAVE_VIEWPORT_CLIP) /********************* Viewport on screen clipping ********************/ /* nothing to draw? */ - if ((x >= LCDM(WIDTH)) || (y >= LCDM(HEIGHT)) + if ((x >= LCDM(WIDTH)) || (y >= LCDM(HEIGHT)) || (x + width <= 0) || (y + height <= 0)) return; - + /* clip image in viewport in screen */ if (x < 0) { @@ -646,7 +646,7 @@ void ICODE_ATTR LCDFN(bitmap_part)(const unsigned char *src, int src_x, if ((width <= 0) || (height <= 0) || (x >= CURRENT_VP->width) || (y >= CURRENT_VP->height) || (x + width <= 0) || (y + height <= 0)) return; - + /* clip image in viewport */ if (x < 0) { @@ -668,14 +668,14 @@ void ICODE_ATTR LCDFN(bitmap_part)(const unsigned char *src, int src_x, /* adjust for viewport */ x += CURRENT_VP->x; y += CURRENT_VP->y; - + #if defined(HAVE_VIEWPORT_CLIP) /********************* Viewport on screen clipping ********************/ /* nothing to draw? */ - if ((x >= LCDM(WIDTH)) || (y >= LCDM(HEIGHT)) + if ((x >= LCDM(WIDTH)) || (y >= LCDM(HEIGHT)) || (x + width <= 0) || (y + height <= 0)) return; - + /* clip image in viewport in screen */ if (x < 0) { @@ -706,7 +706,7 @@ void ICODE_ATTR LCDFN(bitmap_part)(const unsigned char *src, int src_x, bfunc = LCDFN(blockfuncs)[CURRENT_VP->drawmode]; mask = 0xFFu << (shift + src_y); mask_bottom = 0xFFu >> (~ny & 7); - + if (shift == 0) { bool copyopt = (CURRENT_VP->drawmode == DRMODE_SOLID); @@ -719,9 +719,9 @@ void ICODE_ATTR LCDFN(bitmap_part)(const unsigned char *src, int src_x, { const unsigned char *src_row = src; FBFN(data) *dst_row = dst; - + dst_end = dst_row + width; - do + do bfunc(dst_row++, mask, *src_row++); while (dst_row < dst_end); } @@ -751,7 +751,7 @@ void ICODE_ATTR LCDFN(bitmap_part)(const unsigned char *src, int src_x, FBFN(data) *dst_col = dst++; unsigned mask_col = mask; unsigned data = 0; - + for (y = ny; y >= 8; y -= 8) { data |= *src_col << shift; diff --git a/firmware/drivers/lcd-24bit.c b/firmware/drivers/lcd-24bit.c index 65fa01f37f..5ee290efe3 100644 --- a/firmware/drivers/lcd-24bit.c +++ b/firmware/drivers/lcd-24bit.c @@ -869,11 +869,11 @@ void lcd_hline(int x1, int x2, int y) /******************** In viewport clipping **********************/ /* nothing to draw? */ - if (((unsigned)y >= (unsigned)lcd_current_viewport->height) || + if (((unsigned)y >= (unsigned)lcd_current_viewport->height) || (x1 >= lcd_current_viewport->width) || (x2 < 0)) return; - + if (x1 < 0) x1 = 0; if (x2 >= lcd_current_viewport->width) @@ -883,14 +883,14 @@ void lcd_hline(int x1, int x2, int 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 ********************/ /* nothing to draw? */ if (((unsigned)y >= (unsigned) LCD_HEIGHT) || (x1 >= LCD_WIDTH) || (x2 < 0)) - return; - + return; + /* clipping */ if (x1 < 0) x1 = 0; @@ -935,19 +935,19 @@ void lcd_vline(int x, int y1, int y2) 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; - + #if defined(HAVE_VIEWPORT_CLIP) /********************* Viewport on screen clipping ********************/ /* nothing to draw? */ - if (( (unsigned) x >= (unsigned)LCD_WIDTH) || (y1 >= LCD_HEIGHT) + if (( (unsigned) x >= (unsigned)LCD_WIDTH) || (y1 >= LCD_HEIGHT) || (y2 < 0)) return; - + /* clipping */ if (y1 < 0) y1 = 0; @@ -978,7 +978,7 @@ void ICODE_ATTR lcd_bitmap_part(const fb_data *src, int src_x, int src_y, 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) { width += x; @@ -991,23 +991,23 @@ void ICODE_ATTR lcd_bitmap_part(const fb_data *src, int src_x, int src_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; - + height = lcd_current_viewport->height - y; + /* adjust for viewport */ x += lcd_current_viewport->x; y += lcd_current_viewport->y; - + #if defined(HAVE_VIEWPORT_CLIP) /********************* Viewport on screen clipping ********************/ /* nothing to draw? */ - if ((x >= LCD_WIDTH) || (y >= LCD_HEIGHT) + if ((x >= LCD_WIDTH) || (y >= LCD_HEIGHT) || (x + width <= 0) || (y + height <= 0)) return; - + /* clip image in viewport in screen */ if (x < 0) { @@ -1026,7 +1026,7 @@ void ICODE_ATTR lcd_bitmap_part(const fb_data *src, int src_x, int src_y, if (y + height > LCD_HEIGHT) height = LCD_HEIGHT - y; #endif - + src += stride * src_y + src_x; /* move starting point */ dst = FBADDR(x, y); @@ -1052,7 +1052,7 @@ void ICODE_ATTR lcd_bitmap_transparent_part(const fb_data *src, int src_x, 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) { width += x; @@ -1065,23 +1065,23 @@ void ICODE_ATTR lcd_bitmap_transparent_part(const fb_data *src, int src_x, 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; - + height = lcd_current_viewport->height - y; + /* adjust for viewport */ x += lcd_current_viewport->x; y += lcd_current_viewport->y; - + #if defined(HAVE_VIEWPORT_CLIP) /********************* Viewport on screen clipping ********************/ /* nothing to draw? */ - if ((x >= LCD_WIDTH) || (y >= LCD_HEIGHT) + if ((x >= LCD_WIDTH) || (y >= LCD_HEIGHT) || (x + width <= 0) || (y + height <= 0)) return; - + /* clip image in viewport in screen */ if (x < 0) { diff --git a/firmware/drivers/lcd-2bit-horz.c b/firmware/drivers/lcd-2bit-horz.c index 35a2be5b2c..b2114ba830 100644 --- a/firmware/drivers/lcd-2bit-horz.c +++ b/firmware/drivers/lcd-2bit-horz.c @@ -8,7 +8,7 @@ * $Id$ * * LCD driver for horizontally-packed 2bpp greyscale display - * + * * Based on code from the rockbox lcd's driver * * Copyright (c) 2006 Seven Le Mesle (sevlm@free.fr) @@ -199,7 +199,7 @@ static void flippixel(int x, int y) { unsigned mask = pixmask[x & 3]; fb_data *address = FBADDR(x>>2,y); - + *address ^= mask; } @@ -362,7 +362,7 @@ fb_data* lcd_get_backdrop(void) static inline void setblock(fb_data *address, unsigned mask, unsigned bits) { unsigned data = *address; - + bits ^= data; *address = data ^ (bits & mask); } @@ -402,7 +402,7 @@ void lcd_clear_viewport(void) lastmode = lcd_current_viewport->drawmode; /* Invert the INVERSEVID bit and set basic mode to SOLID */ - lcd_current_viewport->drawmode = (~lastmode & DRMODE_INVERSEVID) | + lcd_current_viewport->drawmode = (~lastmode & DRMODE_INVERSEVID) | DRMODE_SOLID; lcd_fillrect(0, 0, lcd_current_viewport->width, lcd_current_viewport->height); @@ -492,7 +492,7 @@ void lcd_drawline(int x1, int y1, int x2, int y2) for (i = 0; i < numpixels; i++) { - if ( ((unsigned)x < (unsigned)lcd_current_viewport->width) + if ( ((unsigned)x < (unsigned)lcd_current_viewport->width) && ((unsigned)y < (unsigned)lcd_current_viewport->height) #if defined(HAVE_VIEWPORT_CLIP) && ((unsigned)x < (unsigned)LCD_WIDTH) @@ -531,13 +531,13 @@ void lcd_hline(int x1, int x2, int y) x1 = x2; x2 = nx; } - + /******************** In viewport clipping **********************/ /* nothing to draw? */ - if (((unsigned)y >= (unsigned)lcd_current_viewport->height) || (x1 >= lcd_current_viewport->width) + if (((unsigned)y >= (unsigned)lcd_current_viewport->height) || (x1 >= lcd_current_viewport->width) || (x2 < 0)) - return; - + return; + if (x1 < 0) x1 = 0; if (x2 >= lcd_current_viewport->width) @@ -547,14 +547,14 @@ void lcd_hline(int x1, int x2, int 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 ********************/ /* nothing to draw? */ if (((unsigned)y >= (unsigned) LCD_HEIGHT) || (x1 >= LCD_WIDTH) || (x2 < 0)) - return; - + return; + /* clipping */ if (x1 < 0) x1 = 0; @@ -567,7 +567,7 @@ void lcd_hline(int x1, int x2, int y) nx = x2 - (x1 & ~3); mask = 0xFFu >> (2 * (x1 & 3)); mask_right = 0xFFu << (2 * (~nx & 3)); - + for (; nx >= 4; nx -= 4) { bfunc(dst++, mask, 0xFFu); @@ -598,8 +598,8 @@ void lcd_vline(int x, int y1, int y2) /* nothing to draw? */ if (((unsigned)x >= (unsigned)lcd_current_viewport->width) || (y1 >= lcd_current_viewport->height) || (y2 < 0)) - return; - + return; + if (y1 < 0) y1 = 0; if (y2 >= lcd_current_viewport->height) @@ -609,26 +609,26 @@ void lcd_vline(int x, int y1, int y2) y1 += lcd_current_viewport->y; y2 += lcd_current_viewport->y; x += lcd_current_viewport->x; - + #if defined(HAVE_VIEWPORT_CLIP) /********************* Viewport on screen clipping ********************/ /* nothing to draw? */ - if (( (unsigned) x >= (unsigned)LCD_WIDTH) || (y1 >= LCD_HEIGHT) + if (( (unsigned) x >= (unsigned)LCD_WIDTH) || (y1 >= LCD_HEIGHT) || (y2 < 0)) return; - + /* clipping */ if (y1 < 0) y1 = 0; if (y2 >= LCD_HEIGHT) y2 = LCD_HEIGHT-1; #endif - + bfunc = lcd_blockfuncs[lcd_current_viewport->drawmode]; dst = FBADDR(x>>2,y1); stride_dst = LCD_FBSTRIDE(lcd_current_viewport->buffer->stride, 0); mask = pixmask[x & 3]; - + dst_end = dst + (y2 - y1) * stride_dst; do { @@ -686,14 +686,14 @@ void lcd_fillrect(int x, int y, int width, int height) /* adjust for viewport */ x += lcd_current_viewport->x; y += lcd_current_viewport->y; - + #if defined(HAVE_VIEWPORT_CLIP) /********************* Viewport on screen clipping ********************/ /* nothing to draw? */ - if ((x >= LCD_WIDTH) || (y >= LCD_HEIGHT) + if ((x >= LCD_WIDTH) || (y >= LCD_HEIGHT) || (x + width <= 0) || (y + height <= 0)) return; - + /* clip image in viewport in screen */ if (x < 0) { @@ -717,7 +717,7 @@ void lcd_fillrect(int x, int y, int width, int height) nx = width - 1 + (x & 3); mask = 0xFFu >> (2 * (x & 3)); mask_right = 0xFFu << (2 * (~nx & 3)); - + for (; nx >= 4; nx -= 4) { unsigned char *dst_col = dst; @@ -770,7 +770,7 @@ void ICODE_ATTR lcd_mono_bitmap_part(const unsigned char *src, int src_x, 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) { width += x; @@ -787,17 +787,17 @@ void ICODE_ATTR lcd_mono_bitmap_part(const unsigned char *src, int src_x, width = lcd_current_viewport->width - x; if (y + height > lcd_current_viewport->height) height = lcd_current_viewport->height - y; - + x += lcd_current_viewport->x; /* adjust for viewport */ y += lcd_current_viewport->y; /* adjust for viewport */ - + #if defined(HAVE_VIEWPORT_CLIP) /********************* Viewport on screen clipping ********************/ /* nothing to draw? */ - if ((x >= LCD_WIDTH) || (y >= LCD_HEIGHT) + if ((x >= LCD_WIDTH) || (y >= LCD_HEIGHT) || (x + width <= 0) || (y + height <= 0)) return; - + /* clip image in viewport in screen */ if (x < 0) { @@ -820,7 +820,7 @@ void ICODE_ATTR lcd_mono_bitmap_part(const unsigned char *src, int src_x, src += stride * (src_y >> 3) + src_x; /* move starting point */ src_y &= 7; src_end = src + width; - + dst = FBADDR(x >> 2,y); stride_dst = LCD_FBSTRIDE(lcd_current_viewport->buffer->stride, 0); dst_end = dst + height * stride_dst; @@ -835,7 +835,7 @@ void ICODE_ATTR lcd_mono_bitmap_part(const unsigned char *src, int src_x, do { const unsigned char *src_col = src++; - unsigned data = (*src_col ^ dmask) >> src_y; + unsigned data = (*src_col ^ dmask) >> src_y; fb_data *dst_col = dst; int fg, bg; long bo; @@ -847,7 +847,7 @@ void ICODE_ATTR lcd_mono_bitmap_part(const unsigned char *src, int src_x, data = *src_col ^ dmask; \ } \ } while (0) - + switch (drmode) { case DRMODE_COMPLEMENT: @@ -861,7 +861,7 @@ void ICODE_ATTR lcd_mono_bitmap_part(const unsigned char *src, int src_x, } while (dst_col < dst_end); break; - + case DRMODE_BG: if (lcd_backdrop) { @@ -919,7 +919,7 @@ void ICODE_ATTR lcd_mono_bitmap_part(const unsigned char *src, int src_x, do { unsigned block = *dst_col; - *dst_col = block ^ ((block ^ ((data & 0x01) ? + *dst_col = block ^ ((block ^ ((data & 0x01) ? fg : *(dst_col + bo))) & dst_mask); dst_col += stride_dst; @@ -981,10 +981,10 @@ void ICODE_ATTR lcd_bitmap_part(const unsigned char *src, int src_x, /******************** Image in viewport clipping **********************/ /* nothing to draw? */ - if ((width <= 0) || (height <= 0) || (x >= lcd_current_viewport->width) || + 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) { width += x; @@ -1005,14 +1005,14 @@ void ICODE_ATTR lcd_bitmap_part(const unsigned char *src, int src_x, /* adjust for viewport */ x += lcd_current_viewport->x; y += lcd_current_viewport->y; - + #if defined(HAVE_VIEWPORT_CLIP) /********************* Viewport on screen clipping ********************/ /* nothing to draw? */ - if ((x >= LCD_WIDTH) || (y >= LCD_HEIGHT) + if ((x >= LCD_WIDTH) || (y >= LCD_HEIGHT) || (x + width <= 0) || (y + height <= 0)) return; - + /* clip image in viewport in screen */ if (x < 0) { @@ -1044,7 +1044,7 @@ void ICODE_ATTR lcd_bitmap_part(const unsigned char *src, int src_x, mask = 0xFF00u >> (2 * (shift + src_x)); mask_right = 0xFFu << (2 * (~nx & 3)); - + shift *= 2; dst_end = dst + height * stride_dst; do @@ -1053,11 +1053,11 @@ void ICODE_ATTR lcd_bitmap_part(const unsigned char *src, int src_x, unsigned char *dst_row = dst; unsigned mask_row = mask >> 8; unsigned data = 0; - + for (x = nx; x >= 4; x -= 4) { data = (data << 8) | *src_row++; - + if (mask_row & 0xFF) { setblock(dst_row, mask_row, data >> shift); diff --git a/firmware/drivers/lcd-2bit-vert.c b/firmware/drivers/lcd-2bit-vert.c index a099c45e98..6a476495d0 100644 --- a/firmware/drivers/lcd-2bit-vert.c +++ b/firmware/drivers/lcd-2bit-vert.c @@ -260,7 +260,7 @@ static void ICODE_ATTR solidblock(fb_data *address, unsigned mask, { unsigned data = *address; unsigned bgp = bg_pattern; - + bits = bgp ^ ((bgp ^ fg_pattern) & bits); *address = data ^ ((data ^ bits) & mask); } @@ -270,7 +270,7 @@ static void ICODE_ATTR solidimgblock(fb_data *address, unsigned mask, { unsigned data = *address; unsigned bgp = *(address + lcd_backdrop_offset); - + bits = bgp ^ ((bgp ^ fg_pattern) & bits); *address = data ^ ((data ^ bits) & mask); } @@ -310,7 +310,7 @@ static void ICODE_ATTR solidinvblock(fb_data *address, unsigned mask, { unsigned data = *address; unsigned fgp = fg_pattern; - + bits = fgp ^ ((fgp ^ bg_pattern) & bits); *address = data ^ ((data ^ bits) & mask); } @@ -320,7 +320,7 @@ static void ICODE_ATTR solidimginvblock(fb_data *address, unsigned mask, { unsigned data = *address; unsigned fgp = fg_pattern; - + bits = fgp ^ ((fgp ^ *(address + lcd_backdrop_offset)) & bits); *address = data ^ ((data ^ bits) & mask); } @@ -347,7 +347,7 @@ void lcd_set_backdrop(fb_data* backdrop) lcd_pixelfuncs = lcd_pixelfuncs_backdrop; lcd_blockfuncs = lcd_blockfuncs_backdrop; } - else + else { lcd_backdrop_offset = 0; lcd_pixelfuncs = lcd_pixelfuncs_bgcolor; @@ -419,7 +419,7 @@ void lcd_clear_viewport(void) /* Set a single pixel */ void lcd_drawpixel(int x, int y) { - if ( ((unsigned)x < (unsigned)lcd_current_viewport->width) + if ( ((unsigned)x < (unsigned)lcd_current_viewport->width) && ((unsigned)y < (unsigned)lcd_current_viewport->height) #if defined(HAVE_VIEWPORT_CLIP) && ((unsigned)x < (unsigned)LCD_WIDTH) @@ -494,7 +494,7 @@ void lcd_drawline(int x1, int y1, int x2, int y2) for (i = 0; i < numpixels; i++) { - if ( ((unsigned)x < (unsigned)lcd_current_viewport->width) + if ( ((unsigned)x < (unsigned)lcd_current_viewport->width) && ((unsigned)y < (unsigned)lcd_current_viewport->height) #if defined(HAVE_VIEWPORT_CLIP) && ((unsigned)x < (unsigned)LCD_WIDTH) @@ -534,12 +534,12 @@ void lcd_hline(int x1, int x2, int y) 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)) - return; + return; if (x1 < 0) x1 = 0; @@ -550,14 +550,14 @@ void lcd_hline(int x1, int x2, int 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 ********************/ /* nothing to draw? */ if (((unsigned)y >= (unsigned) LCD_HEIGHT) || (x1 >= LCD_WIDTH) || (x2 < 0)) - return; - + return; + /* clipping */ if (x1 < 0) x1 = 0; @@ -598,25 +598,25 @@ void lcd_vline(int x, int y1, int y2) /* nothing to draw? */ if (((unsigned)x >= (unsigned)lcd_current_viewport->width) || (y1 >= lcd_current_viewport->height) || (y2 < 0)) - return; - + return; + if (y1 < 0) y1 = 0; if (y2 >= lcd_current_viewport->height) y2 = lcd_current_viewport->height-1; - + /* adjust for viewport */ y1 += lcd_current_viewport->y; y2 += lcd_current_viewport->y; x += lcd_current_viewport->x; - + #if defined(HAVE_VIEWPORT_CLIP) /********************* Viewport on screen clipping ********************/ /* nothing to draw? */ - if (( (unsigned) x >= (unsigned)LCD_WIDTH) || (y1 >= LCD_HEIGHT) + if (( (unsigned) x >= (unsigned)LCD_WIDTH) || (y1 >= LCD_HEIGHT) || (y2 < 0)) return; - + /* clipping */ if (y1 < 0) y1 = 0; @@ -687,18 +687,18 @@ void lcd_fillrect(int x, int y, int width, int height) 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; - + #if defined(HAVE_VIEWPORT_CLIP) /********************* Viewport on screen clipping ********************/ /* nothing to draw? */ - if ((x >= LCD_WIDTH) || (y >= LCD_HEIGHT) + if ((x >= LCD_WIDTH) || (y >= LCD_HEIGHT) || (x + width <= 0) || (y + height <= 0)) return; - + /* clip image in viewport in screen */ if (x < 0) { @@ -817,14 +817,14 @@ void ICODE_ATTR lcd_mono_bitmap_part(const unsigned char *src, int src_x, /* adjust for viewport */ x += lcd_current_viewport->x; y += lcd_current_viewport->y; - + #if defined(HAVE_VIEWPORT_CLIP) /********************* Viewport on screen clipping ********************/ /* nothing to draw? */ - if ((x >= LCD_WIDTH) || (y >= LCD_HEIGHT) + if ((x >= LCD_WIDTH) || (y >= LCD_HEIGHT) || (x + width <= 0) || (y + height <= 0)) return; - + /* clip image in viewport in screen */ if (x < 0) { @@ -856,7 +856,7 @@ void ICODE_ATTR lcd_mono_bitmap_part(const unsigned char *src, int src_x, mask_bottom = 0xFFFFu >> (2 * (~ny & 7)); bfunc = lcd_blockfuncs[lcd_current_viewport->drawmode]; - + if (shift == 0) { unsigned dmask1, dmask2, data; @@ -868,7 +868,7 @@ void ICODE_ATTR lcd_mono_bitmap_part(const unsigned char *src, int src_x, { const unsigned char *src_row = src; fb_data *dst_row = dst + stride_dst; - + dst_end = dst_row + width; if (dmask1 != 0) @@ -895,7 +895,7 @@ void ICODE_ATTR lcd_mono_bitmap_part(const unsigned char *src, int src_x, /* & 0xFFu is unnecessary here - dmask1 can't exceed that*/ dmask2 &= (mask_bottom >> 8); dst_end = dst + width; - + if (dmask1 != 0) { if (dmask2 != 0) @@ -931,8 +931,8 @@ void ICODE_ATTR lcd_mono_bitmap_part(const unsigned char *src, int src_x, fb_data *dst_col = dst++; unsigned mask_col = mask; unsigned data = 0; - - for (y = ny; y >= 8; y -= 8) + + for (y = ny; y >= 8; y -= 8) { data |= *src_col << shift; @@ -995,7 +995,7 @@ void ICODE_ATTR lcd_bitmap_part(const fb_data *src, int src_x, int src_y, 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) { width += x; @@ -1016,14 +1016,14 @@ void ICODE_ATTR lcd_bitmap_part(const fb_data *src, int src_x, int src_y, /* adjust for viewport */ x += lcd_current_viewport->x; y += lcd_current_viewport->y; - + #if defined(HAVE_VIEWPORT_CLIP) /********************* Viewport on screen clipping ********************/ /* nothing to draw? */ - if ((x >= LCD_WIDTH) || (y >= LCD_HEIGHT) + if ((x >= LCD_WIDTH) || (y >= LCD_HEIGHT) || (x + width <= 0) || (y + height <= 0)) return; - + /* clip image in viewport in screen */ if (x < 0) { @@ -1052,7 +1052,7 @@ void ICODE_ATTR lcd_bitmap_part(const fb_data *src, int src_x, int src_y, mask = 0xFFu << (2 * (shift + src_y)); mask_bottom = 0xFFu >> (2 * (~ny & 3)); - + if (shift == 0) { for (; ny >= 4; ny -= 4) @@ -1063,9 +1063,9 @@ void ICODE_ATTR lcd_bitmap_part(const fb_data *src, int src_x, int src_y, { const fb_data *src_row = src; fb_data *dst_row = dst; - + dst_end = dst_row + width; - do + do setblock(dst_row++, mask, *src_row++); while (dst_row < dst_end); } @@ -1095,7 +1095,7 @@ void ICODE_ATTR lcd_bitmap_part(const fb_data *src, int src_x, int src_y, fb_data *dst_col = dst++; unsigned mask_col = mask; unsigned data = 0; - + for (y = ny; y >= 4; y -= 4) { data |= *src_col << shift; diff --git a/firmware/drivers/lcd-2bit-vi.c b/firmware/drivers/lcd-2bit-vi.c index 035e8b6d0d..c09bbce2e0 100644 --- a/firmware/drivers/lcd-2bit-vi.c +++ b/firmware/drivers/lcd-2bit-vi.c @@ -437,7 +437,7 @@ void LCDFN(clear_viewport)(void) lastmode = CURRENT_VP->drawmode; /* Invert the INVERSEVID bit and set basic mode to SOLID */ - CURRENT_VP->drawmode = (~lastmode & DRMODE_INVERSEVID) | + CURRENT_VP->drawmode = (~lastmode & DRMODE_INVERSEVID) | DRMODE_SOLID; LCDFN(fillrect)(0, 0, CURRENT_VP->width, CURRENT_VP->height); @@ -452,7 +452,7 @@ void LCDFN(clear_viewport)(void) /* Set a single pixel */ void LCDFN(drawpixel)(int x, int y) { - if ( ((unsigned)x < (unsigned)CURRENT_VP->width) + if ( ((unsigned)x < (unsigned)CURRENT_VP->width) && ((unsigned)y < (unsigned)CURRENT_VP->height) #if defined(HAVE_VIEWPORT_CLIP) && ((unsigned)x < (unsigned)LCDM(WIDTH)) @@ -527,7 +527,7 @@ void LCDFN(drawline)(int x1, int y1, int x2, int y2) for (i = 0; i < numpixels; i++) { - if ( ((unsigned)x < (unsigned)CURRENT_VP->width) + if ( ((unsigned)x < (unsigned)CURRENT_VP->width) && ((unsigned)y < (unsigned)CURRENT_VP->height) #if defined(HAVE_VIEWPORT_CLIP) && ((unsigned)x < (unsigned)LCDM(WIDTH)) @@ -567,13 +567,13 @@ void LCDFN(hline)(int x1, int x2, int y) x1 = x2; x2 = x; } - + /******************** In viewport clipping **********************/ /* nothing to draw? */ if (((unsigned)y >= (unsigned)CURRENT_VP->height) || (x1 >= CURRENT_VP->width) || (x2 < 0)) return; - + if (x1 < 0) x1 = 0; if (x2 >= CURRENT_VP->width) @@ -589,8 +589,8 @@ void LCDFN(hline)(int x1, int x2, int y) /* nothing to draw? */ if (((unsigned)y >= (unsigned) LCDM(HEIGHT)) || (x1 >= LCDM(WIDTH)) || (x2 < 0)) - return; - + return; + /* clipping */ if (x1 < 0) x1 = 0; @@ -642,14 +642,14 @@ void LCDFN(vline)(int x, int y1, int y2) y1 += CURRENT_VP->y; y2 += CURRENT_VP->y; x += CURRENT_VP->x; - + #if defined(HAVE_VIEWPORT_CLIP) /********************* Viewport on screen clipping ********************/ /* nothing to draw? */ - if (( (unsigned) x >= (unsigned)LCDM(WIDTH)) || (y1 >= LCDM(HEIGHT)) + if (( (unsigned) x >= (unsigned)LCDM(WIDTH)) || (y1 >= LCDM(HEIGHT)) || (y2 < 0)) return; - + /* clipping */ if (y1 < 0) y1 = 0; @@ -707,7 +707,7 @@ void LCDFN(fillrect)(int x, int y, int width, int height) if ((width <= 0) || (height <= 0) || (x >= CURRENT_VP->width) || (y >= CURRENT_VP->height) || (x + width <= 0) || (y + height <= 0)) return; - + if (x < 0) { width += x; @@ -726,14 +726,14 @@ void LCDFN(fillrect)(int x, int y, int width, int height) /* adjust for viewport */ x += CURRENT_VP->x; y += CURRENT_VP->y; - + #if defined(HAVE_VIEWPORT_CLIP) /********************* Viewport on screen clipping ********************/ /* nothing to draw? */ - if ((x >= LCDM(WIDTH)) || (y >= LCDM(HEIGHT)) + if ((x >= LCDM(WIDTH)) || (y >= LCDM(HEIGHT)) || (x + width <= 0) || (y + height <= 0)) return; - + /* clip image in viewport in screen */ if (x < 0) { @@ -855,14 +855,14 @@ void ICODE_ATTR LCDFN(mono_bitmap_part)(const unsigned char *src, int src_x, /* adjust for viewport */ x += CURRENT_VP->x; y += CURRENT_VP->y; - + #if defined(HAVE_VIEWPORT_CLIP) /********************* Viewport on screen clipping ********************/ /* nothing to draw? */ - if ((x >= LCDM(WIDTH)) || (y >= LCDM(HEIGHT)) + if ((x >= LCDM(WIDTH)) || (y >= LCDM(HEIGHT)) || (x + width <= 0) || (y + height <= 0)) return; - + /* clip image in viewport in screen */ if (x < 0) { @@ -1029,10 +1029,10 @@ void ICODE_ATTR LCDFN(bitmap_part)(const FBFN(data) *src, int src_x, #if defined(HAVE_VIEWPORT_CLIP) /********************* Viewport on screen clipping ********************/ /* nothing to draw? */ - if ((x >= LCDM(WIDTH)) || (y >= LCDM(HEIGHT)) + if ((x >= LCDM(WIDTH)) || (y >= LCDM(HEIGHT)) || (x + width <= 0) || (y + height <= 0)) return; - + /* clip image in viewport in screen */ if (x < 0) { diff --git a/firmware/drivers/lcd-bitmap-common.c b/firmware/drivers/lcd-bitmap-common.c index 94829b5d0c..9cd3ba3774 100644 --- a/firmware/drivers/lcd-bitmap-common.c +++ b/firmware/drivers/lcd-bitmap-common.c @@ -613,7 +613,7 @@ void LCDFN(nine_segment_bmp)(const struct bitmap* bm, int x, int y, LCDFN(bmp_part)(bm, src_x, src_y_top, dst_x, dst_y_top, w, seg_h); LCDFN(bmp_part)(bm, src_x, src_y_btm, dst_x, dst_y_btm, w, seg_h); } - + /* left & right in a single loop */ src_y = corner_h; dst_y = corner_h; diff --git a/firmware/drivers/lcd-color-common.c b/firmware/drivers/lcd-color-common.c index 60e95a25ca..3abc671770 100644 --- a/firmware/drivers/lcd-color-common.c +++ b/firmware/drivers/lcd-color-common.c @@ -586,7 +586,7 @@ void lcd_gradient_fillrect_part(int x, int y, int width, int height, int x1, x2; x1 = x; x2 = x + width; - + if (height == 0) return; step_mul = (1 << 16) / src_height; diff --git a/firmware/export/config/mrobe500.h b/firmware/export/config/mrobe500.h index 57d13cf1ab..a7d72f76ac 100644 --- a/firmware/export/config/mrobe500.h +++ b/firmware/export/config/mrobe500.h @@ -81,7 +81,7 @@ #define _RESOLUTION _LCD_RES_VGA #define _ORIENTATION _LCD_LANDSCAPE -#if _RESOLUTION == _LCD_RES_VGA +#if _RESOLUTION == _LCD_RES_VGA #define LCD_NATIVE_WIDTH 480 #define LCD_NATIVE_HEIGHT 640 #define LCD_DPI 216 diff --git a/firmware/export/lcd.h b/firmware/export/lcd.h index af734da913..f5a3b3f1f4 100644 --- a/firmware/export/lcd.h +++ b/firmware/export/lcd.h @@ -34,7 +34,7 @@ * Stride describes the amount that you need to increment to get to the next * line. For screens that have the pixels in contiguous horizontal strips * stride should be equal to the image width. - * + * * For example, if the screen pixels are layed out as follows: * * width0 width1 width2 widthX-1 @@ -57,9 +57,9 @@ * height2 | pixel2 * | | | * \|/ | \|/ - * heightY-1 | pixelY-1 + * heightY-1 | pixelY-1 * - * then you would need to add Y pixels to get to the next line (the next + * then you would need to add Y pixels to get to the next line (the next * line in this case is from width0 to width1). * * The remote might have a different stride than the main screen so the screen -- cgit v1.2.3