Merge branch 'mesa_7_6_branch'
[mesa.git] / src / egl / main / eglconfigutil.c
index 7061df691b2ee3197cf06072a97474b88ee52317..36e94f0d2de841203db50eccb0e7951209594793 100644 (file)
@@ -52,6 +52,83 @@ _eglConfigToContextModesRec(const _EGLConfig *config, __GLcontextModes *mode)
 }
 
 
+/**
+ * Convert a __GLcontextModes object to an _EGLConfig.
+ */
+EGLBoolean
+_eglConfigFromContextModesRec(_EGLConfig *conf, const __GLcontextModes *m,
+                              EGLint conformant, EGLint renderable_type)
+{
+   EGLint config_caveat, surface_type;
+
+   /* must be RGBA */
+   if (!m->rgbMode || !(m->renderType & GLX_RGBA_BIT))
+      return EGL_FALSE;
+
+   config_caveat = EGL_NONE;
+   if (m->visualRating == GLX_SLOW_CONFIG)
+      config_caveat = EGL_SLOW_CONFIG;
+
+   if (m->visualRating == GLX_NON_CONFORMANT_CONFIG)
+      conformant &= ~EGL_OPENGL_BIT;
+   if (!(conformant & EGL_OPENGL_ES_BIT))
+      config_caveat = EGL_NON_CONFORMANT_CONFIG;
+
+   surface_type = 0;
+   if (m->drawableType & GLX_WINDOW_BIT)
+      surface_type |= EGL_WINDOW_BIT;
+   if (m->drawableType & GLX_PIXMAP_BIT)
+      surface_type |= EGL_PIXMAP_BIT;
+   if (m->drawableType & GLX_PBUFFER_BIT)
+      surface_type |= EGL_PBUFFER_BIT;
+
+   SET_CONFIG_ATTRIB(conf, EGL_BUFFER_SIZE, m->rgbBits);
+   SET_CONFIG_ATTRIB(conf, EGL_RED_SIZE, m->redBits);
+   SET_CONFIG_ATTRIB(conf, EGL_GREEN_SIZE, m->greenBits);
+   SET_CONFIG_ATTRIB(conf, EGL_BLUE_SIZE, m->blueBits);
+   SET_CONFIG_ATTRIB(conf, EGL_ALPHA_SIZE, m->alphaBits);
+
+   SET_CONFIG_ATTRIB(conf, EGL_BIND_TO_TEXTURE_RGB, m->bindToTextureRgb);
+   SET_CONFIG_ATTRIB(conf, EGL_BIND_TO_TEXTURE_RGBA, m->bindToTextureRgba);
+   SET_CONFIG_ATTRIB(conf, EGL_COLOR_BUFFER_TYPE, EGL_RGB_BUFFER);
+   SET_CONFIG_ATTRIB(conf, EGL_CONFIG_CAVEAT, config_caveat);
+
+   SET_CONFIG_ATTRIB(conf, EGL_CONFORMANT, conformant);
+   SET_CONFIG_ATTRIB(conf, EGL_DEPTH_SIZE, m->depthBits);
+   SET_CONFIG_ATTRIB(conf, EGL_LEVEL, m->level);
+   SET_CONFIG_ATTRIB(conf, EGL_MAX_PBUFFER_WIDTH, m->maxPbufferWidth);
+   SET_CONFIG_ATTRIB(conf, EGL_MAX_PBUFFER_HEIGHT, m->maxPbufferHeight);
+   SET_CONFIG_ATTRIB(conf, EGL_MAX_PBUFFER_PIXELS, m->maxPbufferPixels);
+
+   SET_CONFIG_ATTRIB(conf, EGL_NATIVE_RENDERABLE, m->xRenderable);
+   SET_CONFIG_ATTRIB(conf, EGL_NATIVE_VISUAL_ID, m->visualID);
+
+   if (m->visualType != GLX_NONE)
+      SET_CONFIG_ATTRIB(conf, EGL_NATIVE_VISUAL_TYPE, m->visualType);
+   else
+      SET_CONFIG_ATTRIB(conf, EGL_NATIVE_VISUAL_TYPE, EGL_NONE);
+
+   SET_CONFIG_ATTRIB(conf, EGL_RENDERABLE_TYPE, renderable_type);
+   SET_CONFIG_ATTRIB(conf, EGL_SAMPLE_BUFFERS, m->sampleBuffers);
+   SET_CONFIG_ATTRIB(conf, EGL_SAMPLES, m->samples);
+   SET_CONFIG_ATTRIB(conf, EGL_STENCIL_SIZE, m->stencilBits);
+
+   SET_CONFIG_ATTRIB(conf, EGL_SURFACE_TYPE, surface_type);
+
+   /* what to do with GLX_TRANSPARENT_INDEX? */
+   if (m->transparentPixel == GLX_TRANSPARENT_RGB) {
+      SET_CONFIG_ATTRIB(conf, EGL_TRANSPARENT_TYPE, EGL_TRANSPARENT_RGB);
+      SET_CONFIG_ATTRIB(conf, EGL_TRANSPARENT_RED_VALUE, m->transparentRed);
+      SET_CONFIG_ATTRIB(conf, EGL_TRANSPARENT_GREEN_VALUE, m->transparentGreen);
+      SET_CONFIG_ATTRIB(conf, EGL_TRANSPARENT_BLUE_VALUE, m->transparentBlue);
+   }
+   else {
+      SET_CONFIG_ATTRIB(conf, EGL_TRANSPARENT_TYPE, EGL_NONE);
+   }
+
+   return EGL_TRUE;
+}
+
 
 /**
  * Creates a set of \c _EGLConfigs that a driver will expose.
@@ -156,6 +233,7 @@ _eglFillInConfigs(_EGLConfig * configs,
             {0x000000FF, 0x0000FF00, 0x00FF0000, 0xFF000000},  /* 8_8_8_8_REV */
          };
 
