Skip to content

Commit 61af6a8

Browse files
authored
Merge pull request #10334 from tannewt/vectorio_in_group
Fix vectorio in group tracking
2 parents 0893345 + 419243a commit 61af6a8

File tree

7 files changed

+20
-1
lines changed

7 files changed

+20
-1
lines changed

ports/espressif/boards/adafruit_qtpy_esp32c3/mpconfigboard.mk

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,8 @@ CIRCUITPY_LEGACY_4MB_FLASH_LAYOUT = 1
1111

1212
CIRCUITPY_ESP_USB_SERIAL_JTAG = 1
1313

14+
# Not enough flash space.
15+
CIRCUITPY_CODEOP = 0
16+
1417
# Not enough pins.
1518
CIRCUITPY_PARALLELDISPLAYBUS = 0

shared-bindings/vectorio/VectorShape.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ vectorio_draw_protocol_impl_t vectorio_vector_shape_draw_protocol_impl = {
8282
.draw_finish_refresh = (draw_finish_refresh_fun)vectorio_vector_shape_finish_refresh,
8383
.draw_get_refresh_areas = (draw_get_refresh_areas_fun)vectorio_vector_shape_get_refresh_areas,
8484
.draw_set_dirty = (draw_set_dirty_fun)common_hal_vectorio_vector_shape_set_dirty,
85+
.draw_set_in_group = (draw_set_in_group_fun)vectorio_vector_shape_set_in_group,
8586
};
8687

8788
// Stub checker does not approve of these shared properties.

shared-bindings/vectorio/VectorShape.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ mp_obj_t common_hal_vectorio_vector_shape_get_pixel_shader(vectorio_vector_shape
4343
void common_hal_vectorio_vector_shape_set_pixel_shader(vectorio_vector_shape_t *self, mp_obj_t pixel_shader);
4444

4545
void vectorio_vector_shape_update_transform(vectorio_vector_shape_t *self, displayio_buffer_transform_t *group_transform);
46+
bool vectorio_vector_shape_set_in_group(vectorio_vector_shape_t *self, bool in_group);
4647

4748
// Composable property definition for shapes that use VectorShape
4849
extern vectorio_draw_protocol_impl_t vectorio_vector_shape_draw_protocol_impl;

shared-bindings/vectorio/__init__.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ typedef bool (*draw_get_dirty_area_fun)(mp_obj_t draw_protocol_self, displayio_a
2323
typedef void (*draw_update_transform_fun)(mp_obj_t draw_protocol_self, displayio_buffer_transform_t *group_transform);
2424
typedef void (*draw_finish_refresh_fun)(mp_obj_t draw_protocol_self);
2525
typedef void (*draw_set_dirty_fun)(mp_obj_t draw_protocol_self);
26+
typedef bool (*draw_set_in_group_fun)(mp_obj_t draw_protocol_self, bool in_group);
2627
typedef displayio_area_t *(*draw_get_refresh_areas_fun)(mp_obj_t draw_protocol_self, displayio_area_t *tail);
2728

2829
typedef struct _vectorio_draw_protocol_impl_t {
@@ -32,6 +33,7 @@ typedef struct _vectorio_draw_protocol_impl_t {
3233
draw_finish_refresh_fun draw_finish_refresh;
3334
draw_get_refresh_areas_fun draw_get_refresh_areas;
3435
draw_set_dirty_fun draw_set_dirty;
36+
draw_set_in_group_fun draw_set_in_group;
3537
} vectorio_draw_protocol_impl_t;
3638

3739
// Draw protocol

shared-module/displayio/Group.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,11 @@ static void _add_layer(displayio_group_t *self, mp_obj_t layer) {
251251
#if CIRCUITPY_VECTORIO
252252
const vectorio_draw_protocol_t *draw_protocol = mp_proto_get(MP_QSTR_protocol_draw, layer);
253253
if (draw_protocol != NULL) {
254-
draw_protocol->draw_protocol_impl->draw_update_transform(draw_protocol->draw_get_protocol_self(layer), &self->absolute_transform);
254+
mp_obj_t protocol_self = draw_protocol->draw_get_protocol_self(layer);
255+
if (draw_protocol->draw_protocol_impl->draw_set_in_group(protocol_self, true)) {
256+
mp_raise_ValueError(MP_ERROR_TEXT("Layer already in a group"));
257+
}
258+
draw_protocol->draw_protocol_impl->draw_update_transform(protocol_self, &self->absolute_transform);
255259
return;
256260
}
257261
#endif
@@ -296,6 +300,7 @@ static void _remove_layer(displayio_group_t *self, size_t index) {
296300
bool has_dirty_area = draw_protocol->draw_protocol_impl->draw_get_dirty_area(layer, &layer_area);
297301
rendered_last_frame = has_dirty_area;
298302
draw_protocol->draw_protocol_impl->draw_update_transform(layer, NULL);
303+
draw_protocol->draw_protocol_impl->draw_set_in_group(layer, false);
299304
}
300305
#endif
301306
layer = mp_obj_cast_to_native_base(

shared-module/vectorio/VectorShape.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -555,3 +555,9 @@ void vectorio_vector_shape_update_transform(vectorio_vector_shape_t *self, displ
555555
self->absolute_transform = group_transform == NULL ? &null_transform : group_transform;
556556
common_hal_vectorio_vector_shape_set_dirty(self);
557557
}
558+
559+
bool vectorio_vector_shape_set_in_group(vectorio_vector_shape_t *self, bool in_group) {
560+
bool was_in_group = self->in_group;
561+
self->in_group = in_group;
562+
return was_in_group;
563+
}

shared-module/vectorio/VectorShape.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ typedef struct {
4343
displayio_area_t current_area;
4444
bool current_area_dirty;
4545
bool hidden;
46+
bool in_group;
4647
} vectorio_vector_shape_t;
4748

4849
displayio_area_t *vectorio_vector_shape_get_refresh_areas(vectorio_vector_shape_t *self, displayio_area_t *tail);

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy