egl: only store device name when Wayland support is built

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>
This commit is contained in:
Frank Binns 2016-06-17 18:41:22 +01:00 committed by Emil Velikov
parent 2dc6930a5a
commit d6f669ba83
5 changed files with 24 additions and 18 deletions

View 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:

View 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;

View 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;

View 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;

View 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;
}