Title: [207976] releases/WebKitGTK/webkit-2.14/Source
Revision
207976
Author
[email protected]
Date
2016-10-27 03:13:29 -0700 (Thu, 27 Oct 2016)

Log Message

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

Modified Paths

Diff

Modified: releases/WebKitGTK/webkit-2.14/Source/WebCore/ChangeLog (207975 => 207976)


--- releases/WebKitGTK/webkit-2.14/Source/WebCore/ChangeLog	2016-10-27 10:12:42 UTC (rev 207975)
+++ releases/WebKitGTK/webkit-2.14/Source/WebCore/ChangeLog	2016-10-27 10:13:29 UTC (rev 207976)
@@ -1,5 +1,23 @@
 2016-10-20  Carlos Garcia Campos  <[email protected]>
 
+        [GTK] Avoid strstr() when checking (E)GL extensions
+        https://bugs.webkit.org/show_bug.cgi?id=161958
+
+        Reviewed by Žan Doberšek.
+
+        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):
+
+2016-10-20  Carlos Garcia Campos  <[email protected]>
+
         Wrong use of EGL_DEPTH_SIZE
         https://bugs.webkit.org/show_bug.cgi?id=155536
 

Modified: releases/WebKitGTK/webkit-2.14/Source/WebCore/platform/graphics/GLContext.cpp (207975 => 207976)


--- releases/WebKitGTK/webkit-2.14/Source/WebCore/platform/graphics/GLContext.cpp	2016-10-27 10:12:42 UTC (rev 207975)
+++ releases/WebKitGTK/webkit-2.14/Source/WebCore/platform/graphics/GLContext.cpp	2016-10-27 10:13:29 UTC (rev 207976)
@@ -149,6 +149,22 @@
     return currentContext()->context();
 }
 
+bool GLContext::isExtensionSupported(const char* extensionList, const char* extension)
+{
+    if (!extensionList)
+        return false;
+
+    ASSERT(extension);
+    int extensionLen = strlen(extension);
+    const char* extensionListPtr = extensionList;
+    while ((extensionListPtr = strstr(extensionListPtr, extension))) {
+        if (extensionListPtr[extensionLen] == ' ' || extensionListPtr[extensionLen] == '\0')
+            return true;
+        extensionListPtr += extensionLen;
+    }
+    return false;
+}
+
 } // namespace WebCore
 
 #endif

Modified: releases/WebKitGTK/webkit-2.14/Source/WebCore/platform/graphics/GLContext.h (207975 => 207976)


--- releases/WebKitGTK/webkit-2.14/Source/WebCore/platform/graphics/GLContext.h	2016-10-27 10:12:42 UTC (rev 207975)
+++ releases/WebKitGTK/webkit-2.14/Source/WebCore/platform/graphics/GLContext.h	2016-10-27 10:13:29 UTC (rev 207976)
@@ -48,6 +48,7 @@
     static std::unique_ptr<GLContext> createOffscreenContext(PlatformDisplay* = nullptr);
     static std::unique_ptr<GLContext> createSharingContext(PlatformDisplay&);
     static GLContext* current();
+    static bool isExtensionSupported(const char* extensionList, const char* extension);
 
     PlatformDisplay& display() const { return m_display; }
 

Modified: releases/WebKitGTK/webkit-2.14/Source/WebCore/platform/graphics/egl/GLContextEGL.cpp (207975 => 207976)


--- releases/WebKitGTK/webkit-2.14/Source/WebCore/platform/graphics/egl/GLContextEGL.cpp	2016-10-27 10:12:42 UTC (rev 207975)
+++ releases/WebKitGTK/webkit-2.14/Source/WebCore/platform/graphics/egl/GLContextEGL.cpp	2016-10-27 10:13:29 UTC (rev 207976)
@@ -151,7 +151,7 @@
         return nullptr;
 
     const char* extensions = eglQueryString(display, EGL_EXTENSIONS);
