Title: [242875] releases/WebKitGTK/webkit-2.24/Source/WebCore
Revision
242875
Author
[email protected]
Date
2019-03-13 02:25:35 -0700 (Wed, 13 Mar 2019)

Log Message

Merge r242640 - GLContextEGL: desired EGL config should search for 8-bit components by default
https://bugs.webkit.org/show_bug.cgi?id=195413

Reviewed by Carlos Garcia Campos.

The EGL config search in GLContextEGL should by default look for
RGBA8888 configurations while allowing RGB565 as an alternative.
This prevents from accidentally landing on an RGBA1010102
configuration that is available with some graphics stacks, and which is
not expected in e.g. window snapshotting that's done for layout test
output comparison.

* platform/graphics/egl/GLContextEGL.cpp:
(WebCore::GLContextEGL::getEGLConfig): EGL config search should by
default request 8-bit color channels.

Modified Paths

Diff

Modified: releases/WebKitGTK/webkit-2.24/Source/WebCore/ChangeLog (242874 => 242875)


--- releases/WebKitGTK/webkit-2.24/Source/WebCore/ChangeLog	2019-03-13 09:25:31 UTC (rev 242874)
+++ releases/WebKitGTK/webkit-2.24/Source/WebCore/ChangeLog	2019-03-13 09:25:35 UTC (rev 242875)
@@ -1,3 +1,21 @@
+2019-03-08  Zan Dobersek  <[email protected]>
+
+        GLContextEGL: desired EGL config should search for 8-bit components by default
+        https://bugs.webkit.org/show_bug.cgi?id=195413
+
+        Reviewed by Carlos Garcia Campos.
+
+        The EGL config search in GLContextEGL should by default look for
+        RGBA8888 configurations while allowing RGB565 as an alternative.
+        This prevents from accidentally landing on an RGBA1010102
+        configuration that is available with some graphics stacks, and which is
+        not expected in e.g. window snapshotting that's done for layout test
+        output comparison.
+
+        * platform/graphics/egl/GLContextEGL.cpp:
+        (WebCore::GLContextEGL::getEGLConfig): EGL config search should by
+        default request 8-bit color channels.
+
 2019-03-13  Miguel Gomez  <[email protected]>
 
         [CoordinatedGraphics] Null dereference in CoordinatedGraphicsLayer::setCoordinatorIncludingSubLayersIfNeeded

Modified: releases/WebKitGTK/webkit-2.24/Source/WebCore/platform/graphics/egl/GLContextEGL.cpp (242874 => 242875)


--- releases/WebKitGTK/webkit-2.24/Source/WebCore/platform/graphics/egl/GLContextEGL.cpp	2019-03-13 09:25:31 UTC (rev 242874)
+++ releases/WebKitGTK/webkit-2.24/Source/WebCore/platform/graphics/egl/GLContextEGL.cpp	2019-03-13 09:25:35 UTC (rev 242875)
@@ -96,6 +96,14 @@
 
 bool GLContextEGL::getEGLConfig(EGLDisplay display, EGLConfig* config, EGLSurfaceType surfaceType)
 {
+    std::array<EGLint, 4> rgbaSize = { 8, 8, 8, 8 };
+    if (const char* environmentVariable = getenv("WEBKIT_EGL_PIXEL_LAYOUT")) {
+        if (!strcmp(environmentVariable, "RGB565"))
+            rgbaSize = { 5, 6, 5, 0 };
+        else
+            WTFLogAlways("Unknown pixel layout %s, falling back to RGBA8888", environmentVariable);
+    }
+
     EGLint attributeList[] = {
 #if USE(OPENGL_ES)
         EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,
@@ -102,31 +110,15 @@
 #else
         EGL_RENDERABLE_TYPE, EGL_OPENGL_BIT,
 #endif
-        EGL_RED_SIZE, 1,
-        EGL_GREEN_SIZE, 1,
-        EGL_BLUE_SIZE, 1,
-        EGL_ALPHA_SIZE, 1,
+        EGL_RED_SIZE, rgbaSize[0],
+        EGL_GREEN_SIZE, rgbaSize[1],
+        EGL_BLUE_SIZE, rgbaSize[2],
+        EGL_ALPHA_SIZE, rgbaSize[3],
         EGL_STENCIL_SIZE, 8,
         EGL_SURFACE_TYPE, EGL_NONE,
         EGL_NONE
     };
 
-    bool isRGB565 = false;
-    if (const char* environmentVariable = getenv("WEBKIT_EGL_PIXEL_LAYOUT")) {
-        if (!strcmp(environmentVariable, "RGB565")) {
-            isRGB565 = true;
-            // EGL_RED_SIZE
-            attributeList[3] = 5;
-            // EGL_GREEN_SIZE
-            attributeList[5] = 6;
-            // EGL_BLUE_SIZE
-            attributeList[7] = 5;
-            // EGL_ALPHA_SIZE
-            attributeList[9] = 0;
-        } else
-            WTFLogAlways("Unknown pixel layout %s, falling back to RGBA8888", environmentVariable);
-    }
-
     switch (surfaceType) {
     case GLContextEGL::PbufferSurface:
         attributeList[13] = EGL_PBUFFER_BIT;
@@ -146,12 +138,9 @@
 
     EGLint numberConfigsReturned;
     Vector<EGLConfig> configs(count);
-    if (!eglChooseConfig(display, attributeList, isRGB565 ? reinterpret_cast<EGLConfig*>(configs.data()) : config, isRGB565 ? count : 1, &numberConfigsReturned) || !numberConfigsReturned)
+    if (!eglChooseConfig(display, attributeList, reinterpret_cast<EGLConfig*>(configs.data()), count, &numberConfigsReturned) || !numberConfigsReturned)
         return false;
 
-    if (!isRGB565)
-        return true;
-
     auto index = configs.findMatching([&](EGLConfig value) {
         EGLint redSize, greenSize, blueSize, alphaSize;
         eglGetConfigAttrib(display, value, EGL_RED_SIZE, &redSize);
@@ -158,7 +147,8 @@
         eglGetConfigAttrib(display, value, EGL_GREEN_SIZE, &greenSize);
         eglGetConfigAttrib(display, value, EGL_BLUE_SIZE, &blueSize);
         eglGetConfigAttrib(display, value, EGL_ALPHA_SIZE, &alphaSize);
-        return (redSize == 5 && greenSize == 6 && blueSize == 5 && !alphaSize);
+        return redSize == rgbaSize[0] && greenSize == rgbaSize[1]
+            && blueSize == rgbaSize[2] && alphaSize == rgbaSize[3];
     });
 
     if (index != notFound) {
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to