From 3237ae4a4ff9296a377ff9194a11038da161208f Mon Sep 17 00:00:00 2001 From: William Wilgus Date: Wed, 7 Oct 2020 02:01:35 -0400 Subject: LCD core move buf ptr and address look up function viewport struct I'm currently running up against the limitations of the lcd_draw functions I want these functions to be able to be used on any size buffer not just buffers with a stride matching the underlying device [DONE] allow the framebuffer to be decoupled from the device framebuffer [DONE need examples] allow for some simple blit like transformations [DONE] remove the device framebuffer from the plugin api [DONE}ditto remote framebuffer [DONE] remove _viewport_get_framebuffer you can call struct *vp = lcd_set_viewport(NULL) and vp->buffer->fb_ptr while remote lcds may compile (and work in the sim) its not been tested on targets [FIXED] backdrops need work to be screen agnostic [FIXED] screen statusbar is not being combined into the main viewport correctly yet [FIXED] screen elements are displayed incorrectly after switch to void* [FIXED] core didn't restore proper viewport on splash etc. [NEEDS TESTING] remote lcd garbled data [FIXED] osd lib garbled screen on bmp_part [FIXED] grey_set_vp needs to return old viewport like lcd_set_viewport [FIXED] Viewport update now handles viewports with differing buffers/strides by copying to the main buffer [FIXED] splash on top of WPS leaves old framebuffer data (doesn't redraw) [UPDATE] refined this a bit more to have clear_viewport set the clean bit and have skin_render do its own screen clear scrolling viewports no longer trigger wps refresh also fixed a bug where guisyncyesno was displaying and then disappearing [ADDED!] New LCD macros that allow you to create properly size frame buffers in you desired size without wasting bytes (LCD_ and LCD_REMOTE_) LCD_STRIDE(w, h) same as STRIDE_MAIN LCD_FBSTRIDE(w, h) returns target specific stride for a buffer W x H LCD_NBELEMS(w, h) returns the number of fb_data sized elemenst needed for a buffer W x H LCD_NATIVE_STRIDE(s) conversion between rockbox native vertical and lcd native stride (2bitH) test_viewports.c has an example of usage [FIXED!!] 2bit targets don't respect non-native strides [FIXED] Few define snags Change-Id: I0d04c3834e464eca84a5a715743a297a0cefd0af --- firmware/drivers/lcd-16bit-vert.c | 98 +++++++++++++++++++++------------------ 1 file changed, 52 insertions(+), 46 deletions(-) (limited to 'firmware/drivers/lcd-16bit-vert.c') diff --git a/firmware/drivers/lcd-16bit-vert.c b/firmware/drivers/lcd-16bit-vert.c index ffe2b85b3c..b336e78c78 100644 --- a/firmware/drivers/lcd-16bit-vert.c +++ b/firmware/drivers/lcd-16bit-vert.c @@ -39,7 +39,7 @@ #include "scroll_engine.h" #define ROW_INC 1 -#define COL_INC LCD_HEIGHT +#define COL_INC lcd_current_viewport->buffer->stride extern lcd_fastpixelfunc_type* const lcd_fastpixelfuncs_backdrop[]; extern lcd_fastpixelfunc_type* const lcd_fastpixelfuncs_bgcolor[]; @@ -61,7 +61,9 @@ void lcd_hline(int x1, int x2, int y) { int x; fb_data *dst, *dst_end; - lcd_fastpixelfunc_type *pfunc = lcd_fastpixelfuncs[current_vp->drawmode]; + int stride_dst; + + lcd_fastpixelfunc_type *pfunc = lcd_fastpixelfuncs[lcd_current_viewport->drawmode]; /* direction flip */ if (x2 < x1) @@ -73,20 +75,20 @@ void lcd_hline(int x1, int x2, int y) /******************** In viewport clipping **********************/ /* nothing to draw? */ - if (((unsigned)y >= (unsigned)current_vp->height) || - (x1 >= current_vp->width) || + if (((unsigned)y >= (unsigned)lcd_current_viewport->height) || + (x1 >= lcd_current_viewport->width) || (x2 < 0)) return; if (x1 < 0) x1 = 0; - if (x2 >= current_vp->width) - x2 = current_vp->width-1; + if (x2 >= lcd_current_viewport->width) + x2 = lcd_current_viewport->width-1; /* Adjust x1 and y to viewport */ - x1 += current_vp->x; - x2 += current_vp->x; - y += current_vp->y; + x1 += lcd_current_viewport->x; + x2 += lcd_current_viewport->x; + y += lcd_current_viewport->y; #if defined(HAVE_VIEWPORT_CLIP) /********************* Viewport on screen clipping ********************/ @@ -103,12 +105,13 @@ void lcd_hline(int x1, int x2, int y) #endif dst = FBADDR(x1 , y ); - dst_end = dst + (x2 - x1) * LCD_HEIGHT; + stride_dst = lcd_current_viewport->buffer->stride; + dst_end = dst + (x2 - x1) * stride_dst; do { pfunc(dst); - dst += LCD_HEIGHT; + dst += stride_dst; } while (dst <= dst_end); } @@ -131,20 +134,20 @@ void lcd_vline(int x, int y1, int y2) /******************** In viewport clipping **********************/ /* nothing to draw? */ - if (((unsigned)x >= (unsigned)current_vp->width) || - (y1 >= current_vp->height) || + if (((unsigned)x >= (unsigned)lcd_current_viewport->width) || + (y1 >= lcd_current_viewport->height) || (y2 < 0)) return; if (y1 < 0) y1 = 0; - if (y2 >= current_vp->height) - y2 = current_vp->height-1; + if (y2 >= lcd_current_viewport->height) + y2 = lcd_current_viewport->height-1; /* adjust for viewport */ - x += current_vp->x; - y1 += current_vp->y; - y2 += current_vp->y; + x += lcd_current_viewport->x; + y1 += lcd_current_viewport->y; + y2 += lcd_current_viewport->y; #if defined(HAVE_VIEWPORT_CLIP) /********************* Viewport on screen clipping ********************/ @@ -163,14 +166,14 @@ void lcd_vline(int x, int y1, int y2) height = y2 - y1 + 1; /* drawmode and optimisation */ - if (current_vp->drawmode & DRMODE_INVERSEVID) + if (lcd_current_viewport->drawmode & DRMODE_INVERSEVID) { - if (current_vp->drawmode & DRMODE_BG) + if (lcd_current_viewport->drawmode & DRMODE_BG) { if (!lcd_backdrop) { fillopt = OPT_SET; - bits = current_vp->bg_pattern; + bits = lcd_current_viewport->bg_pattern; } else fillopt = OPT_COPY; @@ -178,13 +181,13 @@ void lcd_vline(int x, int y1, int y2) } else { - if (current_vp->drawmode & DRMODE_FG) + if (lcd_current_viewport->drawmode & DRMODE_FG) { fillopt = OPT_SET; - bits = current_vp->fg_pattern; + bits = lcd_current_viewport->fg_pattern; } } - if (fillopt == OPT_NONE && current_vp->drawmode != DRMODE_COMPLEMENT) + if (fillopt == OPT_NONE && lcd_current_viewport->drawmode != DRMODE_COMPLEMENT) return; dst = FBADDR(x, y1); @@ -215,11 +218,11 @@ void ICODE_ATTR lcd_bitmap_part(const fb_data *src, int src_x, int src_y, int height) { fb_data *dst; - + int stride_dst; /******************** Image in viewport clipping **********************/ /* nothing to draw? */ - if ((width <= 0) || (height <= 0) || (x >= current_vp->width) || - (y >= current_vp->height) || (x + width <= 0) || (y + height <= 0)) + if ((width <= 0) || (height <= 0) || (x >= lcd_current_viewport->width) || + (y >= lcd_current_viewport->height) || (x + width <= 0) || (y + height <= 0)) return; if (x < 0) @@ -235,14 +238,14 @@ void ICODE_ATTR lcd_bitmap_part(const fb_data *src, int src_x, int src_y, y = 0; } - if (x + width > current_vp->width) - width = current_vp->width - x; - if (y + height > current_vp->height) - height = current_vp->height - y; + if (x + width > lcd_current_viewport->width) + width = lcd_current_viewport->width - x; + if (y + height > lcd_current_viewport->height) + height = lcd_current_viewport->height - y; /* adjust for viewport */ - x += current_vp->x; - y += current_vp->y; + x += lcd_current_viewport->x; + y += lcd_current_viewport->y; #if defined(HAVE_VIEWPORT_CLIP) /********************* Viewport on screen clipping ********************/ @@ -272,13 +275,14 @@ void ICODE_ATTR lcd_bitmap_part(const fb_data *src, int src_x, int src_y, src += stride * src_x + src_y; /* move starting point */ dst = FBADDR(x, y); - fb_data *dst_end = dst + width * LCD_HEIGHT; + stride_dst = lcd_current_viewport->buffer->stride; + fb_data *dst_end = dst + width * stride_dst; do { memcpy(dst, src, height * sizeof(fb_data)); src += stride; - dst += LCD_HEIGHT; + dst += stride_dst; } while (dst < dst_end); } @@ -289,11 +293,12 @@ void ICODE_ATTR lcd_bitmap_transparent_part(const fb_data *src, int src_x, int y, int width, int height) { fb_data *dst, *dst_end; + int stride_dst; /******************** Image in viewport clipping **********************/ /* nothing to draw? */ - if ((width <= 0) || (height <= 0) || (x >= current_vp->width) || - (y >= current_vp->height) || (x + width <= 0) || (y + height <= 0)) + if ((width <= 0) || (height <= 0) || (x >= lcd_current_viewport->width) || + (y >= lcd_current_viewport->height) || (x + width <= 0) || (y + height <= 0)) return; if (x < 0) @@ -309,14 +314,14 @@ void ICODE_ATTR lcd_bitmap_transparent_part(const fb_data *src, int src_x, y = 0; } - if (x + width > current_vp->width) - width = current_vp->width - x; - if (y + height > current_vp->height) - height = current_vp->height - y; + if (x + width > lcd_current_viewport->width) + width = lcd_current_viewport->width - x; + if (y + height > lcd_current_viewport->height) + height = lcd_current_viewport->height - y; /* adjust for viewport */ - x += current_vp->x; - y += current_vp->y; + x += lcd_current_viewport->x; + y += lcd_current_viewport->y; #if defined(HAVE_VIEWPORT_CLIP) /********************* Viewport on screen clipping ********************/ @@ -346,7 +351,8 @@ void ICODE_ATTR lcd_bitmap_transparent_part(const fb_data *src, int src_x, src += stride * src_x + src_y; /* move starting point */ dst = FBADDR(x, y); - dst_end = dst + width * LCD_HEIGHT; + stride_dst = lcd_current_viewport->buffer->stride; + dst_end = dst + width * stride_dst; do { @@ -354,12 +360,12 @@ void ICODE_ATTR lcd_bitmap_transparent_part(const fb_data *src, int src_x, for(i = 0;i < height;i++) { if (src[i] == REPLACEWITHFG_COLOR) - dst[i] = current_vp->fg_pattern; + dst[i] = lcd_current_viewport->fg_pattern; else if(src[i] != TRANSPARENT_COLOR) dst[i] = src[i]; } src += stride; - dst += LCD_HEIGHT; + dst += stride_dst; } while (dst < dst_end); } -- cgit v1.2.3