+#if 0
    static const uint32_t masks_table_bgr[8][4] = {
             {0x00000000, 0x00000000, 0x00000000, 0x00000000},
             {0x00000000, 0x00000000, 0x00000000, 0x00000000},
@@ -177,6 +255,7 @@ _eglFillInConfigs(_EGLConfig * configs,
             {0x00000000, 0x00000000, 0x00000000, 0x00000000},
             {0x00FF0000, 0x0000FF00, 0x000000FF, 0xFF000000},  /* 8_8_8_8_REV */
          };
+#endif
 
    static const uint8_t bytes_per_pixel[8] = {
             0, 0, 0, 2, 2, 4, 0, 4
@@ -192,8 +271,8 @@ _eglFillInConfigs(_EGLConfig * configs,
 
    if ( bytes_per_pixel[index] == 0 ) {
       _eglLog(_EGL_INFO,
-              "[%s:%u] Framebuffer type 0x%04x has 0 bytes per pixel.",
-              __FUNCTION__, __LINE__, fb_type);
+              "[_eglFillInConfigs:%u] Framebuffer type 0x%04x has 0 bytes per pixel.",
+              __LINE__, fb_type);
       return GL_FALSE;
    }
 
@@ -227,8 +306,8 @@ _eglFillInConfigs(_EGLConfig * configs,
 
    default:
       _eglLog(_EGL_WARNING,
-              "[%s:%u] Framebuffer format 0x%04x is not GL_RGB, GL_RGBA, GL_BGR, or GL_BGRA.",
-              __FUNCTION__, __LINE__, fb_format);
+              "[_eglFillInConfigs:%u] Framebuffer format 0x%04x is not GL_RGB, GL_RGBA, GL_BGR, or GL_BGRA.",
+              __LINE__, fb_format);
       return GL_FALSE;
    }