From 4f9e4ddb9914ff73259f006a4cbcf520656f06e0 Mon Sep 17 00:00:00 2001 From: Aidan MacDonald Date: Mon, 26 Sep 2022 09:23:18 +0100 Subject: lcd: Consolidate drawpixel, drawline, and drawrect functions All three functions are nearly identical regardless of the LCD pixel format. Consolidate them into a generic version in lcd-bitmap-common.c. Change-Id: Iab13429ea27ea2b0150b9004535bd27d4a4121a0 --- firmware/drivers/lcd-2bit-vert.c | 111 --------------------------------------- 1 file changed, 111 deletions(-) (limited to 'firmware/drivers/lcd-2bit-vert.c') diff --git a/firmware/drivers/lcd-2bit-vert.c b/firmware/drivers/lcd-2bit-vert.c index 5fd86c409a..9e1eb0ed37 100644 --- a/firmware/drivers/lcd-2bit-vert.c +++ b/firmware/drivers/lcd-2bit-vert.c @@ -419,102 +419,6 @@ void lcd_clear_viewport(void) lcd_current_viewport->flags &= ~(VP_FLAG_VP_SET_CLEAN); } -/* Set a single pixel */ -void lcd_drawpixel(int x, int y) -{ - if (lcd_clip_viewport_pixel(&x, &y)) - lcd_pixelfuncs[lcd_current_viewport->drawmode](x, y); -} - -/* Draw a line */ -void lcd_drawline(int x1, int y1, int x2, int y2) -{ - int numpixels; - int i; - int deltax, deltay; - int d, dinc1, dinc2; - int x, xinc1, xinc2; - int y, yinc1, yinc2; - int x_vp, y_vp, w_vp, h_vp; - lcd_pixelfunc_type *pfunc = lcd_pixelfuncs[lcd_current_viewport->drawmode]; - - deltax = abs(x2 - x1); - if (deltax == 0) - { - /* DEBUGF("lcd_drawline() called for vertical line - optimisation.\n"); */ - lcd_vline(x1, y1, y2); - return; - } - deltay = abs(y2 - y1); - if (deltay == 0) - { - /* DEBUGF("lcd_drawline() called for horizontal line - optimisation.\n"); */ - lcd_hline(x1, x2, y1); - return; - } - xinc2 = 1; - yinc2 = 1; - - if (deltax >= deltay) - { - numpixels = deltax; - d = 2 * deltay - deltax; - dinc1 = deltay * 2; - dinc2 = (deltay - deltax) * 2; - xinc1 = 1; - yinc1 = 0; - } - else - { - numpixels = deltay; - d = 2 * deltax - deltay; - dinc1 = deltax * 2; - dinc2 = (deltax - deltay) * 2; - xinc1 = 0; - yinc1 = 1; - } - numpixels++; /* include endpoints */ - - if (x1 > x2) - { - xinc1 = -xinc1; - xinc2 = -xinc2; - } - - if (y1 > y2) - { - yinc1 = -yinc1; - yinc2 = -yinc2; - } - - x = x1; - y = y1; - - x_vp = lcd_current_viewport->x; - y_vp = lcd_current_viewport->y; - w_vp = lcd_current_viewport->width; - h_vp = lcd_current_viewport->height; - - for (i = 0; i < numpixels; i++) - { - if (x >= 0 && y >= 0 && x < w_vp && y < h_vp) - pfunc(x + x_vp, y + y_vp); - - if (d < 0) - { - d += dinc1; - x += xinc1; - y += yinc1; - } - else - { - d += dinc2; - x += xinc2; - y += yinc2; - } - } -} - /* Draw a horizontal line (optimised) */ void lcd_hline(int x1, int x2, int y) { @@ -567,21 +471,6 @@ void lcd_vline(int x, int y1, int y2) bfunc(dst, mask, 0xFFu); } -/* Draw a rectangular box */ -void lcd_drawrect(int x, int y, int width, int height) -{ - if ((width <= 0) || (height <= 0)) - return; - - int x2 = x + width - 1; - int y2 = y + height - 1; - - lcd_vline(x, y, y2); - lcd_vline(x2, y, y2); - lcd_hline(x, x2, y); - lcd_hline(x, x2, y2); -} - /* Fill a rectangular area */ void lcd_fillrect(int x, int y, int width, int height) { -- cgit v1.2.3