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/export/lcd-remote.h | 74 +++++++++++++++++++++++--------------------- 1 file changed, 38 insertions(+), 36 deletions(-) (limited to 'firmware/export/lcd-remote.h') diff --git a/firmware/export/lcd-remote.h b/firmware/export/lcd-remote.h index 1819a4de72..030b01c736 100644 --- a/firmware/export/lcd-remote.h +++ b/firmware/export/lcd-remote.h @@ -34,29 +34,12 @@ #define REMOTETYPE_H100_LCD 1 #define REMOTETYPE_H300_LCD 2 #define REMOTETYPE_H300_NONLCD 3 -int remote_type(void); -#endif - -#if LCD_REMOTE_DEPTH <= 8 -#if (LCD_REMOTE_PIXELFORMAT == VERTICAL_INTERLEAVED) \ - || (LCD_REMOTE_PIXELFORMAT == HORIZONTAL_INTERLEAVED) -typedef unsigned short fb_remote_data; -#define FB_RDATA_SZ 2 -#else -typedef unsigned char fb_remote_data; -#define FB_RDATA_SZ 1 -#endif -#elif LCD_DEPTH <= 16 -typedef unsigned short fb_remote_data; -#define FB_RDATA_SZ 2 -#else -typedef unsigned long fb_remote_data; -#define FB_RDATA_SZ 4 + int remote_type(void); #endif #if LCD_REMOTE_DEPTH > 1 /* greyscale - 8 bit max */ #ifdef HAVE_LCD_COLOR -extern unsigned lcd_remote_color_to_native(unsigned color); + extern unsigned lcd_remote_color_to_native(unsigned color); #endif #define LCD_REMOTE_MAX_LEVEL ((1 << LCD_REMOTE_DEPTH) - 1) @@ -77,12 +60,19 @@ extern unsigned lcd_remote_color_to_native(unsigned color); /* Frame buffer dimensions (format checks only cover existing targets!) */ #if LCD_REMOTE_DEPTH == 1 -#define LCD_REMOTE_FBHEIGHT ((LCD_REMOTE_HEIGHT+7)/8) +#define LCD_REMOTE_STRIDE(w, h) (h) +#define LCD_REMOTE_FBSTRIDE(w, h) ((h+7)/8) +#define LCD_REMOTE_FBHEIGHT LCD_REMOTE_FBSTRIDE(LCD_REMOTE_WIDTH, LCD_REMOTE_HEIGHT) +#define LCD_REMOTE_NBELEMS(w, h) (((w*LCD_REMOTE_FBSTRIDE(w, h)) + h) / sizeof(fb_remote_data)) #elif LCD_REMOTE_DEPTH == 2 #if LCD_REMOTE_PIXELFORMAT == VERTICAL_INTERLEAVED -#define LCD_REMOTE_FBHEIGHT ((LCD_REMOTE_HEIGHT+7)/8) +#define LCD_REMOTE_STRIDE(w, h) (h) +#define LCD_REMOTE_FBSTRIDE(w, h) ((h+7)/8) +#define LCD_REMOTE_FBHEIGHT LCD_REMOTE_FBSTRIDE(LCD_REMOTE_WIDTH, LCD_REMOTE_HEIGHT) +#define LCD_REMOTE_NBELEMS(w, h) (((w*LCD_REMOTE_FBSTRIDE(w, h)) + h) / sizeof(fb_remote_data)) #endif #endif /* LCD_REMOTE_DEPTH */ + /* Set defaults if not defined different yet. The defaults apply to both * dimensions for LCD_REMOTE_DEPTH >= 8 */ #ifndef LCD_REMOTE_FBWIDTH @@ -92,11 +82,20 @@ extern unsigned lcd_remote_color_to_native(unsigned color); #define LCD_REMOTE_FBHEIGHT LCD_REMOTE_HEIGHT #endif -/* The actual framebuffer */ -extern fb_remote_data *lcd_remote_framebuffer; -extern fb_remote_data lcd_remote_static_framebuffer[LCD_REMOTE_FBHEIGHT][LCD_REMOTE_FBWIDTH]; -#define FBREMOTEADDR(x, y) (lcd_remote_framebuffer + ((y) * LCD_REMOTE_FBWIDTH) + (x)) -#define FRAMEBUFFER_REMOTE_SIZE (sizeof(lcd_remote_static_framebuffer)) +#ifndef LCD_REMOTE_NBELEMS +/* At this time (2020) known remote screens only have vertical stride */ +#define LCD_REMOTE_NBELEMS(w, h) ((w*STRIDE_REMOTE(w, h)) + h) / sizeof(fb_remote_data)) +#define LCD_REMOTE_STRIDE(w, h) STRIDE_REMOTE(w, h) +#define LCD_REMOTE_FBSTRIDE(w, h) STRIDE_REMOTE(w, h) +#endif + +#ifndef LCD_REMOTE_NATIVE_STRIDE +#define LCD_REMOTE_NATIVE_STRIDE(s) (s) +#endif + +extern struct viewport* lcd_remote_current_viewport; +#define FBREMOTEADDR(x,y) (fb_remote_data *)(lcd_remote_current_viewport->buffer->get_address_fn(x, y)) +#define FRAMEBUFFER_REMOTE_SIZE (sizeof(fb_remote_data)*LCD_REMOTE_FBWIDTH*LCD_REMOTE_FBHEIGHT) #if LCD_REMOTE_DEPTH > 1 extern void lcd_remote_set_foreground(unsigned foreground); @@ -112,13 +111,13 @@ extern void lcd_remote_mono_bitmap_part(const unsigned char *src, int src_x, int src_y, int stride, int x, int y, int width, int height); extern void lcd_remote_mono_bitmap(const unsigned char *src, int x, int y, - int width, int height); + int width, int height); extern void lcd_remote_bitmap_transparent_part(const fb_remote_data *src, int src_x, int src_y, int stride, int x, int y, int width, int height); extern void lcd_bitmap_remote_transparent(const fb_remote_data *src, int x, - int y, int width, int height); + int y, int width, int height); #else /* LCD_REMOTE_DEPTH == 1 */ #define lcd_remote_mono_bitmap lcd_remote_bitmap #define lcd_remote_mono_bitmap_part lcd_remote_bitmap_part @@ -137,7 +136,7 @@ extern void lcd_remote_bitmap_part(const fb_remote_data *src, int src_x, extern void lcd_remote_bitmap(const fb_remote_data *src, int x, int y, int width, int height); extern void lcd_remote_nine_segment_bmp(const struct bitmap* bm, int x, int y, - int width, int height); + int width, int height); /* Low-level drawing function types */ typedef void lcd_remote_pixelfunc_type(int x, int y); @@ -146,17 +145,17 @@ typedef void lcd_remote_blockfunc_type(fb_remote_data *address, unsigned mask, /* low level drawing function pointer arrays */ #if LCD_REMOTE_DEPTH > 1 -extern lcd_remote_pixelfunc_type* const *lcd_remote_pixelfuncs; -extern lcd_remote_blockfunc_type* const *lcd_remote_blockfuncs; + extern lcd_remote_pixelfunc_type* const *lcd_remote_pixelfuncs; + extern lcd_remote_blockfunc_type* const *lcd_remote_blockfuncs; #else -extern lcd_remote_pixelfunc_type* const lcd_remote_pixelfuncs[8]; -extern lcd_remote_blockfunc_type* const lcd_remote_blockfuncs[8]; + extern lcd_remote_pixelfunc_type* const lcd_remote_pixelfuncs[8]; + extern lcd_remote_blockfunc_type* const lcd_remote_blockfuncs[8]; #endif #endif /* HAVE_LCD_REMOTE */ #ifdef HAVE_REMOTE_LCD_TICKING -void lcd_remote_emireduce(bool state); + void lcd_remote_emireduce(bool state); #endif void lcd_remote_init_device(void); @@ -170,7 +169,10 @@ extern void lcd_remote_init(void); extern int lcd_remote_default_contrast(void); extern void lcd_remote_set_contrast(int val); -extern void lcd_remote_set_viewport(struct viewport* vp); +extern struct viewport* lcd_remote_init_viewport(struct viewport* vp); +extern struct viewport* lcd_remote_set_viewport(struct viewport* vp); +extern struct viewport* lcd_remote_set_viewport_ex(struct viewport* vp, int flags); + extern void lcd_remote_clear_display(void); extern void lcd_remote_clear_viewport(void); extern void lcd_remote_puts(int x, int y, const unsigned char *str); @@ -212,7 +214,7 @@ extern void lcd_remote_bidir_scroll(int threshold); extern void lcd_remote_scroll_step(int pixels); extern void lcd_remote_bmp_part(const struct bitmap* bm, int src_x, int src_y, - int x, int y, int width, int height); + int x, int y, int width, int height); extern void lcd_remote_bmp(const struct bitmap* bm, int x, int y); #endif /* __LCD_REMOTE_H__ */ -- cgit v1.2.3