From bf4b828cb6537c5e0cb9287669877f6ff2344fb6 Mon Sep 17 00:00:00 2001 From: Derek Foreman Date: Thu, 25 Jan 2018 14:28:23 -0600 Subject: [PATCH] ecore_wl2: Move dmabuf surface specific tests into their own function Refactoring to allow non-dmabuf surface managers. --- src/lib/ecore_wl2/ecore_wl2_surface.c | 30 +++++++++++++++++---------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/src/lib/ecore_wl2/ecore_wl2_surface.c b/src/lib/ecore_wl2/ecore_wl2_surface.c index cd810d21b5..de10b8ad5f 100644 --- a/src/lib/ecore_wl2/ecore_wl2_surface.c +++ b/src/lib/ecore_wl2/ecore_wl2_surface.c @@ -11,6 +11,24 @@ #define MAX_BUFFERS 4 +static Eina_Bool +_evas_dmabuf_surface_check(Ecore_Wl2_Window *win) +{ + Ecore_Wl2_Display *ewd; + Ecore_Wl2_Buffer_Type types = 0; + + ewd = ecore_wl2_window_display_get(win); + if (ecore_wl2_display_shm_get(ewd)) + types |= ECORE_WL2_BUFFER_SHM; + if (ecore_wl2_display_dmabuf_get(ewd)) + types |= ECORE_WL2_BUFFER_DMABUF; + + if (!ecore_wl2_buffer_init(ewd, types)) + return EINA_FALSE; + + return EINA_TRUE; +} + static void _evas_dmabuf_surface_reconfigure(Ecore_Wl2_Surface *s, int w, int h, uint32_t flags EINA_UNUSED, Eina_Bool force) { @@ -215,8 +233,6 @@ EAPI Ecore_Wl2_Surface * ecore_wl2_surface_create(Ecore_Wl2_Window *win, Eina_Bool alpha) { Ecore_Wl2_Surface *out; - Ecore_Wl2_Display *ewd; - Ecore_Wl2_Buffer_Type types = 0; EINA_SAFETY_ON_NULL_RETURN_VAL(win, NULL); @@ -225,19 +241,11 @@ ecore_wl2_surface_create(Ecore_Wl2_Window *win, Eina_Bool alpha) out = calloc(1, sizeof(*out)); if (!out) return NULL; out->wl2_win = win; - - ewd = ecore_wl2_window_display_get(win); - if (ecore_wl2_display_shm_get(ewd)) - types |= ECORE_WL2_BUFFER_SHM; - if (ecore_wl2_display_dmabuf_get(ewd)) - types |= ECORE_WL2_BUFFER_DMABUF; - out->alpha = alpha; out->w = 0; out->h = 0; - /* create surface buffers */ - if (!ecore_wl2_buffer_init(ewd, types)) goto err; + if (!_evas_dmabuf_surface_check(win)) goto err; out->funcs.destroy = _evas_dmabuf_surface_destroy; out->funcs.reconfigure = _evas_dmabuf_surface_reconfigure;