devilhorns pushed a commit to branch master.

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

commit 9492ee21dfa642123043da5d5ef7954e886b0f9c
Author: Chris Michael <cp.mich...@samsung.com>
Date:   Fri Dec 2 13:24:42 2016 -0500

    evas-wayland-shm: Fix issue of destroying & recreating wl_surfaces on hide
    
    When a canvas gets hidden, we don't need to destroy & recreate the
    wl_surface. We can simply attach a NULL wl_buffer to the surface which
    achieves the same result. This saves us from having to always destroy
    & recreate surfaces when we hide/show.
    
    Signed-off-by: Chris Michael <cp.mich...@samsung.com>
---
 src/modules/evas/engines/wayland_shm/evas_dmabuf.c | 17 ++++++++++++-----
 src/modules/evas/engines/wayland_shm/evas_engine.h |  4 +++-
 src/modules/evas/engines/wayland_shm/evas_outbuf.c | 10 ++++++++--
 src/modules/evas/engines/wayland_shm/evas_shm.c    | 16 +++++++++-------
 4 files changed, 32 insertions(+), 15 deletions(-)

diff --git a/src/modules/evas/engines/wayland_shm/evas_dmabuf.c 
b/src/modules/evas/engines/wayland_shm/evas_dmabuf.c
index 63d6e30..df04b5e 100644
--- a/src/modules/evas/engines/wayland_shm/evas_dmabuf.c
+++ b/src/modules/evas/engines/wayland_shm/evas_dmabuf.c
@@ -390,7 +390,7 @@ _fallback(Dmabuf_Surface *s, int w, int h)
    new_data = surf->funcs.data_get(surf, NULL, NULL);
    for (y = 0; y < h; y++)
      memcpy(new_data + y * w * 4, old_data + y * b->stride, w * 4);
-   surf->funcs.post(surf, NULL, 0);
+   surf->funcs.post(surf, NULL, 0, EINA_FALSE);
    buffer_manager->unmap(b);
 
 out:
@@ -600,7 +600,7 @@ _evas_dmabuf_surface_assign(Surface *s)
 }
 
 static void
-_evas_dmabuf_surface_post(Surface *s, Eina_Rectangle *rects, unsigned int 
count)
+_evas_dmabuf_surface_post(Surface *s, Eina_Rectangle *rects, unsigned int 
count, Eina_Bool hidden)
 {
    Dmabuf_Surface *surface;
    Dmabuf_Buffer *b;
@@ -626,9 +626,16 @@ _evas_dmabuf_surface_post(Surface *s, Eina_Rectangle 
*rects, unsigned int count)
         return;
      }
    surface->pre = NULL;
-   wl_surface_attach(surface->wl_surface, b->wl_buffer, 0, 0);
-   _evas_surface_damage(surface->wl_surface, surface->compositor_version,
-                        b->w, b->h, rects, count);
+
+   if (!hidden)
+     {
+        wl_surface_attach(surface->wl_surface, b->wl_buffer, 0, 0);
+        _evas_surface_damage(surface->wl_surface, surface->compositor_version,
+                             b->w, b->h, rects, count);
+     }
+   else
+     wl_surface_attach(surface->wl_surface, NULL, 0, 0);
+
    wl_surface_commit(surface->wl_surface);
 }
 
diff --git a/src/modules/evas/engines/wayland_shm/evas_engine.h 
b/src/modules/evas/engines/wayland_shm/evas_engine.h
index e3a0553..5bfb6c1 100644
--- a/src/modules/evas/engines/wayland_shm/evas_engine.h
+++ b/src/modules/evas/engines/wayland_shm/evas_engine.h
@@ -99,7 +99,7 @@ struct _Surface
         void (*reconfigure)(Surface *surface, int w, int h, uint32_t flags);
         void *(*data_get)(Surface *surface, int *w, int *h);
         int  (*assign)(Surface *surface);
-        void (*post)(Surface *surface, Eina_Rectangle *rects, unsigned int 
count);
+        void (*post)(Surface *surface, Eina_Rectangle *rects, unsigned int 
count, Eina_Bool hidden);
      } funcs;
 };
 
@@ -133,6 +133,8 @@ struct _Outbuf
         /* Eina_Bool redraw : 1; */
         Eina_Bool destination_alpha : 1;
      } priv;
+
+   Eina_Bool hidden : 1;
 };
 
 Eina_Bool _evas_dmabuf_surface_create(Surface *s, int w, int h, int num_buff);
