@@ -156,7 +156,8 @@ STATIC const displayio_area_t* _get_refresh_areas(framebufferio_framebufferdispl
156156 return NULL ;
157157}
158158
159- STATIC bool _refresh_area (framebufferio_framebufferdisplay_obj_t * self , const displayio_area_t * area ) {
159+ #define MARK_ROW_DIRTY (r ) (dirty_row_bitmask[r/8] = (1 << (r & 7)))
160+ STATIC bool _refresh_area (framebufferio_framebufferdisplay_obj_t * self , const displayio_area_t * area , uint8_t * dirty_row_bitmask ) {
160161 uint16_t buffer_size = 128 ; // In uint32_ts
161162
162163 displayio_area_t clipped ;
@@ -235,6 +236,7 @@ STATIC bool _refresh_area(framebufferio_framebufferdisplay_obj_t* self, const di
235236
236237 for (uint16_t i = subrectangle .y1 ; i < subrectangle .y2 ; i ++ ) {
237238 assert (dest >= buf && dest < endbuf && dest + rowsize <= endbuf );
239+ MARK_ROW_DIRTY (i );
238240 memcpy (dest , src , rowsize );
239241 dest += rowstride ;
240242 src += rowsize ;
@@ -251,12 +253,14 @@ STATIC void _refresh_display(framebufferio_framebufferdisplay_obj_t* self) {
251253 displayio_display_core_start_refresh (& self -> core );
252254 const displayio_area_t * current_area = _get_refresh_areas (self );
253255 if (current_area ) {
256+ uint8_t dirty_row_bitmask [(self -> core .height + 7 ) / 8 ];
257+ memset (dirty_row_bitmask , 0 , sizeof (dirty_row_bitmask ));
254258 self -> framebuffer_protocol -> get_bufinfo (self -> framebuffer , & self -> bufinfo );
255259 while (current_area != NULL ) {
256- _refresh_area (self , current_area );
260+ _refresh_area (self , current_area , dirty_row_bitmask );
257261 current_area = current_area -> next ;
258262 }
259- self -> framebuffer_protocol -> swapbuffers (self -> framebuffer );
263+ self -> framebuffer_protocol -> swapbuffers (self -> framebuffer , dirty_row_bitmask );
260264 }
261265 displayio_display_core_finish_refresh (& self -> core );
262266}
0 commit comments