derekf pushed a commit to branch master. http://git.enlightenment.org/core/efl.git/commit/?id=03671c9c2009e9cda7f750d28417e2c8e1f78fa8
commit 03671c9c2009e9cda7f750d28417e2c8e1f78fa8 Author: Derek Foreman <[email protected]> Date: Fri Jan 26 13:00:35 2018 -0600 ecore_wl2: Add a way to register new surface managers And use it for the existing dmabuf surface manager. --- src/lib/ecore_wl2/Ecore_Wl2.h | 6 +++++ src/lib/ecore_wl2/ecore_wl2.c | 15 ++++++++++++ src/lib/ecore_wl2/ecore_wl2_private.h | 2 ++ src/lib/ecore_wl2/ecore_wl2_surface.c | 46 +++++++++++++++++++++++++++++++---- 4 files changed, 64 insertions(+), 5 deletions(-) diff --git a/src/lib/ecore_wl2/Ecore_Wl2.h b/src/lib/ecore_wl2/Ecore_Wl2.h index 464d6bc82d..50699bc211 100644 --- a/src/lib/ecore_wl2/Ecore_Wl2.h +++ b/src/lib/ecore_wl2/Ecore_Wl2.h @@ -30,6 +30,8 @@ # ifdef EFL_BETA_API_SUPPORT +#define ECORE_WL2_SURFACE_INTERFACE_VERSION 1 + typedef struct _Ecore_Wl2_Subsurface Ecore_Wl2_Subsurface; # ifndef _ECORE_WL2_WINDOW_PREDEF @@ -419,6 +421,9 @@ EAPI extern int ECORE_WL2_EVENT_WINDOW_ICONIFY_STATE_CHANGE; /** @since 1.21 */ typedef struct _Ecore_Wl2_Surface_Interface { + int id; + int version; + 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); @@ -2023,6 +2028,7 @@ EAPI void ecore_wl2_surface_post(Ecore_Wl2_Surface *surface, Eina_Rectangle *rec EAPI void ecore_wl2_surface_flush(Ecore_Wl2_Surface *surface); EAPI void ecore_wl2_window_surface_flush(Ecore_Wl2_Window *window); EAPI Ecore_Wl2_Buffer *ecore_wl2_surface_buffer_create(Ecore_Wl2_Surface *surface); +EAPI int ecore_wl2_surface_manager_add(Ecore_Wl2_Surface_Interface *intf); # endif diff --git a/src/lib/ecore_wl2/ecore_wl2.c b/src/lib/ecore_wl2/ecore_wl2.c index c309a92b37..7a1bbee649 100644 --- a/src/lib/ecore_wl2/ecore_wl2.c +++ b/src/lib/ecore_wl2/ecore_wl2.c @@ -57,6 +57,12 @@ EAPI int ECORE_WL2_EVENT_WINDOW_ICONIFY_STATE_CHANGE = 0; EAPI int _ecore_wl2_event_window_www = -1; EAPI int _ecore_wl2_event_window_www_drag = -1; +static Eina_Bool +_ecore_wl2_surface_modules_init(void) +{ + return ecore_wl2_surface_manager_dmabuf_add(); +} + /* public API functions */ EAPI int ecore_wl2_init(void) @@ -89,6 +95,12 @@ ecore_wl2_init(void) goto ecore_event_err; } + if (!_ecore_wl2_surface_modules_init()) + { + ERR("Could not load surface modules"); + goto module_load_err; + } + /* handle creating new Ecore_Wl2 event types */ ECORE_WL2_EVENT_CONNECT = ecore_event_type_new(); ECORE_WL2_EVENT_DISCONNECT = ecore_event_type_new(); @@ -139,6 +151,9 @@ ecore_wl2_init(void) return _ecore_wl2_init_count; +module_load_err: + ecore_event_shutdown(); + ecore_event_err: ecore_shutdown(); diff --git a/src/lib/ecore_wl2/ecore_wl2_private.h b/src/lib/ecore_wl2/ecore_wl2_private.h index 05d264b993..c321df1d30 100644 --- a/src/lib/ecore_wl2/ecore_wl2_private.h +++ b/src/lib/ecore_wl2/ecore_wl2_private.h @@ -606,4 +606,6 @@ EAPI void ecore_wl2_window_weight_set(Ecore_Wl2_Window *window, double w, double EAPI extern int _ecore_wl2_event_window_www; EAPI extern int _ecore_wl2_event_window_www_drag; +Eina_Bool ecore_wl2_surface_manager_dmabuf_add(void); + #endif diff --git a/src/lib/ecore_wl2/ecore_wl2_surface.c b/src/lib/ecore_wl2/ecore_wl2_surface.c index 746dee4758..afc4f5cd7a 100644 --- a/src/lib/ecore_wl2/ecore_wl2_surface.c +++ b/src/lib/ecore_wl2/ecore_wl2_surface.c @@ -10,6 +10,12 @@ #include "linux-dmabuf-unstable-v1-client-protocol.h" #define MAX_BUFFERS 4 + +static Eina_List *_smanagers = NULL; +static int _smanager_count = 0; + +int ECORE_WL2_SURFACE_DMABUF = 0; + typedef struct _Ecore_Wl2_Dmabuf_Private { Ecore_Wl2_Buffer *current; @@ -244,6 +250,7 @@ ecore_wl2_surface_flush(Ecore_Wl2_Surface *surface) static Ecore_Wl2_Surface_Interface dmabuf_smanager = { + .version = 1, .setup = _evas_dmabuf_surface_setup, .destroy = _evas_dmabuf_surface_destroy, .reconfigure = _evas_dmabuf_surface_reconfigure, @@ -257,8 +264,11 @@ EAPI Ecore_Wl2_Surface * ecore_wl2_surface_create(Ecore_Wl2_Window *win, Eina_Bool alpha) { Ecore_Wl2_Surface *out; + Eina_List *l; + Ecore_Wl2_Surface_Interface *intf; EINA_SAFETY_ON_NULL_RETURN_VAL(win, NULL); + EINA_SAFETY_ON_NULL_RETURN_VAL(_smanagers, NULL); if (win->wl2_surface) return win->wl2_surface; @@ -269,13 +279,16 @@ ecore_wl2_surface_create(Ecore_Wl2_Window *win, Eina_Bool alpha) out->alpha = alpha; out->w = 0; out->h = 0; - out->funcs = &dmabuf_smanager; - out->private_data = out->funcs->setup(win); - if (out->private_data) + EINA_LIST_FOREACH(_smanagers, l, intf) { - win->wl2_surface = out; - return out; + out->private_data = intf->setup(win); + if (out->private_data) + { + out->funcs = intf; + win->wl2_surface = out; + return out; + } } free(out); @@ -294,3 +307,26 @@ ecore_wl2_surface_buffer_create(Ecore_Wl2_Surface *surface) return ecore_wl2_buffer_create(ewd, surface->w, surface->h, surface->alpha); } + +EAPI int +ecore_wl2_surface_manager_add(Ecore_Wl2_Surface_Interface *intf) +{ + if (intf->version < ECORE_WL2_SURFACE_INTERFACE_VERSION) + return 0; + + _smanagers = eina_list_prepend(_smanagers, intf); + intf->id = ++_smanager_count; + return intf->id; +} + +/* TEMPORARY HACK FOR TESTING */ +Eina_Bool +ecore_wl2_surface_manager_dmabuf_add(void) +{ + ECORE_WL2_SURFACE_DMABUF = ecore_wl2_surface_manager_add(&dmabuf_smanager); + + if (ECORE_WL2_SURFACE_DMABUF < 1) + return EINA_FALSE; + + return EINA_TRUE; +} --