diff --git a/src/modules/evas/engines/wayland_shm/evas_outbuf.c 
b/src/modules/evas/engines/wayland_shm/evas_outbuf.c
index b25242f..fcfb8b9 100644
--- a/src/modules/evas/engines/wayland_shm/evas_outbuf.c
+++ b/src/modules/evas/engines/wayland_shm/evas_outbuf.c
@@ -55,6 +55,7 @@ _evas_outbuf_setup(int w, int h, Evas_Engine_Info_Wayland 
*info)
    ob->rotation = info->info.rotation;
    ob->depth = info->info.depth;
    ob->priv.destination_alpha = info->info.destination_alpha;
+   ob->hidden = info->info.hidden;
 
    /* default to triple buffer */
    ob->num_buff = 3;
@@ -82,7 +83,8 @@ _evas_outbuf_setup(int w, int h, Evas_Engine_Info_Wayland 
*info)
         sw = h;
         sh = w;
      }
-   else goto unhandled_rotation;
+   else
+     goto unhandled_rotation;
 
    ob->surface = _evas_surface_create(info, sw, sh, ob->num_buff);
    if (!ob->surface) goto surf_err;
@@ -203,6 +205,8 @@ _evas_outbuf_flush(Outbuf *ob, Tilebuf_Rect *surface_damage 
EINA_UNUSED, Tilebuf
 
    LOGFN(__FILE__, __LINE__, __FUNCTION__);
 
+   if (ob->hidden) return;
+
    if (render_mode == EVAS_RENDER_MODE_ASYNC_INIT) return;
 
    if (ob->priv.rect_count) free(ob->priv.rects);
@@ -359,6 +363,8 @@ _evas_outbuf_reconfigure(Outbuf *ob, int w, int h, int rot, 
Outbuf_Depth depth,
    ob->depth = depth;
    ob->priv.destination_alpha = alpha;
 
+   if (ob->hidden) return;
+
    if ((ob->rotation == 0) || (ob->rotation == 180))
      {
         ob->surface->funcs.reconfigure(ob->surface, w, h, resize);
@@ -626,7 +632,7 @@ _evas_outbuf_redraws_clear(Outbuf *ob)
 {
    if (!ob->priv.rect_count) return;
    if (ob->info->info.wl_surface)
-     ob->surface->funcs.post(ob->surface, ob->priv.rects, ob->priv.rect_count);
+     ob->surface->funcs.post(ob->surface, ob->priv.rects, ob->priv.rect_count, 
ob->hidden);
    free(ob->priv.rects);
    ob->priv.rect_count = 0;
 }
diff --git a/src/modules/evas/engines/wayland_shm/evas_shm.c 
b/src/modules/evas/engines/wayland_shm/evas_shm.c
index b6667c7..d38a19f 100644
--- a/src/modules/evas/engines/wayland_shm/evas_shm.c
+++ b/src/modules/evas/engines/wayland_shm/evas_shm.c
@@ -543,9 +543,8 @@ _evas_shm_surface_data_get(Surface *s, int *w, int *h)
 }
 
 void
-_evas_shm_surface_post(Surface *s, Eina_Rectangle *rects, unsigned int count)
+_evas_shm_surface_post(Surface *s, Eina_Rectangle *rects, unsigned int count, 
Eina_Bool hidden)
 {
-   /* struct wl_callback *frame_cb; */
    Shm_Surface *surf;
    Shm_Leaf *leaf;
 
@@ -557,12 +556,15 @@ _evas_shm_surface_post(Surface *s, Eina_Rectangle *rects, 
unsigned int count)
 
    if (!surf->surface) return;
 
-   wl_surface_attach(surf->surface, leaf->data->buffer, 0, 0);
+   if (!hidden)
+     {
+        wl_surface_attach(surf->surface, leaf->data->buffer, 0, 0);
 
-   _evas_surface_damage(surf->surface, surf->compositor_version,
-                        leaf->w, leaf->h, rects, count);
-   /* frame_cb = wl_surface_frame(surface->surface); */
-   /* wl_callback_add_listener(frame_cb, &_shm_frame_listener, surface); */
+        _evas_surface_damage(surf->surface, surf->compositor_version,
+                             leaf->w, leaf->h, rects, count);
+     }
+   else
+     wl_surface_attach(surf->surface, NULL, 0, 0);
 
    wl_surface_commit(surf->surface);
 

-- 


Reply via email to