From c8b342ae51cba357f21a3f6c77f6a527981101b8 Mon Sep 17 00:00:00 2001 From: Daniel Eklöf Date: Fri, 7 May 2021 18:18:35 +0200 Subject: shm: track busy buffers’ age, and add compile-time option to force double buffering MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit By default, age all matching buffers that are busy (i.e. in use by the compositor). This allows us to detect whether we can apply the current frame’s damage directly, or if we need to prepare the buffer first (e.g. copy old buffer, or re-apply last frame’s damage etc). --- render.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'render.c') diff --git a/render.c b/render.c index 9bcd11ba..43b6ee6f 100644 --- a/render.c +++ b/render.c @@ -2048,6 +2048,11 @@ grid_render(struct terminal *term) term->is_searching != term->render.was_searching || term->render.margins) { + if (buf->age > 0) { + LOG_DBG("compositor double buffers (age=%d): last=%p, cur=%p", + buf->age, (void*)term->render.last_buf, (void*)buf); + } + if (term->render.last_buf != NULL && term->render.last_buf->width == buf->width && term->render.last_buf->height == buf->height && @@ -2080,6 +2085,7 @@ grid_render(struct terminal *term) term->render.was_searching = term->is_searching; } + buf->age = 0; tll_foreach(term->grid->scroll_damage, it) { switch (it->item.type) { case DAMAGE_SCROLL: -- cgit v1.3