Title: [269841] trunk/Source/WebCore
Revision
269841
Author
[email protected]
Date
2020-11-16 02:05:32 -0800 (Mon, 16 Nov 2020)

Log Message

PlatformDisplayLibWPE: use eglGetPlatformDisplay when possible
https://bugs.webkit.org/show_bug.cgi?id=218941

Reviewed by Carlos Garcia Campos.

Use the existing wpe_renderer_backend_egl API to detect any desired
EGL platform that should be used to retrieve the global EGLDisplay
object. If such a platform is specified, the eglGetPlatformDisplay
entrypoing from the EGL_EXT_platform_base extension should be used
to retrieve the corresponding EGLDisplay.

If the API or the extension is not available, or if the EGLDisplay is
not retrieved this way, we fall back to eglGetDisplay.

* platform/graphics/libwpe/PlatformDisplayLibWPE.cpp:
(WebCore::PlatformDisplayLibWPE::initialize):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (269840 => 269841)


--- trunk/Source/WebCore/ChangeLog	2020-11-16 09:50:48 UTC (rev 269840)
+++ trunk/Source/WebCore/ChangeLog	2020-11-16 10:05:32 UTC (rev 269841)
@@ -1,3 +1,22 @@
+2020-11-16  Zan Dobersek  <[email protected]>
+
+        PlatformDisplayLibWPE: use eglGetPlatformDisplay when possible
+        https://bugs.webkit.org/show_bug.cgi?id=218941
+
+        Reviewed by Carlos Garcia Campos.
+
+        Use the existing wpe_renderer_backend_egl API to detect any desired
+        EGL platform that should be used to retrieve the global EGLDisplay
+        object. If such a platform is specified, the eglGetPlatformDisplay
+        entrypoing from the EGL_EXT_platform_base extension should be used
+        to retrieve the corresponding EGLDisplay.
+
+        If the API or the extension is not available, or if the EGLDisplay is
+        not retrieved this way, we fall back to eglGetDisplay.
+
+        * platform/graphics/libwpe/PlatformDisplayLibWPE.cpp:
+        (WebCore::PlatformDisplayLibWPE::initialize):
+
 2020-11-10  Sergio Villar Senin  <[email protected]>
 
         [css-flex] Better naming from some methods

Modified: trunk/Source/WebCore/platform/graphics/libwpe/PlatformDisplayLibWPE.cpp (269840 => 269841)


--- trunk/Source/WebCore/platform/graphics/libwpe/PlatformDisplayLibWPE.cpp	2020-11-16 09:50:48 UTC (rev 269840)
+++ trunk/Source/WebCore/platform/graphics/libwpe/PlatformDisplayLibWPE.cpp	2020-11-16 10:05:32 UTC (rev 269841)
@@ -46,6 +46,11 @@
 
 #include <wpe/wpe-egl.h>
 
+#ifndef EGL_EXT_platform_base
+#define EGL_EXT_platform_base 1
+typedef EGLDisplay (EGLAPIENTRYP PFNEGLGETPLATFORMDISPLAYEXTPROC) (EGLenum platform, void *native_display, const EGLint *attrib_list);
+#endif
+
 namespace WebCore {
 
 std::unique_ptr<PlatformDisplayLibWPE> PlatformDisplayLibWPE::create()
@@ -70,7 +75,28 @@
 {
     m_backend = wpe_renderer_backend_egl_create(hostFd);
 
-    m_eglDisplay = eglGetDisplay(wpe_renderer_backend_egl_get_native_display(m_backend));
+    EGLNativeDisplayType eglNativeDisplay = wpe_renderer_backend_egl_get_native_display(m_backend);
+
+#if WPE_CHECK_VERSION(1, 1, 0)
+    uint32_t eglPlatform = wpe_renderer_backend_egl_get_platform(m_backend);
+    if (eglPlatform) {
+        using GetPlatformDisplayType = PFNEGLGETPLATFORMDISPLAYEXTPROC;
+        GetPlatformDisplayType getPlatformDisplay =
+            [] {
+                const char* extensions = eglQueryString(nullptr, EGL_EXTENSIONS);
+                if (GLContext::isExtensionSupported(extensions, "EGL_EXT_platform_base")
+                    || GLContext::isExtensionSupported(extensions, "EGL_KHR_platform_base"))
+                    return reinterpret_cast<GetPlatformDisplayType>(eglGetProcAddress("eglGetPlatformDisplay"));
+                return GetPlatformDisplayType(nullptr);
+            }();
+
+        if (getPlatformDisplay)
+            m_eglDisplay = getPlatformDisplay(eglPlatform, eglNativeDisplay, nullptr);
+    }
+#endif
+
+    if (m_eglDisplay == EGL_NO_DISPLAY)
+        m_eglDisplay = eglGetDisplay(eglNativeDisplay);
     if (m_eglDisplay == EGL_NO_DISPLAY) {
         WTFLogAlways("PlatformDisplayLibWPE: could not create the EGL display: %s.", GLContextEGL::lastErrorString());
         return false;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to