aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--shm.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/shm.c b/shm.c
index 17b9c15d..064d52ec 100644
--- a/shm.c
+++ b/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;
xassert(it->item.pix_instances == pix_instances);
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;
}
}
}