Changeset 207614 in webkit


Ignore:
Timestamp:
Oct 20, 2016 5:36:06 AM (8 years ago)
Author:
Carlos Garcia Campos
Message:

[GTK] Avoid strstr() when checking (E)GL extensions
https://bugs.webkit.org/show_bug.cgi?id=161958

Reviewed by Žan Doberšek.

Source/WebCore:

Add static method GLContext::isExtensionSupported() to properly search extenstions in the given extension
list, and use it instead of strstr().

  • platform/graphics/GLContext.cpp:

(WebCore::GLContext::isExtensionSupported):

  • platform/graphics/GLContext.h:
  • platform/graphics/egl/GLContextEGL.cpp:

(WebCore::GLContextEGL::createSurfacelessContext):

  • platform/graphics/glx/GLContextGLX.cpp:

(WebCore::hasSGISwapControlExtension):

Source/WebKit2:

Use GLContext::isExtensionSupported() instead of strstr().

  • UIProcess/gtk/WaylandCompositor.cpp:

(WebKit::WaylandCompositor::initializeEGL):

Location:
trunk/Source
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r207591 r207614  
     12016-10-20  Carlos Garcia Campos  <cgarcia@igalia.com>
     2
     3        [GTK] Avoid strstr() when checking (E)GL extensions
     4        https://bugs.webkit.org/show_bug.cgi?id=161958
     5
     6        Reviewed by Žan Doberšek.
     7
     8        Add static method GLContext::isExtensionSupported() to properly search extenstions in the given extension
     9        list, and use it instead of strstr().
     10
     11        * platform/graphics/GLContext.cpp:
     12        (WebCore::GLContext::isExtensionSupported):
     13        * platform/graphics/GLContext.h:
     14        * platform/graphics/egl/GLContextEGL.cpp:
     15        (WebCore::GLContextEGL::createSurfacelessContext):
     16        * platform/graphics/glx/GLContextGLX.cpp:
     17        (WebCore::hasSGISwapControlExtension):
     18
    1192016-10-20  Per Arne Vollan  <pvollan@apple.com>
    220
  • trunk/Source/WebCore/platform/graphics/GLContext.cpp

    r205544 r207614  
    150150}
    151151
     152bool GLContext::isExtensionSupported(const char* extensionList, const char* extension)
     153{
     154    if (!extensionList)
     155        return false;
     156
     157    ASSERT(extension);
     158    int extensionLen = strlen(extension);
     159    const char* extensionListPtr = extensionList;
     160    while ((extensionListPtr = strstr(extensionListPtr, extension))) {
     161        if (extensionListPtr[extensionLen] == ' ' || extensionListPtr[extensionLen] == '\0')
     162            return true;
     163        extensionListPtr += extensionLen;
     164    }
     165    return false;
     166}
     167
    152168} // namespace WebCore
    153169
  • trunk/Source/WebCore/platform/graphics/GLContext.h

    r205116 r207614  
    4949    static std::unique_ptr<GLContext> createSharingContext(PlatformDisplay&);
    5050    static GLContext* current();
     51    static bool isExtensionSupported(const char* extensionList, const char* extension);
    5152
    5253    PlatformDisplay& display() const { return m_display; }
  • trunk/Source/WebCore/platform/graphics/egl/GLContextEGL.cpp

    r207590 r207614  
    152152
    153153    const char* extensions = eglQueryString(display, EGL_EXTENSIONS);
    154     if (!strstr(extensions, "EGL_KHR_surfaceless_context") && !strstr(extensions, "EGL_KHR_surfaceless_opengl"))
     154    if (!GLContext::isExtensionSupported(extensions, "EGL_KHR_surfaceless_context") && !GLContext::isExtensionSupported(extensions, "EGL_KHR_surfaceless_opengl"))
    155155        return nullptr;
    156156
  • trunk/Source/WebCore/platform/graphics/glx/GLContextGLX.cpp

    r205852 r207614  
    4646
    4747    initialized = true;
    48     const char* extensions = glXQueryExtensionsString(display, 0);
    49     if (!strstr(extensions, "GLX_SGI_swap_control"))
     48    if (!GLContext::isExtensionSupported(glXQueryExtensionsString(display, 0), "GLX_SGI_swap_control"))
    5049        return false;
    5150
  • trunk/Source/WebKit2/ChangeLog

    r207590 r207614  
     12016-10-20  Carlos Garcia Campos  <cgarcia@igalia.com>
     2
     3        [GTK] Avoid strstr() when checking (E)GL extensions
     4        https://bugs.webkit.org/show_bug.cgi?id=161958
     5
     6        Reviewed by Žan Doberšek.
     7
     8        Use GLContext::isExtensionSupported() instead of strstr().
     9
     10        * UIProcess/gtk/WaylandCompositor.cpp:
     11        (WebKit::WaylandCompositor::initializeEGL):
     12
    1132016-10-20  Carlos Garcia Campos  <cgarcia@igalia.com>
    214
  • trunk/Source/WebKit2/UIProcess/gtk/WaylandCompositor.cpp

    r206961 r207614  
    336336    } else {
    337337        const char* extensions = eglQueryString(PlatformDisplay::sharedDisplay().eglDisplay(), EGL_EXTENSIONS);
    338         if (strstr(extensions, "EGL_KHR_image_base")) {
     338        if (GLContext::isExtensionSupported(extensions, "EGL_KHR_image_base")) {
    339339            eglCreateImage = reinterpret_cast<PFNEGLCREATEIMAGEKHRPROC>(eglGetProcAddress("eglCreateImageKHR"));
    340340            eglDestroyImage = reinterpret_cast<PFNEGLDESTROYIMAGEKHRPROC>(eglGetProcAddress("eglDestroyImageKHR"));
Note: See TracChangeset for help on using the changeset viewer.