shm: track busy buffers’ age, and add compile-time option to force double buffering

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).
This commit is contained in:
Daniel Eklöf 2021-05-07 18:18:35 +02:00
parent 1501d36470
commit c8b342ae51
No known key found for this signature in database
GPG key ID: 5BBD4992C116573F
3 changed files with 34 additions and 11 deletions

View file

@ -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: