[Mesa-dev] [PATCH v2 30/30] egl/dri2: set WL_bind_wayland_display in a consistent way
Emil Velikov
emil.l.velikov at gmail.com
Fri Sep 16 17:02:11 UTC 2016
From: Emil Velikov <emil.velikov at collabora.com>
Introduce a helper and use it throughout the platform code. This allows
us to reduce the amount of ifdef(s) and (potentially) use
kms_swrast_dri.so for !drm platforms (namely wayland and x11).
Note: in the future as other platforms (android, surfaceless) support
the extension they can reuse the helper.
v2: Rebase, check for device_name.
Signed-off-by: Emil Velikov <emil.velikov at collabora.com>
---
src/egl/drivers/dri2/egl_dri2.h | 24 ++++++++++++++++++++++++
src/egl/drivers/dri2/platform_drm.c | 16 ++--------------
src/egl/drivers/dri2/platform_wayland.c | 2 +-
src/egl/drivers/dri2/platform_x11.c | 9 ++-------
4 files changed, 29 insertions(+), 22 deletions(-)
diff --git a/src/egl/drivers/dri2/egl_dri2.h b/src/egl/drivers/dri2/egl_dri2.h
index fb170a5..bf18646 100644
--- a/src/egl/drivers/dri2/egl_dri2.h
+++ b/src/egl/drivers/dri2/egl_dri2.h
@@ -397,4 +397,28 @@ const __DRIconfig *
dri2_get_dri_config(struct dri2_egl_config *conf, EGLint surface_type,
EGLenum colorspace);
+static inline void
+dri2_set_WL_bind_wayland_display(_EGLDriver *drv, _EGLDisplay *disp)
+{
+#ifdef HAVE_WAYLAND_PLATFORM
+ struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp);
+
+ (void) drv;
+
+ if (dri2_dpy->device_name && dri2_dpy->image) {
+ if (dri2_dpy->image->base.version >= 10 &&
+ dri2_dpy->image->getCapabilities != NULL) {
+ int capabilities;
+
+ capabilities =
+ dri2_dpy->image->getCapabilities(dri2_dpy->dri_screen);
+ disp->Extensions.WL_bind_wayland_display =
+ (capabilities & __DRI_IMAGE_CAP_GLOBAL_NAMES) != 0;
+ } else {
+ disp->Extensions.WL_bind_wayland_display = EGL_TRUE;
+ }
+ }
+#endif
+}
+
#endif /* EGL_DRI2_INCLUDED */
diff --git a/src/egl/drivers/dri2/platform_drm.c b/src/egl/drivers/dri2/platform_drm.c
index 2668dff..bb1515f 100644
--- a/src/egl/drivers/dri2/platform_drm.c
+++ b/src/egl/drivers/dri2/platform_drm.c
@@ -697,21 +697,9 @@ dri2_initialize_drm(_EGLDriver *drv, _EGLDisplay *disp)
disp->Extensions.EXT_buffer_age = EGL_TRUE;
#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;
-
- capabilities =
- dri2_dpy->image->getCapabilities(dri2_dpy->dri_screen);
- disp->Extensions.WL_bind_wayland_display =
- (capabilities & __DRI_IMAGE_CAP_GLOBAL_NAMES) != 0;
- } else
- disp->Extensions.WL_bind_wayland_display = EGL_TRUE;
- }
+ dri2_dpy->device_name = loader_get_device_name_for_fd(dri2_dpy->fd);
#endif
+ dri2_set_WL_bind_wayland_display(drv, disp);
/* Fill vtbl last to prevent accidentally calling virtual function during
* initialization.
diff --git a/src/egl/drivers/dri2/platform_wayland.c b/src/egl/drivers/dri2/platform_wayland.c
index 005d2f3..63edf2e 100644
--- a/src/egl/drivers/dri2/platform_wayland.c
+++ b/src/egl/drivers/dri2/platform_wayland.c
@@ -1206,7 +1206,7 @@ dri2_initialize_wayland_drm(_EGLDriver *drv, _EGLDisplay *disp)
dri2_add_config(disp, config, i + 1, types, NULL, rgb565_masks);
}
- disp->Extensions.WL_bind_wayland_display = EGL_TRUE;
+ dri2_set_WL_bind_wayland_display(drv, disp);
/* When cannot convert EGLImage to wl_buffer when on a different gpu,
* because the buffer of the EGLImage has likely a tiling mode the server
* gpu won't support. These is no way to check for now. Thus do not support the
diff --git a/src/egl/drivers/dri2/platform_x11.c b/src/egl/drivers/dri2/platform_x11.c
index c27f289..0b1b514 100644
--- a/src/egl/drivers/dri2/platform_x11.c
+++ b/src/egl/drivers/dri2/platform_x11.c
@@ -1339,10 +1339,7 @@ dri2_initialize_x11_dri3(_EGLDriver *drv, _EGLDisplay *disp)
disp->Extensions.CHROMIUM_sync_control = EGL_TRUE;
disp->Extensions.EXT_buffer_age = EGL_TRUE;
-#ifdef HAVE_WAYLAND_PLATFORM
- if (dri2_dpy->device_name)
- disp->Extensions.WL_bind_wayland_display = EGL_TRUE;
-#endif
+ dri2_set_WL_bind_wayland_display(drv, disp);
if (!dri2_x11_add_configs_for_visuals(dri2_dpy, disp, false))
goto cleanup_configs;
@@ -1458,9 +1455,7 @@ dri2_initialize_x11_dri2(_EGLDriver *drv, _EGLDisplay *disp)
disp->Extensions.NV_post_sub_buffer = EGL_TRUE;
disp->Extensions.CHROMIUM_sync_control = EGL_TRUE;
-#ifdef HAVE_WAYLAND_PLATFORM
- disp->Extensions.WL_bind_wayland_display = EGL_TRUE;
-#endif
+ dri2_set_WL_bind_wayland_display(drv, disp);
if (!dri2_x11_add_configs_for_visuals(dri2_dpy, disp, true))
goto cleanup_configs;
--
2.9.3
More information about the mesa-dev
mailing list