From a1842c04f9cb73210d4cacde61a9e4b115050765 Mon Sep 17 00:00:00 2001 From: Thomas Martitz Date: Wed, 18 Jun 2014 07:15:00 +0200 Subject: lcd-24bit: Introduce a 24-bit mid-level LCD driver With LCD driver all calculation will be performed on RGB888 and the hardware/OS can display from our 24bit framebuffer. It is not yet as performance optimized as the existing drivers but should be good enough.The vast number of small changes is due to the fact that fb_data can be a struct type now, while most of the code expected a scalar type. lcd-as-memframe ASM code does not work with 24bit currently so the with 24bit it enforces the generic C code. All plugins are ported over. Except for rockpaint. It uses so much memory that it wouldnt fit into the 512k plugin buffer anymore (patches welcome). Change-Id: Ibb1964545028ce0d8ff9833ccc3ab66be3ee0754 --- apps/plugins/mpegplayer/mpegplayer.c | 32 +++++++++++++++++++++++++++----- 1 file changed, 27 insertions(+), 5 deletions(-) (limited to 'apps/plugins/mpegplayer/mpegplayer.c') diff --git a/apps/plugins/mpegplayer/mpegplayer.c b/apps/plugins/mpegplayer/mpegplayer.c index 2e84a870a9..97fe7d3f4c 100644 --- a/apps/plugins/mpegplayer/mpegplayer.c +++ b/apps/plugins/mpegplayer/mpegplayer.c @@ -702,7 +702,7 @@ static void draw_oriented_mono_bitmap_part(const unsigned char *src, dst_col--; if (data & 1) - *dst_col = fg_pattern; + *dst_col = FB_SCALARPACK(fg_pattern); #if 0 else *dst_col = bg_pattern; @@ -719,7 +719,7 @@ static void draw_oriented_mono_bitmap_part(const unsigned char *src, while (src < src_end); } -/* draw alpha bitmap for anti-alias font */ + #define ALPHA_COLOR_FONT_DEPTH 2 #define ALPHA_COLOR_LOOKUP_SHIFT (1 << ALPHA_COLOR_FONT_DEPTH) #define ALPHA_COLOR_LOOKUP_SIZE ((1 << ALPHA_COLOR_LOOKUP_SHIFT) - 1) @@ -727,6 +727,7 @@ static void draw_oriented_mono_bitmap_part(const unsigned char *src, #define ALPHA_COLOR_PIXEL_PER_WORD (32 >> ALPHA_COLOR_FONT_DEPTH) #ifdef CPU_ARM #define BLEND_INIT do {} while (0) +#define BLEND_FINISH do {} while(0) #define BLEND_START(acc, color, alpha) \ asm volatile("mul %0, %1, %2" : "=&r" (acc) : "r" (color), "r" (alpha)) #define BLEND_CONT(acc, color, alpha) \ @@ -734,13 +735,18 @@ static void draw_oriented_mono_bitmap_part(const unsigned char *src, #define BLEND_OUT(acc) do {} while (0) #elif defined(CPU_COLDFIRE) #define ALPHA_BITMAP_READ_WORDS -#define BLEND_INIT coldfire_set_macsr(EMAC_UNSIGNED) +#define BLEND_INIT \ + unsigned long _macsr = coldfire_get_macsr(); \ + coldfire_set_macsr(EMAC_UNSIGNED) +#define BLEND_FINISH \ + coldfire_set_macsr(_macsr) #define BLEND_START(acc, color, alpha) \ asm volatile("mac.l %0, %1, %%acc0" :: "%d" (color), "d" (alpha)) #define BLEND_CONT BLEND_START #define BLEND_OUT(acc) asm volatile("movclr.l %%acc0, %0" : "=d" (acc)) #else #define BLEND_INIT do {} while (0) +#define BLEND_FINISH do {} while(0) #define BLEND_START(acc, color, alpha) ((acc) = (color) * (alpha)) #define BLEND_CONT(acc, color, alpha) ((acc) += (color) * (alpha)) #define BLEND_OUT(acc) do {} while (0) @@ -749,6 +755,7 @@ static void draw_oriented_mono_bitmap_part(const unsigned char *src, /* Blend the given two colors */ static inline unsigned blend_two_colors(unsigned c1, unsigned c2, unsigned a) { +#if LCD_DEPTH == 16 a += a >> (ALPHA_COLOR_LOOKUP_SHIFT - 1); #if (LCD_PIXELFORMAT == RGB565SWAPPED) c1 = swap16(c1); @@ -767,6 +774,20 @@ static inline unsigned blend_two_colors(unsigned c1, unsigned c2, unsigned a) #else return p; #endif + +#else /* LCD_DEPTH == 24 */ + unsigned s = c1; + unsigned d = c2; + unsigned s1 = s & 0xff00ff; + unsigned d1 = d & 0xff00ff; + a += a >> (ALPHA_COLOR_LOOKUP_SHIFT - 1); + d1 = (d1 + ((s1 - d1) * a >> ALPHA_COLOR_LOOKUP_SHIFT)) & 0xff00ff; + s &= 0xff00; + d &= 0xff00; + d = (d + ((s - d) * a >> ALPHA_COLOR_LOOKUP_SHIFT)) & 0xff00; + + return d1 | d; +#endif } static void draw_oriented_alpha_bitmap_part(const unsigned char *src, @@ -849,8 +870,9 @@ static void draw_oriented_alpha_bitmap_part(const unsigned char *src, #endif do { - *dst=blend_two_colors(*dst, fg_pattern, - data & ALPHA_COLOR_LOOKUP_SIZE ); + unsigned color = blend_two_colors(FB_UNPACK_SCALAR_LCD(*dst), fg_pattern, + data & ALPHA_COLOR_LOOKUP_SIZE ); + *dst= FB_SCALARPACK(color); dst += LCD_WIDTH; UPDATE_SRC_ALPHA; } -- cgit v1.2.3