Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
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
Loading