@@ -93,13 +93,13 @@ static inline unsigned blend_pixels(unsigned a, unsigned b)
9393
9494 // Not the original author, but a good explanation is found at:
9595 // https://medium.com/@luc.trudeau/fast-averaging-of-high-color-16-bit-pixels-cb4ac7fd1488
96- #if RG_SCREEN_BYTE_ORDER == 0
96+ #if RG_SCREEN_PIXEL_FORMAT == 0 /* 565_BE */
9797 a = (a << 8 ) | (a >> 8 );
9898 b = (b << 8 ) | (b >> 8 );
9999 unsigned s = a ^ b ;
100100 unsigned v = ((s & 0xF7DEU ) >> 1 ) + (a & b ) + (s & 0x0821U );
101101 return (v << 8 ) | (v >> 8 );
102- #else
102+ #else /* 565_LE */
103103 unsigned s = a ^ b ;
104104 return ((s & 0xF7DEU ) >> 1 ) + (a & b ) + (s & 0x0821U );
105105#endif
@@ -191,13 +191,13 @@ static inline void write_update(const rg_surface_t *update)
191191 else
192192 {
193193 #define RENDER_LINE (PTR_TYPE , PIXEL ) { \
194- PTR_TYPE *buffer = (PTR_TYPE *)(data + map_viewport_to_source_y[y] * stride);\
194+ const PTR_TYPE *buffer = (PTR_TYPE *)(data + map_viewport_to_source_y[y] * stride); \
195195 for (int xx = 0; xx < draw_width; ++xx) { \
196196 int x = map_viewport_to_source_x[xx]; \
197197 *line_buffer_ptr++ = (PIXEL); \
198198 } \
199199 }
200- #if RG_SCREEN_BYTE_ORDER == 0
200+ #if RG_SCREEN_PIXEL_FORMAT == 0 /* 565_BE */
201201 if (format == RG_PIXEL_PAL565_BE )
202202 RENDER_LINE (uint8_t , palette [buffer [x ]])
203203 else if (format == RG_PIXEL_565_BE )
@@ -206,7 +206,7 @@ static inline void write_update(const rg_surface_t *update)
206206 RENDER_LINE (uint16_t , (buffer [x ] << 8 ) | (buffer [x ] >> 8 ))
207207 else if (format == RG_PIXEL_PAL565_LE )
208208 RENDER_LINE (uint8_t , (palette [buffer [x ]] << 8 ) | (palette [buffer [x ]] >> 8 ))
209- #else
209+ #else /* 565_LE */
210210 if (format == RG_PIXEL_PAL565_LE )
211211 RENDER_LINE (uint8_t , palette [buffer [x ]])
212212 else if (format == RG_PIXEL_565_LE )
@@ -337,6 +337,7 @@ static void update_viewport_scaling(void)
337337 display .viewport .step_x = (float )src_width / display .viewport .width ;
338338 display .viewport .step_y = (float )src_height / display .viewport .height ;
339339
340+ // For a filter to be applied it has to be enabled in the menu and scaling factor can't be an integer
340341 display .viewport .filter_x = (config .filter == RG_DISPLAY_FILTER_HORIZ || config .filter == RG_DISPLAY_FILTER_BOTH ) &&
341342 (config .scaling && (display .viewport .width % src_width ) != 0 );
342343 display .viewport .filter_y = (config .filter == RG_DISPLAY_FILTER_VERT || config .filter == RG_DISPLAY_FILTER_BOTH ) &&
@@ -605,9 +606,9 @@ void rg_display_write_rect(int left, int top, int width, int height, int stride,
605606 {
606607 const uint16_t * src = (void * )buffer + ((y + line ) * stride );
607608 uint16_t * dst = lcd_buffer + (line * width );
608- #if RG_SCREEN_BYTE_ORDER == 0
609+ #if RG_SCREEN_PIXEL_FORMAT == 0 /* 565_BE */
609610 if ((flags & RG_DISPLAY_WRITE_BE_DATA ) != 0 )
610- #else
611+ #else /* 565_LE */
611612 if ((flags & RG_DISPLAY_WRITE_BE_DATA ) == 0 )
612613 #endif
613614 {
@@ -639,9 +640,9 @@ void rg_display_clear_rect(int left, int top, int width, int height, uint16_t co
639640{
640641 const int screen_left = display .screen .margins .left + left ;
641642 const int screen_top = display .screen .margins .top + top ;
642- #if RG_SCREEN_BYTE_ORDER == 0
643+ #if RG_SCREEN_PIXEL_FORMAT == 0 /* 565_BE */
643644 const uint16_t color = (color_le << 8 ) | (color_le >> 8 );
644- #else
645+ #else /* 565_LE */
645646 const uint16_t color = color_le ;
646647#endif
647648#if !LCD_SCREEN_BUFFER
@@ -701,6 +702,7 @@ bool rg_display_set_geometry(int width, int height, const rg_margins_t *margins)
701702 display .screen .margins = margins ? * margins : (rg_margins_t ){0 , 0 , 0 , 0 };
702703 display .screen .width = display .screen .real_width - (display .screen .margins .left + display .screen .margins .right );
703704 display .screen .height = display .screen .real_height - (display .screen .margins .top + display .screen .margins .bottom );
705+ // display.screen.format = RG_PIXEL_565_BE;
704706 display .changed = true;
705707 // update_viewport_scaling(); // This will be implicitly done by the display task
706708 rg_gui_update_geometry (); // Let the GUI know that the geometry has changed
0 commit comments