summaryrefslogtreecommitdiff
path: root/shared-module/framebufferio
diff options
context:
space:
mode:
authorJeff Epler <jepler@gmail.com>2020-08-06 14:51:52 -0500
committerJeff Epler <jepler@gmail.com>2020-08-12 07:32:18 -0500
commit9c4f644641400c7b7eea37ace73782bc1cec2691 (patch)
treeab40f0bd353c640ccde271212384263904cf0ccb /shared-module/framebufferio
parent5e4ed9341586c3444409feeb61237e86a5c74c6f (diff)
framebufferio: add dirty row tracking
Diffstat (limited to 'shared-module/framebufferio')
-rw-r--r--shared-module/framebufferio/FramebufferDisplay.c10
-rw-r--r--shared-module/framebufferio/FramebufferDisplay.h2
2 files changed, 8 insertions, 4 deletions
diff --git a/shared-module/framebufferio/FramebufferDisplay.c b/shared-module/framebufferio/FramebufferDisplay.c
index 37989c29f..9a6797cd8 100644
--- a/shared-module/framebufferio/FramebufferDisplay.c
+++ b/shared-module/framebufferio/FramebufferDisplay.c
@@ -156,7 +156,8 @@ STATIC const displayio_area_t* _get_refresh_areas(framebufferio_framebufferdispl
return NULL;
}
-STATIC bool _refresh_area(framebufferio_framebufferdisplay_obj_t* self, const displayio_area_t* area) {
+#define MARK_ROW_DIRTY(r) (dirty_row_bitmask[r/8] = (1 << (r & 7)))
+STATIC bool _refresh_area(framebufferio_framebufferdisplay_obj_t* self, const displayio_area_t* area, uint8_t *dirty_row_bitmask) {
uint16_t buffer_size = 128; // In uint32_ts
displayio_area_t clipped;
@@ -235,6 +236,7 @@ STATIC bool _refresh_area(framebufferio_framebufferdisplay_obj_t* self, const di
for (uint16_t i = subrectangle.y1; i < subrectangle.y2; i++) {
assert(dest >= buf && dest < endbuf && dest+rowsize <= endbuf);
+ MARK_ROW_DIRTY(i);
memcpy(dest, src, rowsize);
dest += rowstride;
src += rowsize;
@@ -251,12 +253,14 @@ STATIC void _refresh_display(framebufferio_framebufferdisplay_obj_t* self) {
displayio_display_core_start_refresh(&self->core);
const displayio_area_t* current_area = _get_refresh_areas(self);
if (current_area) {
+ uint8_t dirty_row_bitmask[(self->core.height + 7) / 8];
+ memset(dirty_row_bitmask, 0, sizeof(dirty_row_bitmask));
self->framebuffer_protocol->get_bufinfo(self->framebuffer, &self->bufinfo);
while (current_area != NULL) {
- _refresh_area(self, current_area);
+ _refresh_area(self, current_area, dirty_row_bitmask);
current_area = current_area->next;
}
- self->framebuffer_protocol->swapbuffers(self->framebuffer);
+ self->framebuffer_protocol->swapbuffers(self->framebuffer, dirty_row_bitmask);
}
displayio_display_core_finish_refresh(&self->core);
}
diff --git a/shared-module/framebufferio/FramebufferDisplay.h b/shared-module/framebufferio/FramebufferDisplay.h
index 93ad0118a..027086b5a 100644
--- a/shared-module/framebufferio/FramebufferDisplay.h
+++ b/shared-module/framebufferio/FramebufferDisplay.h
@@ -79,7 +79,7 @@ typedef int (*framebuffer_get_width_fun)(mp_obj_t);
typedef mp_float_t (*framebuffer_get_brightness_fun)(mp_obj_t);
typedef void (*framebuffer_deinit_fun)(mp_obj_t);
typedef void (*framebuffer_get_bufinfo_fun)(mp_obj_t, mp_buffer_info_t *bufinfo);
-typedef void (*framebuffer_swapbuffers_fun)(mp_obj_t);
+typedef void (*framebuffer_swapbuffers_fun)(mp_obj_t, uint8_t *dirty_row_bitmask);
typedef struct _framebuffer_p_t {
MP_PROTOCOL_HEAD // MP_QSTR_protocol_framebuffer