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 +++--- 3 files changed, 31 insertions(+), 17 deletions(-) (limited to 'apps/gui') 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; -- cgit v1.2.3