Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Fix vectorio in group tracking #10334

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 12, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions ports/espressif/boards/adafruit_qtpy_esp32c3/mpconfigboard.mk
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,8 @@ CIRCUITPY_LEGACY_4MB_FLASH_LAYOUT = 1

CIRCUITPY_ESP_USB_SERIAL_JTAG = 1

# Not enough flash space.
CIRCUITPY_CODEOP = 0

# Not enough pins.
CIRCUITPY_PARALLELDISPLAYBUS = 0
1 change: 1 addition & 0 deletions shared-bindings/vectorio/VectorShape.c
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ vectorio_draw_protocol_impl_t vectorio_vector_shape_draw_protocol_impl = {
.draw_finish_refresh = (draw_finish_refresh_fun)vectorio_vector_shape_finish_refresh,
.draw_get_refresh_areas = (draw_get_refresh_areas_fun)vectorio_vector_shape_get_refresh_areas,
.draw_set_dirty = (draw_set_dirty_fun)common_hal_vectorio_vector_shape_set_dirty,
.draw_set_in_group = (draw_set_in_group_fun)vectorio_vector_shape_set_in_group,
};

// Stub checker does not approve of these shared properties.
Expand Down
1 change: 1 addition & 0 deletions shared-bindings/vectorio/VectorShape.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ mp_obj_t common_hal_vectorio_vector_shape_get_pixel_shader(vectorio_vector_shape
void common_hal_vectorio_vector_shape_set_pixel_shader(vectorio_vector_shape_t *self, mp_obj_t pixel_shader);

void vectorio_vector_shape_update_transform(vectorio_vector_shape_t *self, displayio_buffer_transform_t *group_transform);
bool vectorio_vector_shape_set_in_group(vectorio_vector_shape_t *self, bool in_group);

// Composable property definition for shapes that use VectorShape
extern vectorio_draw_protocol_impl_t vectorio_vector_shape_draw_protocol_impl;
Expand Down
2 changes: 2 additions & 0 deletions shared-bindings/vectorio/__init__.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ typedef bool (*draw_get_dirty_area_fun)(mp_obj_t draw_protocol_self, displayio_a
typedef void (*draw_update_transform_fun)(mp_obj_t draw_protocol_self, displayio_buffer_transform_t *group_transform);
typedef void (*draw_finish_refresh_fun)(mp_obj_t draw_protocol_self);
typedef void (*draw_set_dirty_fun)(mp_obj_t draw_protocol_self);
typedef bool (*draw_set_in_group_fun)(mp_obj_t draw_protocol_self, bool in_group);
typedef displayio_area_t *(*draw_get_refresh_areas_fun)(mp_obj_t draw_protocol_self, displayio_area_t *tail);

typedef struct _vectorio_draw_protocol_impl_t {
Expand All @@ -32,6 +33,7 @@ typedef struct _vectorio_draw_protocol_impl_t {
draw_finish_refresh_fun draw_finish_refresh;
draw_get_refresh_areas_fun draw_get_refresh_areas;
draw_set_dirty_fun draw_set_dirty;
draw_set_in_group_fun draw_set_in_group;
} vectorio_draw_protocol_impl_t;

// Draw protocol
Expand Down
7 changes: 6 additions & 1 deletion shared-module/displayio/Group.c
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,11 @@ static void _add_layer(displayio_group_t *self, mp_obj_t layer) {
#if CIRCUITPY_VECTORIO
const vectorio_draw_protocol_t *draw_protocol = mp_proto_get(MP_QSTR_protocol_draw, layer);
if (draw_protocol != NULL) {
draw_protocol->draw_protocol_impl->draw_update_transform(draw_protocol->draw_get_protocol_self(layer), &self->absolute_transform);
mp_obj_t protocol_self = draw_protocol->draw_get_protocol_self(layer);
if (draw_protocol->draw_protocol_impl->draw_set_in_group(protocol_self, true)) {
mp_raise_ValueError(MP_ERROR_TEXT("Layer already in a group"));
}
draw_protocol->draw_protocol_impl->draw_update_transform(protocol_self, &self->absolute_transform);
return;
}
#endif
Expand Down Expand Up @@ -296,6 +300,7 @@ static void _remove_layer(displayio_group_t *self, size_t index) {
bool has_dirty_area = draw_protocol->draw_protocol_impl->draw_get_dirty_area(layer, &layer_area);
rendered_last_frame = has_dirty_area;
draw_protocol->draw_protocol_impl->draw_update_transform(layer, NULL);
draw_protocol->draw_protocol_impl->draw_set_in_group(layer, false);
}
#endif
layer = mp_obj_cast_to_native_base(
Expand Down
6 changes: 6 additions & 0 deletions shared-module/vectorio/VectorShape.c
Original file line number Diff line number Diff line change
Expand Up @@ -555,3 +555,9 @@ void vectorio_vector_shape_update_transform(vectorio_vector_shape_t *self, displ
self->absolute_transform = group_transform == NULL ? &null_transform : group_transform;
common_hal_vectorio_vector_shape_set_dirty(self);
}

bool vectorio_vector_shape_set_in_group(vectorio_vector_shape_t *self, bool in_group) {
bool was_in_group = self->in_group;
self->in_group = in_group;
return was_in_group;
}
1 change: 1 addition & 0 deletions shared-module/vectorio/VectorShape.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ typedef struct {
displayio_area_t current_area;
bool current_area_dirty;
bool hidden;
bool in_group;
} vectorio_vector_shape_t;

displayio_area_t *vectorio_vector_shape_get_refresh_areas(vectorio_vector_shape_t *self, displayio_area_t *tail);
Expand Down