[Mesa-dev] [PATCH 3/3] egl: only store device name when Wayland support is built
Frank Binns
frank.binns at imgtec.com
Fri Jun 17 17:41:22 UTC 2016
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 at imgtec.com>
---
src/egl/drivers/dri2/egl_dri2.c | 5 ++++-
src/egl/drivers/dri2/egl_dri2.h | 2 +-
src/egl/drivers/dri2/platform_drm.c | 3 ++-
src/egl/drivers/dri2/platform_x11.c | 21 ++++++++++-----------
src/egl/drivers/dri2/platform_x11_dri3.c | 11 +++++++----
5 files changed, 24 insertions(+), 18 deletions(-)
diff --git a/src/egl/drivers/dri2/egl_dri2.c b/src/egl/drivers/dri2/egl_dri2.c
index bfde640..95703fb 100644
--- a/src/egl/drivers/dri2/egl_dri2.c
+++ b/src/egl/drivers/dri2/egl_dri2.c
@@ -823,9 +823,12 @@ dri2_terminate(_EGLDriver *drv, _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:
diff --git a/src/egl/drivers/dri2/egl_dri2.h b/src/egl/drivers/dri2/egl_dri2.h
index 925294b..54e58e1 100644
--- a/src/egl/drivers/dri2/egl_dri2.h
+++ b/src/egl/drivers/dri2/egl_dri2.h
@@ -187,7 +187,6 @@ struct dri2_egl_display
struct gbm_dri_device *gbm_dri;
#endif
- char *device_name;
char *driver_name;
__DRIdri2LoaderExtension dri2_loader_extension;
@@ -213,6 +212,7 @@ struct dri2_egl_display
int authenticated;
int formats;
uint32_t capabilities;
+ char *device_name;
#endif
int is_render_node;
diff --git a/src/egl/drivers/dri2/platform_drm.c b/src/egl/drivers/dri2/platform_drm.c
index 9373496..91dde72 100644
--- a/src/egl/drivers/dri2/platform_drm.c
+++ b/src/egl/drivers/dri2/platform_drm.c
@@ -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;
diff --git a/src/egl/drivers/dri2/platform_x11.c b/src/egl/drivers/dri2/platform_x11.c
index 1b50889..d7d6b8a 100644
--- a/src/egl/drivers/dri2/platform_x11.c
+++ b/src/egl/drivers/dri2/platform_x11.c
@@ -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;
diff --git a/src/egl/drivers/dri2/platform_x11_dri3.c b/src/egl/drivers/dri2/platform_x11_dri3.c
index f996750..31649fe 100644
--- a/src/egl/drivers/dri2/platform_x11_dri3.c
+++ b/src/egl/drivers/dri2/platform_x11_dri3.c
@@ -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;
}
--
2.7.4
More information about the mesa-dev
mailing list