mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-03-22 05:33:45 -04:00
shm: auto-purge when we have multiple buffers eligible for re-use
It may happen that we end up with multiple non-busy, same-sized buffers for the same cookie (context), and thus eligible for re-use. Before this patch, we would keep all those buffers around. This is completely unnecessary. Under normal circumstances, we’ll either be re-using a single buffer, or swap between two. In the second case, the “other” buffer is always busy, and thus not eligible for re-use. So, if we _do_ detect multiple, re-usable buffers, pick the one with the lowest “age” (increasing the chance of applying damage tracking, instead of re-drawing everything), and mark the other one for purging.
This commit is contained in:
parent
5d7b729ac5
commit
a486851bdd
1 changed files with 9 additions and 0 deletions
9
shm.c
9
shm.c
|
|
@ -494,6 +494,15 @@ shm_get_buffer(struct wl_shm *shm, int width, int height, unsigned long cookie,
|
||||||
it->item.scroll_damage = NULL;
|
it->item.scroll_damage = NULL;
|
||||||
xassert(it->item.pix_instances == pix_instances);
|
xassert(it->item.pix_instances == pix_instances);
|
||||||
cached = &it->item;
|
cached = &it->item;
|
||||||
|
} else {
|
||||||
|
/* We have multiple buffers eligable for
|
||||||
|
* re-use. Pick the “youngest” one, and mark the
|
||||||
|
* other one for purging */
|
||||||
|
if (it->item.age < cached->age) {
|
||||||
|
cached->purge = true;
|
||||||
|
cached = &it->item;
|
||||||
|
} else
|
||||||
|
it->item.purge = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue