Skip to content
Permalink
Browse files
[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):


Canonical link: https://commits.webkit.org/198408@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@228272 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
magomez committed Feb 8, 2018
1 parent b49734a commit d4437c12b177fd1d965c251ccc5818261463e4cf
Showing with 36 additions and 16 deletions.
  1. +13 −0 Source/WebKit/ChangeLog
  2. +23 −16 Source/WebKit/UIProcess/gtk/WaylandCompositor.cpp
@@ -1,3 +1,16 @@
2018-02-08 Miguel Gomez <magomez@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-08 Frederic Wang <fwang@igalia.com>

Add scrolling node types to distinguish main frames and subframes.
@@ -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 @@ static const struct wl_webkitgtk_interface webkitgtkInterface = {

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,22 +391,13 @@ bool WaylandCompositor::initializeEGL()
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.");
return false;
}

eglBindWaylandDisplay = reinterpret_cast<PFNEGLBINDWAYLANDDISPLAYWL>(eglGetProcAddress("eglBindWaylandDisplayWL"));
eglUnbindWaylandDisplay = reinterpret_cast<PFNEGLUNBINDWAYLANDDISPLAYWL>(eglGetProcAddress("eglUnbindWaylandDisplayWL"));
if (!eglBindWaylandDisplay || !eglUnbindWaylandDisplay) {
WTFLogAlways("WaylandCompositor requires eglBindWaylandDisplayWL and eglUnbindWaylandDisplayWL.");
if (!eglBindWaylandDisplay || !eglUnbindWaylandDisplay || !eglQueryWaylandBuffer) {
WTFLogAlways("WaylandCompositor requires eglBindWaylandDisplayWL, eglUnbindWaylandDisplayWL and eglQueryWaylandBuffer.");
return false;
}

@@ -414,6 +408,19 @@ bool WaylandCompositor::initializeEGL()
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;
}

0 comments on commit d4437c1

Please sign in to comment.