@@ -70,6 +70,15 @@ void common_hal_framebufferio_framebufferdisplay_construct(framebufferio_framebu
70
70
false // reverse_bytes_in_word
71
71
);
72
72
73
+ self -> first_pixel_offset = self -> framebuffer_protocol -> get_first_pixel_offset
74
+ ? self -> framebuffer_protocol -> get_first_pixel_offset (self -> framebuffer )
75
+ : 0 ;
76
+ self -> row_stride = self -> framebuffer_protocol -> get_row_stride
77
+ ? self -> framebuffer_protocol -> get_row_stride (self -> framebuffer )
78
+ : 0 ;
79
+ if (self -> row_stride == 0 ) {
80
+ self -> row_stride = self -> core .width * self -> core .colorspace .depth /8 ;
81
+ }
73
82
self -> first_manual_refresh = !auto_refresh ;
74
83
75
84
self -> native_frames_per_second = self -> framebuffer_protocol -> get_native_frames_per_second (self -> framebuffer );
@@ -209,11 +218,13 @@ STATIC bool _refresh_area(framebufferio_framebufferdisplay_obj_t* self, const di
209
218
210
219
uint8_t * buf = (uint8_t * )self -> bufinfo .buf , * endbuf = buf + self -> bufinfo .len ;
211
220
(void )endbuf ; // Hint to compiler that endbuf is "used" even if NDEBUG
221
+ buf += self -> first_pixel_offset ;
212
222
213
- uint8_t * dest = self -> bufinfo .buf + (subrectangle .y1 * self -> core .width + subrectangle .x1 ) * self -> core .colorspace .depth / 8 ;
223
+ size_t rowstride = self -> row_stride ;
224
+ uint8_t * dest = buf + subrectangle .y1 * rowstride + subrectangle .x1 * self -> core .colorspace .depth / 8 ;
214
225
uint8_t * src = (uint8_t * )buffer ;
215
226
size_t rowsize = (subrectangle .x2 - subrectangle .x1 ) * self -> core .colorspace .depth / 8 ;
216
- size_t rowstride = self -> core . width * self -> core . colorspace . depth / 8 ;
227
+
217
228
for (uint16_t i = subrectangle .y1 ; i < subrectangle .y2 ; i ++ ) {
218
229
assert (dest >= buf && dest < endbuf && dest + rowsize <= endbuf );
219
230
memcpy (dest , src , rowsize );
@@ -230,9 +241,9 @@ STATIC bool _refresh_area(framebufferio_framebufferdisplay_obj_t* self, const di
230
241
231
242
STATIC void _refresh_display (framebufferio_framebufferdisplay_obj_t * self ) {
232
243
displayio_display_core_start_refresh (& self -> core );
233
- self -> framebuffer_protocol -> get_bufinfo (self -> framebuffer , & self -> bufinfo );
234
244
const displayio_area_t * current_area = _get_refresh_areas (self );
235
245
if (current_area ) {
246
+ self -> framebuffer_protocol -> get_bufinfo (self -> framebuffer , & self -> bufinfo );
236
247
while (current_area != NULL ) {
237
248
_refresh_area (self , current_area );
238
249
current_area = current_area -> next ;
0 commit comments