[PATCH xserver 06/10] xwayland: Add Wayland interfaces check

Olivier Fourdan ofourdan at redhat.com
Tue Jun 5 17:38:41 UTC 2018


Introduces a new egl_backend function to let the EGL backend check for
the presence of the required Wayland interfaces.

Signed-off-by: Olivier Fourdan <ofourdan at redhat.com>
---
 hw/xwayland/xwayland-glamor-eglstream.c | 28 ++++++++++++++++++-------
 hw/xwayland/xwayland-glamor-gbm.c       | 14 +++++++++++++
 hw/xwayland/xwayland-glamor.c           | 11 ++++++++++
 hw/xwayland/xwayland.h                  |  7 +++++++
 4 files changed, 52 insertions(+), 8 deletions(-)

diff --git a/hw/xwayland/xwayland-glamor-eglstream.c b/hw/xwayland/xwayland-glamor-eglstream.c
index f3fd97e6e..bf74ae329 100644
--- a/hw/xwayland/xwayland-glamor-eglstream.c
+++ b/hw/xwayland/xwayland-glamor-eglstream.c
@@ -660,6 +660,25 @@ xwl_glamor_eglstream_init_wl_registry(struct xwl_screen *xwl_screen,
     }
 }
 
+static Bool
+xwl_glamor_eglstream_has_wl_interfaces(struct xwl_screen *xwl_screen)
+{
+    struct xwl_eglstream_private *xwl_eglstream =
+        xwl_eglstream_get(xwl_screen);
+
+    if (xwl_eglstream->display == NULL) {
+        ErrorF("glamor: 'wl_eglstream_display' not supported\n");
+        return FALSE;
+    }
+
+    if (xwl_eglstream->controller == NULL) {
+        ErrorF("glamor: 'wl_eglstream_controller' not supported\n");
+        return FALSE;
+    }
+
+    return TRUE;
+}
+
 static inline void
 xwl_eglstream_init_shaders(struct xwl_screen *xwl_screen)
 {
@@ -819,14 +838,6 @@ xwl_glamor_eglstream_init_screen(struct xwl_screen *xwl_screen)
         xwl_eglstream_get(xwl_screen);
     ScreenPtr screen = xwl_screen->screen;
 
-    if (!xwl_eglstream->controller) {
-        ErrorF("No eglstream controller was exposed in the wayland registry. "
-               "This means your version of nvidia's EGL wayland libraries "
-               "are too old, as we require support for this.\n");
-        xwl_eglstream_cleanup(xwl_screen);
-        return FALSE;
-    }
-
     /* We can just let glamor handle CreatePixmap */
     screen->DestroyPixmap = xwl_glamor_eglstream_destroy_pixmap;
 
@@ -898,6 +909,7 @@ xwl_glamor_init_eglstream(struct xwl_screen *xwl_screen)
 
     xwl_screen->egl_backend.init_egl = xwl_glamor_eglstream_init_egl;
     xwl_screen->egl_backend.init_wl_registry = xwl_glamor_eglstream_init_wl_registry;
+    xwl_screen->egl_backend.has_wl_interfaces = xwl_glamor_eglstream_has_wl_interfaces;
     xwl_screen->egl_backend.init_screen = xwl_glamor_eglstream_init_screen;
     xwl_screen->egl_backend.get_wl_buffer_for_pixmap = xwl_glamor_eglstream_get_wl_buffer_for_pixmap;
     xwl_screen->egl_backend.post_damage = xwl_glamor_eglstream_post_damage;
diff --git a/hw/xwayland/xwayland-glamor-gbm.c b/hw/xwayland/xwayland-glamor-gbm.c
index b03e7ee17..33a576da2 100644
--- a/hw/xwayland/xwayland-glamor-gbm.c
+++ b/hw/xwayland/xwayland-glamor-gbm.c
@@ -746,6 +746,19 @@ xwl_glamor_gbm_init_wl_registry(struct xwl_screen *xwl_screen,
         xwl_screen_set_dmabuf_interface(xwl_screen, id, version);
 }
 
+static Bool
+xwl_glamor_gbm_has_wl_interfaces(struct xwl_screen *xwl_screen)
+{
+    struct xwl_gbm_private *xwl_gbm = xwl_gbm_get(xwl_screen);
+
+    if (xwl_gbm->drm == NULL) {
+        ErrorF("glamor: 'wl_drm' not supported\n");
+        return FALSE;
+    }
+
+    return TRUE;
+}
+
 static Bool
 xwl_glamor_gbm_init_egl(struct xwl_screen *xwl_screen)
 {
@@ -887,6 +900,7 @@ xwl_glamor_init_gbm(struct xwl_screen *xwl_screen)
                   xwl_gbm);
 
     xwl_screen->egl_backend.init_wl_registry = xwl_glamor_gbm_init_wl_registry;
+    xwl_screen->egl_backend.has_wl_interfaces = xwl_glamor_gbm_has_wl_interfaces;
     xwl_screen->egl_backend.init_egl = xwl_glamor_gbm_init_egl;
     xwl_screen->egl_backend.init_screen = xwl_glamor_gbm_init_screen;
     xwl_screen->egl_backend.get_wl_buffer_for_pixmap = xwl_glamor_gbm_get_wl_buffer_for_pixmap;
diff --git a/hw/xwayland/xwayland-glamor.c b/hw/xwayland/xwayland-glamor.c
index 14706f6e8..72995de00 100644
--- a/hw/xwayland/xwayland-glamor.c
+++ b/hw/xwayland/xwayland-glamor.c
@@ -76,6 +76,17 @@ xwl_glamor_init_wl_registry(struct xwl_screen *xwl_screen,
                                                  id, interface, version);
 }
 
+Bool
+xwl_glamor_has_wl_interfaces(struct xwl_screen *xwl_screen,
+                            struct xwl_egl_backend *xwl_egl_backend)
+{
+    if (xwl_egl_backend->has_wl_interfaces)
+        return xwl_egl_backend->has_wl_interfaces(xwl_screen);
+
+    /* If the backend has no requirement wrt WL interfaces, we're fine */
+    return TRUE;
+}
+
 struct wl_buffer *
 xwl_glamor_pixmap_get_wl_buffer(PixmapPtr pixmap,
                                 unsigned short width,
diff --git a/hw/xwayland/xwayland.h b/hw/xwayland/xwayland.h
index 6bbe72e46..191f1b297 100644
--- a/hw/xwayland/xwayland.h
+++ b/hw/xwayland/xwayland.h
@@ -69,6 +69,11 @@ struct xwl_egl_backend {
                              uint32_t id, const char *name,
                              uint32_t version);
 
+    /* Check that the required Wayland interfaces are available. This
+     * callback is optional.
+     */
+    Bool (*has_wl_interfaces)(struct xwl_screen *xwl_screen);
+
     /* Called before glamor has been initialized. Backends should setup a
      * valid, glamor compatible EGL context in this hook.
      */
@@ -432,6 +437,8 @@ void xwl_glamor_init_wl_registry(struct xwl_screen *xwl_screen,
                                  struct wl_registry *registry,
                                  uint32_t id, const char *interface,
                                  uint32_t version);
+Bool xwl_glamor_has_wl_interfaces(struct xwl_screen *xwl_screen,
+                                 struct xwl_egl_backend *xwl_egl_backend);
 void xwl_glamor_post_damage(struct xwl_window *xwl_window,
                             PixmapPtr pixmap, RegionPtr region);
 Bool xwl_glamor_allow_commits(struct xwl_window *xwl_window);
-- 
2.17.1



More information about the xorg-devel mailing list