mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-02-26 01:40:12 -05:00
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.
This commit is contained in:
parent
69260dd960
commit
232fb20269
4 changed files with 60 additions and 53 deletions
12
render.c
12
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);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue