summaryrefslogtreecommitdiffstats
path: root/firmware/export/lcd.h
diff options
context:
space:
mode:
authorWilliam Wilgus <wilgus.william@gmail.com>2020-10-31 00:18:57 -0400
committerWilliam Wilgus <wilgus.william@gmail.com>2020-10-31 01:11:30 -0400
commit60f642ba4f6a9bf2d976f133b85b8f6a7502c14c (patch)
treea37547c0972899968a4a2ff148ded098d40f0f36 /firmware/export/lcd.h
parent202f9df0c1e6132631e9e1372d50fe8dc8e87f20 (diff)
downloadrockbox-60f642ba4f6a9bf2d976f133b85b8f6a7502c14c.tar.gz
rockbox-60f642ba4f6a9bf2d976f133b85b8f6a7502c14c.zip
lcd_framebuffer bugfixes, sanity checks
several issues I saw that could pontentially cause problems scroll engine doesn't take text height into account when checking bounds NBELEMS was one whole row too large hopefully I got them right this time Change-Id: If303da8320429c3964fc675351cb088d46303745
Diffstat (limited to 'firmware/export/lcd.h')
-rw-r--r--firmware/export/lcd.h14
1 files changed, 7 insertions, 7 deletions
diff --git a/firmware/export/lcd.h b/firmware/export/lcd.h
index f5a3b3f1f4..ffaf1a63d2 100644
--- a/firmware/export/lcd.h
+++ b/firmware/export/lcd.h
@@ -456,26 +456,26 @@ typedef void lcd_blockfunc_type(fb_data *address, unsigned mask, unsigned bits);
#if LCD_PIXELFORMAT == HORIZONTAL_PACKING
#define LCD_FBSTRIDE(w, h) ((w+7)/8)
#define LCD_FBWIDTH LCD_FBSTRIDE(LCD_WIDTH, LCD_HEIGHT)
-#define LCD_NBELEMS(w, h) (((h*LCD_FBSTRIDE(w, h)) + w) / sizeof(fb_data))
+#define LCD_NBELEMS(w, h) ((((h-1)*LCD_FBSTRIDE(w, h)) + w) / sizeof(fb_data))
#else /* LCD_PIXELFORMAT == VERTICAL_PACKING */
#define LCD_FBSTRIDE(w, h) ((h+7)/8)
#define LCD_FBHEIGHT LCD_FBSTRIDE(LCD_WIDTH, LCD_HEIGHT)
-#define LCD_NBELEMS(w, h) (((w*LCD_FBSTRIDE(w, h)) + h) / sizeof(fb_data))
+#define LCD_NBELEMS(w, h) ((((w-1)*LCD_FBSTRIDE(w, h)) + h) / sizeof(fb_data))
#endif /* LCD_PIXELFORMAT */
#elif LCD_DEPTH == 2
#if LCD_PIXELFORMAT == HORIZONTAL_PACKING
#define LCD_FBSTRIDE(w, h) ((w+3)>>2)
#define LCD_NATIVE_STRIDE(s) LCD_FBSTRIDE(s, s)
#define LCD_FBWIDTH LCD_FBSTRIDE(LCD_WIDTH, LCD_HEIGHT)
-#define LCD_NBELEMS(w, h) (((h*LCD_FBSTRIDE(w, h)) + w) / sizeof(fb_data))
+#define LCD_NBELEMS(w, h) ((((h-1)*LCD_FBSTRIDE(w, h)) + w) / sizeof(fb_data))
#elif LCD_PIXELFORMAT == VERTICAL_PACKING
#define LCD_FBSTRIDE(w, h) ((h+3)/4)
#define LCD_FBHEIGHT LCD_FBSTRIDE(LCD_WIDTH, LCD_HEIGHT)
-#define LCD_NBELEMS(w, h) (((w*LCD_FBSTRIDE(w, h)) + h) / sizeof(fb_data))
+#define LCD_NBELEMS(w, h) ((((w-1)*LCD_FBSTRIDE(w, h)) + h) / sizeof(fb_data))
#elif LCD_PIXELFORMAT == VERTICAL_INTERLEAVED
#define LCD_FBSTRIDE(w, h) ((h+7)/8)
#define LCD_FBHEIGHT LCD_FBSTRIDE(LCD_WIDTH, LCD_HEIGHT)
-#define LCD_NBELEMS(w, h) (((w*LCD_FBSTRIDE(w, h)) + h) / sizeof(fb_data))
+#define LCD_NBELEMS(w, h) ((((w-1)*LCD_FBSTRIDE(w, h)) + h) / sizeof(fb_data))
#endif /* LCD_PIXELFORMAT */
#endif /* LCD_DEPTH */
/* Set defaults if not defined different yet. The defaults apply to both
@@ -494,9 +494,9 @@ typedef void lcd_blockfunc_type(fb_data *address, unsigned mask, unsigned bits);
#ifndef LCD_NBELEMS
#if defined(LCD_STRIDEFORMAT) && LCD_STRIDEFORMAT == VERTICAL_STRIDE
-#define LCD_NBELEMS(w, h) ((w*STRIDE_MAIN(w, h)) + h)
+#define LCD_NBELEMS(w, h) (((w-1)*STRIDE_MAIN(w, h)) + h)
#else
-#define LCD_NBELEMS(w, h) ((h*STRIDE_MAIN(w, h)) + w)
+#define LCD_NBELEMS(w, h) (((h-1)*STRIDE_MAIN(w, h)) + w)
#endif
#define LCD_FBSTRIDE(w, h) STRIDE_MAIN(w, h)
#endif