derekf pushed a commit to branch master.

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

commit 07c41f48c4152f13129000dc9ac3b715bf258dfa
Author: Derek Foreman <[email protected]>
Date:   Fri Jan 26 12:26:40 2018 -0600

    ecore_wl2: Move private data allocation into back-end code
    
    The backend should allocate its own private data and return it instead
    of a bool.
    
    This assumes all back-ends will need some manner of private data, which
    is certanly true for the one back-end we provide.
---
 src/lib/ecore_wl2/Ecore_Wl2.h         |  2 +-
 src/lib/ecore_wl2/ecore_wl2_surface.c | 23 +++++++++++++++--------
 2 files changed, 16 insertions(+), 9 deletions(-)

diff --git a/src/lib/ecore_wl2/Ecore_Wl2.h b/src/lib/ecore_wl2/Ecore_Wl2.h
index 98854b1f7c..464d6bc82d 100644
--- a/src/lib/ecore_wl2/Ecore_Wl2.h
+++ b/src/lib/ecore_wl2/Ecore_Wl2.h
@@ -419,7 +419,7 @@ EAPI extern int 
ECORE_WL2_EVENT_WINDOW_ICONIFY_STATE_CHANGE; /** @since 1.21 */
 
 typedef struct _Ecore_Wl2_Surface_Interface
 {
-   Eina_Bool (*check)(Ecore_Wl2_Window *win);
+   void *(*setup)(Ecore_Wl2_Window *win);
    void (*destroy)(Ecore_Wl2_Surface *surface, void *priv_data);
    void (*reconfigure)(Ecore_Wl2_Surface *surface, void *priv_data, int w, int 
h, uint32_t flags);
    void *(*data_get)(Ecore_Wl2_Surface *surface, void *priv_data, int *w, int 
*h);
diff --git a/src/lib/ecore_wl2/ecore_wl2_surface.c 
b/src/lib/ecore_wl2/ecore_wl2_surface.c
index bfabd9172d..bb05a8190a 100644
--- a/src/lib/ecore_wl2/ecore_wl2_surface.c
+++ b/src/lib/ecore_wl2/ecore_wl2_surface.c
@@ -16,12 +16,16 @@ typedef struct _Ecore_Wl2_Dmabuf_Private
    Eina_List *buffers;
 } Ecore_Wl2_Dmabuf_Private;
 
-static Eina_Bool
-_evas_dmabuf_surface_check(Ecore_Wl2_Window *win)
+static void *
+_evas_dmabuf_surface_setup(Ecore_Wl2_Window *win)
 {
+   Ecore_Wl2_Dmabuf_Private *priv;
    Ecore_Wl2_Display *ewd;
    Ecore_Wl2_Buffer_Type types = 0;
 
+   priv = calloc(1, sizeof(*priv));
+   if (!priv) return NULL;
+
    ewd = ecore_wl2_window_display_get(win);
    if (ecore_wl2_display_shm_get(ewd))
      types |= ECORE_WL2_BUFFER_SHM;
@@ -29,9 +33,12 @@ _evas_dmabuf_surface_check(Ecore_Wl2_Window *win)
      types |= ECORE_WL2_BUFFER_DMABUF;
 
    if (!ecore_wl2_buffer_init(ewd, types))
-     return EINA_FALSE;
+     {
+        free(priv);
+        return NULL;
+     }
 
-   return EINA_TRUE;
+   return priv;
 }
 
 static void
@@ -237,7 +244,7 @@ ecore_wl2_surface_flush(Ecore_Wl2_Surface *surface)
 
 static Ecore_Wl2_Surface_Interface dmabuf_smanager =
 {
-   .check = _evas_dmabuf_surface_check,
+   .setup = _evas_dmabuf_surface_setup,
    .destroy = _evas_dmabuf_surface_destroy,
    .reconfigure = _evas_dmabuf_surface_reconfigure,
    .data_get = _evas_dmabuf_surface_data_get,
@@ -257,15 +264,15 @@ ecore_wl2_surface_create(Ecore_Wl2_Window *win, Eina_Bool 
alpha)
 
    out = calloc(1, sizeof(*out));
    if (!out) return NULL;
-   out->private_data = calloc(1, sizeof(Ecore_Wl2_Dmabuf_Private));
-   if (!out->private_data) return NULL;
+
    out->wl2_win = win;
    out->alpha = alpha;
    out->w = 0;
    out->h = 0;
    out->funcs = &dmabuf_smanager;
 
-   if (out->funcs->check(win))
+   out->private_data = out->funcs->setup(win);
+   if (out->private_data)
      {
         win->wl2_surface = out;
         return out;

-- 


Reply via email to