discomfitor pushed a commit to branch master.

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

commit 0d684d4559c6cd4e8195b3334ab07d3631a64887
Author: Derek Foreman <der...@osg.samsung.com>
Date:   Fri Apr 15 10:38:28 2016 -0500

    wayland_shm: Refactor surface creation
    
    Split this into two parts, one that makes the base surface, one that
    calls the potential back ends.
    
    Once the dmabuf backend is added this will allow a fallback path to
    re-initialize the surface as wl_shm if dmabuf fails.
---
 src/modules/evas/engines/wayland_shm/evas_engine.h |  6 ++++-
 src/modules/evas/engines/wayland_shm/evas_outbuf.c | 26 +++++++++++++++++++++-
 src/modules/evas/engines/wayland_shm/evas_shm.c    | 25 +++++++++------------
 3 files changed, 41 insertions(+), 16 deletions(-)

diff --git a/src/modules/evas/engines/wayland_shm/evas_engine.h 
b/src/modules/evas/engines/wayland_shm/evas_engine.h
index 2441c13..f76cf3c 100644
--- a/src/modules/evas/engines/wayland_shm/evas_engine.h
+++ b/src/modules/evas/engines/wayland_shm/evas_engine.h
@@ -76,6 +76,7 @@ typedef struct _Shm_Surface Shm_Surface;
 
 typedef enum _Surface_Type Surface_Type;
 enum _Surface_Type {
+   SURFACE_EMPTY,
    SURFACE_SHM
 };
 
@@ -86,6 +87,7 @@ struct _Surface
    union {
       Shm_Surface *shm;
    } surf;
+   Evas_Engine_Info_Wayland_Shm *info;
    struct
      {
         void (*destroy)(Surface *surface);
@@ -125,7 +127,7 @@ struct _Outbuf
      } priv;
 };
 
-Surface *_evas_shm_surface_create(Evas_Engine_Info_Wayland_Shm *info, int w, 
int h, int num_buff);
+Eina_Bool _evas_shm_surface_create(Surface *s, int w, int h, int num_buff);
 
 Outbuf *_evas_outbuf_setup(int w, int h, Evas_Engine_Info_Wayland_Shm *info);
 void _evas_outbuf_free(Outbuf *ob);
@@ -140,4 +142,6 @@ void _evas_outbuf_update_region_push(Outbuf *ob, RGBA_Image 
*update, int x, int
 void _evas_outbuf_update_region_free(Outbuf *ob, RGBA_Image *update);
 void _evas_surface_damage(struct wl_surface *s, int compositor_version, int w, 
int h, Eina_Rectangle *rects, unsigned int count);
 
+Eina_Bool _evas_surface_init(Surface *s, int w, int h, int num_buf);
+
 #endif
diff --git a/src/modules/evas/engines/wayland_shm/evas_outbuf.c 
b/src/modules/evas/engines/wayland_shm/evas_outbuf.c
index b9a472c..1ba9a7d 100644
--- a/src/modules/evas/engines/wayland_shm/evas_outbuf.c
+++ b/src/modules/evas/engines/wayland_shm/evas_outbuf.c
@@ -9,6 +9,30 @@
 #define GREEN_MASK 0x00ff00
 #define BLUE_MASK 0x0000ff
 
+Eina_Bool
+_evas_surface_init(Surface *s, int w, int h, int num_buf)
+{
+   if (_evas_shm_surface_create(s, w, h, num_buf)) return EINA_TRUE;
+
+   return EINA_FALSE;
+}
+
+static Surface *
+_evas_surface_create(Evas_Engine_Info_Wayland_Shm *info, int w, int h, int 
num_buf)
+{
+   Surface *out;
+
+   out = calloc(1, sizeof(*out));
+   if (!out) return NULL;
+   out->type = SURFACE_EMPTY;
+   out->info = info;
+
+   if (_evas_surface_init(out, w, h, num_buf)) return out;
+
+   free(out);
+   return NULL;
+}
+
 Outbuf *
 _evas_outbuf_setup(int w, int h, Evas_Engine_Info_Wayland_Shm *info)
 {
@@ -57,7 +81,7 @@ _evas_outbuf_setup(int w, int h, Evas_Engine_Info_Wayland_Shm 
*info)
      }
    else goto unhandled_rotation;
 
-   ob->surface = _evas_shm_surface_create(info, sw, sh, ob->num_buff);
+   ob->surface = _evas_surface_create(info, sw, sh, ob->num_buff);
    if (!ob->surface) goto surf_err;
 
 unhandled_rotation:
diff --git a/src/modules/evas/engines/wayland_shm/evas_shm.c 
b/src/modules/evas/engines/wayland_shm/evas_shm.c
index f716865..2f4fe59 100644
--- a/src/modules/evas/engines/wayland_shm/evas_shm.c
+++ b/src/modules/evas/engines/wayland_shm/evas_shm.c
@@ -407,7 +407,6 @@ _evas_shm_surface_destroy(Surface *surface)
      _shm_leaf_destroy(&surface->surf.shm->leaf[i]);
 
    free(surface->surf.shm);
-   free(surface);
 }
 
 void 
@@ -568,28 +567,25 @@ _evas_shm_surface_post(Surface *s, Eina_Rectangle *rects, 
unsigned int count)
    surf->current = NULL;
 }
 
-Surface *
-_evas_shm_surface_create(Evas_Engine_Info_Wayland_Shm *info, int w, int h, int 
num_buff)
+Eina_Bool
+_evas_shm_surface_create(Surface *s, int w, int h, int num_buff)
 {
-   Surface *s;
    Shm_Surface *surf;
    int i = 0;
 
    LOGFN(__FILE__, __LINE__, __FUNCTION__);
 
-   if (!(s = calloc(1, sizeof(Surface)))) return NULL;
-   if (!(s->surf.shm = calloc(1, sizeof(Shm_Surface)))) goto err;
-   s->type = SURFACE_SHM;
+   if (!(s->surf.shm = calloc(1, sizeof(Shm_Surface)))) return EINA_FALSE;
    surf = s->surf.shm;
 
    surf->w = w;
    surf->h = h;
-   surf->disp = info->info.wl_disp;
-   surf->shm = info->info.wl_shm;
-   surf->surface = info->info.wl_surface;
+   surf->disp = s->info->info.wl_disp;
+   surf->shm = s->info->info.wl_shm;
+   surf->surface = s->info->info.wl_surface;
    surf->num_buff = num_buff;
-   surf->alpha = info->info.destination_alpha;
-   surf->compositor_version = info->info.compositor_version;
+   surf->alpha = s->info->info.destination_alpha;
+   surf->compositor_version = s->info->info.compositor_version;
 
    /* create surface buffers */
    for (; i < surf->num_buff; i++)
@@ -601,15 +597,16 @@ _evas_shm_surface_create(Evas_Engine_Info_Wayland_Shm 
*info, int w, int h, int n
           }
      }
 
+   s->type = SURFACE_SHM;
    s->funcs.destroy = _evas_shm_surface_destroy;
    s->funcs.reconfigure = _evas_shm_surface_reconfigure;
    s->funcs.data_get = _evas_shm_surface_data_get;
    s->funcs.assign = _evas_shm_surface_assign;
    s->funcs.post = _evas_shm_surface_post;
 
-   return s;
+   return EINA_TRUE;
 
 err:
    _evas_shm_surface_destroy(s);
-   return NULL;
+   return EINA_FALSE;
 }

-- 


Reply via email to