aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Eklöf <daniel@ekloef.se>2019-11-02 00:31:48 +0000
committerDaniel Eklöf <daniel@ekloef.se>2019-11-02 00:31:48 +0000
commit6ed97a47be57b89c67df56919669bb48802be850 (patch)
tree464f41c4d3b34f456fe65e733a57c8522b512a6e
parentRevert "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.c32
1 files changed, 16 insertions, 16 deletions
diff --git a/shm.c b/shm.c
index 9b1af9a4..26e58167 100644
--- a/shm.c
+++ b/shm.c
@@ -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)