devilhorns pushed a commit to branch master.

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

commit f86e04b14f99f6baba0ffd734b81f15634f182ef
Author: Derek Foreman <der...@osg.samsung.com>
Date:   Thu Jul 30 11:45:38 2015 -0400

    wayland-shm: Introduce buffer ages
    
    Summary:
    We now track each shm buffer's time since last draw so evas can tell
    what it needs to re-render.
    
    Reviewers: zmike, devilhorns
    
    Reviewed By: devilhorns
    
    Subscribers: cedric
    
    Differential Revision: https://phab.enlightenment.org/D2893
---
 src/modules/evas/engines/wayland_shm/evas_engine.h |  3 +-
 src/modules/evas/engines/wayland_shm/evas_outbuf.c | 22 +++++-------
 src/modules/evas/engines/wayland_shm/evas_shm.c    | 41 +++++++++++++++++++---
 3 files changed, 47 insertions(+), 19 deletions(-)

diff --git a/src/modules/evas/engines/wayland_shm/evas_engine.h 
b/src/modules/evas/engines/wayland_shm/evas_engine.h
index b3424c5..71e63a4 100644
--- a/src/modules/evas/engines/wayland_shm/evas_engine.h
+++ b/src/modules/evas/engines/wayland_shm/evas_engine.h
@@ -63,11 +63,12 @@ struct _Shm_Data
 typedef struct _Shm_Leaf Shm_Leaf;
 struct _Shm_Leaf
 {
-   int w, h, busy;
+   int w, h, busy, age;
    Shm_Data *data;
    Shm_Pool *resize_pool;
    Eina_Bool valid : 1;
    Eina_Bool reconfigure : 1;
+   Eina_Bool drawn : 1;
 };
 
 typedef struct _Shm_Surface Shm_Surface;
diff --git a/src/modules/evas/engines/wayland_shm/evas_outbuf.c 
b/src/modules/evas/engines/wayland_shm/evas_outbuf.c
index e1e8f63..91fa149 100644
--- a/src/modules/evas/engines/wayland_shm/evas_outbuf.c
+++ b/src/modules/evas/engines/wayland_shm/evas_outbuf.c
@@ -251,26 +251,20 @@ _evas_outbuf_flush(Outbuf *ob, Tilebuf_Rect *rects 
EINA_UNUSED, Evas_Render_Mode
 Render_Engine_Swap_Mode 
 _evas_outbuf_swap_mode_get(Outbuf *ob)
 {
-   int count = 0, ret = 0;
+   int age;
 
    LOGFN(__FILE__, __LINE__, __FUNCTION__);
 
    if (!_evas_shm_surface_assign(ob->surface)) return MODE_FULL;
 
-   /* This was broken, for now we just do full redraws */
-   return MODE_FULL;
-
-   if (count == ob->surface->num_buff) ret = MODE_FULL;
-   else if (count == 0) ret = MODE_COPY;
-   else if (count == 1) ret = MODE_DOUBLE;
-   else if (count == 2) ret = MODE_TRIPLE;
-   else if (count == 3) ret = MODE_QUADRUPLE;
-   else ret = MODE_FULL;
+   age = ob->surface->current->age;
+   if (age > ob->surface->num_buff) return MODE_FULL;
+   else if (age == 1) return MODE_COPY;
+   else if (age == 2) return MODE_DOUBLE;
+   else if (age == 3) return MODE_TRIPLE;
+   else if (age == 4) return MODE_QUADRUPLE;
 
-   /* DBG("SWAPMODE: %d (0=FULL, 1=COPY, 2=DOUBLE, 3=TRIPLE, 4=QUAD", ret); */
-   /* DBG("\tBusy: %d", count); */
-
-   return ret;
+   return MODE_FULL;
 }
 
 int 
diff --git a/src/modules/evas/engines/wayland_shm/evas_shm.c 
b/src/modules/evas/engines/wayland_shm/evas_shm.c
index 9860d9f..30f02f8 100644
--- a/src/modules/evas/engines/wayland_shm/evas_shm.c
+++ b/src/modules/evas/engines/wayland_shm/evas_shm.c
@@ -290,7 +290,8 @@ _shm_leaf_create(Shm_Surface *surface, Shm_Leaf *leaf, int 
w, int h)
    leaf->w = w;
    leaf->h = h;
    leaf->valid = EINA_TRUE;
-
+   leaf->drawn = EINA_FALSE;
+   leaf->age = 0;
    wl_buffer_add_listener(leaf->data->buffer, &_shm_buffer_listener, surface);
 
    return EINA_TRUE;
@@ -408,6 +409,7 @@ Eina_Bool
 _evas_shm_surface_assign(Shm_Surface *surface)
 {
    int i;
+   surface->current = NULL;
 
    for (i = 0; i < surface->num_buff; i++)
      {
@@ -415,10 +417,39 @@ _evas_shm_surface_assign(Shm_Surface *surface)
         if (surface->leaf[i].valid)
           {
              surface->current = &surface->leaf[i];
-             return EINA_TRUE;
+             break;
+          }
+     }
+
+   /* If we ran out of buffers we're in trouble, reset all ages */
+   if (!surface->current)
+     {
+        for (i = 0; i < surface->num_buff; i++)
+          {
+             if (surface->leaf[i].valid)
+               {
+                  surface->leaf[i].drawn = EINA_FALSE;
+                  surface->leaf[i].age = 0;
+               }
           }
+        return EINA_FALSE;
      }
-   return EINA_FALSE;
+
+   /* Increment ages of all valid buffers */
+   for (i = 0; i < surface->num_buff; i++)
+     {
+        if (surface->leaf[i].valid && surface->leaf[i].drawn)
+          {
+             surface->leaf[i].age++;
+             if (surface->leaf[i].age > surface->num_buff)
+               {
+                  surface->leaf[i].age = 0;
+                  surface->leaf[i].drawn = EINA_FALSE;
+               }
+          }
+     }
+
+   return EINA_TRUE;
 }
 
 void *
@@ -475,6 +506,8 @@ _evas_shm_surface_post(Shm_Surface *surface, Eina_Rectangle 
*rects, unsigned int
 
    wl_surface_commit(surface->surface);
 
-   leaf->busy = 1;
+   leaf->busy = EINA_TRUE;
+   leaf->drawn = EINA_TRUE;
+   leaf->age = 0;
    surface->current = NULL;
 }

-- 


Reply via email to