egl: only store device name when Wayland support is built
authorFrank Binns <frank.binns@imgtec.com>
Fri, 17 Jun 2016 17:41:22 +0000 (18:41 +0100)
committerEmil Velikov <emil.l.velikov@gmail.com>
Thu, 1 Sep 2016 14:47:58 +0000 (15:47 +0100)
The device name is only needed for WL_bind_wayland_display so make this clear
by only storing the device name when Wayland support is built.

Signed-off-by: Frank Binns <frank.binns@imgtec.com>
Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
src/egl/drivers/dri2/egl_dri2.c
src/egl/drivers/dri2/egl_dri2.h
src/egl/drivers/dri2/platform_drm.c
src/egl/drivers/dri2/platform_x11.c
src/egl/drivers/dri2/platform_x11_dri3.c

index 19f54dec660fbd9cc4771be16e78769a10a37934..859612f1b978bd638f1de7929b186d5c39833d59 100644 (file)
@@ -858,9 +858,12 @@ dri2_display_release(_EGLDisplay *disp) {
       close(dri2_dpy->fd);
    if (dri2_dpy->driver)
       dlclose(dri2_dpy->driver);
-   free(dri2_dpy->device_name);
    free(dri2_dpy->driver_name);
 
+#ifdef HAVE_WAYLAND_PLATFORM
+   free(dri2_dpy->device_name);
+#endif
+
    switch (disp->Platform) {
 #ifdef HAVE_X11_PLATFORM
    case _EGL_PLATFORM_X11:
index 7daec3ce5f4485b306c907a8847c40d550e6de8d..b1cbf944ddaebfde5c3825a120766cb529b95f9e 100644 (file)
@@ -194,7 +194,6 @@ struct dri2_egl_display
    struct gbm_dri_device    *gbm_dri;
 #endif
 
-   char                     *device_name;
    char                     *driver_name;
 
    __DRIdri2LoaderExtension    dri2_loader_extension;
@@ -221,6 +220,7 @@ struct dri2_egl_display
    int                      authenticated;
    int                      formats;
    uint32_t                  capabilities;
+   char                     *device_name;
 #endif
 
    int              is_render_node;
index 1ce282fcaa62871a6da017d439c1b8f8039cfb0d..e678db8991ed885d40cd141962e9fbfea07a957a 100644 (file)
@@ -639,7 +639,6 @@ dri2_initialize_drm(_EGLDriver *drv, _EGLDisplay *disp)
       goto cleanup;
 
    dri2_dpy->fd = fd;
-   dri2_dpy->device_name = loader_get_device_name_for_fd(dri2_dpy->fd);
    dri2_dpy->driver_name = strdup(dri2_dpy->gbm_dri->base.driver_name);
 
    dri2_dpy->dri_screen = dri2_dpy->gbm_dri->screen;
@@ -701,6 +700,8 @@ dri2_initialize_drm(_EGLDriver *drv, _EGLDisplay *disp)
 
 #ifdef HAVE_WAYLAND_PLATFORM
    if (dri2_dpy->image) {
+       dri2_dpy->device_name = loader_get_device_name_for_fd(dri2_dpy->fd);
+
        if (dri2_dpy->image->base.version >= 10 &&
            dri2_dpy->image->getCapabilities != NULL) {
            int capabilities;
index c8a9808a8113ab26e1b74b0b30347ddf5d05184b..179152f8157889c69f1d029d88d70550dcbf2a41 100644 (file)
@@ -665,23 +665,16 @@ dri2_x11_connect(struct dri2_egl_display *dri2_dpy)
 
    device_name = xcb_dri2_connect_device_name (connect);
 
-   dri2_dpy->device_name =
-      strndup(device_name,
-              xcb_dri2_connect_device_name_length(connect));
-
-   dri2_dpy->fd = loader_open_device(dri2_dpy->device_name);
+   dri2_dpy->fd = loader_open_device(device_name);
    if (dri2_dpy->fd == -1) {
       _eglLog(_EGL_WARNING,
-              "DRI2: could not open %s (%s)", dri2_dpy->device_name,
-              strerror(errno));
-      free(dri2_dpy->device_name);
+              "DRI2: could not open %s (%s)", device_name, strerror(errno));
       free(connect);
       return EGL_FALSE;
    }
 
    if (!dri2_x11_local_authenticate(dri2_dpy)) {
       close(dri2_dpy->fd);
-      free(dri2_dpy->device_name);
       free(connect);
       return EGL_FALSE;
    }
@@ -700,13 +693,19 @@ dri2_x11_connect(struct dri2_egl_display *dri2_dpy)
                  xcb_dri2_connect_driver_name_length(connect));
    }
 
-   if (dri2_dpy->device_name == NULL || dri2_dpy->driver_name == NULL) {
+   if (dri2_dpy->driver_name == NULL) {
       close(dri2_dpy->fd);
-      free(dri2_dpy->device_name);
       free(dri2_dpy->driver_name);
       free(connect);
       return EGL_FALSE;
    }
+
+#ifdef HAVE_WAYLAND_PLATFORM
+   dri2_dpy->device_name =
+      strndup(device_name,
+              xcb_dri2_connect_device_name_length(connect));
+#endif
+
    free(connect);
 
    return EGL_TRUE;
index f996750b588c4b28e1629374097fa4c982ce0597..31649fe849e3ad2753673df8a2cd603bca1ac307 100644 (file)
@@ -229,6 +229,7 @@ dri3_create_surface(_EGLDriver *drv, _EGLDisplay *disp, EGLint type,
 static int
 dri3_authenticate(_EGLDisplay *disp, uint32_t id)
 {
+#ifdef HAVE_WAYLAND_PLATFORM
    struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp);
 
    if (dri2_dpy->device_name) {
@@ -239,6 +240,7 @@ dri3_authenticate(_EGLDisplay *disp, uint32_t id)
 
    _eglLog(_EGL_WARNING,
            "Wayland client primary node authentication isn't supported");
+#endif
 
    return -1;
 }
@@ -533,11 +535,12 @@ dri3_x11_connect(struct dri2_egl_display *dri2_dpy)
       return EGL_FALSE;
    }
 
-   /* Only try to get a render device name since it's only needed for
-    * WL_bind_wayland_display and dri3 doesn't provide a mechanism for
-    * authenticating client opened device node fds. If this fails then
-    * don't advertise the extension. */
+#ifdef HAVE_WAYLAND_PLATFORM
+   /* Only try to get a render device name since dri3 doesn't provide a
+    * mechanism for authenticating client opened device node fds. If this
+    * fails then don't advertise the extension. */
    dri2_dpy->device_name = drmGetRenderDeviceNameFromFd(dri2_dpy->fd);
+#endif
 
    return EGL_TRUE;
 }