aboutsummaryrefslogtreecommitdiff
path: root/render.c
diff options
context:
space:
mode:
authorDaniel Eklöf <daniel@ekloef.se>2021-07-16 14:47:57 +0000
committerDaniel Eklöf <daniel@ekloef.se>2021-07-17 17:14:42 +0000
commit232fb20269b68157874f57d676c1b0b95c2386aa (patch)
treeca4de1f2c6dc21a8d0261c55e97b4ac8358be122 /render.c
parentshm: we may exit with busy buffers remaining (seen on KDE) (diff)
shm: replace 'locked' attribute with a ref-counter
The initial ref-count is either 1 or 0, depending on whether the buffer is supposed to be released "immeidately" (meaning, as soon as the compositor releases it). Two new user facing functions have been added: shm_addref() and shm_unref(). Our renderer now uses these two functions instead of manually setting and clearing the 'locked' attribute. shm_unref() will decrement the ref-counter, and destroy the buffer when the counter reaches zero. Except if the buffer is currently "busy" (compositor owned), in which case destruction is deferred to the release event. The buffer is still removed from the list though.
Diffstat (limited to 'render.c')
-rw-r--r--render.c12
1 files changed, 5 insertions, 7 deletions
diff --git a/render.c b/render.c
index 90fdae7b..c6835664 100644
--- a/render.c
+++ b/render.c
@@ -2324,19 +2324,18 @@ grid_render(struct terminal *term)
}
if (term->render.last_buf != NULL) {
- term->render.last_buf->locked = false;
- free(term->render.last_buf->scroll_damage);
- term->render.last_buf->scroll_damage = NULL;
+ shm_unref(term->render.last_buf);
+ term->render.last_buf = NULL;
}
term->render.last_buf = buf;
term->render.was_flashing = term->flash.active;
term->render.was_searching = term->is_searching;
- buf->locked = true;
+ shm_addref(buf);
buf->age = 0;
- xassert(buf->scroll_damage == NULL);
+ free(term->render.last_buf->scroll_damage);
buf->scroll_damage_count = tll_length(term->grid->scroll_damage);
buf->scroll_damage = xmalloc(
buf->scroll_damage_count * sizeof(buf->scroll_damage[0]));
@@ -3484,8 +3483,7 @@ damage_view:
tll_free(term->normal.scroll_damage);
tll_free(term->alt.scroll_damage);
- if (term->render.last_buf != NULL)
- term->render.last_buf->locked = false;
+ shm_unref(term->render.last_buf);
term->render.last_buf = NULL;
term_damage_view(term);
render_refresh_csd(term);