Merge "Fix EGLConfigSelection for IVI on Genx." into tizen
authorRusty Lynch <rusty.lynch@intel.com>
Thu, 20 Jun 2013 01:15:31 +0000 (18:15 -0700)
committerGerrit Code Review <gerrit@review.vlan103.tizen.org>
Thu, 20 Jun 2013 01:15:31 +0000 (18:15 -0700)
Source/WebCore/platform/graphics/surfaces/egl/EGLConfigSelector.cpp

index 5429b11..8dcfe7e 100644 (file)
@@ -26,7 +26,7 @@
 #include "config.h"
 #include "EGLConfigSelector.h"
 
-#if USE(EGL)
+#if USE(EGL) || ENABLE(TIZEN_CANVAS_GRAPHICS_SURFACE)
 
 #include "EGLHelper.h"
 
@@ -96,7 +96,6 @@ EGLConfig EGLConfigSelector::createConfig(EGLint expectedSurfaceType)
         return 0;
 
     EGLint numConfigs;
-
     eglGetConfigs(m_sharedDisplay, 0, 0, &numConfigs);
 
     if (!numConfigs) {
@@ -132,6 +131,19 @@ EGLConfig EGLConfigSelector::createConfig(EGLint expectedSurfaceType)
     static bool isVendorMesa = EGLHelper::isVendor("mesa");
     static bool isVendorArm = EGLHelper::isVendor("arm");
 
+    if (isVendorMesa) {
+        // Force depth if stencil is true or depth if stencil is true.
+        if ((m_attributes & GLPlatformSurface::SupportStencil) || (m_attributes & GLPlatformSurface::SupportDepth)) {
+            m_attributes &= GLPlatformSurface::SupportStencil;
+            m_attributes &= GLPlatformSurface::SupportDepth;
+        }
+
+        expectedDepthSize = m_attributes & GLPlatformSurface::SupportDepth ? 24 : 0;
+        expectedStencilSize = m_attributes & GLPlatformSurface::SupportStencil ? 8 : 0;
+        // Doesn't support EGLConfig with no alpha.
+        expectedAlpha = 8;
+    }
+
     if (!expectedAlpha && isVendorImagination)
         expectedConfigAttribute = EGL_NON_CONFORMANT_CONFIG;
 
@@ -145,59 +157,74 @@ EGLConfig EGLConfigSelector::createConfig(EGLint expectedSurfaceType)
     for (int i = 0; i < numConfigs; i++) {
         EGLConfig tempConfig = configs[i];
         eglGetConfigAttrib(m_sharedDisplay, tempConfig, EGL_RENDERABLE_TYPE, &renderType);
-
         if (!(renderType & expectedRenderType))
             continue;
 
         if (expectedConfigAttribute != EGL_NONE) {
             eglGetConfigAttrib(m_sharedDisplay, tempConfig, EGL_CONFIG_CAVEAT, &configAttribute);
 
-            if (expectedConfigAttribute != configAttribute)
+            if (expectedConfigAttribute != configAttribute) {
+                LOG_ERROR("Expected config attribute didnt match. Checking next EGLConfig.");
                 continue;
+            }
         }
 
         if (expectedMatchFormat != EGL_NONE) {
             eglGetConfigAttrib(m_sharedDisplay, tempConfig, EGL_MATCH_FORMAT_KHR, &matchFormat);
 
-            if (expectedMatchFormat != matchFormat)
+            if (expectedMatchFormat != matchFormat) {
+                LOG_ERROR("ExpectedMatchFormat didnt match. Checking next EGLConfig.");
                 continue;
+            }
         }
 
         eglGetConfigAttrib(m_sharedDisplay, tempConfig, EGL_ALPHA_SIZE, &alpha);
 
-        if (alpha != expectedAlpha)
+        if (alpha != expectedAlpha) {
+            LOG_ERROR("Failed to match %s Attribute Value. Retrieved %d, Expected: %d. Checking next EGLConfig.", "alpha", alpha, expectedAlpha);
             continue;
+        }
 
         eglGetConfigAttrib(m_sharedDisplay, tempConfig, EGL_RED_SIZE, &red);
 
-        if (red != expectedRed)
+        if (red != expectedRed) {
+            LOG_ERROR("Failed to match %s Attribute Value. Retrieved %d, Expected: %d. Checking next EGLConfig.", "red", red, expectedRed);
             continue;
+        }
 
         eglGetConfigAttrib(m_sharedDisplay, tempConfig, EGL_GREEN_SIZE, &green);
 
-        if (green != expectedGreen)
+        if (green != expectedGreen) {
+            LOG_ERROR("Failed to match %s Attribute Value. Retrieved %d, Expected: %d. Checking next EGLConfig.", "Green", green, expectedGreen);
             continue;
+        }
 
         eglGetConfigAttrib(m_sharedDisplay, tempConfig, EGL_BLUE_SIZE, &blue);
 
-        if (blue != expectedBlue)
+        if (blue != expectedBlue) {
+            LOG_ERROR("Failed to match %s Attribute Value. Retrieved %d, Expected: %d. Checking next EGLConfig.", "Blue", blue, expectedBlue);
             continue;
+        }
 
-        if (!isVendorMesa) {
-            eglGetConfigAttrib(m_sharedDisplay, tempConfig, EGL_STENCIL_SIZE, &stencil);
+        eglGetConfigAttrib(m_sharedDisplay, tempConfig, EGL_STENCIL_SIZE, &stencil);
 
-            if (stencil != expectedStencilSize)
-                continue;
+        if (stencil != expectedStencilSize) {
+            LOG_ERROR("Failed to match %s Attribute Value. Retrieved %d, Expected: %d. Checking next EGLConfig.", "Stencil", stencil, expectedStencilSize);
+            continue;
+        }
 
-            eglGetConfigAttrib(m_sharedDisplay, tempConfig, EGL_DEPTH_SIZE, &depth);
+        eglGetConfigAttrib(m_sharedDisplay, tempConfig, EGL_DEPTH_SIZE, &depth);
 
-            if (depth != expectedDepthSize)
-                continue;
+        if (depth != expectedDepthSize) {
+            LOG_ERROR("Failed to match %s Attribute Value. Retrieved %d, Expected: %d. Checking next EGLConfig.", "Depth", depth, expectedDepthSize);
+            continue;
+        }
 
-            eglGetConfigAttrib(m_sharedDisplay, tempConfig, EGL_SAMPLES, &samples);
+        eglGetConfigAttrib(m_sharedDisplay, tempConfig, EGL_SAMPLES, &samples);
 
-            if (samples != expectedSamples)
-                continue;
+        if (samples != expectedSamples) {
+            LOG_ERROR("Failed to match %s Attribute Value. Retrieved %d, Expected: %d. Checking next EGLConfig.", "Samples", samples, expectedSamples);
+            continue;
         }
 
         eglGetConfigAttrib(m_sharedDisplay, tempConfig, EGL_SURFACE_TYPE, &surface);