From cfeeb7889d5346e2abaf9b198375df62c58b098f Mon Sep 17 00:00:00 2001 From: William Wilgus Date: Mon, 21 Mar 2022 18:54:52 -0400 Subject: Lcd save function pointer to frame buffer get_address_fn before loops Calling multiple levels of indirection in a loop slows things down Really these need to be rewritten to take a start and end address like most of the rest of the codebase But this is safer without having test hardware in hand Change-Id: Idae7b92ee779d020ed7fcc9334e2d5a9c710e64d --- firmware/drivers/lcd-color-common.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) (limited to 'firmware/drivers/lcd-color-common.c') diff --git a/firmware/drivers/lcd-color-common.c b/firmware/drivers/lcd-color-common.c index 935f4e59dd..20d8c65e21 100644 --- a/firmware/drivers/lcd-color-common.c +++ b/firmware/drivers/lcd-color-common.c @@ -214,6 +214,7 @@ void lcd_drawline(int x1, int y1, int x2, int y2) int d, dinc1, dinc2; int x, xinc1, xinc2; int y, yinc1, yinc2; + int x_vp, y_vp, w_vp, h_vp; lcd_fastpixelfunc_type *pfunc = lcd_fastpixelfuncs[lcd_current_viewport->drawmode]; deltay = abs(y2 - y1); @@ -268,16 +269,23 @@ void lcd_drawline(int x1, int y1, int x2, int y2) x = x1; y = y1; + void *(*fbaddr)(int x, int y) = FB_CURRENTVP_BUFFER->get_address_fn; + 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 ( ((unsigned)x < (unsigned)lcd_current_viewport->width) - && ((unsigned)y < (unsigned)lcd_current_viewport->height) + if ((x >= 0 && y >= 0) + && (x < w_vp) + && (y < h_vp) #if defined(HAVE_VIEWPORT_CLIP) - && ((unsigned)x < (unsigned)LCD_WIDTH) - && ((unsigned)y < (unsigned)LCD_HEIGHT) + && (x < LCD_WIDTH) + && (y < LCD_HEIGHT) #endif ) - pfunc(FBADDR(x + lcd_current_viewport->x, y + lcd_current_viewport->y)); + pfunc(fbaddr( x + x_vp, y + y_vp)); if (d < 0) { -- cgit v1.2.3