derekf pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=a5c7fbd006b5e4e578e2a938a609c2aa79315fc2

commit a5c7fbd006b5e4e578e2a938a609c2aa79315fc2
Author: Derek Foreman <der...@osg.samsung.com>
Date:   Wed Nov 8 14:15:52 2017 -0600

    wayland_shm: Return oldest buffer for new renders
    
    This is what the old shm code has been doing, and it's probably better
    than what the dmabuf code was doing.
    
    We currently allocate 3 buffers.  The usual case has us swapping between
    two of those buffers and saving that third buffer for emergencies - if
    we ever need that third buffer it'll require a full redraw.
    
    If we return the oldest available buffer the usual case requires a little
    more damage but we should never hit the full redraw case, which can cause
    a frame drop on slow hardware.
---
 src/modules/evas/engines/wayland_shm/evas_dmabuf.c | 28 +++++++---------------
 1 file changed, 9 insertions(+), 19 deletions(-)

diff --git a/src/modules/evas/engines/wayland_shm/evas_dmabuf.c 
b/src/modules/evas/engines/wayland_shm/evas_dmabuf.c
index 2d263de0c1..77849a4e46 100644
--- a/src/modules/evas/engines/wayland_shm/evas_dmabuf.c
+++ b/src/modules/evas/engines/wayland_shm/evas_dmabuf.c
@@ -600,29 +600,19 @@ _evas_dmabuf_surface_data_get(Surface *s, int *w, int *h)
 static Dmabuf_Buffer *
 _evas_dmabuf_surface_wait(Dmabuf_Surface *s)
 {
-   int iterations = 0, i;
-   struct wl_display *disp;
+   int i = 0, best = -1, best_age = -1;
 
-   disp = ecore_wl2_display_get(s->surface->info->info.wl2_display);
-
-   while (iterations++ < 10)
+   for (i = 0; i < s->nbuf; i++)
      {
-        for (i = 0; i < s->nbuf; i++)
-          if (!s->buffer[i]->locked &&
-              !s->buffer[i]->busy)
-            return s->buffer[i];
-
-        wl_display_dispatch_pending(disp);
+        if (s->buffer[i]->locked || s->buffer[i]->busy) continue;
+        if (s->buffer[i]->age > best_age)
+          {
+             best = i;
+             best_age = s->buffer[i]->age;
+          }
      }
 
-   /* May be we have a possible render target that just hasn't been
-    * given a wl_buffer yet - draw there and let the success handler
-    * figure it out.
-    */
-   for (i = 0; i < s->nbuf; i++)
-     if (!s->buffer[i]->locked && !s->buffer[i]->busy)
-       return s->buffer[i];
-
+   if (best >= 0) return s->buffer[best];
    return NULL;
 }
 

-- 


Reply via email to