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-2bit-vert.c | 210 ++++++++++++++++++++++----------------- 1 file changed, 121 insertions(+), 89 deletions(-) (limited to 'firmware/drivers/lcd-2bit-vert.c') diff --git a/firmware/drivers/lcd-2bit-vert.c b/firmware/drivers/lcd-2bit-vert.c index 501e568a69..a099c45e98 100644 --- a/firmware/drivers/lcd-2bit-vert.c +++ b/firmware/drivers/lcd-2bit-vert.c @@ -36,8 +36,8 @@ /*** globals ***/ -fb_data lcd_static_framebuffer[LCD_FBHEIGHT][LCD_FBWIDTH] IRAM_LCDFRAMEBUFFER; -fb_data *lcd_framebuffer = &lcd_static_framebuffer[0][0]; +static fb_data lcd_static_framebuffer[LCD_FBHEIGHT][LCD_FBWIDTH] IRAM_LCDFRAMEBUFFER; +static void *lcd_frameaddress_default(int x, int y); const unsigned char lcd_dibits[16] ICONST_ATTR = { 0x00, 0x03, 0x0C, 0x0F, 0x30, 0x33, 0x3C, 0x3F, @@ -51,6 +51,15 @@ static const unsigned char pixmask[4] ICONST_ATTR = { static fb_data* lcd_backdrop = NULL; static long lcd_backdrop_offset IDATA_ATTR = 0; +/* shouldn't be changed unless you want system-wide framebuffer changes! */ +struct frame_buffer_t lcd_framebuffer_default = +{ + .fb_ptr = &lcd_static_framebuffer[0][0], + .get_address_fn = &lcd_frameaddress_default, + .stride = STRIDE_MAIN(LCD_WIDTH, LCD_HEIGHT), + .elems = (LCD_FBWIDTH*LCD_FBHEIGHT), +}; + static struct viewport default_vp = { .x = 0, @@ -59,18 +68,32 @@ static struct viewport default_vp = .height = LCD_HEIGHT, .font = FONT_SYSFIXED, .drawmode = DRMODE_SOLID, + .buffer = NULL, .fg_pattern = LCD_DEFAULT_FG, .bg_pattern = LCD_DEFAULT_BG }; -static struct viewport* current_vp IBSS_ATTR; +struct viewport* lcd_current_viewport IBSS_ATTR; static unsigned fg_pattern IBSS_ATTR; static unsigned bg_pattern IBSS_ATTR; +static void *lcd_frameaddress_default(int x, int y) +{ + /* the default expects a buffer the same size as the screen */ + struct frame_buffer_t *fb = lcd_current_viewport->buffer; + +#if defined(LCD_STRIDEFORMAT) && LCD_STRIDEFORMAT == VERTICAL_STRIDE + size_t element = (x * LCD_NATIVE_STRIDE(fb->stride)) + y; +#else + size_t element = (y * LCD_NATIVE_STRIDE(fb->stride)) + x; +#endif + return fb->fb_ptr + element; /*(element % fb->elems);*/ +} + /* LCD init */ void lcd_init(void) { - /* Initialise the viewport */ + /* Initialize the viewport */ lcd_set_viewport(NULL); lcd_clear_display(); @@ -83,34 +106,34 @@ void lcd_init(void) void lcd_set_drawmode(int mode) { - current_vp->drawmode = mode & (DRMODE_SOLID|DRMODE_INVERSEVID); + lcd_current_viewport->drawmode = mode & (DRMODE_SOLID|DRMODE_INVERSEVID); } int lcd_get_drawmode(void) { - return current_vp->drawmode; + return lcd_current_viewport->drawmode; } void lcd_set_foreground(unsigned brightness) { - current_vp->fg_pattern = brightness; + lcd_current_viewport->fg_pattern = brightness; fg_pattern = 0x55 * (~brightness & 3); } unsigned lcd_get_foreground(void) { - return current_vp->fg_pattern; + return lcd_current_viewport->fg_pattern; } void lcd_set_background(unsigned brightness) { - current_vp->bg_pattern = brightness; + lcd_current_viewport->bg_pattern = brightness; bg_pattern = 0x55 * (~brightness & 3); } unsigned lcd_get_background(void) { - return current_vp->bg_pattern; + return lcd_current_viewport->bg_pattern; } void lcd_set_drawinfo(int mode, unsigned fg_brightness, unsigned bg_brightness) @@ -122,27 +145,27 @@ void lcd_set_drawinfo(int mode, unsigned fg_brightness, unsigned bg_brightness) int lcd_getwidth(void) { - return current_vp->width; + return lcd_current_viewport->width; } int lcd_getheight(void) { - return current_vp->height; + return lcd_current_viewport->height; } void lcd_setfont(int newfont) { - current_vp->font = newfont; + lcd_current_viewport->font = newfont; } int lcd_getfont(void) { - return current_vp->font; + return lcd_current_viewport->font; } int lcd_getstringsize(const unsigned char *str, int *w, int *h) { - return font_getstringsize(str, w, h, current_vp->font); + return font_getstringsize(str, w, h, lcd_current_viewport->font); } /*** low-level drawing functions ***/ @@ -320,7 +343,7 @@ void lcd_set_backdrop(fb_data* backdrop) lcd_backdrop = backdrop; if (backdrop) { - lcd_backdrop_offset = (long)backdrop - (long)lcd_framebuffer; + lcd_backdrop_offset = (long)backdrop - (long)FBADDR(0,0); lcd_pixelfuncs = lcd_pixelfuncs_backdrop; lcd_blockfuncs = lcd_blockfuncs_backdrop; } @@ -351,16 +374,16 @@ static inline void setblock(fb_data *address, unsigned mask, unsigned bits) /* Clear the whole display */ void lcd_clear_display(void) { - if (current_vp->drawmode & DRMODE_INVERSEVID) + if (lcd_current_viewport->drawmode & DRMODE_INVERSEVID) { - memset(lcd_framebuffer, fg_pattern, FRAMEBUFFER_SIZE); + memset(FBADDR(0,0), fg_pattern, FRAMEBUFFER_SIZE); } else { if (lcd_backdrop) - memcpy(lcd_framebuffer, lcd_backdrop, FRAMEBUFFER_SIZE); + memcpy(FBADDR(0,0), lcd_backdrop, FRAMEBUFFER_SIZE); else - memset(lcd_framebuffer, bg_pattern, FRAMEBUFFER_SIZE); + memset(FBADDR(0,0), bg_pattern, FRAMEBUFFER_SIZE); } lcd_scroll_info.lines = 0; @@ -371,37 +394,39 @@ void lcd_clear_viewport(void) { int lastmode; - if (current_vp == &default_vp) + if (lcd_current_viewport == &default_vp && + default_vp.buffer == &lcd_framebuffer_default) { lcd_clear_display(); } else { - lastmode = current_vp->drawmode; + lastmode = lcd_current_viewport->drawmode; /* Invert the INVERSEVID bit and set basic mode to SOLID */ - current_vp->drawmode = (~lastmode & DRMODE_INVERSEVID) | + lcd_current_viewport->drawmode = (~lastmode & DRMODE_INVERSEVID) | DRMODE_SOLID; - lcd_fillrect(0, 0, current_vp->width, current_vp->height); + lcd_fillrect(0, 0, lcd_current_viewport->width, lcd_current_viewport->height); - current_vp->drawmode = lastmode; + lcd_current_viewport->drawmode = lastmode; - lcd_scroll_stop_viewport(current_vp); + lcd_scroll_stop_viewport(lcd_current_viewport); } + lcd_current_viewport->flags &= ~(VP_FLAG_VP_SET_CLEAN); } /* Set a single pixel */ void lcd_drawpixel(int x, int y) { - if ( ((unsigned)x < (unsigned)current_vp->width) - && ((unsigned)y < (unsigned)current_vp->height) + if ( ((unsigned)x < (unsigned)lcd_current_viewport->width) + && ((unsigned)y < (unsigned)lcd_current_viewport->height) #if defined(HAVE_VIEWPORT_CLIP) && ((unsigned)x < (unsigned)LCD_WIDTH) && ((unsigned)y < (unsigned)LCD_HEIGHT) #endif ) - lcd_pixelfuncs[current_vp->drawmode](current_vp->x + x, current_vp->y + y); + lcd_pixelfuncs[lcd_current_viewport->drawmode](lcd_current_viewport->x + x, lcd_current_viewport->y + y); } /* Draw a line */ @@ -413,7 +438,7 @@ void lcd_drawline(int x1, int y1, int x2, int y2) int d, dinc1, dinc2; int x, xinc1, xinc2; int y, yinc1, yinc2; - lcd_pixelfunc_type *pfunc = lcd_pixelfuncs[current_vp->drawmode]; + lcd_pixelfunc_type *pfunc = lcd_pixelfuncs[lcd_current_viewport->drawmode]; deltax = abs(x2 - x1); if (deltax == 0) @@ -469,14 +494,14 @@ void lcd_drawline(int x1, int y1, int x2, int y2) for (i = 0; i < numpixels; i++) { - if ( ((unsigned)x < (unsigned)current_vp->width) - && ((unsigned)y < (unsigned)current_vp->height) + if ( ((unsigned)x < (unsigned)lcd_current_viewport->width) + && ((unsigned)y < (unsigned)lcd_current_viewport->height) #if defined(HAVE_VIEWPORT_CLIP) && ((unsigned)x < (unsigned)LCD_WIDTH) && ((unsigned)y < (unsigned)LCD_HEIGHT) #endif ) - pfunc(current_vp->x + x, current_vp->y + y); + pfunc(lcd_current_viewport->x + x, lcd_current_viewport->y + y); if (d < 0) { @@ -512,19 +537,19 @@ 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 ********************/ @@ -542,7 +567,7 @@ void lcd_hline(int x1, int x2, int y) width = x2 - x1 + 1; - bfunc = lcd_blockfuncs[current_vp->drawmode]; + bfunc = lcd_blockfuncs[lcd_current_viewport->drawmode]; dst = FBADDR(x1,y>>2); mask = pixmask[y & 3]; @@ -557,6 +582,7 @@ void lcd_vline(int x, int y1, int y2) { int ny; fb_data *dst; + int stride_dst; unsigned mask, mask_bottom; lcd_blockfunc_type *bfunc; @@ -570,19 +596,19 @@ 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 */ - y1 += current_vp->y; - y2 += current_vp->y; - x += current_vp->x; + y1 += lcd_current_viewport->y; + y2 += lcd_current_viewport->y; + x += lcd_current_viewport->x; #if defined(HAVE_VIEWPORT_CLIP) /********************* Viewport on screen clipping ********************/ @@ -598,8 +624,9 @@ void lcd_vline(int x, int y1, int y2) y2 = LCD_HEIGHT-1; #endif - bfunc = lcd_blockfuncs[current_vp->drawmode]; + bfunc = lcd_blockfuncs[lcd_current_viewport->drawmode]; dst = FBADDR(x,y1>>2); + stride_dst = lcd_current_viewport->buffer->stride; ny = y2 - (y1 & ~3); mask = 0xFFu << (2 * (y1 & 3)); mask_bottom = 0xFFu >> (2 * (~ny & 3)); @@ -607,7 +634,7 @@ void lcd_vline(int x, int y1, int y2) for (; ny >= 4; ny -= 4) { bfunc(dst, mask, 0xFFu); - dst += LCD_WIDTH; + dst += stride_dst; mask = 0xFFu; } mask &= mask_bottom; @@ -634,6 +661,7 @@ void lcd_fillrect(int x, int y, int width, int height) { int ny; fb_data *dst, *dst_end; + int stride_dst; unsigned mask, mask_bottom; unsigned bits = 0; lcd_blockfunc_type *bfunc; @@ -641,8 +669,8 @@ void lcd_fillrect(int x, int y, int width, int height) /******************** 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) @@ -655,14 +683,14 @@ void lcd_fillrect(int x, int y, int width, int height) height += 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 ********************/ @@ -688,9 +716,9 @@ void lcd_fillrect(int x, int y, int width, int height) height = LCD_HEIGHT - y; #endif - if (current_vp->drawmode & DRMODE_INVERSEVID) + if (lcd_current_viewport->drawmode & DRMODE_INVERSEVID) { - if ((current_vp->drawmode & DRMODE_BG) && !lcd_backdrop) + if ((lcd_current_viewport->drawmode & DRMODE_BG) && !lcd_backdrop) { fillopt = true; bits = bg_pattern; @@ -698,14 +726,15 @@ void lcd_fillrect(int x, int y, int width, int height) } else { - if (current_vp->drawmode & DRMODE_FG) + if (lcd_current_viewport->drawmode & DRMODE_FG) { fillopt = true; bits = fg_pattern; } } - bfunc = lcd_blockfuncs[current_vp->drawmode]; + bfunc = lcd_blockfuncs[lcd_current_viewport->drawmode]; dst = FBADDR(x,y>>2); + stride_dst = lcd_current_viewport->buffer->stride; ny = height - 1 + (y & 3); mask = 0xFFu << (2 * (y & 3)); mask_bottom = 0xFFu >> (2 * (~ny & 3)); @@ -724,7 +753,7 @@ void lcd_fillrect(int x, int y, int width, int height) while (dst_row < dst_end); } - dst += LCD_WIDTH; + dst += stride_dst; mask = 0xFFu; } mask &= mask_bottom; @@ -758,13 +787,14 @@ void ICODE_ATTR lcd_mono_bitmap_part(const unsigned char *src, int src_x, { int shift, ny; fb_data *dst, *dst_end; + int stride_dst; unsigned mask, mask_bottom; lcd_blockfunc_type *bfunc; /******************** 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) @@ -779,14 +809,14 @@ void ICODE_ATTR lcd_mono_bitmap_part(const unsigned char *src, int src_x, src_y -= 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 ********************/ @@ -818,13 +848,14 @@ void ICODE_ATTR lcd_mono_bitmap_part(const unsigned char *src, int src_x, src_y &= 7; y -= src_y; dst = FBADDR(x,y>>2); + stride_dst = lcd_current_viewport->buffer->stride; shift = y & 3; ny = height - 1 + shift + src_y; mask = 0xFFFFu << (2 * (shift + src_y)); /* Overflowing bits aren't important. */ mask_bottom = 0xFFFFu >> (2 * (~ny & 7)); - bfunc = lcd_blockfuncs[current_vp->drawmode]; + bfunc = lcd_blockfuncs[lcd_current_viewport->drawmode]; if (shift == 0) { @@ -836,7 +867,7 @@ void ICODE_ATTR lcd_mono_bitmap_part(const unsigned char *src, int src_x, for (; ny >= 8; ny -= 8) { const unsigned char *src_row = src; - fb_data *dst_row = dst + LCD_WIDTH; + fb_data *dst_row = dst + stride_dst; dst_end = dst_row + width; @@ -845,7 +876,7 @@ void ICODE_ATTR lcd_mono_bitmap_part(const unsigned char *src, int src_x, do { data = *src_row++; - bfunc(dst_row - LCD_WIDTH, dmask1, lcd_dibits[data&0x0F]); + bfunc(dst_row - stride_dst, dmask1, lcd_dibits[data&0x0F]); bfunc(dst_row++, dmask2, lcd_dibits[(data>>4)&0x0F]); } while (dst_row < dst_end); @@ -857,7 +888,7 @@ void ICODE_ATTR lcd_mono_bitmap_part(const unsigned char *src, int src_x, while (dst_row < dst_end); } src += stride; - dst += 2*LCD_WIDTH; + dst += 2*stride_dst; dmask1 = dmask2 = 0xFFu; } dmask1 &= mask_bottom; @@ -873,7 +904,7 @@ void ICODE_ATTR lcd_mono_bitmap_part(const unsigned char *src, int src_x, { data = *src++; bfunc(dst, dmask1, lcd_dibits[data&0x0F]); - bfunc((dst++) + LCD_WIDTH, dmask2, lcd_dibits[(data>>4)&0x0F]); + bfunc((dst++) + stride_dst, dmask2, lcd_dibits[(data>>4)&0x0F]); } while (dst < dst_end); } @@ -887,7 +918,7 @@ void ICODE_ATTR lcd_mono_bitmap_part(const unsigned char *src, int src_x, else { do - bfunc((dst++) + LCD_WIDTH, dmask2, lcd_dibits[((*src++)>>4)&0x0F]); + bfunc((dst++) + stride_dst, dmask2, lcd_dibits[((*src++)>>4)&0x0F]); while (dst < dst_end); } } @@ -909,7 +940,7 @@ void ICODE_ATTR lcd_mono_bitmap_part(const unsigned char *src, int src_x, { if (mask_col & 0xFFu) bfunc(dst_col, mask_col, lcd_dibits[data&0x0F]); - bfunc(dst_col + LCD_WIDTH, mask_col >> 8, + bfunc(dst_col + stride_dst, mask_col >> 8, lcd_dibits[(data>>4)&0x0F]); mask_col = 0xFFFFu; } @@ -917,7 +948,7 @@ void ICODE_ATTR lcd_mono_bitmap_part(const unsigned char *src, int src_x, mask_col >>= 16; src_col += stride; - dst_col += 2*LCD_WIDTH; + dst_col += 2*stride_dst; data >>= 8; } data |= *src_col << shift; @@ -925,7 +956,7 @@ void ICODE_ATTR lcd_mono_bitmap_part(const unsigned char *src, int src_x, if (mask_col & 0xFFu) bfunc(dst_col, mask_col, lcd_dibits[data&0x0F]); if (mask_col & 0xFF00u) - bfunc(dst_col + LCD_WIDTH, mask_col >> 8, + bfunc(dst_col + stride_dst, mask_col >> 8, lcd_dibits[(data>>4)&0x0F]); } while (dst < dst_end); @@ -956,12 +987,13 @@ void ICODE_ATTR lcd_bitmap_part(const fb_data *src, int src_x, int src_y, { int shift, ny; fb_data *dst, *dst_end; + int stride_dst; unsigned mask, mask_bottom; /******************** 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) @@ -976,14 +1008,14 @@ void ICODE_ATTR lcd_bitmap_part(const fb_data *src, int src_x, int src_y, src_y -= 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 ********************/ @@ -1010,11 +1042,11 @@ void ICODE_ATTR lcd_bitmap_part(const fb_data *src, int src_x, int src_y, if (y + height > LCD_HEIGHT) height = LCD_HEIGHT - y; #endif - src += stride * (src_y >> 2) + src_x; /* move starting point */ src_y &= 3; y -= src_y; dst = FBADDR(x,y>>2); + stride_dst = lcd_current_viewport->buffer->stride; shift = y & 3; ny = height - 1 + shift + src_y; @@ -1038,7 +1070,7 @@ void ICODE_ATTR lcd_bitmap_part(const fb_data *src, int src_x, int src_y, while (dst_row < dst_end); } src += stride; - dst += LCD_WIDTH; + dst += stride_dst; mask = 0xFFu; } mask &= mask_bottom; @@ -1077,7 +1109,7 @@ void ICODE_ATTR lcd_bitmap_part(const fb_data *src, int src_x, int src_y, mask_col >>= 8; src_col += stride; - dst_col += LCD_WIDTH; + dst_col += stride_dst; data >>= 8; } data |= *src_col << shift; -- cgit v1.2.3