-    if (!strstr(extensions, "EGL_KHR_surfaceless_context") && !strstr(extensions, "EGL_KHR_surfaceless_opengl"))
+    if (!GLContext::isExtensionSupported(extensions, "EGL_KHR_surfaceless_context") && !GLContext::isExtensionSupported(extensions, "EGL_KHR_surfaceless_opengl"))
         return nullptr;
 
     EGLConfig config;

Modified: releases/WebKitGTK/webkit-2.14/Source/WebCore/platform/graphics/glx/GLContextGLX.cpp (207975 => 207976)


--- releases/WebKitGTK/webkit-2.14/Source/WebCore/platform/graphics/glx/GLContextGLX.cpp	2016-10-27 10:12:42 UTC (rev 207975)
+++ releases/WebKitGTK/webkit-2.14/Source/WebCore/platform/graphics/glx/GLContextGLX.cpp	2016-10-27 10:13:29 UTC (rev 207976)
@@ -67,8 +67,7 @@
         return !!glXSwapIntervalSGI;
 
     initialized = true;
-    const char* extensions = glXQueryExtensionsString(display, 0);
-    if (!strstr(extensions, "GLX_SGI_swap_control"))
+    if (!GLContext::isExtensionSupported(glXQueryExtensionsString(display, 0), "GLX_SGI_swap_control"))
         return false;
 
     glXSwapIntervalSGI = reinterpret_cast<PFNGLXSWAPINTERVALSGIPROC>(glXGetProcAddress(reinterpret_cast<const unsigned char*>("glXSwapIntervalSGI")));

Modified: releases/WebKitGTK/webkit-2.14/Source/WebKit2/ChangeLog (207975 => 207976)


--- releases/WebKitGTK/webkit-2.14/Source/WebKit2/ChangeLog	2016-10-27 10:12:42 UTC (rev 207975)
+++ releases/WebKitGTK/webkit-2.14/Source/WebKit2/ChangeLog	2016-10-27 10:13:29 UTC (rev 207976)
@@ -1,5 +1,17 @@
 2016-10-20  Carlos Garcia Campos  <[email protected]>
 
+        [GTK] Avoid strstr() when checking (E)GL extensions
+        https://bugs.webkit.org/show_bug.cgi?id=161958
+
+        Reviewed by Žan Doberšek.
+
+        Use GLContext::isExtensionSupported() instead of strstr().
+
+        * UIProcess/gtk/WaylandCompositor.cpp:
+        (WebKit::WaylandCompositor::initializeEGL):
+
+2016-10-20  Carlos Garcia Campos  <[email protected]>
+
         Wrong use of EGL_DEPTH_SIZE
         https://bugs.webkit.org/show_bug.cgi?id=155536
 

Modified: releases/WebKitGTK/webkit-2.14/Source/WebKit2/UIProcess/gtk/WaylandCompositor.cpp (207975 => 207976)


--- releases/WebKitGTK/webkit-2.14/Source/WebKit2/UIProcess/gtk/WaylandCompositor.cpp	2016-10-27 10:12:42 UTC (rev 207975)
+++ releases/WebKitGTK/webkit-2.14/Source/WebKit2/UIProcess/gtk/WaylandCompositor.cpp	2016-10-27 10:13:29 UTC (rev 207976)
@@ -335,7 +335,7 @@
         eglDestroyImage = reinterpret_cast<PFNEGLDESTROYIMAGEKHRPROC>(eglGetProcAddress("eglDestroyImage"));
     } else {
         const char* extensions = eglQueryString(PlatformDisplay::sharedDisplay().eglDisplay(), EGL_EXTENSIONS);
-        if (strstr(extensions, "EGL_KHR_image_base")) {
+        if (GLContext::isExtensionSupported(extensions, "EGL_KHR_image_base")) {
             eglCreateImage = reinterpret_cast<PFNEGLCREATEIMAGEKHRPROC>(eglGetProcAddress("eglCreateImageKHR"));
             eglDestroyImage = reinterpret_cast<PFNEGLDESTROYIMAGEKHRPROC>(eglGetProcAddress("eglDestroyImageKHR"));
         }
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to