Skip to content

Commit

Permalink
Merge pull request #8050 from FoamyGuy/hidden_refresh_areas
Browse files Browse the repository at this point in the history
don't consider refresh areas for hidden groups or tilegrids
  • Loading branch information
tannewt authored Jun 21, 2023
2 parents 28b0e34 + 4bf4d14 commit 0da6241
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
4 changes: 3 additions & 1 deletion shared-module/displayio/Group.c
Original file line number Diff line number Diff line change
Expand Up @@ -456,7 +456,9 @@ displayio_area_t *displayio_group_get_refresh_areas(displayio_group_t *self, dis
layer = mp_obj_cast_to_native_base(
self->members->items[i], &displayio_tilegrid_type);
if (layer != MP_OBJ_NULL) {
tail = displayio_tilegrid_get_refresh_areas(layer, tail);
if (!displayio_tilegrid_get_rendered_hidden(layer)) {
tail = displayio_tilegrid_get_refresh_areas(layer, tail);
}
continue;
}
layer = mp_obj_cast_to_native_base(
Expand Down
7 changes: 7 additions & 0 deletions shared-module/displayio/TileGrid.c
Original file line number Diff line number Diff line change
Expand Up @@ -82,15 +82,21 @@ bool common_hal_displayio_tilegrid_get_hidden(displayio_tilegrid_t *self) {
return self->hidden;
}

bool displayio_tilegrid_get_rendered_hidden(displayio_tilegrid_t *self) {
return self->rendered_hidden;
}

void common_hal_displayio_tilegrid_set_hidden(displayio_tilegrid_t *self, bool hidden) {
self->hidden = hidden;
self->rendered_hidden = false;
if (!hidden) {
self->full_change = true;
}
}

void displayio_tilegrid_set_hidden_by_parent(displayio_tilegrid_t *self, bool hidden) {
self->hidden_by_parent = hidden;
self->rendered_hidden = false;
if (!hidden) {
self->full_change = true;
}
Expand Down Expand Up @@ -582,6 +588,7 @@ displayio_area_t *displayio_tilegrid_get_refresh_areas(displayio_tilegrid_t *sel
bool hidden = self->hidden || self->hidden_by_parent;
// Check hidden first because it trumps all other changes.
if (hidden) {
self->rendered_hidden = true;
if (!first_draw) {
self->previous_area.next = tail;
return &self->previous_area;
Expand Down
3 changes: 3 additions & 0 deletions shared-module/displayio/TileGrid.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ typedef struct {
bool transpose_xy : 1;
bool hidden : 1;
bool hidden_by_parent : 1;
bool rendered_hidden : 1;
uint8_t padding : 6;
} displayio_tilegrid_t;

Expand All @@ -86,4 +87,6 @@ void displayio_tilegrid_update_transform(displayio_tilegrid_t *group, const disp
bool displayio_tilegrid_get_previous_area(displayio_tilegrid_t *self, displayio_area_t *area);
void displayio_tilegrid_finish_refresh(displayio_tilegrid_t *self);

bool displayio_tilegrid_get_rendered_hidden(displayio_tilegrid_t *self);

#endif // MICROPY_INCLUDED_SHARED_MODULE_DISPLAYIO_TILEGRID_H

0 comments on commit 0da6241

Please sign in to comment.