summaryrefslogtreecommitdiffstats
path: root/firmware/drivers/lcd-color-common.c
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/drivers/lcd-color-common.c')
-rw-r--r--firmware/drivers/lcd-color-common.c18
1 files changed, 13 insertions, 5 deletions
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)
{