Skip to content

Commit b6a5f42

Browse files
committed
use draw protocol impl
1 parent 330e01d commit b6a5f42

File tree

3 files changed

+7
-16
lines changed

3 files changed

+7
-16
lines changed

shared-bindings/vectorio/VectorShape.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ vectorio_draw_protocol_impl_t vectorio_vector_shape_draw_protocol_impl = {
7878
.draw_update_transform = (draw_update_transform_fun)vectorio_vector_shape_update_transform,
7979
.draw_finish_refresh = (draw_finish_refresh_fun)vectorio_vector_shape_finish_refresh,
8080
.draw_get_refresh_areas = (draw_get_refresh_areas_fun)vectorio_vector_shape_get_refresh_areas,
81+
.draw_set_dirty = (draw_set_dirty_fun)common_hal_vectorio_vector_shape_set_dirty,
8182
};
8283

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

shared-bindings/vectorio/__init__.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ typedef bool (*draw_fill_area_fun)(mp_obj_t draw_protocol_self, const _displayio
1717
typedef bool (*draw_get_dirty_area_fun)(mp_obj_t draw_protocol_self, displayio_area_t *current_dirty_area);
1818
typedef void (*draw_update_transform_fun)(mp_obj_t draw_protocol_self, displayio_buffer_transform_t *group_transform);
1919
typedef void (*draw_finish_refresh_fun)(mp_obj_t draw_protocol_self);
20+
typedef void (*draw_set_dirty_fun)(mp_obj_t draw_protocol_self);
2021
typedef displayio_area_t *(*draw_get_refresh_areas_fun)(mp_obj_t draw_protocol_self, displayio_area_t *tail);
2122

2223
typedef struct _vectorio_draw_protocol_impl_t {
@@ -25,6 +26,7 @@ typedef struct _vectorio_draw_protocol_impl_t {
2526
draw_update_transform_fun draw_update_transform;
2627
draw_finish_refresh_fun draw_finish_refresh;
2728
draw_get_refresh_areas_fun draw_get_refresh_areas;
29+
draw_set_dirty_fun draw_set_dirty;
2830
} vectorio_draw_protocol_impl_t;
2931

3032
// Draw protocol

shared-module/displayio/Group.c

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -70,22 +70,10 @@ void common_hal_displayio_group_set_hidden(displayio_group_t *self, bool hidden)
7070
continue;
7171
}
7272
#if CIRCUITPY_VECTORIO
73-
layer = mp_obj_cast_to_native_base(
74-
self->members->items[i], &vectorio_circle_type);
75-
if (layer != MP_OBJ_NULL) {
76-
common_hal_vectorio_vector_shape_set_dirty(common_hal_vectorio_circle_get_draw_protocol(layer));
77-
continue;
78-
}
79-
layer = mp_obj_cast_to_native_base(
80-
self->members->items[i], &vectorio_rectangle_type);
81-
if (layer != MP_OBJ_NULL) {
82-
common_hal_vectorio_vector_shape_set_dirty(common_hal_vectorio_rectangle_get_draw_protocol(layer));
83-
continue;
84-
}
85-
layer = mp_obj_cast_to_native_base(
86-
self->members->items[i], &vectorio_polygon_type);
87-
if (layer != MP_OBJ_NULL) {
88-
common_hal_vectorio_vector_shape_set_dirty(common_hal_vectorio_polygon_get_draw_protocol(layer));
73+
const vectorio_draw_protocol_t *draw_protocol = mp_proto_get(MP_QSTR_protocol_draw, self->members->items[i]);
74+
if (draw_protocol != NULL) {
75+
layer = draw_protocol->draw_get_protocol_self(self->members->items[i]);
76+
draw_protocol->draw_protocol_impl->draw_set_dirty(layer);
8977
continue;
9078
}
9179
#endif

0 commit comments

Comments
 (0)