From 68d3ce2acd44b97516f56c689bffa87bbdfc74c7 Mon Sep 17 00:00:00 2001 From: Thomas Martitz Date: Fri, 8 Feb 2013 23:41:51 +0100 Subject: 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 --- firmware/drivers/lcd-16bit-common.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'firmware') diff --git a/firmware/drivers/lcd-16bit-common.c b/firmware/drivers/lcd-16bit-common.c index 39edda5939..7f6a51790d 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; -- cgit v1.2.3