Fix TileGrid's dirty tracking when changing top left

This commit is contained in:
Scott Shawcroft 2019-06-16 14:43:13 -07:00
parent c4170d2f18
commit da3d75f7b1
No known key found for this signature in database
GPG Key ID: 9349BC7E64B1921E

View File

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