diff options
| author | Daniel Eklöf <daniel@ekloef.se> | 2019-11-02 00:31:48 +0000 |
|---|---|---|
| committer | Daniel Eklöf <daniel@ekloef.se> | 2019-11-02 00:31:48 +0000 |
| commit | 6ed97a47be57b89c67df56919669bb48802be850 (patch) | |
| tree | 464f41c4d3b34f456fe65e733a57c8522b512a6e | |
| parent | Revert "render: last_buf may point to a free:d buffer" (diff) | |
shm: purge buffers *before* we (maybe) return one from the cache
| -rw-r--r-- | shm.c | 32 |
1 files changed, 16 insertions, 16 deletions
@@ -42,22 +42,6 @@ static const struct wl_buffer_listener buffer_listener = { struct buffer * 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 */ tll_foreach(buffers, it) { 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_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 */ tll_foreach(buffers, it) { if (it->item.cookie != cookie) |
