summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWilliam Wilgus <wilgus.william@gmail.com>2024-04-02 10:42:27 -0400
committerWilliam Wilgus <me.theuser@yahoo.com>2024-04-02 19:28:19 -0400
commit957920e9157bde1fc4c0bd3127746038679173d6 (patch)
treec4ea4e50dfa21e37afd9f3e8415f06cacf2ed949
parent5641e8140a88c7fb5b43daa64d097ec24d654275 (diff)
downloadrockbox-957920e915.tar.gz
rockbox-957920e915.zip
lcd-bitmap-common 16-bit devices remove branch in character loop
do the depth check outside of the loop make a helper function to have same fn signatures between mono_bitmap_part & lcd_alpha_bitmap_part Change-Id: I42fab535133607f937430357dab7a20fa97805a8
-rw-r--r--firmware/drivers/lcd-bitmap-common.c57
1 files changed, 35 insertions, 22 deletions
diff --git a/firmware/drivers/lcd-bitmap-common.c b/firmware/drivers/lcd-bitmap-common.c
index 75d31e3453..5c2c23a9cf 100644
--- a/firmware/drivers/lcd-bitmap-common.c
+++ b/firmware/drivers/lcd-bitmap-common.c
@@ -374,6 +374,13 @@ void LCDFN(update_viewport_rect)(int x, int y, int width, int height)
LCDFN(update_rect)(vp->x + x, vp->y + y, width, height);
}
+/* helper to align function signatures between mono_bitmap & alpha_bitmap_part */
+static void LCDFN(mono_bmp_part_helper)(const unsigned char *src, int src_x,
+ int src_y, int stride, int x, int y, int width, int height)
+{
+ LCDFN(mono_bitmap_part)(src, src_x, src_y, stride, x, y, width, height);
+}
+
#ifndef BOOTLOADER
/* put a string at a given pixel position, skipping first ofs pixel columns */
static void LCDFN(putsxyofs)(int x, int y, int ofs, const unsigned char *str)
@@ -404,6 +411,15 @@ static void LCDFN(putsxyofs)(int x, int y, int ofs, const unsigned char *str)
}
}
+ void (*bmp_part_fn)(const unsigned char *src, int src_x, int src_y,
+ int stride, int x, int y, int width, int height);
+#if defined(MAIN_LCD) && defined(HAVE_LCD_COLOR)
+ if (pf->depth)
+ bmp_part_fn = lcd_alpha_bitmap_part;
+ else
+#endif
+ bmp_part_fn = LCDFN(mono_bmp_part_helper);
+
rtl_next_non_diac_width = 0;
last_non_diacritic_width = 0;
/* Mark diacritic and rtl flags for each character */
@@ -411,7 +427,7 @@ static void LCDFN(putsxyofs)(int x, int y, int ofs, const unsigned char *str)
{
bool is_rtl, is_diac;
const unsigned char *bits;
- int width, base_width, drawmode = 0, base_ofs = 0;
+ int width, base_width, base_ofs = 0;
const unsigned short next_ch = ucs[1];
if (x >= LCDFN(current_viewport)->width)
@@ -459,6 +475,8 @@ static void LCDFN(putsxyofs)(int x, int y, int ofs, const unsigned char *str)
continue;
}
+ bits = font_get_bits(pf, *ucs);
+
if (is_diac)
{
/* XXX: Suggested by amiconn:
@@ -475,25 +493,17 @@ static void LCDFN(putsxyofs)(int x, int y, int ofs, const unsigned char *str)
* buffer using OR, and then draw the final bitmap instead of the
* chars, without touching the drawmode
**/
- drawmode = LCDFN(current_viewport)->drawmode;
+ int drawmode = LCDFN(current_viewport)->drawmode;
LCDFN(current_viewport)->drawmode = DRMODE_FG;
-
base_ofs = (base_width - width) / 2;
- }
- bits = font_get_bits(pf, *ucs);
+ bmp_part_fn(bits, ofs, 0, width, x + base_ofs, y, width - ofs, pf->height);
-#if defined(MAIN_LCD) && defined(HAVE_LCD_COLOR)
- if (pf->depth)
- lcd_alpha_bitmap_part(bits, ofs, 0, width, x + base_ofs, y,
- width - ofs, pf->height);
+ LCDFN(current_viewport)->drawmode = drawmode;
+ }
else
-#endif
- LCDFN(mono_bitmap_part)(bits, ofs, 0, width, x + base_ofs,
- y, width - ofs, pf->height);
- if (is_diac)
{
- LCDFN(current_viewport)->drawmode = drawmode;
+ bmp_part_fn(bits, ofs, 0, width, x + base_ofs, y, width - ofs, pf->height);
}
if (next_ch)
@@ -544,6 +554,15 @@ static void LCDFN(putsxyofs)(int x, int y, int ofs, const unsigned char *str)
}
}
+ void (*bmp_part_fn)(const unsigned char *src, int src_x, int src_y,
+ int stride, int x, int y, int width, int height);
+#if defined(MAIN_LCD) && defined(HAVE_LCD_COLOR) && !defined(DISABLE_ALPHA_BITMAP)
+ if (pf->depth)
+ bmp_part_fn = lcd_alpha_bitmap_part;
+ else
+#endif
+ bmp_part_fn = mono_bmp_part_helper;
+
/* allow utf but no diacritics or rtl lang */
for (ucs = bidi_l2v(str, 1); *ucs; ucs++)
{
@@ -563,14 +582,8 @@ static void LCDFN(putsxyofs)(int x, int y, int ofs, const unsigned char *str)
bits = font_get_bits(pf, *ucs);
-#if defined(MAIN_LCD) && defined(HAVE_LCD_COLOR) && !defined(DISABLE_ALPHA_BITMAP)
- if (pf->depth)
- lcd_alpha_bitmap_part(bits, ofs, 0, width, x, y,
- width - ofs, pf->height);
- else
-#endif
- LCDFN(mono_bitmap_part)(bits, ofs, 0, width, x,
- y, width - ofs, pf->height);
+ bmp_part_fn(bits, ofs, 0, width, x, y, width - ofs, pf->height);
+
if (next_ch)
{
x += width - ofs;