@@ -125,6 +125,24 @@ static void _get_screen_area(vectorio_vector_shape_t *self, displayio_area_t *ou
125125}
126126
127127
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+
128146// For use by Group to know where it needs to redraw on layer removal.
129147bool vectorio_vector_shape_get_dirty_area (vectorio_vector_shape_t * self , displayio_area_t * out_area ) {
130148 out_area -> x1 = out_area -> x2 ;
@@ -166,10 +184,8 @@ void common_hal_vectorio_vector_shape_construct(vectorio_vector_shape_t *self,
166184 vectorio_ishape_t ishape ,
167185 mp_obj_t pixel_shader , int32_t x , int32_t y ) {
168186 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 );
173189 self -> pixel_shader = pixel_shader ;
174190 self -> ishape = ishape ;
175191 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
191207 if (self -> x == x ) {
192208 return ;
193209 }
194- vectorio_vector_shape_validate_x_bounds (x );
195- self -> x = x ;
210+ check_bounds_and_set_x (self , x );
196211 common_hal_vectorio_vector_shape_set_dirty (self );
197212}
198213
@@ -208,8 +223,7 @@ void common_hal_vectorio_vector_shape_set_y(vectorio_vector_shape_t *self, mp_in
208223 if (self -> y == y ) {
209224 return ;
210225 }
211- vectorio_vector_shape_validate_y_bounds (y );
212- self -> y = y ;
226+ check_bounds_and_set_y (self , y );
213227 common_hal_vectorio_vector_shape_set_dirty (self );
214228}
215229
@@ -239,13 +253,11 @@ void common_hal_vectorio_vector_shape_set_location(vectorio_vector_shape_t *self
239253 }
240254 bool dirty = false;
241255 if (self -> x != x ) {
242- vectorio_vector_shape_validate_x_bounds (x );
243- self -> x = x ;
256+ check_bounds_and_set_x (self , x );
244257 dirty = true;
245258 }
246259 if (self -> y != y ) {
247- vectorio_vector_shape_validate_y_bounds (y );
248- self -> y = y ;
260+ check_bounds_and_set_y (self , y );
249261 dirty = true;
250262 }
251263 if (dirty ) {
@@ -254,20 +266,6 @@ void common_hal_vectorio_vector_shape_set_location(vectorio_vector_shape_t *self
254266}
255267
256268
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-
271269mp_obj_t common_hal_vectorio_vector_shape_get_pixel_shader (vectorio_vector_shape_t * self ) {
272270 VECTORIO_SHAPE_DEBUG ("%p get_pixel_shader\n" , self );
273271 return self -> pixel_shader ;
0 commit comments