@@ -164,10 +164,10 @@ void common_hal_vectorio_vector_shape_set_dirty(void *vector_shape) {
164
164
165
165
void common_hal_vectorio_vector_shape_construct (vectorio_vector_shape_t * self ,
166
166
vectorio_ishape_t ishape ,
167
- mp_obj_t pixel_shader , uint16_t x , uint16_t y ) {
167
+ mp_obj_t pixel_shader , int32_t x , int32_t y ) {
168
168
VECTORIO_SHAPE_DEBUG ("%p vector_shape_construct x:%3d, y:%3d\n" , self , x , y );
169
- self -> x = x ;
170
- self -> y = y ;
169
+ common_hal_vectorio_vector_shape_set_x ( self , x ) ;
170
+ common_hal_vectorio_vector_shape_set_y ( self , y ) ;
171
171
self -> pixel_shader = pixel_shader ;
172
172
self -> ishape = ishape ;
173
173
self -> absolute_transform = & null_transform ; // Critical to have a valid transform before getting screen area.
@@ -184,13 +184,16 @@ mp_int_t common_hal_vectorio_vector_shape_get_x(vectorio_vector_shape_t *self) {
184
184
}
185
185
186
186
187
- void common_hal_vectorio_vector_shape_set_x (vectorio_vector_shape_t * self , mp_int_t x ) {
187
+ bool common_hal_vectorio_vector_shape_set_x (vectorio_vector_shape_t * self , mp_int_t x ) {
188
188
VECTORIO_SHAPE_DEBUG ("%p set_x %d\n" , self , x );
189
189
if (self -> x == x ) {
190
- return ;
190
+ return false; // it's not dirty
191
+ }
192
+ if (x < SHRT_MIN || x > SHRT_MAX ) {
193
+ mp_raise_ValueError_varg (translate ("unsupported %q type" ), MP_QSTR_point );
191
194
}
192
195
self -> x = x ;
193
- common_hal_vectorio_vector_shape_set_dirty ( self );
196
+ return true; // it's dirty
194
197
}
195
198
196
199
@@ -200,13 +203,16 @@ mp_int_t common_hal_vectorio_vector_shape_get_y(vectorio_vector_shape_t *self) {
200
203
}
201
204
202
205
203
- void common_hal_vectorio_vector_shape_set_y (vectorio_vector_shape_t * self , mp_int_t y ) {
206
+ bool common_hal_vectorio_vector_shape_set_y (vectorio_vector_shape_t * self , mp_int_t y ) {
204
207
VECTORIO_SHAPE_DEBUG ("%p set_y %d\n" , self , y );
205
208
if (self -> y == y ) {
206
- return ;
209
+ return false; // it's not dirty
210
+ }
211
+ if (y < SHRT_MIN || y > SHRT_MAX ) {
212
+ mp_raise_ValueError_varg (translate ("unsupported %q type" ), MP_QSTR_point );
207
213
}
208
214
self -> y = y ;
209
- common_hal_vectorio_vector_shape_set_dirty ( self );
215
+ return true; // it's dirty
210
216
}
211
217
212
218
mp_obj_tuple_t * common_hal_vectorio_vector_shape_get_location (vectorio_vector_shape_t * self ) {
@@ -230,14 +236,14 @@ void common_hal_vectorio_vector_shape_set_location(vectorio_vector_shape_t *self
230
236
mp_int_t x ;
231
237
mp_int_t y ;
232
238
if (!mp_obj_get_int_maybe (tuple_items [ 0 ], & x )
233
- || !mp_obj_get_int_maybe (tuple_items [ 1 ], & y )
234
- || x < SHRT_MIN || x > SHRT_MAX || y < SHRT_MIN || y > SHRT_MAX
235
- ) {
239
+ || !mp_obj_get_int_maybe (tuple_items [ 1 ], & y )) {
236
240
mp_raise_ValueError_varg (translate ("unsupported %q type" ), MP_QSTR_point );
237
241
}
238
- self -> x = (int16_t )x ;
239
- self -> y = (int16_t )y ;
240
- common_hal_vectorio_vector_shape_set_dirty (self );
242
+ bool dirty = common_hal_vectorio_vector_shape_set_x (self , x );
243
+ dirty |= common_hal_vectorio_vector_shape_set_y (self , y );
244
+ if (dirty ) {
245
+ common_hal_vectorio_vector_shape_set_dirty (self );
246
+ }
241
247
}
242
248
243
249
0 commit comments