summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Martitz <kugel@rockbox.org>2013-02-08 23:41:51 +0100
committerThomas Martitz <kugel@rockbox.org>2013-02-12 10:34:49 +0100
commit68d3ce2acd44b97516f56c689bffa87bbdfc74c7 (patch)
tree61d45b82c0a6881fa229b6b98f76f3cada81f557
parent1430b07894d1f7c11b907d8b3e42a91fccc5139b (diff)
downloadrockbox-68d3ce2acd44b97516f56c689bffa87bbdfc74c7.zip
rockbox-68d3ce2acd44b97516f56c689bffa87bbdfc74c7.tar.gz
rockbox-68d3ce2acd44b97516f56c689bffa87bbdfc74c7.tar.bz2
rockbox-68d3ce2acd44b97516f56c689bffa87bbdfc74c7.tar.xz
bitmap drawing: use temp vars to help gcc opmize loops.
By saving current_vp fields into temp vars just before the loop gcc can put them into registers. This yields ~15% speedup for drawing anti-aliased fonts. Change-Id: I4c0c9f5ff7a7f084e2eb08c4ed874176b1f9832c
-rw-r--r--firmware/drivers/lcd-16bit-common.c20
1 files changed, 10 insertions, 10 deletions
diff --git a/firmware/drivers/lcd-16bit-common.c b/firmware/drivers/lcd-16bit-common.c
index 39edda5..7f6a517 100644
--- a/firmware/drivers/lcd-16bit-common.c
+++ b/firmware/drivers/lcd-16bit-common.c
@@ -853,12 +853,6 @@ static inline unsigned blend_two_colors(unsigned c1, unsigned c2, unsigned a)
#endif
}
-/* Blend the given color with the value from the alpha_color_lookup table */
-static inline unsigned blend_color(unsigned c, unsigned a)
-{
- return blend_two_colors(c, current_vp->fg_pattern, a);
-}
-
/* Blend an image with an alpha channel
* if image is NULL, drawing will happen according to the drawmode
* src is the alpha channel (4bit per pixel) */
@@ -979,7 +973,10 @@ static void ICODE_ATTR lcd_alpha_bitmap_part_mix(const fb_data* image,
/* go through the rows and update each pixel */
do
{
- unsigned bg;
+ /* saving current_vp->fg/bg_pattern and lcd_backdrop_offset into these
+ * temp vars just before the loop helps gcc to opimize the loop better
+ * (testing showed ~15% speedup) */
+ unsigned fg, bg;
uintptr_t bo;
col = width;
dst = dst_row;
@@ -1053,9 +1050,10 @@ static void ICODE_ATTR lcd_alpha_bitmap_part_mix(const fb_data* image,
while (--col);
break;
case DRMODE_FG:
+ fg = current_vp->fg_pattern;
do
{
- *dst = blend_color(*dst, data & ALPHA_COLOR_LOOKUP_SIZE );
+ *dst = blend_two_colors(*dst, fg, data & ALPHA_COLOR_LOOKUP_SIZE );
dst += COL_INC;
UPDATE_SRC_ALPHA;
}
@@ -1063,10 +1061,11 @@ static void ICODE_ATTR lcd_alpha_bitmap_part_mix(const fb_data* image,
break;
case DRMODE_SOLID|DRMODE_INT_MOD:
bo = lcd_backdrop_offset;
+ fg = current_vp->fg_pattern;
do
{
fb_data *c = (fb_data *)((uintptr_t)dst + bo);
- *dst = blend_color(*c, data & ALPHA_COLOR_LOOKUP_SIZE );
+ *dst = blend_two_colors(*c, fg, data & ALPHA_COLOR_LOOKUP_SIZE );
dst += COL_INC;
UPDATE_SRC_ALPHA;
}
@@ -1074,9 +1073,10 @@ static void ICODE_ATTR lcd_alpha_bitmap_part_mix(const fb_data* image,
break;
case DRMODE_SOLID:
bg = current_vp->bg_pattern;
+ fg = current_vp->fg_pattern;
do
{
- *dst = blend_color(bg,
+ *dst = blend_two_colors(bg, fg,
data & ALPHA_COLOR_LOOKUP_SIZE );
dst += COL_INC;
UPDATE_SRC_ALPHA;