ecore_wl2: Filter buffer types by compositor capabilities
authorDerek Foreman <derekf@osg.samsung.com>
Tue, 14 Nov 2017 21:45:39 +0000 (15:45 -0600)
committerDerek Foreman <derekf@osg.samsung.com>
Wed, 15 Nov 2017 17:54:37 +0000 (11:54 -0600)
It does us no good to be able to allocate dmabuf capable memory if the
compositor can't handle it.  This should fix failures on systems where
allocation is possible but the compositor doesn't advertise dmabuf.

src/lib/ecore_wl2/Ecore_Wl2.h
src/lib/ecore_wl2/ecore_wl2_buffer.c
src/modules/evas/engines/wayland_shm/evas_dmabuf.c

index f4c1c81..1f58cd4 100644 (file)
@@ -2006,7 +2006,7 @@ EAPI void ecore_wl2_window_update_begin(Ecore_Wl2_Window *window);
 
 EAPI void ecore_wl2_window_damage(Ecore_Wl2_Window *window, Eina_Rectangle *rects, unsigned int count);
 
-EAPI Eina_Bool ecore_wl2_buffer_init(Ecore_Wl2_Buffer_Type types);
+EAPI Eina_Bool ecore_wl2_buffer_init(Ecore_Wl2_Display *ewd, Ecore_Wl2_Buffer_Type types);
 EAPI Ecore_Wl2_Buffer *ecore_wl2_buffer_create(Ecore_Wl2_Display *ewd, int w, int h, Eina_Bool alpha);
 EAPI void ecore_wl2_buffer_destroy(Ecore_Wl2_Buffer *b);
 EAPI struct wl_buffer *ecore_wl2_buffer_wl_buffer_get(Ecore_Wl2_Display *ewd, Ecore_Wl2_Buffer *buf);
index 32e779e..6fd7252 100644 (file)
@@ -398,11 +398,11 @@ _wl_shm_buffer_manager_setup(int fd EINA_UNUSED)
 }
 
 EAPI Eina_Bool
-ecore_wl2_buffer_init(Ecore_Wl2_Buffer_Type types)
+ecore_wl2_buffer_init(Ecore_Wl2_Display *ewd, Ecore_Wl2_Buffer_Type types)
 {
    int fd;
-   Eina_Bool dmabuf = types & ECORE_WL2_BUFFER_DMABUF;
-   Eina_Bool shm = types & ECORE_WL2_BUFFER_SHM;
+   Eina_Bool dmabuf = ewd->wl.dmabuf && (types & ECORE_WL2_BUFFER_DMABUF);
+   Eina_Bool shm = ewd->wl.shm && (types & ECORE_WL2_BUFFER_SHM);
    Eina_Bool success = EINA_FALSE;
 
    if (buffer_manager)
index b54424b..b137c27 100644 (file)
@@ -171,13 +171,15 @@ _evas_dmabuf_surface_destroy(Surface *s)
 Eina_Bool
 _evas_dmabuf_surface_create(Surface *s, int w, int h, int num_buff)
 {
+   Ecore_Wl2_Display *ewd;
    Ecore_Wl2_Buffer_Type types = 0;
    Dmabuf_Surface *surf = NULL;
    int i = 0;
 
-   if (ecore_wl2_display_shm_get(s->info->info.wl2_display))
+   ewd = s->info->info.wl2_display;
+   if (ecore_wl2_display_shm_get(ewd))
      types |= ECORE_WL2_BUFFER_SHM;
-   if (ecore_wl2_display_dmabuf_get(s->info->info.wl2_display))
+   if (ecore_wl2_display_dmabuf_get(ewd))
      types |= ECORE_WL2_BUFFER_DMABUF;
 
    if (!(s->surf.dmabuf = calloc(1, sizeof(Dmabuf_Surface)))) return EINA_FALSE;
@@ -191,7 +193,7 @@ _evas_dmabuf_surface_create(Surface *s, int w, int h, int num_buff)
    surf->buffer = calloc(surf->nbuf, sizeof(Ecore_Wl2_Buffer *));
    if (!surf->buffer) goto err;
 
-   if (!ecore_wl2_buffer_init(types)) goto err;
+   if (!ecore_wl2_buffer_init(ewd, types)) goto err;
 
    if (w && h)
      {