egl/x11: Honor the EGL_PLATFORM_X11_SCREEN_EXT attribute
authorAdam Jackson <ajax@redhat.com>
Tue, 2 May 2017 16:27:01 +0000 (12:27 -0400)
committerAdam Jackson <ajax@redhat.com>
Thu, 4 May 2017 16:52:18 +0000 (12:52 -0400)
Introduce _egl_display::Options::Platforms for private storage.
For X11 platforms we can use it for the screen number as set by
EGL_PLATFORM_X11_SCREEN_EXT.

Reviewed-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
Signed-off-by: Adam Jackson <ajax@redhat.com>
src/egl/drivers/dri2/platform_x11.c
src/egl/main/egldisplay.c
src/egl/main/egldisplay.h

index 2f1086e28f0befb35edafa7d23f159b9347229e1..c78656a5be1d4ec6f3169015e299b06912d634ce 100644 (file)
@@ -1191,7 +1191,7 @@ dri2_get_xcb_connection(_EGLDriver *drv, _EGLDisplay *disp,
                         struct dri2_egl_display *dri2_dpy)
 {
    xcb_screen_iterator_t s;
-   int screen = 0;
+   int screen = (uintptr_t)disp->Options.Platform;
    const char *msg;
 
    disp->DriverData = (void *) dri2_dpy;
index 37711bd8695ea744dd18d66053e89d1946a57d0e..b047a5de4295e57ec9469a2e9c5a2b62d62513e7 100644 (file)
@@ -472,7 +472,7 @@ _eglUnlinkResource(_EGLResource *res, _EGLResourceType type)
 
 #ifdef HAVE_X11_PLATFORM
 static EGLBoolean
-_eglParseX11DisplayAttribList(const EGLint *attrib_list)
+_eglParseX11DisplayAttribList(_EGLDisplay *display, const EGLint *attrib_list)
 {
    int i;
 
@@ -486,11 +486,10 @@ _eglParseX11DisplayAttribList(const EGLint *attrib_list)
 
       /* EGL_EXT_platform_x11 recognizes exactly one attribute,
        * EGL_PLATFORM_X11_SCREEN_EXT, which is optional.
-       * 
-       * Mesa supports connecting to only the default screen, so we reject
-       * screen != 0.
        */
-      if (attrib != EGL_PLATFORM_X11_SCREEN_EXT || value != 0) {
+      if (attrib == EGL_PLATFORM_X11_SCREEN_EXT) {
+         display->Options.Platform = (void *)value;
+      } else {
          _eglError(EGL_BAD_ATTRIBUTE, "eglGetPlatformDisplay");
          return EGL_FALSE;
       }
@@ -503,11 +502,17 @@ _EGLDisplay*
 _eglGetX11Display(Display *native_display,
                   const EGLint *attrib_list)
 {
-   if (!_eglParseX11DisplayAttribList(attrib_list)) {
+   _EGLDisplay *display = _eglFindDisplay(_EGL_PLATFORM_X11,
+                                          native_display);
+
+   if (!display)
+      _eglError(EGL_BAD_ALLOC, "eglGetPlatformDisplay");
+
+   if (!_eglParseX11DisplayAttribList(display, attrib_list)) {
       return NULL;
    }
 
-   return _eglFindDisplay(_EGL_PLATFORM_X11, native_display);
+   return display;
 }
 #endif /* HAVE_X11_PLATFORM */
 
index 6c1049d23c3b00e582471f86f9853a5df86aeb4e..4d3d96e17492ecf0c14508f3be1c4623a1c9cf90 100644 (file)
@@ -151,6 +151,7 @@ struct _egl_display
    struct {
       EGLBoolean TestOnly;    /**< Driver should not set fields when true */
       EGLBoolean UseFallback; /**< Use fallback driver (sw or less features) */
+      void *Platform;         /**< Platform-specific options */
    } Options;
 
    /* these fields are set by the driver during init */