discomfitor pushed a commit to branch master.

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

commit cd124f938f4ac9c23687d51a017d616f53468b76
Author: Derek Foreman <der...@osg.samsung.com>
Date:   Fri Apr 8 15:11:21 2016 -0500

    wayland_shm: Make new Surface abstraction to wrap Shm_Surface
    
    Wraps the Shm_Surface allocator in a new Surface type that will
    potentially use different allocators, such as dmabuf in a future commit.
---
 src/modules/evas/engines/wayland_shm/evas_engine.h | 28 ++++++++++++----
 src/modules/evas/engines/wayland_shm/evas_shm.c    | 37 +++++++++++++++-------
 2 files changed, 47 insertions(+), 18 deletions(-)

diff --git a/src/modules/evas/engines/wayland_shm/evas_engine.h 
b/src/modules/evas/engines/wayland_shm/evas_engine.h
index 880b878..3e2e59a 100644
--- a/src/modules/evas/engines/wayland_shm/evas_engine.h
+++ b/src/modules/evas/engines/wayland_shm/evas_engine.h
@@ -73,6 +73,20 @@ extern int _evas_engine_way_shm_log_dom;
 
 typedef struct _Shm_Surface Shm_Surface;
 
+typedef enum _Surface_Type Surface_Type;
+enum _Surface_Type {
+   SURFACE_SHM
+};
+
+typedef struct _Surface Surface;
+struct _Surface
+{
+   Surface_Type type;
+   union {
+      Shm_Surface *shm;
+   } surf;
+};
+
 struct _Outbuf
 {
    int w, h;
@@ -83,7 +97,7 @@ struct _Outbuf
 
    Evas_Engine_Info_Wayland_Shm *info;
 
-   Shm_Surface *surface;
+   Surface *surface;
 
    struct 
      {
@@ -102,12 +116,12 @@ struct _Outbuf
      } priv;
 };
 
-Shm_Surface *_evas_shm_surface_create(struct wl_display *disp, struct wl_shm 
*shm, struct wl_surface *surface, int w, int h, int num_buff, Eina_Bool alpha, 
int compositor_version);
-void _evas_shm_surface_destroy(Shm_Surface *surface);
-void _evas_shm_surface_reconfigure(Shm_Surface *surface, int dx, int dy, int 
w, int h, int num_buff, uint32_t flags);
-void *_evas_shm_surface_data_get(Shm_Surface *surface, int *w, int *h);
-int _evas_shm_surface_assign(Shm_Surface *surface);
-void _evas_shm_surface_post(Shm_Surface *surface, Eina_Rectangle *rects, 
unsigned int count);
+Surface *_evas_shm_surface_create(struct wl_display *disp, struct wl_shm *shm, 
struct wl_surface *surface, int w, int h, int num_buff, Eina_Bool alpha, int 
compositor_version);
+void _evas_shm_surface_destroy(Surface *surface);
+void _evas_shm_surface_reconfigure(Surface *surface, int dx, int dy, int w, 
int h, int num_buff, uint32_t flags);
+void *_evas_shm_surface_data_get(Surface *surface, int *w, int *h);
+int _evas_shm_surface_assign(Surface *surface);
+void _evas_shm_surface_post(Surface *surface, Eina_Rectangle *rects, unsigned 
int count);
 
 Outbuf *_evas_outbuf_setup(int w, int h, int rot, Outbuf_Depth depth, 
Eina_Bool alpha, struct wl_shm *shm, struct wl_surface *surface, struct 
wl_display *disp, int compositor_version);
 void _evas_outbuf_free(Outbuf *ob);
diff --git a/src/modules/evas/engines/wayland_shm/evas_shm.c 
b/src/modules/evas/engines/wayland_shm/evas_shm.c
index 69e776f..22a2778 100644
--- a/src/modules/evas/engines/wayland_shm/evas_shm.c
+++ b/src/modules/evas/engines/wayland_shm/evas_shm.c
@@ -395,15 +395,19 @@ _shm_leaf_destroy(Shm_Leaf *leaf)
    leaf->resize_pool = NULL;
 }
 
-Shm_Surface *
+Surface *
 _evas_shm_surface_create(struct wl_display *disp, struct wl_shm *shm, struct 
wl_surface *surface, int w, int h, int num_buff, Eina_Bool alpha, int 
compositor_version)
 {
+   Surface *s;
    Shm_Surface *surf;
    int i = 0;
 
    LOGFN(__FILE__, __LINE__, __FUNCTION__);
 
-   if (!(surf = calloc(1, sizeof(Shm_Surface)))) return NULL;
+   if (!(s = calloc(1, sizeof(Surface)))) return NULL;
+   if (!(s->surf.shm = calloc(1, sizeof(Shm_Surface)))) goto err;
+   s->type = SURFACE_SHM;
+   surf = s->surf.shm;
 
    surf->dx = 0;
    surf->dy = 0;
@@ -426,33 +430,38 @@ _evas_shm_surface_create(struct wl_display *disp, struct 
wl_shm *shm, struct wl_
           }
      }
 
-   return surf;
+   return s;
 
 err:
-   _evas_shm_surface_destroy(surf);
+   _evas_shm_surface_destroy(s);
    return NULL;
 }
 
 void 
-_evas_shm_surface_destroy(Shm_Surface *surface)
+_evas_shm_surface_destroy(Surface *surface)
 {
    int i = 0;
 
    LOGFN(__FILE__, __LINE__, __FUNCTION__);
 
-   for (; i < surface->num_buff; i++)
-     _shm_leaf_destroy(&surface->leaf[i]);
+   if (!surface) return;
+
+   for (; i < surface->surf.shm->num_buff; i++)
+     _shm_leaf_destroy(&surface->surf.shm->leaf[i]);
 
+   free(surface->surf.shm);
    free(surface);
 }
 
 void 
-_evas_shm_surface_reconfigure(Shm_Surface *surface, int dx, int dy, int w, int 
h, int num_buff, uint32_t flags)
+_evas_shm_surface_reconfigure(Surface *s, int dx, int dy, int w, int h, int 
num_buff, uint32_t flags)
 {
+   Shm_Surface *surface;
    int i = 0, resize = 0;
 
    LOGFN(__FILE__, __LINE__, __FUNCTION__);
 
+   surface = s->surf.shm;
    resize = !!flags;
 
    for (; i < surface->num_buff; i++)
@@ -511,10 +520,12 @@ _evas_shm_surface_wait(Shm_Surface *surface)
 }
 
 int
-_evas_shm_surface_assign(Shm_Surface *surface)
+_evas_shm_surface_assign(Surface *s)
 {
    int i;
+   Shm_Surface *surface;
 
+   surface = s->surf.shm;
    surface->current = _evas_shm_surface_wait(surface);
 
    /* If we ran out of buffers we're in trouble, reset all ages */
@@ -550,10 +561,12 @@ _evas_shm_surface_assign(Shm_Surface *surface)
 }
 
 void *
-_evas_shm_surface_data_get(Shm_Surface *surface, int *w, int *h)
+_evas_shm_surface_data_get(Surface *s, int *w, int *h)
 {
+   Shm_Surface *surface;
    LOGFN(__FILE__, __LINE__, __FUNCTION__);
 
+   surface = s->surf.shm;
    if (w) *w = 0;
    if (h) *h = 0;
 
@@ -572,13 +585,15 @@ _evas_shm_surface_data_get(Shm_Surface *surface, int *w, 
int *h)
 }
 
 void
-_evas_shm_surface_post(Shm_Surface *surface, Eina_Rectangle *rects, unsigned 
int count)
+_evas_shm_surface_post(Surface *s, Eina_Rectangle *rects, unsigned int count)
 {
    /* struct wl_callback *frame_cb; */
+   Shm_Surface *surface;
    Shm_Leaf *leaf;
 
    LOGFN(__FILE__, __LINE__, __FUNCTION__);
 
+   surface = s->surf.shm;
    leaf = surface->current;
    if (!leaf) return;
 

-- 


Reply via email to