summaryrefslogtreecommitdiff
path: root/supervisor
diff options
context:
space:
mode:
authorScott Shawcroft <scott@tannewt.org>2019-06-06 15:11:02 -0700
committerScott Shawcroft <scott@tannewt.org>2019-06-12 11:32:39 -0700
commiteb21fc3e31790cee094d5c11811b55a57625340a (patch)
treee45c5dac67e7369dbff9c56c444d4c50984e7c27 /supervisor
parenta06a97e2cba36233d229ba44c3acd9007affe1c9 (diff)
Add partial display update support.
Different operations to the display tree have different costs. Be aware of these costs when optimizing your code. * Changing tiles indices in a TileGrid will update an area covering them all. * Changing a palette will refresh every object that references it. * Moving a TileGrid will update both where it was and where it moved to. * Adding something to a Group will refresh each individual area it covers. * Removing things from a Group will refresh one area that covers all previous locations. (Not separate areas like add.) * Setting a new top level Group will refresh the entire display. Only TileGrid moves are optimized for overlap. All other overlaps cause sending of duplicate pixels. This also adds flip_x, flip_y and transpose_xy to TileGrid. They change the direction of the pixels but not the location. Fixes #1169. Fixes #1705. Fixes #1923.
Diffstat (limited to 'supervisor')
-rw-r--r--supervisor/shared/display.c32
1 files changed, 20 insertions, 12 deletions
diff --git a/supervisor/shared/display.c b/supervisor/shared/display.c
index 5eab74e16..c3afb3e00 100644
--- a/supervisor/shared/display.c
+++ b/supervisor/shared/display.c
@@ -50,6 +50,10 @@ void supervisor_start_terminal(uint16_t width_px, uint16_t height_px) {
}
width_in_tiles = (width_px - blinka_bitmap.width * scale) / (grid->tile_width * scale);
uint16_t height_in_tiles = height_px / (grid->tile_height * scale);
+ uint16_t remaining_pixels = height_px % (grid->tile_height * scale);
+ if (remaining_pixels > 0) {
+ height_in_tiles += 1;
+ }
circuitpython_splash.scale = scale;
uint16_t total_tiles = width_in_tiles * height_in_tiles;
@@ -67,11 +71,13 @@ void supervisor_start_terminal(uint16_t width_px, uint16_t height_px) {
if (tiles == NULL) {
return;
}
-
+ if (remaining_pixels > 0) {
+ grid->y -= (grid->tile_height - remaining_pixels);
+ }
grid->width_in_tiles = width_in_tiles;
grid->height_in_tiles = height_in_tiles;
- grid->area.x2 = grid->area.x1 + width_in_tiles * grid->tile_width;
- grid->area.y2 = grid->area.y1 + height_in_tiles * grid->tile_height;
+ grid->pixel_width = width_in_tiles * grid->tile_width;
+ grid->pixel_height = height_in_tiles * grid->tile_height;
grid->tiles = tiles;
supervisor_terminal.cursor_x = 0;
@@ -157,12 +163,10 @@ displayio_tilegrid_t blinka_sprite = {
.base = {.type = &displayio_tilegrid_type },
.bitmap = &blinka_bitmap,
.pixel_shader = &blinka_palette,
- .area = {
- .x1 = 0,
- .y1 = 0,
- .x2 = 16,
- .y2 = 16
- },
+ .x = 0,
+ .y = 0,
+ .pixel_width = 16,
+ .pixel_height = 16,
.bitmap_width_in_tiles = 1,
.width_in_tiles = 1,
.height_in_tiles = 1,
@@ -171,8 +175,12 @@ displayio_tilegrid_t blinka_sprite = {
.top_left_x = 16,
.top_left_y = 16,
.tiles = 0,
- .needs_refresh = false,
- .inline_tiles = true
+ .partial_change = false,
+ .full_change = false,
+ .first_draw = true,
+ .moved = false,
+ .inline_tiles = true,
+ .in_group = true
};
displayio_group_child_t splash_children[2] = {
@@ -188,5 +196,5 @@ displayio_group_t circuitpython_splash = {
.size = 2,
.max_size = 2,
.children = splash_children,
- .needs_refresh = true
+ .item_removed = false
};