Title: [207616] trunk/Source/WebCore
Revision
207616
Author
commit-qu...@webkit.org
Date
2016-10-20 06:18:09 -0700 (Thu, 20 Oct 2016)

Log Message

Prefer eglGetPlatformDisplay to eglGetDisplay
https://bugs.webkit.org/show_bug.cgi?id=163333

Patch by Adam Jackson <a...@redhat.com> on 2016-10-20
Reviewed by Carlos Garcia Campos.

eglGetDisplay forces the implementation to guess what kind of void* it's been handed. Different implementations
do different things, in particular glvnd and Mesa behave differently. Fortunately there exists API to tell EGL
what kind of display it is, so let's use it.

* platform/graphics/wayland/PlatformDisplayWayland.cpp:
(WebCore::PlatformDisplayWayland::initialize):
* platform/graphics/x11/PlatformDisplayX11.cpp:
(WebCore::PlatformDisplayX11::initializeEGLDisplay):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (207615 => 207616)


--- trunk/Source/WebCore/ChangeLog	2016-10-20 12:37:53 UTC (rev 207615)
+++ trunk/Source/WebCore/ChangeLog	2016-10-20 13:18:09 UTC (rev 207616)
@@ -1,3 +1,19 @@
+2016-10-20  Adam Jackson  <a...@redhat.com>
+
+        Prefer eglGetPlatformDisplay to eglGetDisplay
+        https://bugs.webkit.org/show_bug.cgi?id=163333
+
+        Reviewed by Carlos Garcia Campos.
+
+        eglGetDisplay forces the implementation to guess what kind of void* it's been handed. Different implementations
+        do different things, in particular glvnd and Mesa behave differently. Fortunately there exists API to tell EGL
+        what kind of display it is, so let's use it.
+
+        * platform/graphics/wayland/PlatformDisplayWayland.cpp:
+        (WebCore::PlatformDisplayWayland::initialize):
+        * platform/graphics/x11/PlatformDisplayX11.cpp:
+        (WebCore::PlatformDisplayX11::initializeEGLDisplay):
+
 2016-10-20  Carlos Garcia Campos  <cgar...@igalia.com>
 
         [GTK] Avoid including egl.h headers in internal headers

Modified: trunk/Source/WebCore/platform/graphics/wayland/PlatformDisplayWayland.cpp (207615 => 207616)


--- trunk/Source/WebCore/platform/graphics/wayland/PlatformDisplayWayland.cpp	2016-10-20 12:37:53 UTC (rev 207615)
+++ trunk/Source/WebCore/platform/graphics/wayland/PlatformDisplayWayland.cpp	2016-10-20 13:18:09 UTC (rev 207616)
@@ -34,6 +34,7 @@
 // and egl.h checks that to decide whether it's Wayland platform.
 #include <wayland-egl.h>
 #include <EGL/egl.h>
+#include <EGL/eglext.h>
 #include <wtf/Assertions.h>
 
 namespace WebCore {
@@ -65,7 +66,16 @@
     wl_registry_add_listener(m_registry.get(), &s_registryListener, this);
     wl_display_roundtrip(m_display);
 
-    m_eglDisplay = eglGetDisplay(m_display);
+    const char* extensions = eglQueryString(nullptr, EGL_EXTENSIONS);
+    if (GLContext::isExtensionSupported(extensions, "EGL_KHR_platform_base")) {
+        if (auto* getPlatformDisplay = reinterpret_cast<PFNEGLGETPLATFORMDISPLAYEXTPROC>(eglGetProcAddress("eglGetPlatformDisplay")))
+            m_eglDisplay = getPlatformDisplay(EGL_PLATFORM_WAYLAND_KHR, m_display, nullptr);
+    } else if (GLContext::isExtensionSupported(extensions, "EGL_EXT_platform_base")) {
+        if (auto* getPlatformDisplay = reinterpret_cast<PFNEGLGETPLATFORMDISPLAYEXTPROC>(eglGetProcAddress("eglGetPlatformDisplayEXT")))
+            m_eglDisplay = getPlatformDisplay(EGL_PLATFORM_WAYLAND_KHR, m_display, nullptr);
+    } else
+        m_eglDisplay = eglGetDisplay(m_display);
+
     PlatformDisplay::initializeEGLDisplay();
 }
 

Modified: trunk/Source/WebCore/platform/graphics/x11/PlatformDisplayX11.cpp (207615 => 207616)


--- trunk/Source/WebCore/platform/graphics/x11/PlatformDisplayX11.cpp	2016-10-20 12:37:53 UTC (rev 207615)
+++ trunk/Source/WebCore/platform/graphics/x11/PlatformDisplayX11.cpp	2016-10-20 13:18:09 UTC (rev 207616)
@@ -37,6 +37,7 @@
 
 #if USE(EGL)
 #include <EGL/egl.h>
+#include <EGL/eglext.h>
 #endif
 
 namespace WebCore {
@@ -64,7 +65,16 @@
 #if USE(EGL)
 void PlatformDisplayX11::initializeEGLDisplay()
 {
-    m_eglDisplay = eglGetDisplay(m_display);
+    const char* extensions = eglQueryString(nullptr, EGL_EXTENSIONS);
+    if (GLContext::isExtensionSupported(extensions, "EGL_KHR_platform_base")) {
+        if (auto* getPlatformDisplay = reinterpret_cast<PFNEGLGETPLATFORMDISPLAYEXTPROC>(eglGetProcAddress("eglGetPlatformDisplay")))
+            m_eglDisplay = getPlatformDisplay(EGL_PLATFORM_X11_KHR, m_display, nullptr);
+    } else if (GLContext::isExtensionSupported(extensions, "EGL_EXT_platform_base")) {
+        if (auto* getPlatformDisplay = reinterpret_cast<PFNEGLGETPLATFORMDISPLAYEXTPROC>(eglGetProcAddress("eglGetPlatformDisplayEXT")))
+            m_eglDisplay = getPlatformDisplay(EGL_PLATFORM_X11_KHR, m_display, nullptr);
+    } else
+        m_eglDisplay = eglGetDisplay(m_display);
+
     PlatformDisplay::initializeEGLDisplay();
 }
 #endif
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to