mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-03-28 07:58:00 -04:00
shm: purge buffers *before* we (maybe) return one from the cache
This commit is contained in:
parent
bf9aff056a
commit
6ed97a47be
1 changed files with 16 additions and 16 deletions
32
shm.c
32
shm.c
|
|
@ -42,22 +42,6 @@ static const struct wl_buffer_listener buffer_listener = {
|
||||||
struct buffer *
|
struct buffer *
|
||||||
shm_get_buffer(struct wl_shm *shm, int width, int height, unsigned long cookie)
|
shm_get_buffer(struct wl_shm *shm, int width, int height, unsigned long cookie)
|
||||||
{
|
{
|
||||||
tll_foreach(buffers, it) {
|
|
||||||
if (it->item.width != width)
|
|
||||||
continue;
|
|
||||||
if (it->item.height != height)
|
|
||||||
continue;
|
|
||||||
if (it->item.cookie != cookie)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
if (!it->item.busy) {
|
|
||||||
LOG_DBG("cookie=%lx: re-using buffer from cache", cookie);
|
|
||||||
it->item.busy = true;
|
|
||||||
it->item.purge = false;
|
|
||||||
return &it->item;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Purge buffers marked for purging */
|
/* Purge buffers marked for purging */
|
||||||
tll_foreach(buffers, it) {
|
tll_foreach(buffers, it) {
|
||||||
if (it->item.cookie != cookie)
|
if (it->item.cookie != cookie)
|
||||||
|
|
@ -75,6 +59,22 @@ shm_get_buffer(struct wl_shm *shm, int width, int height, unsigned long cookie)
|
||||||
tll_remove(buffers, it);
|
tll_remove(buffers, it);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
tll_foreach(buffers, it) {
|
||||||
|
if (it->item.width != width)
|
||||||
|
continue;
|
||||||
|
if (it->item.height != height)
|
||||||
|
continue;
|
||||||
|
if (it->item.cookie != cookie)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (!it->item.busy) {
|
||||||
|
LOG_DBG("cookie=%lx: re-using buffer from cache", cookie);
|
||||||
|
it->item.busy = true;
|
||||||
|
it->item.purge = false;
|
||||||
|
return &it->item;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* Purge old buffers associated with this cookie */
|
/* Purge old buffers associated with this cookie */
|
||||||
tll_foreach(buffers, it) {
|
tll_foreach(buffers, it) {
|
||||||
if (it->item.cookie != cookie)
|
if (it->item.cookie != cookie)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue