diff options
| author | Scott Shawcroft <scott@adafruit.com> | 2019-06-18 10:29:12 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-06-18 10:29:12 -0700 |
| commit | 13c3d06c6a379e1aa4fd0ad6fb6f92621e248344 (patch) | |
| tree | 9adf75bbae62ece321a511eebb757361fae44c88 | |
| parent | e6ded8dd2212850aecce8907e50df6ee93f03a1c (diff) | |
| parent | 7490adf8e945b7c040ea5a22293675b8b29da8da (diff) | |
Merge pull request #1952 from tannewt/fixup_tilegrid_dirty
Fix TileGrid's dirty tracking when changing top left
| -rw-r--r-- | shared-module/displayio/TileGrid.c | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/shared-module/displayio/TileGrid.c b/shared-module/displayio/TileGrid.c index 97b704c40..cdca45a29 100644 --- a/shared-module/displayio/TileGrid.c +++ b/shared-module/displayio/TileGrid.c @@ -219,10 +219,19 @@ void common_hal_displayio_tilegrid_set_tile(displayio_tilegrid_t *self, uint16_t } else { tile_area = &temp_area; } - tile_area->x1 = x * self->tile_width; + int16_t tx = (x - self->top_left_x) % self->width_in_tiles; + if (tx < 0) { + tx += self->width_in_tiles; + } + tile_area->x1 = tx * self->tile_width; tile_area->x2 = tile_area->x1 + self->tile_width; - tile_area->y1 = y * self->tile_height; + int16_t ty = (y - self->top_left_y) % self->height_in_tiles; + if (ty < 0) { + ty += self->height_in_tiles; + } + tile_area->y1 = ty * self->tile_height; tile_area->y2 = tile_area->y1 + self->tile_height; + if (self->partial_change) { displayio_area_expand(&self->dirty_area, &temp_area); } |
