Title: [228664] releases/WebKitGTK/webkit-2.20/Source/WebKit
Revision
228664
Author
carlo...@webkit.org
Date
2018-02-19 05:16:58 -0800 (Mon, 19 Feb 2018)

Log Message

Merge r228272 - [GTK] WaylandCompositor misusing eglGetProcAddress
https://bugs.webkit.org/show_bug.cgi?id=182490

Reviewed by Michael Catanzaro.

Check that the appropriate extensions are available before calling eglGetProcAddress, as even
getting a non null value from it, the functionality can be disabled at runtime.

* UIProcess/gtk/WaylandCompositor.cpp:
(WebKit::WaylandCompositor::initializeEGL):

Modified Paths

Diff

Modified: releases/WebKitGTK/webkit-2.20/Source/WebKit/ChangeLog (228663 => 228664)


--- releases/WebKitGTK/webkit-2.20/Source/WebKit/ChangeLog	2018-02-19 13:16:52 UTC (rev 228663)
+++ releases/WebKitGTK/webkit-2.20/Source/WebKit/ChangeLog	2018-02-19 13:16:58 UTC (rev 228664)
@@ -1,3 +1,16 @@
+2018-02-08  Miguel Gomez  <mago...@igalia.com>
+
+        [GTK] WaylandCompositor misusing eglGetProcAddress
+        https://bugs.webkit.org/show_bug.cgi?id=182490
+
+        Reviewed by Michael Catanzaro.
+
+        Check that the appropriate extensions are available before calling eglGetProcAddress, as even
+        getting a non null value from it, the functionality can be disabled at runtime.
+
+        * UIProcess/gtk/WaylandCompositor.cpp:
+        (WebKit::WaylandCompositor::initializeEGL):
+
 2018-02-07  Antti Koivisto  <an...@apple.com> and Youenn Fablet  <you...@apple.com>
 
         REGRESSION(r227758): Webpage fails to load due to crash in com.apple.WebKit: WebKit::WebFrameLoaderClient::dispatchDecidePolicyForResponse + 267

Modified: releases/WebKitGTK/webkit-2.20/Source/WebKit/UIProcess/gtk/WaylandCompositor.cpp (228663 => 228664)


--- releases/WebKitGTK/webkit-2.20/Source/WebKit/UIProcess/gtk/WaylandCompositor.cpp	2018-02-19 13:16:52 UTC (rev 228663)
+++ releases/WebKitGTK/webkit-2.20/Source/WebKit/UIProcess/gtk/WaylandCompositor.cpp	2018-02-19 13:16:58 UTC (rev 228664)
@@ -40,7 +40,9 @@
 #if USE(OPENGL_ES_2)
 #include <GLES2/gl2.h>
 #include <GLES2/gl2ext.h>
+#include <WebCore/Extensions3DOpenGLES.h>
 #else
+#include <WebCore/Extensions3DOpenGL.h>
 #include <WebCore/OpenGLShims.h>
 #endif
 
