egl: Surface type validaction should depend on extensions supported.
[mesa.git] / src / egl / main / eglconfig.c
index 31d69a770808e2463f87908c117a6fd3335630c3..635ffee92b2dead2b4c8c0b3dafae4cb85300b0a 100644 (file)
@@ -4,13 +4,11 @@
 
 
 #include <stdlib.h>
-#include <stdio.h>
 #include <string.h>
 #include <assert.h>
 #include "eglconfig.h"
 #include "egldisplay.h"
-#include "egldriver.h"
-#include "eglglobals.h"
+#include "eglcurrent.h"
 #include "egllog.h"
 
 
  * IDs are from 1 to N respectively.
  */
 void
-_eglInitConfig(_EGLConfig *config, EGLint id)
+_eglInitConfig(_EGLConfig *config, _EGLDisplay *dpy, EGLint id)
 {
    memset(config, 0, sizeof(*config));
 
+   config->Display = dpy;
+
    /* some attributes take non-zero default values */
    SET_CONFIG_ATTRIB(config, EGL_CONFIG_ID,               id);
    SET_CONFIG_ATTRIB(config, EGL_CONFIG_CAVEAT,           EGL_NONE);
@@ -224,7 +224,8 @@ static const struct {
    { EGL_MATCH_NATIVE_PIXMAP,       ATTRIB_TYPE_PSEUDO,
                                     ATTRIB_CRITERION_SPECIAL,
                                     EGL_NONE },
-   { EGL_PRESERVED_RESOURCES,       ATTRIB_TYPE_PSEUDO,
+   /* there is a gap before EGL_SAMPLES */
+   { 0x3030,                        ATTRIB_TYPE_PSEUDO,
                                     ATTRIB_CRITERION_IGNORE,
                                     0 },
    { EGL_NONE,                      ATTRIB_TYPE_PSEUDO,
@@ -328,6 +329,8 @@ _eglValidateConfig(const _EGLConfig *conf, EGLBoolean for_matching)
                    EGL_VG_ALPHA_FORMAT_PRE_BIT |
                    EGL_MULTISAMPLE_RESOLVE_BOX_BIT |
                    EGL_SWAP_BEHAVIOR_PRESERVED_BIT;
+            if (conf->Display->Extensions.MESA_screen_surface)
+               mask |= EGL_SCREEN_BIT_MESA;
             break;
          case EGL_RENDERABLE_TYPE:
          case EGL_CONFORMANT:
@@ -730,7 +733,7 @@ _eglChooseConfig(_EGLDriver *drv, _EGLDisplay *disp, const EGLint *attrib_list,
    if (!num_configs)
       return _eglError(EGL_BAD_PARAMETER, "eglChooseConfigs");
 
-   _eglInitConfig(&criteria, 0);
+   _eglInitConfig(&criteria, disp, 0);
    if (!_eglParseConfigAttribList(&criteria, attrib_list))
       return _eglError(EGL_BAD_ATTRIBUTE, "eglChooseConfig");
 
@@ -772,7 +775,7 @@ _eglIsConfigAttribValid(_EGLConfig *conf, EGLint attr)
 
    /* there are some holes in the range */
    switch (attr) {
-   case EGL_PRESERVED_RESOURCES:
+   case 0x3030 /* a gap before EGL_SAMPLES */:
    case EGL_NONE:
 #ifdef EGL_VERSION_1_4
    case EGL_MATCH_NATIVE_PIXMAP: