diff options
author | Gregory Hainaut <[email protected]> | 2017-05-29 13:18:27 +0200 |
---|---|---|
committer | Emil Velikov <[email protected]> | 2017-05-29 17:06:57 +0100 |
commit | 3fde8db53a6296ad8f635843f58717ebd9a36e85 (patch) | |
tree | ddd7bfcc4f3353ffe2d8ac6c0532904ae01df882 /src/egl | |
parent | 63b78c939bcca5a0ec29259e312b986604d617f3 (diff) |
egl: implement __DRIbackgroundCallableExtension.isThreadSafe
v2:
bump version
v3:
Add code comment
s/IsGlThread/IsThread/ (and variation)
Include X11/Xlibint.h protected by ifdef
v5: based on Daniel feedback
Move non X11 code outside of X11 define
Always return true for Wayland
Signed-off-by: Gregory Hainaut <[email protected]>
Reviewed-by: Emil Velikov <[email protected]>
Diffstat (limited to 'src/egl')
-rw-r--r-- | src/egl/drivers/dri2/egl_dri2.c | 34 |
1 files changed, 33 insertions, 1 deletions
diff --git a/src/egl/drivers/dri2/egl_dri2.c b/src/egl/drivers/dri2/egl_dri2.c index 787c377c12e..80d366d244a 100644 --- a/src/egl/drivers/dri2/egl_dri2.c +++ b/src/egl/drivers/dri2/egl_dri2.c @@ -55,6 +55,10 @@ #include "wayland-drm-client-protocol.h" #endif +#ifdef HAVE_X11_PLATFORM +#include "X11/Xlibint.h" +#endif + #include "egl_dri2.h" #include "loader/loader.h" #include "util/u_atomic.h" @@ -92,10 +96,38 @@ dri_set_background_context(void *loaderPrivate) _eglBindContextToThread(ctx, t); } +static GLboolean +dri_is_thread_safe(void *loaderPrivate) +{ + struct dri2_egl_surface *dri2_surf = loaderPrivate; + _EGLDisplay *display = dri2_surf->base.Resource.Display; + +#ifdef HAVE_X11_PLATFORM + Display *xdpy = (Display*)display->PlatformDisplay; + + /* Check Xlib is running in thread safe mode when running on EGL/X11-xlib + * platform + * + * 'lock_fns' is the XLockDisplay function pointer of the X11 display 'dpy'. + * It wll be NULL if XInitThreads wasn't called. + */ + if (display->Platform == _EGL_PLATFORM_X11 && xdpy && !xdpy->lock_fns) + return false; +#endif + +#ifdef HAVE_WAYLAND_PLATFORM + if (display->Platform == _EGL_PLATFORM_WAYLAND) + return true; +#endif + + return true; +} + const __DRIbackgroundCallableExtension background_callable_extension = { - .base = { __DRI_BACKGROUND_CALLABLE, 1 }, + .base = { __DRI_BACKGROUND_CALLABLE, 2 }, .setBackgroundContext = dri_set_background_context, + .isThreadSafe = dri_is_thread_safe, }; const __DRIuseInvalidateExtension use_invalidate = { |