@@ -373,11 +375,12 @@
 
 bool WaylandCompositor::initializeEGL()
 {
+    const char* extensions = eglQueryString(PlatformDisplay::sharedDisplay().eglDisplay(), EGL_EXTENSIONS);
+
     if (PlatformDisplay::sharedDisplay().eglCheckVersion(1, 5)) {
         eglCreateImage = reinterpret_cast<PFNEGLCREATEIMAGEKHRPROC>(eglGetProcAddress("eglCreateImage"));
         eglDestroyImage = reinterpret_cast<PFNEGLDESTROYIMAGEKHRPROC>(eglGetProcAddress("eglDestroyImage"));
     } else {
-        const char* extensions = eglQueryString(PlatformDisplay::sharedDisplay().eglDisplay(), EGL_EXTENSIONS);
         if (GLContext::isExtensionSupported(extensions, "EGL_KHR_image_base")) {
             eglCreateImage = reinterpret_cast<PFNEGLCREATEIMAGEKHRPROC>(eglGetProcAddress("eglCreateImageKHR"));
             eglDestroyImage = reinterpret_cast<PFNEGLDESTROYIMAGEKHRPROC>(eglGetProcAddress("eglDestroyImageKHR"));
@@ -388,25 +391,16 @@
         return false;
     }
 
-    glImageTargetTexture2D = reinterpret_cast<PFNGLEGLIMAGETARGETTEXTURE2DOESPROC>(eglGetProcAddress("glEGLImageTargetTexture2DOES"));
-    if (!glImageTargetTexture2D) {
-        WTFLogAlways("WaylandCompositor requires glEGLImageTargetTexture2D.");
-        return false;
+    if (GLContext::isExtensionSupported(extensions, "EGL_WL_bind_wayland_display")) {
+        eglBindWaylandDisplay = reinterpret_cast<PFNEGLBINDWAYLANDDISPLAYWL>(eglGetProcAddress("eglBindWaylandDisplayWL"));
+        eglUnbindWaylandDisplay = reinterpret_cast<PFNEGLUNBINDWAYLANDDISPLAYWL>(eglGetProcAddress("eglUnbindWaylandDisplayWL"));
+        eglQueryWaylandBuffer = reinterpret_cast<PFNEGLQUERYWAYLANDBUFFERWL>(eglGetProcAddress("eglQueryWaylandBufferWL"));
     }
-
-    eglQueryWaylandBuffer = reinterpret_cast<PFNEGLQUERYWAYLANDBUFFERWL>(eglGetProcAddress("eglQueryWaylandBufferWL"));
-    if (!eglQueryWaylandBuffer) {
-        WTFLogAlways("WaylandCompositor requires eglQueryWaylandBuffer.");
+    if (!eglBindWaylandDisplay || !eglUnbindWaylandDisplay || !eglQueryWaylandBuffer) {
+        WTFLogAlways("WaylandCompositor requires eglBindWaylandDisplayWL, eglUnbindWaylandDisplayWL and eglQueryWaylandBuffer.");
         return false;
     }
 
-    eglBindWaylandDisplay = reinterpret_cast<PFNEGLBINDWAYLANDDISPLAYWL>(eglGetProcAddress("eglBindWaylandDisplayWL"));
-    eglUnbindWaylandDisplay = reinterpret_cast<PFNEGLUNBINDWAYLANDDISPLAYWL>(eglGetProcAddress("eglUnbindWaylandDisplayWL"));
-    if (!eglBindWaylandDisplay || !eglUnbindWaylandDisplay) {
-        WTFLogAlways("WaylandCompositor requires eglBindWaylandDisplayWL and eglUnbindWaylandDisplayWL.");
-        return false;
-    }
-
     m_eglContext = GLContext::createOffscreenContext();
     if (!m_eglContext)
         return false;
@@ -414,6 +408,19 @@
     if (!m_eglContext->makeContextCurrent())
         return false;
 
+#if USE(OPENGL_ES_2)
+    std::unique_ptr<Extensions3DOpenGLES> glExtensions = std::make_unique<Extensions3DOpenGLES>(nullptr,  false);
+#else
+    std::unique_ptr<Extensions3DOpenGL> glExtensions = std::make_unique<Extensions3DOpenGL>(nullptr, GLContext::current()->version() >= 320);
+#endif
+    if (glExtensions->supports("GL_OES_EGL_image") || glExtensions->supports("GL_OES_EGL_image_external"))
+        glImageTargetTexture2D = reinterpret_cast<PFNGLEGLIMAGETARGETTEXTURE2DOESPROC>(eglGetProcAddress("glEGLImageTargetTexture2DOES"));
+
+    if (!glImageTargetTexture2D) {
+        WTFLogAlways("WaylandCompositor requires glEGLImageTargetTexture2D.");
+        return false;
+    }
+
     return true;
 }
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to