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/gui/color_picker.c | 38 ++++-- apps/gui/line.h | 4 +- apps/gui/skin_engine/skin_render.c | 6 +- apps/plugin.c | 2 +- apps/plugin.h | 2 +- apps/plugins/SOURCES | 3 +- apps/plugins/SUBDIRS | 2 +- apps/plugins/doom/i_video.c | 2 +- apps/plugins/fft/fft.c | 8 +- apps/plugins/fire.c | 16 +-- apps/plugins/fractals/mandelbrot_set.c | 5 +- apps/plugins/imageviewer/jpeg/yuv2rgb.c | 8 +- apps/plugins/imageviewer/ppm/ppm_decoder.c | 4 +- apps/plugins/invadrox.c | 9 +- apps/plugins/lib/bmp_smooth_scale.c | 186 ++++++++++++++--------------- apps/plugins/lib/osd.c | 3 + apps/plugins/lib/pluginlib_bmp.c | 6 +- apps/plugins/lib/xlcd_draw.c | 12 +- apps/plugins/logo.c | 8 +- apps/plugins/lua/rocklib.c | 4 +- apps/plugins/mpegplayer/alloc.c | 1 - apps/plugins/mpegplayer/mpegplayer.c | 32 ++++- apps/plugins/pacbox/arcade.c | 2 +- apps/plugins/pictureflow/pictureflow.c | 62 +++++----- apps/plugins/plasma.c | 2 +- apps/plugins/rockblox.c | 2 +- apps/plugins/rockboy/lcd-gb.h | 6 +- apps/plugins/rockboy/lcd.c | 14 +-- apps/plugins/rockboy/sys_rockbox.c | 9 ++ apps/plugins/superdom.c | 4 +- apps/plugins/zxbox/zxvid_16bpp.c | 6 +- apps/recorder/bmp.c | 17 ++- apps/recorder/resize.c | 12 +- 33 files changed, 284 insertions(+), 213 deletions(-) (limited to 'apps') diff --git a/apps/gui/color_picker.c b/apps/gui/color_picker.c index 907b1744c5..a66b131560 100644 --- a/apps/gui/color_picker.c +++ b/apps/gui/color_picker.c @@ -60,7 +60,7 @@ struct rgb_pick /* list of primary colors */ #define SB_PRIM 0 #define SB_FILL 1 -static const fb_data prim_rgb[][3] = +static const unsigned prim_rgb[][3] = { /* Foreground colors for sliders */ { @@ -87,13 +87,13 @@ static const unsigned char rgb_max[3] = /* Unpacks the color value into native rgb values and 24 bit rgb values */ static void unpack_rgb(struct rgb_pick *rgb) { - unsigned color = _LCD_UNSWAP_COLOR(rgb->color); - rgb->red = _RGB_UNPACK_RED(color); - rgb->green = _RGB_UNPACK_GREEN(color); - rgb->blue = _RGB_UNPACK_BLUE(color); - rgb->r = _RGB_UNPACK_RED_LCD(color); - rgb->g = _RGB_UNPACK_GREEN_LCD(color); - rgb->b = _RGB_UNPACK_BLUE_LCD(color); + unsigned color = rgb->color; + rgb->red = RGB_UNPACK_RED(color); + rgb->green = RGB_UNPACK_GREEN(color); + rgb->blue = RGB_UNPACK_BLUE(color); + rgb->r = RGB_UNPACK_RED_LCD(color); + rgb->g = RGB_UNPACK_GREEN_LCD(color); + rgb->b = RGB_UNPACK_BLUE_LCD(color); } /* Packs the native rgb colors into a color value */ @@ -159,6 +159,7 @@ static void draw_screen(struct screen *display, char *title, int max_label_width; int text_x, text_top; int slider_x, slider_width; + int value_width; bool display_three_rows; struct viewport vp; @@ -185,7 +186,12 @@ static void draw_screen(struct screen *display, char *title, TITLE_MARGIN_BOTTOM + SELECTOR_TB_MARGIN; text_x = SELECTOR_WIDTH; slider_x = text_x + max_label_width + SLIDER_TEXT_MARGIN; - slider_width = vp.width - slider_x*2 - max_label_width; + slider_width = vp.width - text_x - slider_x - SLIDER_TEXT_MARGIN; + if (display->depth >= 24) + display->getstringsize("255", &value_width, NULL); + else + display->getstringsize("63", &value_width, NULL); + slider_width -= value_width; line_height = char_height + 2*SELECTOR_TB_MARGIN; /* Find out if there's enough room for three sliders or just @@ -252,7 +258,10 @@ static void draw_screen(struct screen *display, char *title, vp.flags &= ~VP_FLAG_ALIGNMENT_MASK; display->putsxy(text_x, text_top, buf); /* Draw color value */ - snprintf(buf, 3, "%02d", rgb->rgb_val[i]); + if (display->depth >= 24) + snprintf(buf, 4, "%03d", rgb->rgb_val[i]); + else + snprintf(buf, 3, "%02d", rgb->rgb_val[i]); vp.flags |= VP_FLAG_ALIGN_RIGHT; display->putsxy(text_x, text_top, buf); @@ -324,7 +333,7 @@ static int touchscreen_slider(struct screen *display, { short x, y; int char_height, line_height; - int max_label_width; + int max_label_width, value_width; int text_top, slider_x, slider_width; bool display_three_rows; int button; @@ -345,7 +354,12 @@ static int touchscreen_slider(struct screen *display, text_top = MARGIN_TOP + char_height + TITLE_MARGIN_BOTTOM + SELECTOR_TB_MARGIN; slider_x = SELECTOR_WIDTH + max_label_width + SLIDER_TEXT_MARGIN; - slider_width = vp.width - slider_x*2 - max_label_width; + slider_width = vp.width - SELECTOR_WIDTH - slider_x - SLIDER_TEXT_MARGIN; + if (display->depth >= 24) + display->getstringsize("255", &value_width, NULL); + else + display->getstringsize("63", &value_width, NULL); + slider_width -= value_width; line_height = char_height + 2*SELECTOR_TB_MARGIN; /* same logic as in draw_screen */ diff --git a/apps/gui/line.h b/apps/gui/line.h index c14f04d9a2..8a1cc05af2 100644 --- a/apps/gui/line.h +++ b/apps/gui/line.h @@ -66,10 +66,10 @@ struct line_desc { int16_t line; /* line text color if STYLE_COLORED is specified, in native * lcd format (convert with LCD_RGBPACK() if necessary) */ - fb_data text_color; + unsigned text_color; /* line color if STYLE_COLORBAR or STYLE_GRADIENT is specified, in native * lcd format (convert with LCD_RGBPACK() if necessary) */ - fb_data line_color, line_end_color; + unsigned line_color, line_end_color; /* line decorations, see STYLE_DEFAULT etc. */ enum line_styles style; /* whether the line can scroll */ diff --git a/apps/gui/skin_engine/skin_render.c b/apps/gui/skin_engine/skin_render.c index 700694e382..4415619b7e 100644 --- a/apps/gui/skin_engine/skin_render.c +++ b/apps/gui/skin_engine/skin_render.c @@ -136,9 +136,9 @@ static bool do_non_text_tags(struct gui_wps *gwps, struct skin_draw_info *info, * come before the text style tag color fields need to be preserved */ if (data->style & STYLE_GRADIENT) { - fb_data tc = linedes->text_color, - lc = linedes->line_color, - lec = linedes->line_end_color; + unsigned tc = linedes->text_color, + lc = linedes->line_color, + lec = linedes->line_end_color; *linedes = *data; linedes->text_color = tc; linedes->line_color = lc; diff --git a/apps/plugin.c b/apps/plugin.c index 4bed707c11..d0e6ade547 100644 --- a/apps/plugin.c +++ b/apps/plugin.c @@ -184,7 +184,7 @@ static const struct plugin_api rockbox_api = { lcd_get_backdrop, lcd_set_backdrop, #endif -#if LCD_DEPTH == 16 +#if LCD_DEPTH >= 16 lcd_bitmap_transparent_part, lcd_bitmap_transparent, #if MEMORYSIZE > 2 diff --git a/apps/plugin.h b/apps/plugin.h index fd4e468b91..1ed1c041d1 100644 --- a/apps/plugin.h +++ b/apps/plugin.h @@ -242,7 +242,7 @@ struct plugin_api { fb_data* (*lcd_get_backdrop)(void); void (*lcd_set_backdrop)(fb_data* backdrop); #endif -#if LCD_DEPTH == 16 +#if LCD_DEPTH >= 16 void (*lcd_bitmap_transparent_part)(const fb_data *src, int src_x, int src_y, int stride, int x, int y, int width, int height); diff --git a/apps/plugins/SOURCES b/apps/plugins/SOURCES index 59bd4023cc..c56cd5eb46 100644 --- a/apps/plugins/SOURCES +++ b/apps/plugins/SOURCES @@ -195,7 +195,8 @@ codebuster.c fireworks.c #endif -#if LCD_DEPTH >= 16 +#if LCD_DEPTH == 16 +/* FIXME: make it work with 24bit (needs lot of memory) */ rockpaint.c #endif diff --git a/apps/plugins/SUBDIRS b/apps/plugins/SUBDIRS index c22977f137..8e653983b7 100644 --- a/apps/plugins/SUBDIRS +++ b/apps/plugins/SUBDIRS @@ -22,7 +22,7 @@ clock rockboy #endif -#ifdef HAVE_TAGCACHE +#if defined(HAVE_TAGCACHE) pictureflow #endif diff --git a/apps/plugins/doom/i_video.c b/apps/plugins/doom/i_video.c index 57803fb57d..10aee392a2 100644 --- a/apps/plugins/doom/i_video.c +++ b/apps/plugins/doom/i_video.c @@ -790,7 +790,7 @@ static void I_UploadNewPalette(int pal) #ifndef HAVE_LCD_COLOR paldata[i]=(3*r+6*g+b)/10; #else - paldata[i] = LCD_RGBPACK(r,g,b); + paldata[i] = FB_RGBPACK(r,g,b); #endif } diff --git a/apps/plugins/fft/fft.c b/apps/plugins/fft/fft.c index e591954664..2b7f6a4fbe 100644 --- a/apps/plugins/fft/fft.c +++ b/apps/plugins/fft/fft.c @@ -929,13 +929,15 @@ static void draw_spectrogram_vertical(unsigned this_max, unsigned graph_max) if(bins_acc >= ARRAYLEN_PLOT) { unsigned index = (SHADES-1)*bins_max / graph_max; + unsigned color; /* These happen because we exaggerate the graph a little for * linear mode */ if(index >= SHADES) index = SHADES-1; - mylcd_set_foreground(SPECTROGRAPH_PALETTE(index)); + color = FB_UNPACK_SCALAR_LCD(SPECTROGRAPH_PALETTE(index)); + mylcd_set_foreground(color); mylcd_drawpixel(fft_spectrogram_pos, y); if(--y < 0) @@ -973,13 +975,15 @@ static void draw_spectrogram_horizontal(unsigned this_max, unsigned graph_max) if(bins_acc >= ARRAYLEN_PLOT) { unsigned index = (SHADES-1)*bins_max / graph_max; + unsigned color; /* These happen because we exaggerate the graph a little for * linear mode */ if(index >= SHADES) index = SHADES-1; - mylcd_set_foreground(SPECTROGRAPH_PALETTE(index)); + color = FB_UNPACK_SCALAR_LCD(SPECTROGRAPH_PALETTE(index)); + mylcd_set_foreground(color); mylcd_drawpixel(x, fft_spectrogram_pos); if(++x >= LCD_WIDTH) diff --git a/apps/plugins/fire.c b/apps/plugins/fire.c index 478296b5f8..4fc30173da 100644 --- a/apps/plugins/fire.c +++ b/apps/plugins/fire.c @@ -100,20 +100,20 @@ static void color_palette_init(fb_data* palette) int i; for (i = 0; i < 32; i++){ /* black to blue, 32 values*/ - palette[i]=LCD_RGBPACK(0, 0, 2*i); + palette[i]=FB_RGBPACK(0, 0, 2*i); /* blue to red, 32 values*/ - palette[i + 32]=LCD_RGBPACK(8*i, 0, 64 - 2*i); + palette[i + 32]=FB_RGBPACK(8*i, 0, 64 - 2*i); /* red to yellow, 32 values*/ - palette[i + 64]=LCD_RGBPACK(255, 8*i, 0); + palette[i + 64]=FB_RGBPACK(255, 8*i, 0); /* yellow to white, 162 values */ - palette[i + 96]=LCD_RGBPACK(255, 255, 0 + 4*i); - palette[i + 128]=LCD_RGBPACK(255, 255, 64 + 4*i); - palette[i + 160]=LCD_RGBPACK(255, 255, 128 + 4*i); - palette[i + 192]=LCD_RGBPACK(255, 255, 192 + i); - palette[i + 224]=LCD_RGBPACK(255, 255, 224 + i); + palette[i + 96]=FB_RGBPACK(255, 255, 0 + 4*i); + palette[i + 128]=FB_RGBPACK(255, 255, 64 + 4*i); + palette[i + 160]=FB_RGBPACK(255, 255, 128 + 4*i); + palette[i + 192]=FB_RGBPACK(255, 255, 192 + i); + palette[i + 224]=FB_RGBPACK(255, 255, 224 + i); } #if defined(HAVE_LCD_MODES) && (HAVE_LCD_MODES & LCD_MODE_PAL256) rb->lcd_pal256_update_pal(palette); diff --git a/apps/plugins/fractals/mandelbrot_set.c b/apps/plugins/fractals/mandelbrot_set.c index 6e47527a20..583095913f 100644 --- a/apps/plugins/fractals/mandelbrot_set.c +++ b/apps/plugins/fractals/mandelbrot_set.c @@ -43,8 +43,8 @@ static fb_data imgbuffer[LCD_HEIGHT]; #endif #ifdef HAVE_LCD_COLOR -#define COLOR(iter) (fb_data)LCOLOR(iter) -#define CONVERGENCE_COLOR LCD_RGBPACK(0, 0, 0) +#define COLOR(iter) FB_SCALARPACK(LCOLOR(iter)) +#define CONVERGENCE_COLOR FB_RGBPACK(0, 0, 0) #else /* greyscale */ #define COLOR(iter) (unsigned char)LCOLOR(iter) #define CONVERGENCE_COLOR 0 @@ -413,4 +413,3 @@ static int mandelbrot_precision(int d) return changed; } - diff --git a/apps/plugins/imageviewer/jpeg/yuv2rgb.c b/apps/plugins/imageviewer/jpeg/yuv2rgb.c index 2395f232b2..764dc71a47 100644 --- a/apps/plugins/imageviewer/jpeg/yuv2rgb.c +++ b/apps/plugins/imageviewer/jpeg/yuv2rgb.c @@ -106,7 +106,7 @@ static fb_data pixel_to_lcd_colour(void) b = component_to_lcd(p->b, LCD_BLUE_BITS, NODITHER_DELTA); b = clamp_component_bits(b, LCD_BLUE_BITS); - return LCD_RGBPACK_LCD(r, g, b); + return FB_RGBPACK_LCD(r, g, b); } /** write a monochrome pixel to the colour LCD **/ @@ -119,7 +119,7 @@ static fb_data pixel_to_lcd_gray(void) b = component_to_lcd(g, LCD_BLUE_BITS, NODITHER_DELTA); g = component_to_lcd(g, LCD_GREEN_BITS, NODITHER_DELTA); - return LCD_RGBPACK_LCD(r, g, b); + return FB_RGBPACK_LCD(r, g, b); } /** @@ -163,7 +163,7 @@ static fb_data pixel_odither_to_lcd(void) p->col += p->inc; - return LCD_RGBPACK_LCD(r, g, b); + return FB_RGBPACK_LCD(r, g, b); } /** @@ -217,7 +217,7 @@ static fb_data pixel_fsdither_to_lcd(void) distribute_error(&p->ce[BLU], &p->e[BLU], bc, epos, inc); /* Pack and return pixel */ - return LCD_RGBPACK_LCD(r, g, b); + return FB_RGBPACK_LCD(r, g, b); } /* Functions for each output mode, colour then grayscale. */ diff --git a/apps/plugins/imageviewer/ppm/ppm_decoder.c b/apps/plugins/imageviewer/ppm/ppm_decoder.c index be459293fe..4a86be1a3a 100644 --- a/apps/plugins/imageviewer/ppm/ppm_decoder.c +++ b/apps/plugins/imageviewer/ppm/ppm_decoder.c @@ -197,7 +197,7 @@ static int read_ppm_row(int fd, struct ppm_info *ppm, int row) { return PLUGIN_ERROR; } - *dst = LCD_RGBPACK( + *dst = FB_RGBPACK( (255 * r)/ppm->maxval, (255 * g)/ppm->maxval, (255 * b)/ppm->maxval); @@ -216,7 +216,7 @@ static int read_ppm_row(int fd, struct ppm_info *ppm, int row) { return PLUGIN_ERROR; } - *dst = LCD_RGBPACK( + *dst = FB_RGBPACK( (255 * r)/ppm->maxval, (255 * g)/ppm->maxval, (255 * b)/ppm->maxval); diff --git a/apps/plugins/invadrox.c b/apps/plugins/invadrox.c index ef53715753..158ad2f4d7 100644 --- a/apps/plugins/invadrox.c +++ b/apps/plugins/invadrox.c @@ -1027,7 +1027,7 @@ static inline void draw_ship(void) } -static inline void fire_alpha(int xc, int yc, fb_data color) +static inline void fire_alpha(int xc, int yc, unsigned color) { int oldmode = rb->lcd_get_drawmode(); @@ -1128,12 +1128,12 @@ static void move_fire(void) /* Check for hit*/ for (i = FIRE_SPEED; i >= 0; i--) { pix = get_pixel(fire_x, fire_y + i); - if(pix == screen_white) { + if(!memcmp(&pix, &screen_white, sizeof(fb_data))) { hit_white = true; fire_y += i; break; } - if(pix == screen_green) { + if(!memcmp(&pix, &screen_green, sizeof(fb_data))) { hit_green = true; fire_y += i; break; @@ -1336,7 +1336,8 @@ static void move_bombs(void) /* Check for green (ship or shield) */ for (j = BOMB_HEIGHT; j >= BOMB_HEIGHT - BOMB_SPEED; j--) { bombs[i].target = 0; - if(get_pixel(bombs[i].x + BOMB_WIDTH / 2, bombs[i].y + j) == screen_green) { + fb_data pix = get_pixel(bombs[i].x + BOMB_WIDTH / 2, bombs[i].y + j); + if(!memcmp(&pix, &screen_green, sizeof(fb_data))) { /* Move to hit pixel */ bombs[i].x += BOMB_WIDTH / 2; bombs[i].y += j; diff --git a/apps/plugins/lib/bmp_smooth_scale.c b/apps/plugins/lib/bmp_smooth_scale.c index e99ff33d71..c5f258cdbf 100644 --- a/apps/plugins/lib/bmp_smooth_scale.c +++ b/apps/plugins/lib/bmp_smooth_scale.c @@ -130,38 +130,38 @@ void smooth_resize_bitmap(struct bitmap *src_bmp, struct bitmap *dest_bmp) if (XAP > 0) { pix = ypoint + xpoint; - r = RGB_UNPACK_RED(*pix) * INV_XAP; - g = RGB_UNPACK_GREEN(*pix) * INV_XAP; - b = RGB_UNPACK_BLUE(*pix) * INV_XAP; + r = FB_UNPACK_RED(*pix) * INV_XAP; + g = FB_UNPACK_GREEN(*pix) * INV_XAP; + b = FB_UNPACK_BLUE(*pix) * INV_XAP; pix++; - r += RGB_UNPACK_RED(*pix) * XAP; - g += RGB_UNPACK_GREEN(*pix) * XAP; - b += RGB_UNPACK_BLUE(*pix) * XAP; + r += FB_UNPACK_RED(*pix) * XAP; + g += FB_UNPACK_GREEN(*pix) * XAP; + b += FB_UNPACK_BLUE(*pix) * XAP; pix += sow; - rr = RGB_UNPACK_RED(*pix) * XAP; - gg = RGB_UNPACK_GREEN(*pix) * XAP; - bb = RGB_UNPACK_BLUE(*pix) * XAP; + rr = FB_UNPACK_RED(*pix) * XAP; + gg = FB_UNPACK_GREEN(*pix) * XAP; + bb = FB_UNPACK_BLUE(*pix) * XAP; pix--; - rr += RGB_UNPACK_RED(*pix) * INV_XAP; - gg += RGB_UNPACK_GREEN(*pix) * INV_XAP; - bb += RGB_UNPACK_BLUE(*pix) * INV_XAP; + rr += FB_UNPACK_RED(*pix) * INV_XAP; + gg += FB_UNPACK_GREEN(*pix) * INV_XAP; + bb += FB_UNPACK_BLUE(*pix) * INV_XAP; r = ((rr * YAP) + (r * INV_YAP)) >> 16; g = ((gg * YAP) + (g * INV_YAP)) >> 16; b = ((bb * YAP) + (b * INV_YAP)) >> 16; - *dptr++ = LCD_RGBPACK(r, g, b); + *dptr++ = FB_RGBPACK(r, g, b); } else { pix = ypoint + xpoint; - r = RGB_UNPACK_RED(*pix) * INV_YAP; - g = RGB_UNPACK_GREEN(*pix) * INV_YAP; - b = RGB_UNPACK_BLUE(*pix) * INV_YAP; + r = FB_UNPACK_RED(*pix) * INV_YAP; + g = FB_UNPACK_GREEN(*pix) * INV_YAP; + b = FB_UNPACK_BLUE(*pix) * INV_YAP; pix += sow; - r += RGB_UNPACK_RED(*pix) * YAP; - g += RGB_UNPACK_GREEN(*pix) * YAP; - b += RGB_UNPACK_BLUE(*pix) * YAP; + r += FB_UNPACK_RED(*pix) * YAP; + g += FB_UNPACK_GREEN(*pix) * YAP; + b += FB_UNPACK_BLUE(*pix) * YAP; r >>= 8; g >>= 8; b >>= 8; - *dptr++ = LCD_RGBPACK(r, g, b); + *dptr++ = FB_RGBPACK(r, g, b); } } } else { @@ -176,17 +176,17 @@ void smooth_resize_bitmap(struct bitmap *src_bmp, struct bitmap *dest_bmp) if (XAP > 0) { pix = ypoint + xpoint; - r = RGB_UNPACK_RED(*pix) * INV_XAP; - g = RGB_UNPACK_GREEN(*pix) * INV_XAP; - b = RGB_UNPACK_BLUE(*pix) * INV_XAP; + r = FB_UNPACK_RED(*pix) * INV_XAP; + g = FB_UNPACK_GREEN(*pix) * INV_XAP; + b = FB_UNPACK_BLUE(*pix) * INV_XAP; pix++; - r += RGB_UNPACK_RED(*pix) * XAP; - g += RGB_UNPACK_GREEN(*pix) * XAP; - b += RGB_UNPACK_BLUE(*pix) * XAP; + r += FB_UNPACK_RED(*pix) * XAP; + g += FB_UNPACK_GREEN(*pix) * XAP; + b += FB_UNPACK_BLUE(*pix) * XAP; r >>= 8; g >>= 8; b >>= 8; - *dptr++ = LCD_RGBPACK(r, g, b); + *dptr++ = FB_RGBPACK(r, g, b); } else *dptr++ = sptr[xpoint]; } @@ -221,37 +221,37 @@ void smooth_resize_bitmap(struct bitmap *src_bmp, struct bitmap *dest_bmp) val_x += inc_x; pix = ypoint + xpoint; - r = (RGB_UNPACK_RED(*pix) * yap) >> 10; - g = (RGB_UNPACK_GREEN(*pix) * yap) >> 10; - b = (RGB_UNPACK_BLUE(*pix) * yap) >> 10; + r = (FB_UNPACK_RED(*pix) * yap) >> 10; + g = (FB_UNPACK_GREEN(*pix) * yap) >> 10; + b = (FB_UNPACK_BLUE(*pix) * yap) >> 10; pix += sow; for (j = (1 << 14) - yap; j > Cy; j -= Cy) { - r += (RGB_UNPACK_RED(*pix) * Cy) >> 10; - g += (RGB_UNPACK_GREEN(*pix) * Cy) >> 10; - b += (RGB_UNPACK_BLUE(*pix) * Cy) >> 10; + r += (FB_UNPACK_RED(*pix) * Cy) >> 10; + g += (FB_UNPACK_GREEN(*pix) * Cy) >> 10; + b += (FB_UNPACK_BLUE(*pix) * Cy) >> 10; pix += sow; } if (j > 0) { - r += (RGB_UNPACK_RED(*pix) * j) >> 10; - g += (RGB_UNPACK_GREEN(*pix) * j) >> 10; - b += (RGB_UNPACK_BLUE(*pix) * j) >> 10; + r += (FB_UNPACK_RED(*pix) * j) >> 10; + g += (FB_UNPACK_GREEN(*pix) * j) >> 10; + b += (FB_UNPACK_BLUE(*pix) * j) >> 10; } if (XAP > 0) { pix = ypoint + xpoint + 1; - rr = (RGB_UNPACK_RED(*pix) * yap) >> 10; - gg = (RGB_UNPACK_GREEN(*pix) * yap) >> 10; - bb = (RGB_UNPACK_BLUE(*pix) * yap) >> 10; + rr = (FB_UNPACK_RED(*pix) * yap) >> 10; + gg = (FB_UNPACK_GREEN(*pix) * yap) >> 10; + bb = (FB_UNPACK_BLUE(*pix) * yap) >> 10; pix += sow; for (j = (1 << 14) - yap; j > Cy; j -= Cy) { - rr += (RGB_UNPACK_RED(*pix) * Cy) >> 10; - gg += (RGB_UNPACK_GREEN(*pix) * Cy) >> 10; - bb += (RGB_UNPACK_BLUE(*pix) * Cy) >> 10; + rr += (FB_UNPACK_RED(*pix) * Cy) >> 10; + gg += (FB_UNPACK_GREEN(*pix) * Cy) >> 10; + bb += (FB_UNPACK_BLUE(*pix) * Cy) >> 10; pix += sow; } if (j > 0) { - rr += (RGB_UNPACK_RED(*pix) * j) >> 10; - gg += (RGB_UNPACK_GREEN(*pix) * j) >> 10; - bb += (RGB_UNPACK_BLUE(*pix) * j) >> 10; + rr += (FB_UNPACK_RED(*pix) * j) >> 10; + gg += (FB_UNPACK_GREEN(*pix) * j) >> 10; + bb += (FB_UNPACK_BLUE(*pix) * j) >> 10; } r = r * INV_XAP; g = g * INV_XAP; @@ -264,7 +264,7 @@ void smooth_resize_bitmap(struct bitmap *src_bmp, struct bitmap *dest_bmp) g >>= 4; b >>= 4; } - *dptr = LCD_RGBPACK(r, g, b); + *dptr = FB_RGBPACK(r, g, b); dptr++; } } @@ -297,37 +297,37 @@ void smooth_resize_bitmap(struct bitmap *src_bmp, struct bitmap *dest_bmp) xap = XAP & 0xffff; pix = ypoint + xpoint; - r = (RGB_UNPACK_RED(*pix) * xap) >> 10; - g = (RGB_UNPACK_GREEN(*pix) * xap) >> 10; - b = (RGB_UNPACK_BLUE(*pix) * xap) >> 10; + r = (FB_UNPACK_RED(*pix) * xap) >> 10; + g = (FB_UNPACK_GREEN(*pix) * xap) >> 10; + b = (FB_UNPACK_BLUE(*pix) * xap) >> 10; pix++; for (j = (1 << 14) - xap; j > Cx; j -= Cx) { - r += (RGB_UNPACK_RED(*pix) * Cx) >> 10; - g += (RGB_UNPACK_GREEN(*pix) * Cx) >> 10; - b += (RGB_UNPACK_BLUE(*pix) * Cx) >> 10; + r += (FB_UNPACK_RED(*pix) * Cx) >> 10; + g += (FB_UNPACK_GREEN(*pix) * Cx) >> 10; + b += (FB_UNPACK_BLUE(*pix) * Cx) >> 10; pix++; } if (j > 0) { - r += (RGB_UNPACK_RED(*pix) * j) >> 10; - g += (RGB_UNPACK_GREEN(*pix) * j) >> 10; - b += (RGB_UNPACK_BLUE(*pix) * j) >> 10; + r += (FB_UNPACK_RED(*pix) * j) >> 10; + g += (FB_UNPACK_GREEN(*pix) * j) >> 10; + b += (FB_UNPACK_BLUE(*pix) * j) >> 10; } if (YAP > 0) { pix = ypoint + xpoint + sow; - rr = (RGB_UNPACK_RED(*pix) * xap) >> 10; - gg = (RGB_UNPACK_GREEN(*pix) * xap) >> 10; - bb = (RGB_UNPACK_BLUE(*pix) * xap) >> 10; + rr = (FB_UNPACK_RED(*pix) * xap) >> 10; + gg = (FB_UNPACK_GREEN(*pix) * xap) >> 10; + bb = (FB_UNPACK_BLUE(*pix) * xap) >> 10; pix++; for (j = (1 << 14) - xap; j > Cx; j -= Cx) { - rr += (RGB_UNPACK_RED(*pix) * Cx) >> 10; - gg += (RGB_UNPACK_GREEN(*pix) * Cx) >> 10; - bb += (RGB_UNPACK_BLUE(*pix) * Cx) >> 10; + rr += (FB_UNPACK_RED(*pix) * Cx) >> 10; + gg += (FB_UNPACK_GREEN(*pix) * Cx) >> 10; + bb += (FB_UNPACK_BLUE(*pix) * Cx) >> 10; pix++; } if (j > 0) { - rr += (RGB_UNPACK_RED(*pix) * j) >> 10; - gg += (RGB_UNPACK_GREEN(*pix) * j) >> 10; - bb += (RGB_UNPACK_BLUE(*pix) * j) >> 10; + rr += (FB_UNPACK_RED(*pix) * j) >> 10; + gg += (FB_UNPACK_GREEN(*pix) * j) >> 10; + bb += (FB_UNPACK_BLUE(*pix) * j) >> 10; } r = r * INV_YAP; g = g * INV_YAP; @@ -340,7 +340,7 @@ void smooth_resize_bitmap(struct bitmap *src_bmp, struct bitmap *dest_bmp) g >>= 4; b >>= 4; } - *dptr = LCD_RGBPACK(r, g, b); + *dptr = FB_RGBPACK(r, g, b); dptr++; } } @@ -378,20 +378,20 @@ void smooth_resize_bitmap(struct bitmap *src_bmp, struct bitmap *dest_bmp) pix = sptr; sptr += sow; - rx = (RGB_UNPACK_RED(*pix) * xap) >> 9; - gx = (RGB_UNPACK_GREEN(*pix) * xap) >> 9; - bx = (RGB_UNPACK_BLUE(*pix) * xap) >> 9; + rx = (FB_UNPACK_RED(*pix) * xap) >> 9; + gx = (FB_UNPACK_GREEN(*pix) * xap) >> 9; + bx = (FB_UNPACK_BLUE(*pix) * xap) >> 9; pix++; for (i = (1 << 14) - xap; i > Cx; i -= Cx) { - rx += (RGB_UNPACK_RED(*pix) * Cx) >> 9; - gx += (RGB_UNPACK_GREEN(*pix) * Cx) >> 9; - bx += (RGB_UNPACK_BLUE(*pix) * Cx) >> 9; + rx += (FB_UNPACK_RED(*pix) * Cx) >> 9; + gx += (FB_UNPACK_GREEN(*pix) * Cx) >> 9; + bx += (FB_UNPACK_BLUE(*pix) * Cx) >> 9; pix++; } if (i > 0) { - rx += (RGB_UNPACK_RED(*pix) * i) >> 9; - gx += (RGB_UNPACK_GREEN(*pix) * i) >> 9; - bx += (RGB_UNPACK_BLUE(*pix) * i) >> 9; + rx += (FB_UNPACK_RED(*pix) * i) >> 9; + gx += (FB_UNPACK_GREEN(*pix) * i) >> 9; + bx += (FB_UNPACK_BLUE(*pix) * i) >> 9; } r = (rx * yap) >> 14; @@ -401,20 +401,20 @@ void smooth_resize_bitmap(struct bitmap *src_bmp, struct bitmap *dest_bmp) for (j = (1 << 14) - yap; j > Cy; j -= Cy) { pix = sptr; sptr += sow; - rx = (RGB_UNPACK_RED(*pix) * xap) >> 9; - gx = (RGB_UNPACK_GREEN(*pix) * xap) >> 9; - bx = (RGB_UNPACK_BLUE(*pix) * xap) >> 9; + rx = (FB_UNPACK_RED(*pix) * xap) >> 9; + gx = (FB_UNPACK_GREEN(*pix) * xap) >> 9; + bx = (FB_UNPACK_BLUE(*pix) * xap) >> 9; pix++; for (i = (1 << 14) - xap; i > Cx; i -= Cx) { - rx += (RGB_UNPACK_RED(*pix) * Cx) >> 9; - gx += (RGB_UNPACK_GREEN(*pix) * Cx) >> 9; - bx += (RGB_UNPACK_BLUE(*pix) * Cx) >> 9; + rx += (FB_UNPACK_RED(*pix) * Cx) >> 9; + gx += (FB_UNPACK_GREEN(*pix) * Cx) >> 9; + bx += (FB_UNPACK_BLUE(*pix) * Cx) >> 9; pix++; } if (i > 0) { - rx += (RGB_UNPACK_RED(*pix) * i) >> 9; - gx += (RGB_UNPACK_GREEN(*pix) * i) >> 9; - bx += (RGB_UNPACK_BLUE(*pix) * i) >> 9; + rx += (FB_UNPACK_RED(*pix) * i) >> 9; + gx += (FB_UNPACK_GREEN(*pix) * i) >> 9; + bx += (FB_UNPACK_BLUE(*pix) * i) >> 9; } r += (rx * Cy) >> 14; @@ -424,20 +424,20 @@ void smooth_resize_bitmap(struct bitmap *src_bmp, struct bitmap *dest_bmp) if (j > 0) { pix = sptr; sptr += sow; - rx = (RGB_UNPACK_RED(*pix) * xap) >> 9; - gx = (RGB_UNPACK_GREEN(*pix) * xap) >> 9; - bx = (RGB_UNPACK_BLUE(*pix) * xap) >> 9; + rx = (FB_UNPACK_RED(*pix) * xap) >> 9; + gx = (FB_UNPACK_GREEN(*pix) * xap) >> 9; + bx = (FB_UNPACK_BLUE(*pix) * xap) >> 9; pix++; for (i = (1 << 14) - xap; i > Cx; i -= Cx) { - rx += (RGB_UNPACK_RED(*pix) * Cx) >> 9; - gx += (RGB_UNPACK_GREEN(*pix) * Cx) >> 9; - bx += (RGB_UNPACK_BLUE(*pix) * Cx) >> 9; + rx += (FB_UNPACK_RED(*pix) * Cx) >> 9; + gx += (FB_UNPACK_GREEN(*pix) * Cx) >> 9; + bx += (FB_UNPACK_BLUE(*pix) * Cx) >> 9; pix++; } if (i > 0) { - rx += (RGB_UNPACK_RED(*pix) * i) >> 9; - gx += (RGB_UNPACK_GREEN(*pix) * i) >> 9; - bx += (RGB_UNPACK_BLUE(*pix) * i) >> 9; + rx += (FB_UNPACK_RED(*pix) * i) >> 9; + gx += (FB_UNPACK_GREEN(*pix) * i) >> 9; + bx += (FB_UNPACK_BLUE(*pix) * i) >> 9; } r += (rx * j) >> 14; @@ -445,7 +445,7 @@ void smooth_resize_bitmap(struct bitmap *src_bmp, struct bitmap *dest_bmp) b += (bx * j) >> 14; } - *dptr = LCD_RGBPACK(r >> 5, g >> 5, b >> 5); + *dptr = FB_RGBPACK(r >> 5, g >> 5, b >> 5); dptr++; } } diff --git a/apps/plugins/lib/osd.c b/apps/plugins/lib/osd.c index 598a76759c..e6fc39178a 100644 --- a/apps/plugins/lib/osd.c +++ b/apps/plugins/lib/osd.c @@ -112,6 +112,9 @@ static struct osd grey_osd; # define _OSD_WIDTH2BYTES(w) ((w)*2) # define _OSD_BYTES2WIDTH(b) ((b)/2) # endif /* end stride type selection */ +#elif LCD_DEPTH == 24 +# define _OSD_WIDTH2BYTES(w) ((w)*3) +# define _OSD_BYTES2WIDTH(b) ((b)/3) #else /* other LCD depth */ # error Unknown LCD depth; please define macros #endif /* LCD_DEPTH */ diff --git a/apps/plugins/lib/pluginlib_bmp.c b/apps/plugins/lib/pluginlib_bmp.c index f1dd9b7b38..f3edfbf425 100644 --- a/apps/plugins/lib/pluginlib_bmp.c +++ b/apps/plugins/lib/pluginlib_bmp.c @@ -70,9 +70,9 @@ int save_bmp_file( char* filename, struct bitmap *bm ) fb_data *d = (fb_data*)( bm->data ) + (x+y*bm->width); unsigned char c[] = { - RGB_UNPACK_BLUE( *d ), - RGB_UNPACK_GREEN( *d ), - RGB_UNPACK_RED( *d ) + FB_UNPACK_BLUE( *d ), + FB_UNPACK_GREEN( *d ), + FB_UNPACK_RED( *d ) }; rb->write( fh, c, 3 ); } diff --git a/apps/plugins/lib/xlcd_draw.c b/apps/plugins/lib/xlcd_draw.c index 3be15718f6..83ddf68e5c 100644 --- a/apps/plugins/lib/xlcd_draw.c +++ b/apps/plugins/lib/xlcd_draw.c @@ -170,7 +170,7 @@ void xlcd_filltriangle_screen(struct screen* display, xlcd_filltriangle_vertical(display, x1, y1, x2, y2, x3, y3); } -#if LCD_DEPTH >= 8 +#if LCD_DEPTH >= 8 && LCD_DEPTH <= 16 #ifdef HAVE_LCD_COLOR static const fb_data graylut[256] = { @@ -244,6 +244,8 @@ static const fb_data graylut[256] = { }; #endif /* HAVE_LCD_COLOR */ +/* unused functions, enable when needed */ +#if 0 /* Draw a partial greyscale bitmap, canonical 8 bit format */ void xlcd_gray_bitmap_part(const unsigned char *src, int src_x, int src_y, int stride, int x, int y, int width, int height) @@ -286,7 +288,13 @@ void xlcd_gray_bitmap_part(const unsigned char *src, int src_x, int src_y, #ifdef HAVE_LCD_COLOR do +#if LCD_DEPTH == 16 *dst_row++ = graylut[*src_row++]; +#else + /* untested change because this function is completely unused */ + *dst_row->r = *dst_row->g = *dst_row->b = *src_row++; + dst_row++; +#endif while (src_row < row_end); #endif @@ -302,6 +310,7 @@ void xlcd_gray_bitmap(const unsigned char *src, int x, int y, int width, { xlcd_gray_bitmap_part(src, 0, 0, width, x, y, width, height); } +#endif #ifdef HAVE_LCD_COLOR /* Draw a partial colour bitmap, canonical 24 bit RGB format */ @@ -379,4 +388,3 @@ void xlcd_color_bitmap(const unsigned char *src, int x, int y, int width, #endif /* LCD_DEPTH >= 8 */ #endif /* HAVE_LCD_BITMAP */ - diff --git a/apps/plugins/logo.c b/apps/plugins/logo.c index aae9e54562..a7257fae4b 100644 --- a/apps/plugins/logo.c +++ b/apps/plugins/logo.c @@ -42,14 +42,12 @@ static const struct button_mapping *plugin_contexts[] #define REMOTE_LOGO_WIDTH BMPWIDTH_remote_rockboxlogo #define REMOTE_LOGO_HEIGHT BMPHEIGHT_remote_rockboxlogo #define REMOTE_LOGO remote_rockboxlogo -extern const fb_remote_data remote_rockboxlogo[]; #endif /* HAVE_REMOTE_LCD */ #define LOGO rockboxlogo #include "pluginbitmaps/rockboxlogo.h" #define LOGO_WIDTH BMPWIDTH_rockboxlogo #define LOGO_HEIGHT BMPHEIGHT_rockboxlogo -extern const fb_data rockboxlogo[]; #else /* !LCD_BITMAP */ #define DISPLAY_WIDTH 55 @@ -103,10 +101,10 @@ enum plugin_status plugin_start(const void* parameter) { while (1) { #ifdef HAVE_LCD_BITMAP rb->lcd_clear_display(); - rb->lcd_bitmap(LOGO, x, y, LOGO_WIDTH, LOGO_HEIGHT); + rb->lcd_bitmap((const fb_data*)LOGO, x, y, LOGO_WIDTH, LOGO_HEIGHT); #ifdef REMOTE_LOGO rb->lcd_remote_clear_display(); - rb->lcd_remote_bitmap(REMOTE_LOGO, + rb->lcd_remote_bitmap((const fb_data*)REMOTE_LOGO, (x * (REMOTE_WIDTH - REMOTE_LOGO_WIDTH)) / (DISPLAY_WIDTH - LOGO_WIDTH), (y * (REMOTE_HEIGHT - REMOTE_LOGO_HEIGHT)) / (DISPLAY_HEIGHT - LOGO_HEIGHT), REMOTE_LOGO_WIDTH, REMOTE_LOGO_HEIGHT); @@ -195,5 +193,3 @@ enum plugin_status plugin_start(const void* parameter) { } } } - - diff --git a/apps/plugins/lua/rocklib.c b/apps/plugins/lua/rocklib.c index 27c1177748..2268063d3f 100644 --- a/apps/plugins/lua/rocklib.c +++ b/apps/plugins/lua/rocklib.c @@ -138,14 +138,14 @@ static fb_data* rli_element(lua_State *L) static int rli_set(lua_State *L) { - fb_data newvalue = (fb_data) luaL_checknumber(L, 4); + fb_data newvalue = FB_SCALARPACK((unsigned)luaL_checknumber(L, 4)); *rli_element(L) = newvalue; return 0; } static int rli_get(lua_State *L) { - lua_pushnumber(L, *rli_element(L)); + lua_pushnumber(L, FB_UNPACK_SCALAR_LCD(*rli_element(L))); return 1; } diff --git a/apps/plugins/mpegplayer/alloc.c b/apps/plugins/mpegplayer/alloc.c index eb58c67f44..cbf930a7eb 100644 --- a/apps/plugins/mpegplayer/alloc.c +++ b/apps/plugins/mpegplayer/alloc.c @@ -231,4 +231,3 @@ void codec_free(void* ptr) #endif (void)ptr; } - 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; } diff --git a/apps/plugins/pacbox/arcade.c b/apps/plugins/pacbox/arcade.c index 426a81d487..236b5fc63d 100644 --- a/apps/plugins/pacbox/arcade.c +++ b/apps/plugins/pacbox/arcade.c @@ -340,7 +340,7 @@ void decodeROMs(void) for( i=0; i<256; i++ ) { c = decoded_palette[ color_data_[i] & 0x0F ]; #ifdef HAVE_LCD_COLOR - palette[i] = LCD_RGBPACK((unsigned char) (c), + palette[i] = FB_RGBPACK((unsigned char) (c), (unsigned char) (c >> 8), (unsigned char) (c >> 16)); #else diff --git a/apps/plugins/pictureflow/pictureflow.c b/apps/plugins/pictureflow/pictureflow.c index 796b66a48d..1003b0c65c 100644 --- a/apps/plugins/pictureflow/pictureflow.c +++ b/apps/plugins/pictureflow/pictureflow.c @@ -470,7 +470,6 @@ static int pf_state; /** code */ static bool free_slide_prio(int prio); -static inline unsigned fade_color(pix_t c, unsigned a); bool load_new_slide(void); int load_surface(int); @@ -646,10 +645,15 @@ static inline PFreal fcos(int iangle) return fsin(iangle + (IANGLE_MAX >> 2)); } -static inline unsigned scale_val(unsigned val, unsigned bits) +/* scales the 8bit subpixel value to native lcd format, indicated by bits */ +static inline unsigned scale_subpixel_lcd(unsigned val, unsigned bits) { + (void) bits; +#if LCD_PIXELFORMAT != RGB888 val = val * ((1 << bits) - 1); - return ((val >> 8) + val + 128) >> 8; + val = ((val >> 8) + val + 128) >> 8; +#endif + return val; } static void output_row_8_transposed(uint32_t row, void * row_in, @@ -666,10 +670,10 @@ static void output_row_8_transposed(uint32_t row, void * row_in, unsigned r, g, b; for (; dest < end; dest += ctx->bm->height) { - r = scale_val(qp->red, 5); - g = scale_val(qp->green, 6); - b = scale_val((qp++)->blue, 5); - *dest = LCD_RGBPACK_LCD(r,g,b); + r = scale_subpixel_lcd(qp->red, 5); + g = scale_subpixel_lcd(qp->green, 6); + b = scale_subpixel_lcd((qp++)->blue, 5); + *dest = FB_RGBPACK_LCD(r,g,b); } #endif } @@ -690,11 +694,11 @@ static void output_row_32_transposed(uint32_t row, void * row_in, int r, g, b; for (; dest < end; dest += ctx->bm->height) { - r = scale_val(SC_OUT(qp->r, ctx), 5); - g = scale_val(SC_OUT(qp->g, ctx), 6); - b = scale_val(SC_OUT(qp->b, ctx), 5); + r = scale_subpixel_lcd(SC_OUT(qp->r, ctx), 5); + g = scale_subpixel_lcd(SC_OUT(qp->g, ctx), 6); + b = scale_subpixel_lcd(SC_OUT(qp->b, ctx), 5); qp++; - *dest = LCD_RGBPACK_LCD(r,g,b); + *dest = FB_RGBPACK_LCD(r,g,b); } #endif } @@ -714,10 +718,10 @@ static void output_row_32_transposed_fromyuv(uint32_t row, void * row_in, v = SC_OUT(qp->r, ctx); qp++; yuv_to_rgb(y, u, v, &r, &g, &b); - r = scale_val(r, 5); - g = scale_val(g, 6); - b = scale_val(b, 5); - *dest = LCD_RGBPACK_LCD(r, g, b); + r = scale_subpixel_lcd(r, 5); + g = scale_subpixel_lcd(g, 6); + b = scale_subpixel_lcd(b, 5); + *dest = FB_RGBPACK_LCD(r, g, b); } } #endif @@ -1793,14 +1797,13 @@ static void recalc_offsets(void) offsetY = DISPLAY_WIDTH / 2 * (fsin(itilt) + PFREAL_ONE / 2); } - /** - Fade the given color by spreading the fb_data (ushort) - to an uint, multiply and compress the result back to a ushort. + Fade the given color by spreading the fb_data + to an uint, multiply and compress the result back to a fb_data. */ -#if (LCD_PIXELFORMAT == RGB565SWAPPED) -static inline unsigned fade_color(pix_t c, unsigned a) +static inline pix_t fade_color(pix_t c, unsigned a) { +#if (LCD_PIXELFORMAT == RGB565SWAPPED) unsigned int result; c = swap16(c); a = (a + 2) & 0x1fc; @@ -1808,24 +1811,29 @@ static inline unsigned fade_color(pix_t c, unsigned a) result |= ((c & 0x7e0) * a) & 0x7e000; result >>= 8; return swap16(result); -} + #elif LCD_PIXELFORMAT == RGB565 -static inline unsigned fade_color(pix_t c, unsigned a) -{ unsigned int result; a = (a + 2) & 0x1fc; result = ((c & 0xf81f) * a) & 0xf81f00; result |= ((c & 0x7e0) * a) & 0x7e000; result >>= 8; return result; -} + +#elif LCD_PIXELFORMAT == RGB888 + unsigned int pixel = FB_UNPACK_SCALAR_LCD(c); + unsigned int result; + a = (a + 2) & 0x1fc; + result = ((pixel & 0xff00ff) * a) & 0xff00ff00; + result |= ((pixel & 0x00ff00) * a) & 0x00ff0000; + result >>= 8; + return FB_SCALARPACK(result); + #else -static inline unsigned fade_color(pix_t c, unsigned a) -{ unsigned val = c; return MULUQ(val, a) >> 8; -} #endif +} /** * Render a single slide diff --git a/apps/plugins/plasma.c b/apps/plugins/plasma.c index 5b2b3ae94d..541d53cdef 100644 --- a/apps/plugins/plasma.c +++ b/apps/plugins/plasma.c @@ -105,7 +105,7 @@ static void shades_generate(int time) if (blue > 255) blue= 510 - blue; - colours[i] = LCD_RGBPACK(red, green, blue); + colours[i] = FB_RGBPACK(red, green, blue); r++; g++; b++; } diff --git a/apps/plugins/rockblox.c b/apps/plugins/rockblox.c index 77e834e52b..762f5befc4 100644 --- a/apps/plugins/rockblox.c +++ b/apps/plugins/rockblox.c @@ -789,7 +789,7 @@ static const short scoring[4] = { /* scoring for each number of lines */ struct figure { #if LCD_DEPTH >= 2 - unsigned short color[3]; /* color of figure (light,middle,shadow) */ + unsigned int color[3]; /* color of figure (light,middle,shadow) */ #endif unsigned short max_or; /* max orientations */ signed short shapeX[4], shapeY[4]; /* implementation of figures */ diff --git a/apps/plugins/rockboy/lcd-gb.h b/apps/plugins/rockboy/lcd-gb.h index 36b971a88b..239ccbec74 100644 --- a/apps/plugins/rockboy/lcd-gb.h +++ b/apps/plugins/rockboy/lcd-gb.h @@ -3,6 +3,7 @@ #ifndef __LCD_GB_H__ #define __LCD_GB_H__ +#include "lcd.h" #include "defs.h" struct vissprite @@ -23,7 +24,7 @@ struct scan #elif LCD_DEPTH > 4 byte buf[256]; #endif - un16 pal[64]; + fb_data pal[64]; byte pri[256]; struct vissprite vs[16]; int ns, l, x, y, s, t, u, v, wx, wy, wt, wv; @@ -61,6 +62,3 @@ void pal_dirty(void) ICODE_ATTR; void lcd_reset(void); #endif - - - diff --git a/apps/plugins/rockboy/lcd.c b/apps/plugins/rockboy/lcd.c index 2dc983f812..e8d43f772a 100644 --- a/apps/plugins/rockboy/lcd.c +++ b/apps/plugins/rockboy/lcd.c @@ -19,7 +19,7 @@ struct scan scan IBSS_ATTR; #define BG (scan.bg) #define WND (scan.wnd) -#if LCD_DEPTH ==16 +#if LCD_DEPTH >= 16 #define BUF (scan.buf) #else #define BUF (scan.buf[scanline_ind]) @@ -1154,6 +1154,7 @@ void set_pal(void) static void updatepalette(int i) { int c, r, g, b; + fb_data px; c = (lcd.pal[i<<1] | ((int)lcd.pal[(i<<1)|1] << 8)) & 0x7FFF; r = (c & 0x001F) << 3; @@ -1167,18 +1168,16 @@ static void updatepalette(int i) g = (g >> fb.cc[1].r) << fb.cc[1].l; b = (b >> fb.cc[2].r) << fb.cc[2].l; -#if LCD_PIXELFORMAT == RGB565 c = r|g|b; -#elif LCD_PIXELFORMAT == RGB565SWAPPED - c = swap16(r|g|b); -#endif + + px = FB_SCALARPACK_LCD(c); /* updatepalette might get called, but the pallete does not necessarily * need to be updated. */ - if(PAL[i]!=c) + if(memcmp(&PAL[i], &px, sizeof(fb_data))) { - PAL[i] = c; + PAL[i] = px; #if defined(HAVE_LCD_MODES) && (HAVE_LCD_MODES & LCD_MODE_PAL256) rb->lcd_pal256_update_pal(PAL); #endif @@ -1256,4 +1255,3 @@ void lcd_reset(void) lcd_begin(); vram_dirty(); } - diff --git a/apps/plugins/rockboy/sys_rockbox.c b/apps/plugins/rockboy/sys_rockbox.c index 1bf63b7a74..a758f73da3 100644 --- a/apps/plugins/rockboy/sys_rockbox.c +++ b/apps/plugins/rockboy/sys_rockbox.c @@ -261,12 +261,21 @@ void vid_init(void) fb.enabled=1; #if defined(HAVE_LCD_COLOR) +#if LCD_DEPTH == 24 + fb.cc[0].r = 0; /* 8-8 (wasted bits on red) */ + fb.cc[0].l = 16; /* this is the offset to the R bits (24-8) */ + fb.cc[1].r = 0; /* 8-6 (wasted bits on green) */ + fb.cc[1].l = 8; /* This is the offset to the G bits (24-8-8) */ + fb.cc[2].r = 0; /* 8-5 (wasted bits on red) */ + fb.cc[2].l = 0; /* This is the offset to the B bits (24-8-8-8) */ +#else fb.cc[0].r = 3; /* 8-5 (wasted bits on red) */ fb.cc[0].l = 11; /* this is the offset to the R bits (16-5) */ fb.cc[1].r = 2; /* 8-6 (wasted bits on green) */ fb.cc[1].l = 5; /* This is the offset to the G bits (16-5-6) */ fb.cc[2].r = 3; /* 8-5 (wasted bits on red) */ fb.cc[2].l = 0; /* This is the offset to the B bits (16-5-6-5) */ +#endif #else fb.mode=3; #endif diff --git a/apps/plugins/superdom.c b/apps/plugins/superdom.c index be480bcbb1..5e1479cd3b 100644 --- a/apps/plugins/superdom.c +++ b/apps/plugins/superdom.c @@ -23,8 +23,6 @@ #include "lib/display_text.h" #include "pluginbitmaps/superdom_boarditems.h" - -extern const fb_data superdom_boarditems[]; char buf[255]; #define COLOUR_DARK 0 @@ -32,7 +30,7 @@ char buf[255]; #define MARGIN 5 -#if (LCD_DEPTH == 16) +#if (LCD_DEPTH >= 16) #define MY_BITMAP_PART rb->lcd_bitmap_transparent_part #else #define MY_BITMAP_PART rb->lcd_mono_bitmap_part diff --git a/apps/plugins/zxbox/zxvid_16bpp.c b/apps/plugins/zxbox/zxvid_16bpp.c index 19ac0f2d5c..6380d3d7d7 100644 --- a/apps/plugins/zxbox/zxvid_16bpp.c +++ b/apps/plugins/zxbox/zxvid_16bpp.c @@ -12,7 +12,7 @@ #define IB0 (0xFF-B0) #define IB1 (0xFF-B1) -static const fb_data _16bpp_colors[32] = { +static const unsigned _16bpp_colors[32] = { /* normal */ LCD_RGBPACK(N0, N0, N0), LCD_RGBPACK(N0, N0, N1), LCD_RGBPACK(N1, N0, N0), LCD_RGBPACK(N1, N0, N1), @@ -60,7 +60,7 @@ void update_screen(void) */ frameb = rb->lcd_framebuffer; for ( y = 0 ; y < HEIGHT*WIDTH; y++ ){ - frameb[y] = _16bpp_colors[(unsigned)sp_image[y]]; + frameb[y] = FB_SCALARPACK(_16bpp_colors[(unsigned)sp_image[y]]); } #else @@ -74,7 +74,7 @@ void update_screen(void) srcx = 0; /* reset our x counter before each row... */ for(x = 0; x < LCD_WIDTH; x++) { - *frameb = _16bpp_colors[image[srcx>>16]]; + *frameb = FB_SCALARPACK(_16bpp_colors[image[srcx>>16]]); srcx += X_STEP; /* move through source image */ frameb++; } diff --git a/apps/recorder/bmp.c b/apps/recorder/bmp.c index a6d6dd71b1..a9cc34b2c6 100644 --- a/apps/recorder/bmp.c +++ b/apps/recorder/bmp.c @@ -455,7 +455,7 @@ void output_row_8_native(uint32_t row, void * row_in, *dest++ |= vi_pattern[bright] << shift; } #endif /* LCD_PIXELFORMAT */ -#elif LCD_DEPTH == 16 +#elif LCD_DEPTH >= 16 /* iriver h300, colour iPods, X5 */ (void)fb_width; fb_data *dest = STRIDE_MAIN((fb_data *)ctx->bm->data + fb_width * row, @@ -470,15 +470,18 @@ void output_row_8_native(uint32_t row, void * row_in, bm_alpha += ALIGN_UP(ctx->bm->width, 2) * row/2; for (col = 0; col < ctx->bm->width; col++) { + (void) delta; if (ctx->dither) delta = DITHERXDY(col,dy); r = qp->red; g = qp->green; b = qp->blue; +#if LCD_DEPTH < 24 r = (31 * r + (r >> 3) + delta) >> 8; g = (63 * g + (g >> 2) + delta) >> 8; b = (31 * b + (b >> 3) + delta) >> 8; - *dest = LCD_RGBPACK_LCD(r, g, b); +#endif + *dest = FB_RGBPACK_LCD(r, g, b); dest += STRIDE_MAIN(1, ctx->bm->height); if (bm_alpha) { /* pack alpha channel for 2 pixels into 1 byte and negate @@ -526,8 +529,8 @@ int read_bmp_fd(int fd, bool dither = false; #endif -#ifdef HAVE_REMOTE_LCD bool remote = false; +#ifdef HAVE_REMOTE_LCD if (format & FORMAT_REMOTE) { remote = true; #if LCD_REMOTE_DEPTH == 1 @@ -710,9 +713,7 @@ int read_bmp_fd(int fd, case 16: #if LCD_DEPTH >= 16 /* don't dither 16 bit BMP to LCD with same or larger depth */ -#ifdef HAVE_REMOTE_LCD if (!remote) -#endif dither = false; #endif if (compression == 0) { /* BI_RGB, i.e. 15 bit */ @@ -755,6 +756,12 @@ int read_bmp_fd(int fd, break; } +#if LCD_DEPTH >= 24 + /* Never dither 24/32 bit BMP to 24 bit LCDs */ + if (depth >= 24 && !remote) + dither = false; +#endif + /* Search to the beginning of the image data */ lseek(fd, (off_t)letoh32(bmph.off_bits), SEEK_SET); diff --git a/apps/recorder/resize.c b/apps/recorder/resize.c index 32384537d4..ac6b7a3120 100644 --- a/apps/recorder/resize.c +++ b/apps/recorder/resize.c @@ -680,6 +680,7 @@ static void output_row_32_native_fromyuv(uint32_t row, void * row_in, unsigned r, g, b, y, u, v; for (col = 0; col < ctx->bm->width; col++) { + (void) delta; if (ctx->dither) delta = DITHERXDY(col,dy); y = SC_OUT(qp->b, ctx); @@ -687,10 +688,12 @@ static void output_row_32_native_fromyuv(uint32_t row, void * row_in, v = SC_OUT(qp->r, ctx); qp++; yuv_to_rgb(y, u, v, &r, &g, &b); +#if LCD_DEPTH < 24 r = (31 * r + (r >> 3) + delta) >> 8; g = (63 * g + (g >> 2) + delta) >> 8; b = (31 * b + (b >> 3) + delta) >> 8; - *dest = LCD_RGBPACK_LCD(r, g, b); +#endif + *dest = FB_RGBPACK_LCD(r, g, b); dest += DEST_STEP; } } @@ -764,7 +767,7 @@ static void output_row_32_native(uint32_t row, void * row_in, *dest++ |= vi_pattern[bright] << shift; } #endif /* LCD_PIXELFORMAT */ -#elif LCD_DEPTH == 16 +#elif LCD_DEPTH >= 16 /* iriver h300, colour iPods, X5 */ (void)fb_width; fb_data *dest = STRIDE_MAIN((fb_data *)ctx->bm->data + fb_width * row, @@ -780,16 +783,19 @@ static void output_row_32_native(uint32_t row, void * row_in, bm_alpha += ALIGN_UP(ctx->bm->width, 2)*row/2; for (col = 0; col < ctx->bm->width; col++) { + (void) delta; if (ctx->dither) delta = DITHERXDY(col,dy); q0 = *qp++; r = SC_OUT(q0.r, ctx); g = SC_OUT(q0.g, ctx); b = SC_OUT(q0.b, ctx); +#if LCD_DEPTH < 24 r = (31 * r + (r >> 3) + delta) >> 8; g = (63 * g + (g >> 2) + delta) >> 8; b = (31 * b + (b >> 3) + delta) >> 8; - *dest = LCD_RGBPACK_LCD(r, g, b); +#endif + *dest = FB_RGBPACK_LCD(r, g, b); dest += STRIDE_MAIN(1, ctx->bm->height); if (bm_alpha) { /* pack alpha channel for 2 pixels into 1 byte */ -- cgit v1.2.3