Be cognizant of null transform for .transpose_xy
This commit is contained in:
parent
dca2989df8
commit
d1184e7e94
@ -74,6 +74,7 @@ void common_hal_displayio_tilegrid_construct(displayio_tilegrid_t *self, mp_obj_
|
||||
self->flip_x = false;
|
||||
self->flip_y = false;
|
||||
self->transpose_xy = false;
|
||||
self->absolute_transform = NULL;
|
||||
}
|
||||
|
||||
|
||||
@ -104,23 +105,30 @@ bool displayio_tilegrid_get_previous_area(displayio_tilegrid_t *self, displayio_
|
||||
}
|
||||
|
||||
void _update_current_x(displayio_tilegrid_t *self) {
|
||||
int16_t width;
|
||||
uint16_t width;
|
||||
if (self->transpose_xy) {
|
||||
width = self->pixel_height;
|
||||
} else {
|
||||
width = self->pixel_width;
|
||||
}
|
||||
if (self->absolute_transform->transpose_xy) {
|
||||
self->current_area.y1 = self->absolute_transform->y + self->absolute_transform->dy * self->x;
|
||||
self->current_area.y2 = self->absolute_transform->y + self->absolute_transform->dy * (self->x + width);
|
||||
|
||||
// If there's no transform, substitute an identity transform so the calculations will work.
|
||||
const displayio_buffer_transform_t* absolute_transform =
|
||||
self->absolute_transform == NULL
|
||||
? &null_transform
|
||||
: self->absolute_transform;
|
||||
|
||||
if (absolute_transform->transpose_xy) {
|
||||
self->current_area.y1 = absolute_transform->y + absolute_transform->dy * self->x;
|
||||
self->current_area.y2 = absolute_transform->y + absolute_transform->dy * (self->x + width);
|
||||
if (self->current_area.y2 < self->current_area.y1) {
|
||||
int16_t temp = self->current_area.y2;
|
||||
self->current_area.y2 = self->current_area.y1;
|
||||
self->current_area.y1 = temp;
|
||||
}
|
||||
} else {
|
||||
self->current_area.x1 = self->absolute_transform->x + self->absolute_transform->dx * self->x;
|
||||
self->current_area.x2 = self->absolute_transform->x + self->absolute_transform->dx * (self->x + width);
|
||||
self->current_area.x1 = absolute_transform->x + absolute_transform->dx * self->x;
|
||||
self->current_area.x2 = absolute_transform->x + absolute_transform->dx * (self->x + width);
|
||||
if (self->current_area.x2 < self->current_area.x1) {
|
||||
int16_t temp = self->current_area.x2;
|
||||
self->current_area.x2 = self->current_area.x1;
|
||||
@ -130,23 +138,30 @@ void _update_current_x(displayio_tilegrid_t *self) {
|
||||
}
|
||||
|
||||
void _update_current_y(displayio_tilegrid_t *self) {
|
||||
int16_t height;
|
||||
uint16_t height;
|
||||
if (self->transpose_xy) {
|
||||
height = self->pixel_width;
|
||||
} else {
|
||||
height = self->pixel_height;
|
||||
}
|
||||
if (self->absolute_transform->transpose_xy) {
|
||||
self->current_area.x1 = self->absolute_transform->x + self->absolute_transform->dx * self->y;
|
||||
self->current_area.x2 = self->absolute_transform->x + self->absolute_transform->dx * (self->y + height);
|
||||
|
||||
// If there's no transform, substitute an identity transform so the calculations will work.
|
||||
const displayio_buffer_transform_t* absolute_transform =
|
||||
self->absolute_transform == NULL
|
||||
? &null_transform
|
||||
: self->absolute_transform;
|
||||
|
||||
if (absolute_transform->transpose_xy) {
|
||||
self->current_area.x1 = absolute_transform->x + absolute_transform->dx * self->y;
|
||||
self->current_area.x2 = absolute_transform->x + absolute_transform->dx * (self->y + height);
|
||||
if (self->current_area.x2 < self->current_area.x1) {
|
||||
int16_t temp = self->current_area.x2;
|
||||
self->current_area.x2 = self->current_area.x1;
|
||||
self->current_area.x1 = temp;
|
||||
}
|
||||
} else {
|
||||
self->current_area.y1 = self->absolute_transform->y + self->absolute_transform->dy * self->y;
|
||||
self->current_area.y2 = self->absolute_transform->y + self->absolute_transform->dy * (self->y + height);
|
||||
self->current_area.y1 = absolute_transform->y + absolute_transform->dy * self->y;
|
||||
self->current_area.y2 = absolute_transform->y + absolute_transform->dy * (self->y + height);
|
||||
if (self->current_area.y2 < self->current_area.y1) {
|
||||
int16_t temp = self->current_area.y2;
|
||||
self->current_area.y2 = self->current_area.y1;
|
||||
|
@ -26,6 +26,20 @@
|
||||
|
||||
primary_display_t displays[CIRCUITPY_DISPLAY_LIMIT];
|
||||
|
||||
displayio_buffer_transform_t null_transform = {
|
||||
.x = 0,
|
||||
.y = 0,
|
||||
.dx = 1,
|
||||
.dy = 1,
|
||||
.scale = 1,
|
||||
.width = 0,
|
||||
.height = 0,
|
||||
.mirror_x = false,
|
||||
.mirror_y = false,
|
||||
.transpose_xy = false
|
||||
};
|
||||
|
||||
|
||||
#if CIRCUITPY_RGBMATRIX
|
||||
STATIC bool any_display_uses_this_framebuffer(mp_obj_base_t *obj) {
|
||||
for (uint8_t i = 0; i < CIRCUITPY_DISPLAY_LIMIT; i++) {
|
||||
|
@ -51,6 +51,8 @@ typedef struct {
|
||||
bool transpose_xy;
|
||||
} displayio_buffer_transform_t;
|
||||
|
||||
extern displayio_buffer_transform_t null_transform;
|
||||
|
||||
void displayio_area_union(const displayio_area_t* a,
|
||||
const displayio_area_t* b,
|
||||
displayio_area_t* u);
|
||||
|
@ -93,20 +93,6 @@ void common_hal_vectorio_vector_shape_set_dirty(void *vector_shape) {
|
||||
}
|
||||
|
||||
|
||||
static displayio_buffer_transform_t null_transform = {
|
||||
.x = 0,
|
||||
.y = 0,
|
||||
.dx = 1,
|
||||
.dy = 1,
|
||||
.scale = 1,
|
||||
.width = 0,
|
||||
.height = 0,
|
||||
.mirror_x = false,
|
||||
.mirror_y = false,
|
||||
.transpose_xy = false
|
||||
};
|
||||
|
||||
|
||||
void common_hal_vectorio_vector_shape_construct(vectorio_vector_shape_t *self,
|
||||
vectorio_ishape_t ishape,
|
||||
mp_obj_t pixel_shader, uint16_t x, uint16_t y) {
|
||||
|
Loading…
Reference in New Issue
Block a user