@@ -125,6 +125,24 @@ static void _get_screen_area(vectorio_vector_shape_t *self, displayio_area_t *ou
125
125
}
126
126
127
127
128
+ STATIC
129
+ void check_bounds_and_set_x (vectorio_vector_shape_t * self , mp_int_t x ) {
130
+ if (x < SHRT_MIN || x > SHRT_MAX ) {
131
+ mp_raise_ValueError_varg (translate ("%q must be between %d and %d" ), MP_QSTR_x , SHRT_MIN , SHRT_MAX );
132
+ }
133
+ self -> x = x ;
134
+ }
135
+
136
+
137
+ STATIC
138
+ void check_bounds_and_set_y (vectorio_vector_shape_t * self , mp_int_t y ) {
139
+ if (y < SHRT_MIN || y > SHRT_MAX ) {
140
+ mp_raise_ValueError_varg (translate ("%q must be between %d and %d" ), MP_QSTR_y , SHRT_MIN , SHRT_MAX );
141
+ }
142
+ self -> y = y ;
143
+ }
144
+
145
+
128
146
// For use by Group to know where it needs to redraw on layer removal.
129
147
bool vectorio_vector_shape_get_dirty_area (vectorio_vector_shape_t * self , displayio_area_t * out_area ) {
130
148
out_area -> x1 = out_area -> x2 ;
@@ -166,10 +184,8 @@ void common_hal_vectorio_vector_shape_construct(vectorio_vector_shape_t *self,
166
184
vectorio_ishape_t ishape ,
167
185
mp_obj_t pixel_shader , int32_t x , int32_t y ) {
168
186
VECTORIO_SHAPE_DEBUG ("%p vector_shape_construct x:%3d, y:%3d\n" , self , x , y );
169
- vectorio_vector_shape_validate_x_bounds (x );
170
- self -> x = x ;
171
- vectorio_vector_shape_validate_y_bounds (y );
172
- self -> y = y ;
187
+ check_bounds_and_set_x (self , x );
188
+ check_bounds_and_set_y (self , y );
173
189
self -> pixel_shader = pixel_shader ;
174
190
self -> ishape = ishape ;
175
191
self -> absolute_transform = & null_transform ; // Critical to have a valid transform before getting screen area.
@@ -191,8 +207,7 @@ void common_hal_vectorio_vector_shape_set_x(vectorio_vector_shape_t *self, mp_in
191
207
if (self -> x == x ) {
192
208
return ;
193
209
}
194
- vectorio_vector_shape_validate_x_bounds (x );
195
- self -> x = x ;
210
+ check_bounds_and_set_x (self , x );
196
211
common_hal_vectorio_vector_shape_set_dirty (self );
197
212
}
198
213
@@ -208,8 +223,7 @@ void common_hal_vectorio_vector_shape_set_y(vectorio_vector_shape_t *self, mp_in
208
223
if (self -> y == y ) {
209
224
return ;
210
225
}
211
- vectorio_vector_shape_validate_y_bounds (y );
212
- self -> y = y ;
226
+ check_bounds_and_set_y (self , y );
213
227
common_hal_vectorio_vector_shape_set_dirty (self );
214
228
}
215
229
@@ -239,13 +253,11 @@ void common_hal_vectorio_vector_shape_set_location(vectorio_vector_shape_t *self
239
253
}
240
254
bool dirty = false;
241
255
if (self -> x != x ) {
242
- vectorio_vector_shape_validate_x_bounds (x );
243
- self -> x = x ;
256
+ check_bounds_and_set_x (self , x );
244
257
dirty = true;
245
258
}
246
259
if (self -> y != y ) {
247
- vectorio_vector_shape_validate_y_bounds (y );
248
- self -> y = y ;
260
+ check_bounds_and_set_y (self , y );
249
261
dirty = true;
250
262
}
251
263
if (dirty ) {
@@ -254,20 +266,6 @@ void common_hal_vectorio_vector_shape_set_location(vectorio_vector_shape_t *self
254
266
}
255
267
256
268
257
- void vectorio_vector_shape_validate_x_bounds (mp_int_t x ) {
258
- if (x < SHRT_MIN || x > SHRT_MAX ) {
259
- mp_raise_ValueError_varg (translate ("%q must be between %d and %d" ), MP_QSTR_x , SHRT_MIN , SHRT_MAX );
260
- }
261
- }
262
-
263
-
264
- void vectorio_vector_shape_validate_y_bounds (mp_int_t y ) {
265
- if (y < SHRT_MIN || y > SHRT_MAX ) {
266
- mp_raise_ValueError_varg (translate ("%q must be between %d and %d" ), MP_QSTR_y , SHRT_MIN , SHRT_MAX );
267
- }
268
- }
269
-
270
-
271
269
mp_obj_t common_hal_vectorio_vector_shape_get_pixel_shader (vectorio_vector_shape_t * self ) {
272
270
VECTORIO_SHAPE_DEBUG ("%p get_pixel_shader\n" , self );
273
271
return self -> pixel_shader ;
0 commit comments