summaryrefslogtreecommitdiff
path: root/src/lib/ecore_wl2/ecore_wl2_surface.c
diff options
context:
space:
mode:
authorDerek Foreman <derekf@osg.samsung.com>2018-01-26 13:00:35 -0600
committerDerek Foreman <derekf@osg.samsung.com>2018-01-26 15:54:00 -0600
commit03671c9c2009e9cda7f750d28417e2c8e1f78fa8 (patch)
tree291eb34f931e60ac40d526e537a1b5a556050451 /src/lib/ecore_wl2/ecore_wl2_surface.c
parent83f8db157e1b47fc3398ccd6f51c421762f9c227 (diff)
ecore_wl2: Add a way to register new surface managers
And use it for the existing dmabuf surface manager.
Diffstat (limited to 'src/lib/ecore_wl2/ecore_wl2_surface.c')
-rw-r--r--src/lib/ecore_wl2/ecore_wl2_surface.c46
1 files changed, 41 insertions, 5 deletions
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 @@
10#include "linux-dmabuf-unstable-v1-client-protocol.h" 10#include "linux-dmabuf-unstable-v1-client-protocol.h"
11 11
12#define MAX_BUFFERS 4 12#define MAX_BUFFERS 4
13
14static Eina_List *_smanagers = NULL;
15static int _smanager_count = 0;
16
17int ECORE_WL2_SURFACE_DMABUF = 0;
18
13typedef struct _Ecore_Wl2_Dmabuf_Private 19typedef struct _Ecore_Wl2_Dmabuf_Private
14{ 20{
15 Ecore_Wl2_Buffer *current; 21 Ecore_Wl2_Buffer *current;
@@ -244,6 +250,7 @@ ecore_wl2_surface_flush(Ecore_Wl2_Surface *surface)
244 250
245static Ecore_Wl2_Surface_Interface dmabuf_smanager = 251static Ecore_Wl2_Surface_Interface dmabuf_smanager =
246{ 252{
253 .version = 1,
247 .setup = _evas_dmabuf_surface_setup, 254 .setup = _evas_dmabuf_surface_setup,
248 .destroy = _evas_dmabuf_surface_destroy, 255 .destroy = _evas_dmabuf_surface_destroy,
249 .reconfigure = _evas_dmabuf_surface_reconfigure, 256 .reconfigure = _evas_dmabuf_surface_reconfigure,
@@ -257,8 +264,11 @@ EAPI Ecore_Wl2_Surface *
257ecore_wl2_surface_create(Ecore_Wl2_Window *win, Eina_Bool alpha) 264ecore_wl2_surface_create(Ecore_Wl2_Window *win, Eina_Bool alpha)
258{ 265{
259 Ecore_Wl2_Surface *out; 266 Ecore_Wl2_Surface *out;
267 Eina_List *l;
268 Ecore_Wl2_Surface_Interface *intf;
260 269
261 EINA_SAFETY_ON_NULL_RETURN_VAL(win, NULL); 270 EINA_SAFETY_ON_NULL_RETURN_VAL(win, NULL);
271 EINA_SAFETY_ON_NULL_RETURN_VAL(_smanagers, NULL);
262 272
263 if (win->wl2_surface) return win->wl2_surface; 273 if (win->wl2_surface) return win->wl2_surface;
264 274
@@ -269,13 +279,16 @@ ecore_wl2_surface_create(Ecore_Wl2_Window *win, Eina_Bool alpha)
269 out->alpha = alpha; 279 out->alpha = alpha;
270 out->w = 0; 280 out->w = 0;
271 out->h = 0; 281 out->h = 0;
272 out->funcs = &dmabuf_smanager;
273 282
274 out->private_data = out->funcs->setup(win); 283 EINA_LIST_FOREACH(_smanagers, l, intf)
275 if (out->private_data)
276 { 284 {
277 win->wl2_surface = out; 285 out->private_data = intf->setup(win);
278 return out; 286 if (out->private_data)
287 {
288 out->funcs = intf;
289 win->wl2_surface = out;
290 return out;
291 }
279 } 292 }
280 293
281 free(out); 294 free(out);
@@ -294,3 +307,26 @@ ecore_wl2_surface_buffer_create(Ecore_Wl2_Surface *surface)
294 307
295 return ecore_wl2_buffer_create(ewd, surface->w, surface->h, surface->alpha); 308 return ecore_wl2_buffer_create(ewd, surface->w, surface->h, surface->alpha);
296} 309}
310
311EAPI int
312ecore_wl2_surface_manager_add(Ecore_Wl2_Surface_Interface *intf)
313{
314 if (intf->version < ECORE_WL2_SURFACE_INTERFACE_VERSION)
315 return 0;
316
317 _smanagers = eina_list_prepend(_smanagers, intf);
318 intf->id = ++_smanager_count;
319 return intf->id;
320}
321
322/* TEMPORARY HACK FOR TESTING */
323Eina_Bool
324ecore_wl2_surface_manager_dmabuf_add(void)
325{
326 ECORE_WL2_SURFACE_DMABUF = ecore_wl2_surface_manager_add(&dmabuf_smanager);
327
328 if (ECORE_WL2_SURFACE_DMABUF < 1)
329 return EINA_FALSE;
330
331 return EINA_TRUE;
332}