Make the x and y bounds checking functions static
This commit is contained in:
parent
2bc260a102
commit
145836e7e5
@ -125,6 +125,24 @@ static void _get_screen_area(vectorio_vector_shape_t *self, displayio_area_t *ou
|
||||
}
|
||||
|
||||
|
||||
STATIC
|
||||
void check_bounds_and_set_x(vectorio_vector_shape_t *self, mp_int_t x) {
|
||||
if (x < SHRT_MIN || x > SHRT_MAX) {
|
||||
mp_raise_ValueError_varg(translate("%q must be between %d and %d"), MP_QSTR_x, SHRT_MIN, SHRT_MAX);
|
||||
}
|
||||
self->x = x;
|
||||
}
|
||||
|
||||
|
||||
STATIC
|
||||
void check_bounds_and_set_y(vectorio_vector_shape_t *self, mp_int_t y) {
|
||||
if (y < SHRT_MIN || y > SHRT_MAX) {
|
||||
mp_raise_ValueError_varg(translate("%q must be between %d and %d"), MP_QSTR_y, SHRT_MIN, SHRT_MAX);
|
||||
}
|
||||
self->y = y;
|
||||
}
|
||||
|
||||
|
||||
// For use by Group to know where it needs to redraw on layer removal.
|
||||
bool vectorio_vector_shape_get_dirty_area(vectorio_vector_shape_t *self, displayio_area_t *out_area) {
|
||||
out_area->x1 = out_area->x2;
|
||||
@ -166,10 +184,8 @@ void common_hal_vectorio_vector_shape_construct(vectorio_vector_shape_t *self,
|
||||
vectorio_ishape_t ishape,
|
||||
mp_obj_t pixel_shader, int32_t x, int32_t y) {
|
||||
VECTORIO_SHAPE_DEBUG("%p vector_shape_construct x:%3d, y:%3d\n", self, x, y);
|
||||
vectorio_vector_shape_validate_x_bounds(x);
|
||||
self->x = x;
|
||||
vectorio_vector_shape_validate_y_bounds(y);
|
||||
self->y = y;
|
||||
check_bounds_and_set_x(self, x);
|
||||
check_bounds_and_set_y(self, y);
|
||||
self->pixel_shader = pixel_shader;
|
||||
self->ishape = ishape;
|
||||
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
|
||||
if (self->x == x) {
|
||||
return;
|
||||
}
|
||||
vectorio_vector_shape_validate_x_bounds(x);
|
||||
self->x = x;
|
||||
check_bounds_and_set_x(self, x);
|
||||
common_hal_vectorio_vector_shape_set_dirty(self);
|
||||
}
|
||||
|
||||
@ -208,8 +223,7 @@ void common_hal_vectorio_vector_shape_set_y(vectorio_vector_shape_t *self, mp_in
|
||||
if (self->y == y) {
|
||||
return;
|
||||
}
|
||||
vectorio_vector_shape_validate_y_bounds(y);
|
||||
self->y = y;
|
||||
check_bounds_and_set_y(self, y);
|
||||
common_hal_vectorio_vector_shape_set_dirty(self);
|
||||
}
|
||||
|
||||
@ -239,13 +253,11 @@ void common_hal_vectorio_vector_shape_set_location(vectorio_vector_shape_t *self
|
||||
}
|
||||
bool dirty = false;
|
||||
if (self->x != x) {
|
||||
vectorio_vector_shape_validate_x_bounds(x);
|
||||
self->x = x;
|
||||
check_bounds_and_set_x(self, x);
|
||||
dirty = true;
|
||||
}
|
||||
if (self->y != y) {
|
||||
vectorio_vector_shape_validate_y_bounds(y);
|
||||
self->y = y;
|
||||
check_bounds_and_set_y(self, y);
|
||||
dirty = true;
|
||||
}
|
||||
if (dirty) {
|
||||
@ -254,20 +266,6 @@ void common_hal_vectorio_vector_shape_set_location(vectorio_vector_shape_t *self
|
||||
}
|
||||
|
||||
|
||||
void vectorio_vector_shape_validate_x_bounds(mp_int_t x) {
|
||||
if (x < SHRT_MIN || x > SHRT_MAX) {
|
||||
mp_raise_ValueError_varg(translate("%q must be between %d and %d"), MP_QSTR_x, SHRT_MIN, SHRT_MAX);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void vectorio_vector_shape_validate_y_bounds(mp_int_t y) {
|
||||
if (y < SHRT_MIN || y > SHRT_MAX) {
|
||||
mp_raise_ValueError_varg(translate("%q must be between %d and %d"), MP_QSTR_y, SHRT_MIN, SHRT_MAX);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
mp_obj_t common_hal_vectorio_vector_shape_get_pixel_shader(vectorio_vector_shape_t *self) {
|
||||
VECTORIO_SHAPE_DEBUG("%p get_pixel_shader\n", self);
|
||||
return self->pixel_shader;
|
||||
|
@ -51,7 +51,4 @@ bool vectorio_vector_shape_fill_area(vectorio_vector_shape_t *self, const _displ
|
||||
bool vectorio_vector_shape_get_previous_area(vectorio_vector_shape_t *self, displayio_area_t *out_area);
|
||||
void vectorio_vector_shape_finish_refresh(vectorio_vector_shape_t *self);
|
||||
|
||||
void vectorio_vector_shape_validate_x_bounds(mp_int_t x);
|
||||
void vectorio_vector_shape_validate_y_bounds(mp_int_t y);
|
||||
|
||||
#endif // MICROPY_INCLUDED_SHARED_MODULE_VECTORIO_SHAPE_H
|
||||
|
Loading…
x
Reference in New Issue
Block a user