aboutsummaryrefslogtreecommitdiff
path: root/render.c
diff options
context:
space:
mode:
authorDaniel Eklöf <daniel@ekloef.se>2022-10-06 15:09:32 +0000
committerDaniel Eklöf <daniel@ekloef.se>2022-10-10 15:19:17 +0000
commit3565cbd636dacf15049504d686219b787783733c (patch)
tree6588d89dfc861fd5ec74b1343054dbefa62dec56 /render.c
parentrender: delay reflow for ‘resize-delay-ms’ milliseconds (diff)
render: performance improvements during interactive resize
Instead of copying the entire grid when an interactive resize is started, stash the complete grid (to be used in the final reflow). Copy the current viewport only, to be used during the interactive resize. This gets rid of the initial "pause" when snapshotting the grid when an interactive resize is started.
Diffstat (limited to 'render.c')
-rw-r--r--render.c42
1 files changed, 37 insertions, 5 deletions
diff --git a/render.c b/render.c
index 034c9946..d2fce8b0 100644
--- a/render.c
+++ b/render.c
@@ -3900,13 +3900,45 @@ maybe_resize(struct terminal *term, int width, int height, bool force)
* the original grid, before the resize started.
*/
if (term->window->is_resizing && term->render.resizing.grid == NULL) {
+ /* Stash the current ‘normal’ grid, as-is, to be used when
+ * doing the final reflow */
+ term->render.resizing.screen_rows = term->rows;
+ term->render.resizing.grid = xmalloc(sizeof(*term->render.resizing.grid));
+ *term->render.resizing.grid = term->normal;
+
+
/*
- * TODO: snapshotting a large grid is slow. To improve, move
- * normal -> resizing.grid, and instantiate a small (screen
- * sized) new “normal”
+ * Copy the current viewport to a new grid that will be used
+ * during the resize. For now, throw away sixels and OSC-8
+ * URLs. They’ll be "restored" when we do the final reflow.
+ *
+ * TODO:
+ * - sixels?
+ * - OSC-8?
*/
- term->render.resizing.grid = grid_snapshot(&term->normal);
- term->render.resizing.screen_rows = term->rows;
+ struct grid g = {
+ .num_rows = 1 << (32 - __builtin_clz(term->rows - 1)),
+ .num_cols = term->cols,
+ .offset = 0,
+ .view = 0,
+ .cursor = term->normal.cursor,
+ .saved_cursor = term->normal.saved_cursor,
+ .rows = xcalloc(g.num_rows, sizeof(g.rows[0])),
+ .cur_row = NULL,
+ .scroll_damage = tll_init(),
+ .sixel_images = tll_init(),
+ .kitty_kbd = term->normal.kitty_kbd,
+ };
+
+ for (size_t i = 0, j = term->normal.view; i < term->rows;
+ i++, j = (j + 1) & (term->normal.num_rows - 1))
+ {
+ g.rows[i] = grid_row_alloc(term->cols, false);
+ memcpy(g.rows[i]->cells, term->normal.rows[j]->cells,
+ term->cols * sizeof(g.rows[i]->cells[0]));
+ }
+
+ term->normal = g;
}
/* Screen rows/cols before resize */