diff options
author | Jens Arnold <amiconn@rockbox.org> | 2006-02-22 21:41:44 +0000 |
---|---|---|
committer | Jens Arnold <amiconn@rockbox.org> | 2006-02-22 21:41:44 +0000 |
commit | e6dac9130d62688d7b547b6a7fcdb9b956d9bb04 (patch) | |
tree | 0996daa908f5f87b13e91836916c324de546ab16 | |
parent | 6922e80c9e38c515ed6254d927d10431e1009193 (diff) | |
download | rockbox-e6dac9130d62688d7b547b6a7fcdb9b956d9bb04.tar.gz rockbox-e6dac9130d62688d7b547b6a7fcdb9b956d9bb04.zip |
Made LCD_RGBPACK() macro more efficient when used with variable arguments.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@8789 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r-- | firmware/export/lcd.h | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/firmware/export/lcd.h b/firmware/export/lcd.h index 87dda891b9..ba0e216990 100644 --- a/firmware/export/lcd.h +++ b/firmware/export/lcd.h | |||
@@ -150,9 +150,11 @@ typedef void lcd_fastpixelfunc_type(fb_data *address); | |||
150 | #define LCD_MAX_RED 31 | 150 | #define LCD_MAX_RED 31 |
151 | #define LCD_MAX_GREEN 63 | 151 | #define LCD_MAX_GREEN 63 |
152 | #define LCD_MAX_BLUE 31 | 152 | #define LCD_MAX_BLUE 31 |
153 | #define _RGBPACK(r, g, b) ( ((((r) * 31 + 127) / 255) << 11) \ | 153 | #define _RGBPACK(r, g, b) ( ((((r) * (31*257) + (127*257)) >> 16) << 11) \ |
154 | |((((g) * 63 + 127) / 255) << 5) \ | 154 | |((((g) * (63*257) + (127*257)) >> 16) << 5) \ |
155 | | (((b) * 31 + 127) / 255)) | 155 | | (((b) * (31*257) + (127*257)) >> 16)) |
156 | /* Note: ((x * 257) >> 16) almost equals (x / 255), but it avoids the division, | ||
157 | * so it's faster when the macro is used for variable r, g, b in the source. */ | ||
156 | #if (LCD_PIXELFORMAT == RGB565SWAPPED) | 158 | #if (LCD_PIXELFORMAT == RGB565SWAPPED) |
157 | #define LCD_RGBPACK(r, g, b) ( ((_RGBPACK((r), (g), (b)) & 0xff00) >> 8) \ | 159 | #define LCD_RGBPACK(r, g, b) ( ((_RGBPACK((r), (g), (b)) & 0xff00) >> 8) \ |
158 | |((_RGBPACK((r), (g), (b)) & 0x00ff) << 8)) | 160 | |((_RGBPACK((r), (g), (b)) & 0x00ff) << 8)) |
@@ -163,9 +165,9 @@ typedef void lcd_fastpixelfunc_type(fb_data *address); | |||
163 | #define LCD_MAX_RED 63 | 165 | #define LCD_MAX_RED 63 |
164 | #define LCD_MAX_GREEN 63 | 166 | #define LCD_MAX_GREEN 63 |
165 | #define LCD_MAX_BLUE 63 | 167 | #define LCD_MAX_BLUE 63 |
166 | #define LCD_RGBPACK(r, g, b) ( ((((r) * 63 + 127) / 255) << 12) \ | 168 | #define LCD_RGBPACK(r, g, b) ( ((((r) * (63*257) + (127*257)) >> 16) << 12) \ |
167 | |((((g) * 63 + 127) / 255) << 6) \ | 169 | |((((g) * (63*257) + (127*257)) >> 16) << 6) \ |
168 | | (((b) * 63 + 127) / 255)) | 170 | | (((b) * (63*257) + (127*257)) >> 16)) |
169 | #else | 171 | #else |
170 | /* other colour depths */ | 172 | /* other colour depths */ |
171 | #endif | 173 | #endif |