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/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 ++- 4 files changed, 109 insertions(+), 98 deletions(-) (limited to 'apps/plugins/lib') 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 */ - -- cgit v1.2.3