Merge pull request #4331 from dhalbert/tilegrid-transpose-fix

Tilegrid transpose fix
This commit is contained in:
Dan Halbert 2021-03-04 21:53:21 -05:00 committed by GitHub
commit c68073e12b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 43 additions and 26 deletions

View File

@ -475,7 +475,7 @@ jobs:
id: idf-cache
with:
path: ${{ github.workspace }}/.idf_tools
key: ${{ runner.os }}-idf-tools-${{ hashFiles('.git/modules/ports/esp32s2/esp-idf/HEAD') }}-20210303
key: ${{ runner.os }}-idf-tools-${{ hashFiles('.git/modules/ports/esp32s2/esp-idf/HEAD') }}-20210304
- name: Clone IDF submodules
run: |
(cd $IDF_PATH && git submodule update --init)

@ -1 +1 @@
Subproject commit 5285548c7543354ac8e13da37499019e204b1c49
Subproject commit 280297bdb7aec67adf347ec046943a48a71647df

View File

@ -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;
}
@ -110,17 +111,24 @@ void _update_current_x(displayio_tilegrid_t *self) {
} 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;
@ -136,17 +144,24 @@ void _update_current_y(displayio_tilegrid_t *self) {
} 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;

View File

@ -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++) {

View File

@ -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);

View File

@ -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) {