Fix EGLConfigSelection for IVI on Genx. 56/4056/1
authorKondapally Kalyan <kalyan.kondapally@intel.com>
Tue, 18 Jun 2013 15:59:51 +0000 (18:59 +0300)
committerKondapally Kalyan <kalyan.kondapally@intel.com>
Tue, 18 Jun 2013 15:59:51 +0000 (18:59 +0300)
Currently, In some cases we request for depth
with no stencil support or vice versa. This causes a conflict
during config selection with mesa. On current hardware we don't
support configurations without alpha support. These patch fixes
these issues when vendor is Mesa. These changes don't effect other
profiles. Added Tizen specific pre-processor macro till the changes
end up in upstream webkit.

Change-Id: I10fe3e92de45cb195f6b9e44f096f16c2fe83d78

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);