summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Halbert <halbert@adafruit.com>2021-03-04 21:53:21 -0500
committerGitHub <noreply@github.com>2021-03-04 21:53:21 -0500
commitc68073e12b49a33460baa320da87374d359ed96b (patch)
treeb008dffa8a12091a2d9ca53e708abc6923499e5c
parent7970c882a658da804ae897ae481ba05c6a59bcba (diff)
parentb1268107af48dce7a1406ebed22790fee65f506b (diff)
Merge pull request #4331 from dhalbert/tilegrid-transpose-fix
Tilegrid transpose fix
-rw-r--r--.github/workflows/build.yml2
m---------lib/tinyusb0
-rw-r--r--shared-module/displayio/TileGrid.c35
-rw-r--r--shared-module/displayio/__init__.c14
-rw-r--r--shared-module/displayio/area.h2
-rw-r--r--shared-module/vectorio/VectorShape.c14
6 files changed, 42 insertions, 25 deletions
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index 9a3f1a8d2..7fa2953b3 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -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)
diff --git a/lib/tinyusb b/lib/tinyusb
-Subproject 5285548c7543354ac8e13da37499019e204b1c4
+Subproject 280297bdb7aec67adf347ec046943a48a71647d
diff --git a/shared-module/displayio/TileGrid.c b/shared-module/displayio/TileGrid.c
index 2cd3a4948..96473d4a8 100644
--- a/shared-module/displayio/TileGrid.c
+++ b/shared-module/displayio/TileGrid.c
@@ -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;
diff --git a/shared-module/displayio/__init__.c b/shared-module/displayio/__init__.c
index a9bb3b21b..740af0570 100644
--- a/shared-module/displayio/__init__.c
+++ b/shared-module/displayio/__init__.c
@@ -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++) {
diff --git a/shared-module/displayio/area.h b/shared-module/displayio/area.h
index ec7c389b4..7ad36883c 100644
--- a/shared-module/displayio/area.h
+++ b/shared-module/displayio/area.h
@@ -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);
diff --git a/shared-module/vectorio/VectorShape.c b/shared-module/vectorio/VectorShape.c
index 81f46b3fa..b5d36339e 100644
--- a/shared-module/vectorio/VectorShape.c
+++ b/shared-module/vectorio/VectorShape.c
@@ -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) {