evas-wayland-shm: Improve next buffer selection algorithm
authorChris Michael <cp.michael@samsung.com>
Wed, 26 Oct 2016 15:53:49 +0000 (11:53 -0400)
committerChris Michael <cp.michael@samsung.com>
Wed, 26 Oct 2016 15:53:49 +0000 (11:53 -0400)
When triple buffering it's possible that we'll only need two buffers at
a time for long durations.  When we finally call upon a third buffer it
hasn't been used recently enough to do a partial redraw.
By picking the oldest available buffer when multiple buffers are free we
can increase the likelihood of doing partial redraws.

Based on 79409757c6493738c21015708a1ba5178942ad94 by Derek Foreman.

Signed-off-by: Chris Michael <cp.michael@samsung.com>
src/modules/evas/engines/wayland_shm/evas_shm.c

index e051b25..d86d466 100644 (file)
@@ -461,18 +461,19 @@ _evas_shm_surface_reconfigure(Surface *s, int w, int h, uint32_t flags)
 static Shm_Leaf *
 _evas_shm_surface_wait(Shm_Surface *surface)
 {
-   int iterations = 0, i;
+   int i = 0, best = -1, best_age = -1;
 
-   while (iterations++ < 10)
+   for (i = 0; i < surface->num_buff; i++)
      {
-        for (i = 0; i < surface->num_buff; i++)
+        if (surface->leaf[i].busy) continue;
+        if ((surface->leaf[i].valid) && (surface->leaf[i].age > best_age))
           {
-             if (surface->leaf[i].busy) continue;
-             if (surface->leaf[i].valid) return &surface->leaf[i];
+             best = i;
+             best_age = surface->leaf[i].age;
           }
-
-        wl_display_dispatch_pending(surface->disp);
      }
+
+   if (best >= 0) return &surface->leaf[best];
    return NULL;
 }