Changeset 228272 in webkit


Ignore:
Timestamp:
Feb 8, 2018 6:05:13 AM (6 years ago)
Author:
magomez@igalia.com
Message:

[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):

Location:
trunk/Source/WebKit
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit/ChangeLog

    r228264 r228272  
     12018-02-08  Miguel Gomez  <magomez@igalia.com>
     2
     3        [GTK] WaylandCompositor misusing eglGetProcAddress
     4        https://bugs.webkit.org/show_bug.cgi?id=182490
     5
     6        Reviewed by Michael Catanzaro.
     7
     8        Check that the appropriate extensions are available before calling eglGetProcAddress, as even
     9        getting a non null value from it, the functionality can be disabled at runtime.
     10
     11        * UIProcess/gtk/WaylandCompositor.cpp:
     12        (WebKit::WaylandCompositor::initializeEGL):
     13
    1142018-02-08  Frederic Wang  <fwang@igalia.com>
    215
  • trunk/Source/WebKit/UIProcess/gtk/WaylandCompositor.cpp

    r222422 r228272  
    4141#include <GLES2/gl2.h>
    4242#include <GLES2/gl2ext.h>
     43#include <WebCore/Extensions3DOpenGLES.h>
    4344#else
     45#include <WebCore/Extensions3DOpenGL.h>
    4446#include <WebCore/OpenGLShims.h>
    4547#endif
     
    374376bool WaylandCompositor::initializeEGL()
    375377{
     378    const char* extensions = eglQueryString(PlatformDisplay::sharedDisplay().eglDisplay(), EGL_EXTENSIONS);
     379
    376380    if (PlatformDisplay::sharedDisplay().eglCheckVersion(1, 5)) {
    377381        eglCreateImage = reinterpret_cast<PFNEGLCREATEIMAGEKHRPROC>(eglGetProcAddress("eglCreateImage"));
    378382        eglDestroyImage = reinterpret_cast<PFNEGLDESTROYIMAGEKHRPROC>(eglGetProcAddress("eglDestroyImage"));
    379383    } else {
    380         const char* extensions = eglQueryString(PlatformDisplay::sharedDisplay().eglDisplay(), EGL_EXTENSIONS);
    381384        if (GLContext::isExtensionSupported(extensions, "EGL_KHR_image_base")) {
    382385            eglCreateImage = reinterpret_cast<PFNEGLCREATEIMAGEKHRPROC>(eglGetProcAddress("eglCreateImageKHR"));
     
    389392    }
    390393
    391     glImageTargetTexture2D = reinterpret_cast<PFNGLEGLIMAGETARGETTEXTURE2DOESPROC>(eglGetProcAddress("glEGLImageTargetTexture2DOES"));
     394    if (GLContext::isExtensionSupported(extensions, "EGL_WL_bind_wayland_display")) {
     395        eglBindWaylandDisplay = reinterpret_cast<PFNEGLBINDWAYLANDDISPLAYWL>(eglGetProcAddress("eglBindWaylandDisplayWL"));
     396        eglUnbindWaylandDisplay = reinterpret_cast<PFNEGLUNBINDWAYLANDDISPLAYWL>(eglGetProcAddress("eglUnbindWaylandDisplayWL"));
     397        eglQueryWaylandBuffer = reinterpret_cast<PFNEGLQUERYWAYLANDBUFFERWL>(eglGetProcAddress("eglQueryWaylandBufferWL"));
     398    }
     399    if (!eglBindWaylandDisplay || !eglUnbindWaylandDisplay || !eglQueryWaylandBuffer) {
     400        WTFLogAlways("WaylandCompositor requires eglBindWaylandDisplayWL, eglUnbindWaylandDisplayWL and eglQueryWaylandBuffer.");
     401        return false;
     402    }
     403
     404    m_eglContext = GLContext::createOffscreenContext();
     405    if (!m_eglContext)
     406        return false;
     407
     408    if (!m_eglContext->makeContextCurrent())
     409        return false;
     410
     411#if USE(OPENGL_ES_2)
     412    std::unique_ptr<Extensions3DOpenGLES> glExtensions = std::make_unique<Extensions3DOpenGLES>(nullptr,  false);
     413#else
     414    std::unique_ptr<Extensions3DOpenGL> glExtensions = std::make_unique<Extensions3DOpenGL>(nullptr, GLContext::current()->version() >= 320);
     415#endif
     416    if (glExtensions->supports("GL_OES_EGL_image") || glExtensions->supports("GL_OES_EGL_image_external"))
     417        glImageTargetTexture2D = reinterpret_cast<PFNGLEGLIMAGETARGETTEXTURE2DOESPROC>(eglGetProcAddress("glEGLImageTargetTexture2DOES"));
     418
    392419    if (!glImageTargetTexture2D) {
    393420        WTFLogAlways("WaylandCompositor requires glEGLImageTargetTexture2D.");
    394421        return false;
    395422    }
    396 
    397     eglQueryWaylandBuffer = reinterpret_cast<PFNEGLQUERYWAYLANDBUFFERWL>(eglGetProcAddress("eglQueryWaylandBufferWL"));
    398     if (!eglQueryWaylandBuffer) {
    399         WTFLogAlways("WaylandCompositor requires eglQueryWaylandBuffer.");
    400         return false;
    401     }
    402 
    403     eglBindWaylandDisplay = reinterpret_cast<PFNEGLBINDWAYLANDDISPLAYWL>(eglGetProcAddress("eglBindWaylandDisplayWL"));
    404     eglUnbindWaylandDisplay = reinterpret_cast<PFNEGLUNBINDWAYLANDDISPLAYWL>(eglGetProcAddress("eglUnbindWaylandDisplayWL"));
    405     if (!eglBindWaylandDisplay || !eglUnbindWaylandDisplay) {
    406         WTFLogAlways("WaylandCompositor requires eglBindWaylandDisplayWL and eglUnbindWaylandDisplayWL.");
    407         return false;
    408     }
    409 
    410     m_eglContext = GLContext::createOffscreenContext();
    411     if (!m_eglContext)
    412         return false;
    413 
    414     if (!m_eglContext->makeContextCurrent())
    415         return false;
    416423
    417424    return true;
Note: See TracChangeset for help on using the changeset viewer.