[GTK] Wayland: do not use EGL_PLATFORM_WAYLAND_KHR with eglGetPlatformDisplayEXT
https://bugs.webkit.org/show_bug.cgi?id=202689

Patch by Carlos Garcia Campos <cgarcia@igalia.com> on 2019-10-09
Reviewed by Žan Doberšek.

Use EGL_PLATFORM_WAYLAND_EXT instead. It shouldn't really matter because both are the same value.

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

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@250903 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog
index d6a3f38..73ed715 100644
--- a/Source/WebCore/ChangeLog
+++ b/Source/WebCore/ChangeLog
@@ -1,3 +1,15 @@
+2019-10-09  Carlos Garcia Campos  <cgarcia@igalia.com>
+
+        [GTK] Wayland: do not use EGL_PLATFORM_WAYLAND_KHR with eglGetPlatformDisplayEXT
+        https://bugs.webkit.org/show_bug.cgi?id=202689
+
+        Reviewed by Žan Doberšek.
+
+        Use EGL_PLATFORM_WAYLAND_EXT instead. It shouldn't really matter because both are the same value.
+
+        * platform/graphics/wayland/PlatformDisplayWayland.cpp:
+        (WebCore::PlatformDisplayWayland::initialize):
+
 2019-10-09  Antti Koivisto  <antti@apple.com>
 
         [CSS Shadow Parts] Allow exporting single part with multiple names using exportparts attribute
diff --git a/Source/WebCore/platform/graphics/wayland/PlatformDisplayWayland.cpp b/Source/WebCore/platform/graphics/wayland/PlatformDisplayWayland.cpp
index 05f92c2..066bbf8 100644
--- a/Source/WebCore/platform/graphics/wayland/PlatformDisplayWayland.cpp
+++ b/Source/WebCore/platform/graphics/wayland/PlatformDisplayWayland.cpp
@@ -93,16 +93,22 @@
     wl_display_roundtrip(m_display);
 
 #if USE(EGL)
-#if defined(EGL_KHR_platform_wayland)
+#if defined(EGL_KHR_platform_wayland) || defined(EGL_EXT_platform_wayland)
     const char* extensions = eglQueryString(nullptr, EGL_EXTENSIONS);
+#if defined(EGL_KHR_platform_wayland)
     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
+    }
 #endif
+#if defined(EGL_EXT_platform_wayland)
+    if (m_eglDisplay == EGL_NO_DISPLAY && GLContext::isExtensionSupported(extensions, "EGL_EXT_platform_base")) {
+        if (auto* getPlatformDisplay = reinterpret_cast<PFNEGLGETPLATFORMDISPLAYEXTPROC>(eglGetProcAddress("eglGetPlatformDisplayEXT")))
+            m_eglDisplay = getPlatformDisplay(EGL_PLATFORM_WAYLAND_EXT, m_display, nullptr);
+    }
+#endif
+#endif
+    if (m_eglDisplay == EGL_NO_DISPLAY)
         m_eglDisplay = eglGetDisplay(m_display);
 
     PlatformDisplay::initializeEGLDisplay();