Title: [183731] trunk/Source
Revision
183731
Author
[email protected]
Date
2015-05-03 08:20:34 -0700 (Sun, 03 May 2015)

Log Message

[GTK][EFL] Unify platform display handling
https://bugs.webkit.org/show_bug.cgi?id=144517

Reviewed by Martin Robinson.

Source/WebCore:

There are several places were we are handling the X display
connection:

- GLContext::sharedX11Display() creates a new connection.
- X11Helper::nativeDisplay() creates a new connection.
- BackingStoreBackendCairoX11 uses the GTK+ shared connection.
- NetscapePlugin::x11HostDisplay() uses the GTK+/ecore shared connection
- The rest of the GTK+ code uses the shared GTK+ connection

And then we also have WaylandDisplay and the code to check if the
current display is wayland or X11.
We could unify all these to share the same connection to reduce
the amount of ifdefs and ensure a single connection. That will
also allow us to use "smart pointers" for the X resources that
need a Display* to be freed.

* PlatformEfl.cmake: Add new files to compilation.
* PlatformGTK.cmake: Move some files to WebCore_SOURCES sinc ethey
don't use GTK+ anymore, and add new files to compilation.
* platform/graphics/GLContext.cpp:
(WebCore::GLContext::cleanupActiveContextsAtExit): Remove the
custom X11 connection.
(WebCore::GLContext::createContextForWindow): Check if the shared
display is Wayland to create a EGL context in such case.
* platform/graphics/PlatformDisplay.cpp: Added.
(WebCore::PlatformDisplay::createPlatformDisplay): Creates the
shared display, using the GTK+/ecore shared connection.
(WebCore::PlatformDisplay::sharedDisplay): Return the shared display.
* platform/graphics/PlatformDisplay.h: Added.
* platform/graphics/egl/GLContextEGL.cpp:
(WebCore::sharedEGLDisplay): Use PlatformDisplay::sharedDisplay()
to get the native display.
(WebCore::GLContextEGL::createPixmapContext): Ditto.
* platform/graphics/glx/GLContextGLX.cpp:
(WebCore::GLContextGLX::createWindowContext): Ditto.
(WebCore::GLContextGLX::createPbufferContext): Ditto.
(WebCore::GLContextGLX::createPixmapContext): Ditto.
(WebCore::GLContextGLX::createContext): Ditto.
(WebCore::GLContextGLX::~GLContextGLX): Ditto.
(WebCore::GLContextGLX::defaultFrameBufferSize): Ditto.
(WebCore::GLContextGLX::makeContextCurrent): Ditto.
(WebCore::GLContextGLX::swapBuffers): Ditto.
(WebCore::GLContextGLX::cairoDevice): Ditto.
* platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.cpp:
(WebCore::MediaPlayerPrivateGStreamerBase::ensureGstGLContext): Ditto.
* platform/graphics/surfaces/glx/X11Helper.cpp:
(WebCore::X11Helper::nativeDisplay): Ditto.
* platform/graphics/wayland/PlatformDisplayWayland.cpp: Renamed from Source/WebCore/platform/graphics/wayland/WaylandDisplay.cpp.
(WebCore::PlatformDisplayWayland::globalCallback):
(WebCore::PlatformDisplayWayland::globalRemoveCallback):
(WebCore::PlatformDisplayWayland::create): Renamed instance() as
create() since the single instance is now handled by PlatformDisplay.
(WebCore::PlatformDisplayWayland::PlatformDisplayWayland):
(WebCore::PlatformDisplayWayland::createSurface):
(WebCore::PlatformDisplayWayland::createSharingGLContext):
* platform/graphics/wayland/PlatformDisplayWayland.h: Renamed from Source/WebCore/platform/graphics/wayland/WaylandDisplay.h.
* platform/graphics/x11/PlatformDisplayX11.cpp: Added.
(WebCore::PlatformDisplayX11::PlatformDisplayX11):
(WebCore::PlatformDisplayX11::~PlatformDisplayX11):
* platform/graphics/x11/PlatformDisplayX11.h: Added.
* platform/gtk/GtkUtilities.cpp:
(WebCore::getDisplaySystemType): Deleted.
* platform/gtk/GtkUtilities.h:

Source/WebKit2:

* UIProcess/API/gtk/WebKitWebViewBase.cpp:
(webkitWebViewBaseRealize): Use PlatformDisplay::sharedDisplay()
to checkt the display type.
(webkitWebViewBaseCreateWebPage): Ditto.
* UIProcess/cairo/BackingStoreCairo.cpp:
(WebKit::BackingStore::createBackend): Pass the native X11 shared
display to BackingStoreBackendCairoX11.
* WebProcess/Plugins/Netscape/x11/NetscapePluginX11.cpp:
(WebKit::NetscapePlugin::x11HostDisplay): Return the native X11
shared display.

Modified Paths

Added Paths

Removed Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (183730 => 183731)


--- trunk/Source/WebCore/ChangeLog	2015-05-03 10:14:55 UTC (rev 183730)
+++ trunk/Source/WebCore/ChangeLog	2015-05-03 15:20:34 UTC (rev 183731)
@@ -1,5 +1,76 @@
 2015-05-03  Carlos Garcia Campos  <[email protected]>
 
+        [GTK][EFL] Unify platform display handling
+        https://bugs.webkit.org/show_bug.cgi?id=144517
+
+        Reviewed by Martin Robinson.
+
+        There are several places were we are handling the X display
+        connection:
+
+        - GLContext::sharedX11Display() creates a new connection.
+        - X11Helper::nativeDisplay() creates a new connection.
+        - BackingStoreBackendCairoX11 uses the GTK+ shared connection.
+        - NetscapePlugin::x11HostDisplay() uses the GTK+/ecore shared connection
+        - The rest of the GTK+ code uses the shared GTK+ connection
+
+        And then we also have WaylandDisplay and the code to check if the
+        current display is wayland or X11.
+        We could unify all these to share the same connection to reduce
+        the amount of ifdefs and ensure a single connection. That will
+        also allow us to use "smart pointers" for the X resources that
+        need a Display* to be freed.
+
+        * PlatformEfl.cmake: Add new files to compilation.
+        * PlatformGTK.cmake: Move some files to WebCore_SOURCES sinc ethey
+        don't use GTK+ anymore, and add new files to compilation.
+        * platform/graphics/GLContext.cpp:
+        (WebCore::GLContext::cleanupActiveContextsAtExit): Remove the
+        custom X11 connection.
+        (WebCore::GLContext::createContextForWindow): Check if the shared
+        display is Wayland to create a EGL context in such case.
+        * platform/graphics/PlatformDisplay.cpp: Added.
+        (WebCore::PlatformDisplay::createPlatformDisplay): Creates the
+        shared display, using the GTK+/ecore shared connection.
+        (WebCore::PlatformDisplay::sharedDisplay): Return the shared display.
+        * platform/graphics/PlatformDisplay.h: Added.
+        * platform/graphics/egl/GLContextEGL.cpp:
+        (WebCore::sharedEGLDisplay): Use PlatformDisplay::sharedDisplay()
+        to get the native display.
+        (WebCore::GLContextEGL::createPixmapContext): Ditto.
+        * platform/graphics/glx/GLContextGLX.cpp:
+        (WebCore::GLContextGLX::createWindowContext): Ditto.
+        (WebCore::GLContextGLX::createPbufferContext): Ditto.
+        (WebCore::GLContextGLX::createPixmapContext): Ditto.
+        (WebCore::GLContextGLX::createContext): Ditto.
+        (WebCore::GLContextGLX::~GLContextGLX): Ditto.
+        (WebCore::GLContextGLX::defaultFrameBufferSize): Ditto.
+        (WebCore::GLContextGLX::makeContextCurrent): Ditto.
+        (WebCore::GLContextGLX::swapBuffers): Ditto.
+        (WebCore::GLContextGLX::cairoDevice): Ditto.
+        * platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.cpp:
+        (WebCore::MediaPlayerPrivateGStreamerBase::ensureGstGLContext): Ditto.
+        * platform/graphics/surfaces/glx/X11Helper.cpp:
+        (WebCore::X11Helper::nativeDisplay): Ditto.
+        * platform/graphics/wayland/PlatformDisplayWayland.cpp: Renamed from Source/WebCore/platform/graphics/wayland/WaylandDisplay.cpp.
+        (WebCore::PlatformDisplayWayland::globalCallback):
+        (WebCore::PlatformDisplayWayland::globalRemoveCallback):
+        (WebCore::PlatformDisplayWayland::create): Renamed instance() as
+        create() since the single instance is now handled by PlatformDisplay.
+        (WebCore::PlatformDisplayWayland::PlatformDisplayWayland):
+        (WebCore::PlatformDisplayWayland::createSurface):
+        (WebCore::PlatformDisplayWayland::createSharingGLContext):
+        * platform/graphics/wayland/PlatformDisplayWayland.h: Renamed from Source/WebCore/platform/graphics/wayland/WaylandDisplay.h.
+        * platform/graphics/x11/PlatformDisplayX11.cpp: Added.
+        (WebCore::PlatformDisplayX11::PlatformDisplayX11):
+        (WebCore::PlatformDisplayX11::~PlatformDisplayX11):
+        * platform/graphics/x11/PlatformDisplayX11.h: Added.
+        * platform/gtk/GtkUtilities.cpp:
+        (WebCore::getDisplaySystemType): Deleted.
+        * platform/gtk/GtkUtilities.h:
+
+2015-05-03  Carlos Garcia Campos  <[email protected]>
+
         [GTK] API tests crashing on debug builds due to extra unref
         https://bugs.webkit.org/show_bug.cgi?id=144508
 

Modified: trunk/Source/WebCore/PlatformEfl.cmake (183730 => 183731)


--- trunk/Source/WebCore/PlatformEfl.cmake	2015-05-03 10:14:55 UTC (rev 183730)
+++ trunk/Source/WebCore/PlatformEfl.cmake	2015-05-03 15:20:34 UTC (rev 183731)
@@ -17,6 +17,7 @@
     "${WEBCORE_DIR}/platform/graphics/surfaces/glx"
     "${WEBCORE_DIR}/platform/graphics/texmap"
     "${WEBCORE_DIR}/platform/graphics/texmap/coordinated"
+    "${WEBCORE_DIR}/platform/graphics/x11"
     "${WEBCORE_DIR}/platform/linux"
     "${WEBCORE_DIR}/platform/mediastream/openwebrtc"
     "${WEBCORE_DIR}/platform/mock/mediasource"
@@ -107,6 +108,7 @@
     platform/geoclue/GeolocationProviderGeoclue2.cpp
 
     platform/graphics/ImageSource.cpp
+    platform/graphics/PlatformDisplay.cpp
     platform/graphics/WOFFFileFormat.cpp
 
     platform/graphics/cairo/BackingStoreBackendCairoImpl.cpp
@@ -195,6 +197,8 @@
     platform/graphics/texmap/coordinated/TiledBackingStore.cpp
     platform/graphics/texmap/coordinated/UpdateAtlas.cpp
 
+    platform/graphics/x11/PlatformDisplayX11.cpp
+
     platform/image-decoders/ImageDecoder.cpp
 
     platform/image-decoders/bmp/BMPImageDecoder.cpp

Modified: trunk/Source/WebCore/PlatformGTK.cmake (183730 => 183731)


--- trunk/Source/WebCore/PlatformGTK.cmake	2015-05-03 10:14:55 UTC (rev 183730)
+++ trunk/Source/WebCore/PlatformGTK.cmake	2015-05-03 15:20:34 UTC (rev 183731)
@@ -17,6 +17,7 @@
     "${WEBCORE_DIR}/platform/graphics/opengl"
     "${WEBCORE_DIR}/platform/graphics/opentype"
     "${WEBCORE_DIR}/platform/graphics/wayland"
+    "${WEBCORE_DIR}/platform/graphics/x11"
     "${WEBCORE_DIR}/platform/linux"
     "${WEBCORE_DIR}/platform/mediastream/openwebrtc"
     "${WEBCORE_DIR}/platform/mock/mediasource"
@@ -63,6 +64,7 @@
     platform/geoclue/GeolocationProviderGeoclue1.cpp
     platform/geoclue/GeolocationProviderGeoclue2.cpp
 
+    platform/graphics/GLContext.cpp
     platform/graphics/GraphicsContext3DPrivate.cpp
     platform/graphics/ImageSource.cpp
     platform/graphics/WOFFFileFormat.cpp
@@ -87,11 +89,15 @@
     platform/graphics/cairo/RefPtrCairo.cpp
     platform/graphics/cairo/TransformationMatrixCairo.cpp
 
+    platform/graphics/egl/GLContextEGL.cpp
+
     platform/graphics/freetype/FontCacheFreeType.cpp
     platform/graphics/freetype/FontCustomPlatformDataFreeType.cpp
     platform/graphics/freetype/GlyphPageTreeNodeFreeType.cpp
     platform/graphics/freetype/SimpleFontDataFreeType.cpp
 
+    platform/graphics/glx/GLContextGLX.cpp
+
     platform/graphics/gstreamer/AudioTrackPrivateGStreamer.cpp
     platform/graphics/gstreamer/GRefPtrGStreamer.cpp
     platform/graphics/gstreamer/GStreamerUtilities.cpp
@@ -119,6 +125,8 @@
 
     platform/graphics/opentype/OpenTypeVerticalData.cpp
 
+    platform/graphics/x11/PlatformDisplayX11.cpp
+
     platform/gtk/ErrorsGtk.cpp
     platform/gtk/EventLoopGtk.cpp
     platform/gtk/FileSystemGtk.cpp
@@ -191,14 +199,10 @@
     page/gtk/DragControllerGtk.cpp
     page/gtk/EventHandlerGtk.cpp
 
-    platform/graphics/GLContext.cpp
+    platform/graphics/PlatformDisplay.cpp
 
-    platform/graphics/egl/GLContextEGL.cpp
-
     platform/graphics/freetype/FontPlatformDataFreeType.cpp
 
-    platform/graphics/glx/GLContextGLX.cpp
-
     platform/graphics/gtk/ColorGtk.cpp
     platform/graphics/gtk/GdkCairoUtilities.cpp
     platform/graphics/gtk/IconGtk.cpp
@@ -472,7 +476,7 @@
 
 if (ENABLE_WAYLAND_TARGET)
     list(APPEND WebCorePlatformGTK_SOURCES
-        platform/graphics/wayland/WaylandDisplay.cpp
+        platform/graphics/wayland/PlatformDisplayWayland.cpp
         platform/graphics/wayland/WaylandEventSource.cpp
         platform/graphics/wayland/WaylandSurface.cpp
 

Modified: trunk/Source/WebCore/platform/graphics/GLContext.cpp (183730 => 183731)


--- trunk/Source/WebCore/platform/graphics/GLContext.cpp	2015-05-03 10:14:55 UTC (rev 183730)
+++ trunk/Source/WebCore/platform/graphics/GLContext.cpp	2015-05-03 15:20:34 UTC (rev 183731)
@@ -22,6 +22,9 @@
 
 #include "GLContext.h"
 
+#include "PlatformDisplay.h"
+#include <wtf/ThreadSpecific.h>
+
 #if USE(EGL)
 #include "GLContextEGL.h"
 #endif
@@ -30,19 +33,6 @@
 #include "GLContextGLX.h"
 #endif
 
-#include <wtf/ThreadSpecific.h>
-
-#if PLATFORM(X11)
-#include <X11/Xlib.h>
-#endif
-
-#if PLATFORM(GTK)
-#include <gdk/gdk.h>
-#if PLATFORM(WAYLAND) && !defined(GTK_API_VERSION_2) && defined(GDK_WINDOWING_WAYLAND)
-#include <gdk/gdkwayland.h>
-#endif
-#endif
-
 using WTF::ThreadSpecific;
 
 namespace WebCore {
@@ -74,25 +64,6 @@
 }
 
 #if PLATFORM(X11)
-// We do not want to call glXMakeContextCurrent using different Display pointers,
-// because it might lead to crashes in some drivers (fglrx). We use a shared display
-// pointer here.
-static Display* gSharedX11Display = 0;
-Display* GLContext::sharedX11Display()
-{
-    if (!gSharedX11Display)
-        gSharedX11Display = XOpenDisplay(0);
-    return gSharedX11Display;
-}
-
-void GLContext::cleanupSharedX11Display()
-{
-    if (!gSharedX11Display)
-        return;
-    XCloseDisplay(gSharedX11Display);
-    gSharedX11Display = 0;
-}
-
 // Because of driver bugs, exiting the program when there are active pbuffers
 // can crash the X server (this has been observed with the official Nvidia drivers).
 // We need to ensure that we clean everything up on exit. There are several reasons
@@ -137,18 +108,14 @@
     ActiveContextList& contextList = activeContextList();
     for (size_t i = 0; i < contextList.size(); ++i)
         delete contextList[i];
-
-    cleanupSharedX11Display();
 }
 #endif // PLATFORM(X11)
 
 
 std::unique_ptr<GLContext> GLContext::createContextForWindow(GLNativeWindowType windowHandle, GLContext* sharingContext)
 {
-#if PLATFORM(GTK) && PLATFORM(WAYLAND) && !defined(GTK_API_VERSION_2) && defined(GDK_WINDOWING_WAYLAND) && USE(EGL)
-    GdkDisplay* display = gdk_display_manager_get_default_display(gdk_display_manager_get());
-
-    if (GDK_IS_WAYLAND_DISPLAY(display)) {
+#if PLATFORM(WAYLAND) && USE(EGL)
+    if (PlatformDisplay::sharedDisplay().type() == PlatformDisplay::Type::Wayland) {
         if (auto eglContext = GLContextEGL::createContext(windowHandle, sharingContext))
             return WTF::move(eglContext);
         return nullptr;

Added: trunk/Source/WebCore/platform/graphics/PlatformDisplay.cpp (0 => 183731)


--- trunk/Source/WebCore/platform/graphics/PlatformDisplay.cpp	                        (rev 0)
+++ trunk/Source/WebCore/platform/graphics/PlatformDisplay.cpp	2015-05-03 15:20:34 UTC (rev 183731)
@@ -0,0 +1,88 @@
+/*
+ * Copyright (C) 2015 Igalia S.L
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1.  Redistributions of source code must retain the above copyright
+ *     notice, this list of conditions and the following disclaimer.
+ * 2.  Redistributions in binary form must reproduce the above copyright
+ *     notice, this list of conditions and the following disclaimer in the
+ *     documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "PlatformDisplay.h"
+
+#include <mutex>
+#include <wtf/NeverDestroyed.h>
+
+#if PLATFORM(X11)
+#include "PlatformDisplayX11.h"
+#endif
+
+#if PLATFORM(WAYLAND)
+#include "PlatformDisplayWayland.h"
+#endif
+
+#if PLATFORM(GTK)
+#include <gdk/gdkx.h>
+#endif
+
+#if PLATFORM(EFL) && defined(HAVE_ECORE_X)
+#include <Ecore_X.h>
+#endif
+
+namespace WebCore {
+
+std::unique_ptr<PlatformDisplay> PlatformDisplay::createPlatformDisplay()
+{
+#if PLATFORM(GTK)
+#if defined(GTK_API_VERSION_2)
+    return std::make_unique<PlatformDisplayX11>(GDK_DISPLAY_XDISPLAY(gdk_display_get_default()));
+#else
+    GdkDisplay* display = gdk_display_manager_get_default_display(gdk_display_manager_get());
+#if PLATFORM(X11)
+    if (GDK_IS_X11_DISPLAY(display))
+        return std::make_unique<PlatformDisplayX11>(GDK_DISPLAY_XDISPLAY(display));
+#endif
+#if PLATFORM(WAYLAND)
+    if (GDK_IS_WAYLAND_DISPLAY(display))
+        return PlatformDisplayWayland::create();
+#endif
+#endif
+#elif PLATFORM(EFL) && defined(HAVE_ECORE_X)
+    return std::make_unique<PlatformDisplayX11>(static_cast<Display*>(ecore_x_display_get()));
+#endif
+
+#if PLATFORM(X11)
+    return std::make_unique<PlatformDisplayX11>();
+#endif
+
+    ASSERT_NOT_REACHED();
+    return nullptr;
+}
+
+PlatformDisplay& PlatformDisplay::sharedDisplay()
+{
+    static std::once_flag onceFlag;
+    static std::unique_ptr<PlatformDisplay> display;
+    std::call_once(onceFlag, []{
+        display = createPlatformDisplay();
+    });
+    return *display;
+}
+
+} // namespace WebCore

Added: trunk/Source/WebCore/platform/graphics/PlatformDisplay.h (0 => 183731)


--- trunk/Source/WebCore/platform/graphics/PlatformDisplay.h	                        (rev 0)
+++ trunk/Source/WebCore/platform/graphics/PlatformDisplay.h	2015-05-03 15:20:34 UTC (rev 183731)
@@ -0,0 +1,65 @@
+/*
+ * Copyright (C) 2015 Igalia S.L
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1.  Redistributions of source code must retain the above copyright
+ *     notice, this list of conditions and the following disclaimer.
+ * 2.  Redistributions in binary form must reproduce the above copyright
+ *     notice, this list of conditions and the following disclaimer in the
+ *     documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef PlatformDisplay_h
+#define PlatformDisplay_h
+
+#include <wtf/Noncopyable.h>
+#include <wtf/TypeCasts.h>
+
+namespace WebCore {
+
+class PlatformDisplay {
+    WTF_MAKE_NONCOPYABLE(PlatformDisplay); WTF_MAKE_FAST_ALLOCATED;
+public:
+    static PlatformDisplay& sharedDisplay();
+    virtual ~PlatformDisplay() = default;
+
+    enum class Type {
+#if PLATFORM(X11)
+        X11,
+#endif
+#if PLATFORM(WAYLAND)
+        Wayland,
+#endif
+    };
+
+    virtual Type type() const = 0;
+
+protected:
+    PlatformDisplay() = default;
+
+private:
+    static std::unique_ptr<PlatformDisplay> createPlatformDisplay();
+};
+
+} // namespace WebCore
+
+#define SPECIALIZE_TYPE_TRAITS_PLATFORM_DISPLAY(ToClassName, DisplayType) \
+SPECIALIZE_TYPE_TRAITS_BEGIN(WebCore::ToClassName) \
+    static bool isType(const WebCore::PlatformDisplay& display) { return display.type() == WebCore::PlatformDisplay::Type::DisplayType; } \
+SPECIALIZE_TYPE_TRAITS_END()
+
+#endif // PltformDisplay_h

Modified: trunk/Source/WebCore/platform/graphics/egl/GLContextEGL.cpp (183730 => 183731)


--- trunk/Source/WebCore/platform/graphics/egl/GLContextEGL.cpp	2015-05-03 10:14:55 UTC (rev 183730)
+++ trunk/Source/WebCore/platform/graphics/egl/GLContextEGL.cpp	2015-05-03 15:20:34 UTC (rev 183731)
@@ -34,11 +34,12 @@
 #include "OpenGLShims.h"
 #endif
 
-#if PLATFORM(GTK)
-#include "GtkUtilities.h"
-#if PLATFORM(WAYLAND) && !defined(GTK_API_VERSION_2)
-#include "WaylandDisplay.h"
+#if PLATFORM(X11)
+#include "PlatformDisplayX11.h"
 #endif
+
+#if PLATFORM(WAYLAND)
+#include "PlatformDisplayWayland.h"
 #endif
 
 #if ENABLE(ACCELERATED_2D_CANVAS)
@@ -64,13 +65,15 @@
     static bool initialized = false;
     if (!initialized) {
         initialized = true;
-#if PLATFORM(GTK) && PLATFORM(WAYLAND) && !defined(GTK_API_VERSION_2)
-        if (getDisplaySystemType() == DisplaySystemType::Wayland && WaylandDisplay::instance())
-            gSharedEGLDisplay = eglGetDisplay(WaylandDisplay::instance()->nativeDisplay());
+
+        const auto& sharedDisplay = PlatformDisplay::sharedDisplay();
+#if PLATFORM(WAYLAND)
+        if (is<PlatformDisplayWayland>(sharedDisplay))
+            gSharedEGLDisplay = eglGetDisplay(downcast<PlatformDisplayWayland>(sharedDisplay).native());
         else // Note that this branch continutes outside this #if-guarded segment.
 #endif
 #if PLATFORM(X11)
-            gSharedEGLDisplay = eglGetDisplay(GLContext::sharedX11Display());
+            gSharedEGLDisplay = eglGetDisplay(downcast<PlatformDisplayX11>(sharedDisplay).native());
 #else
             gSharedEGLDisplay = eglGetDisplay(EGL_DEFAULT_DISPLAY);
 #endif
@@ -186,7 +189,8 @@
     if (!eglGetConfigAttrib(display, config, EGL_DEPTH_SIZE, &depth))
         return nullptr;
 
-    Pixmap pixmap = XCreatePixmap(sharedX11Display(), DefaultRootWindow(sharedX11Display()), 1, 1, depth);
+    Display* x11Display = downcast<PlatformDisplayX11>(PlatformDisplay::sharedDisplay()).native();
+    Pixmap pixmap = XCreatePixmap(x11Display, DefaultRootWindow(x11Display), 1, 1, depth);
     if (!pixmap)
         return nullptr;
 

Modified: trunk/Source/WebCore/platform/graphics/glx/GLContextGLX.cpp (183730 => 183731)


--- trunk/Source/WebCore/platform/graphics/glx/GLContextGLX.cpp	2015-05-03 10:14:55 UTC (rev 183730)
+++ trunk/Source/WebCore/platform/graphics/glx/GLContextGLX.cpp	2015-05-03 15:20:34 UTC (rev 183731)
@@ -22,6 +22,7 @@
 #if USE(GLX)
 #include "GraphicsContext3D.h"
 #include "OpenGLShims.h"
+#include "PlatformDisplayX11.h"
 #include <GL/glx.h>
 #include <cairo.h>
 
@@ -33,7 +34,7 @@
 
 std::unique_ptr<GLContextGLX> GLContextGLX::createWindowContext(XID window, GLContext* sharingContext)
 {
-    Display* display = sharedX11Display();
+    Display* display = downcast<PlatformDisplayX11>(PlatformDisplay::sharedDisplay()).native();
     XWindowAttributes attributes;
     if (!XGetWindowAttributes(display, window, &attributes))
         return nullptr;
@@ -72,7 +73,7 @@
     };
 
     int returnedElements;
-    Display* display = sharedX11Display();
+    Display* display = downcast<PlatformDisplayX11>(PlatformDisplay::sharedDisplay()).native();
     GLXFBConfig* configs = glXChooseFBConfig(display, 0, fbConfigAttributes, &returnedElements);
     if (!returnedElements) {
         XFree(configs);
@@ -112,7 +113,7 @@
         0
     };
 
-    Display* display = sharedX11Display();
+    Display* display = downcast<PlatformDisplayX11>(PlatformDisplay::sharedDisplay()).native();
     XVisualInfo* visualInfo = glXChooseVisual(display, DefaultScreen(display), visualAttributes);
     if (!visualInfo)
         return nullptr;
@@ -142,9 +143,6 @@
 
 std::unique_ptr<GLContextGLX> GLContextGLX::createContext(XID window, GLContext* sharingContext)
 {
-    if (!sharedX11Display())
-        return nullptr;
-
     static bool initialized = false;
     static bool success = true;
     if (!initialized) {
@@ -191,24 +189,25 @@
     if (m_cairoDevice)
         cairo_device_destroy(m_cairoDevice);
 
+    Display* display = downcast<PlatformDisplayX11>(PlatformDisplay::sharedDisplay()).native();
     if (m_context) {
         // This may be necessary to prevent crashes with NVidia's closed source drivers. Originally
         // from Mozilla's 3D canvas implementation at: http://bitbucket.org/ilmari/canvas3d/
         glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
-        glXMakeCurrent(sharedX11Display(), None, None);
-        glXDestroyContext(sharedX11Display(), m_context);
+        glXMakeCurrent(display, None, None);
+        glXDestroyContext(display, m_context);
     }
 
     if (m_pbuffer) {
-        glXDestroyPbuffer(sharedX11Display(), m_pbuffer);
+        glXDestroyPbuffer(display, m_pbuffer);
         m_pbuffer = 0;
     }
     if (m_glxPixmap) {
-        glXDestroyGLXPixmap(sharedX11Display(), m_glxPixmap);
+        glXDestroyGLXPixmap(display, m_glxPixmap);
         m_glxPixmap = 0;
     }
     if (m_pixmap) {
-        XFreePixmap(sharedX11Display(), m_pixmap);
+        XFreePixmap(display, m_pixmap);
         m_pixmap = 0;
     }
 }
@@ -226,7 +225,8 @@
     int x, y;
     Window rootWindow;
     unsigned int width, height, borderWidth, depth;
-    if (!XGetGeometry(sharedX11Display(), m_window, &rootWindow, &x, &y, &width, &height, &borderWidth, &depth))
+    Display* display = downcast<PlatformDisplayX11>(PlatformDisplay::sharedDisplay()).native();
+    if (!XGetGeometry(display, m_window, &rootWindow, &x, &y, &width, &height, &borderWidth, &depth))
         return IntSize();
 
     return IntSize(width, height);
@@ -240,19 +240,20 @@
     if (glXGetCurrentContext() == m_context)
         return true;
 
+    Display* display = downcast<PlatformDisplayX11>(PlatformDisplay::sharedDisplay()).native();
     if (m_window)
-        return glXMakeCurrent(sharedX11Display(), m_window, m_context);
+        return glXMakeCurrent(display, m_window, m_context);
 
     if (m_pbuffer)
-        return glXMakeCurrent(sharedX11Display(), m_pbuffer, m_context);
+        return glXMakeCurrent(display, m_pbuffer, m_context);
 
-    return ::glXMakeCurrent(sharedX11Display(), m_glxPixmap, m_context);
+    return ::glXMakeCurrent(display, m_glxPixmap, m_context);
 }
 
 void GLContextGLX::swapBuffers()
 {
     if (m_window)
-        glXSwapBuffers(sharedX11Display(), m_window);
+        glXSwapBuffers(downcast<PlatformDisplayX11>(PlatformDisplay::sharedDisplay()).native(), m_window);
 }
 
 void GLContextGLX::waitNative()
@@ -266,7 +267,7 @@
         return m_cairoDevice;
 
 #if ENABLE(ACCELERATED_2D_CANVAS)
-    m_cairoDevice = cairo_glx_device_create(sharedX11Display(), m_context);
+    m_cairoDevice = cairo_glx_device_create(downcast<PlatformDisplayX11>(PlatformDisplay::sharedDisplay()).native(), m_context);
 #endif
 
     return m_cairoDevice;

Modified: trunk/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.cpp (183730 => 183731)


--- trunk/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.cpp	2015-05-03 10:14:55 UTC (rev 183730)
+++ trunk/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.cpp	2015-05-03 15:20:34 UTC (rev 183731)
@@ -71,6 +71,12 @@
 #include <gst/gl/egl/gstgldisplay_egl.h>
 #endif
 
+#if PLATFORM(X11)
+#include "PlatformDisplayX11.h"
+#elif PLATFORM(WAYLAND)
+#include "PlatformDisplayWayland.h"
+#endif
+
 // gstglapi.h may include eglplatform.h and it includes X.h, which
 // defines None, breaking MediaPlayer::None enum
 #if PLATFORM(X11) && GST_GL_HAVE_PLATFORM_EGL
@@ -228,12 +234,11 @@
         return true;
 
     if (!m_glDisplay) {
+        const auto& sharedDisplay = PlatformDisplay::sharedDisplay();
 #if PLATFORM(X11)
-        Display* display = GLContext::sharedX11Display();
-        m_glDisplay = GST_GL_DISPLAY(gst_gl_display_x11_new_with_display(display));
+        m_glDisplay = GST_GL_DISPLAY(gst_gl_display_x11_new_with_display(downcast<PlatformDisplayX11>(sharedDisplay).native()));
 #elif PLATFORM(WAYLAND)
-        EGLDisplay display = WaylandDisplay::instance()->eglDisplay();
-        m_glDisplay = GST_GL_DISPLAY(gst_gl_display_egl_new_with_egl_display(display));
+        m_glDisplay = GST_GL_DISPLAY(gst_gl_display_egl_new_with_egl_display(downcast<PlatformDisplayWayland>(sharedDisplay).native()));
 #endif
     }
 

Modified: trunk/Source/WebCore/platform/graphics/surfaces/glx/X11Helper.cpp (183730 => 183731)


--- trunk/Source/WebCore/platform/graphics/surfaces/glx/X11Helper.cpp	2015-05-03 10:14:55 UTC (rev 183730)
+++ trunk/Source/WebCore/platform/graphics/surfaces/glx/X11Helper.cpp	2015-05-03 15:20:34 UTC (rev 183731)
@@ -26,6 +26,8 @@
 #include "config.h"
 #include "X11Helper.h"
 
+#include "PlatformDisplayX11.h"
+
 namespace WebCore {
 
 // Used for handling XError.
@@ -53,25 +55,6 @@
     return 0;
 }
 
-struct DisplayConnection {
-    DisplayConnection()
-    {
-        m_display = XOpenDisplay(0);
-
-        if (!m_display)
-            LOG_ERROR("Failed to make connection with X");
-    }
-
-    ~DisplayConnection()
-    {
-        XCloseDisplay(m_display);
-    }
-
-    Display* display() { return m_display; }
-private:
-    Display* m_display;
-};
-
 struct OffScreenRootWindow {
 
     OffScreenRootWindow()
@@ -331,9 +314,7 @@
 
 Display* X11Helper::nativeDisplay()
 {
-    // Display connection will only be broken at program shutdown.
-    static DisplayConnection displayConnection;
-    return displayConnection.display();
+    return downcast<PlatformDisplayX11>(PlatformDisplay::sharedDisplay()).native();
 }
 
 Window X11Helper::offscreenRootWindow()

Copied: trunk/Source/WebCore/platform/graphics/wayland/PlatformDisplayWayland.cpp (from rev 183730, trunk/Source/WebCore/platform/graphics/wayland/WaylandDisplay.cpp) (0 => 183731)


--- trunk/Source/WebCore/platform/graphics/wayland/PlatformDisplayWayland.cpp	                        (rev 0)
+++ trunk/Source/WebCore/platform/graphics/wayland/PlatformDisplayWayland.cpp	2015-05-03 15:20:34 UTC (rev 183731)
@@ -0,0 +1,135 @@
+/*
+ * Copyright (C) 2014 Igalia S.L.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "PlatformDisplayWayland.h"
+
+#if PLATFORM(WAYLAND)
+
+#include "GLContextEGL.h"
+#include "WaylandSurface.h"
+#include <cstring>
+#include <glib.h>
+
+namespace WebCore {
+
+const struct wl_registry_listener PlatformDisplayWayland::m_registryListener = {
+    PlatformDisplayWayland::globalCallback,
+    PlatformDisplayWayland::globalRemoveCallback
+};
+
+void PlatformDisplayWayland::globalCallback(void* data, struct wl_registry* registry, uint32_t name, const char* interface, uint32_t)
+{
+    auto display = static_cast<PlatformDisplayWayland*>(data);
+    if (!std::strcmp(interface, "wl_compositor"))
+        display->m_compositor = static_cast<struct wl_compositor*>(wl_registry_bind(registry, name, &wl_compositor_interface, 1));
+    else if (!std::strcmp(interface, "wl_webkitgtk"))
+        display->m_webkitgtk = static_cast<struct wl_webkitgtk*>(wl_registry_bind(registry, name, &wl_webkitgtk_interface, 1));
+}
+
+void PlatformDisplayWayland::globalRemoveCallback(void*, struct wl_registry*, uint32_t)
+{
+    // FIXME: if this can happen without the UI Process getting shut down
+    // we should probably destroy our cached display instance.
+}
+
+std::unique_ptr<PlatformDisplayWayland> PlatformDisplayWayland::create()
+{
+    struct wl_display* wlDisplay = wl_display_connect("webkitgtk-wayland-compositor-socket");
+    if (!wlDisplay)
+        return nullptr;
+
+    auto display = std::make_unique<PlatformDisplayWayland>(wlDisplay);
+    if (!display->isInitialized())
+        return nullptr;
+
+    return WTF::move(display);
+}
+
+PlatformDisplayWayland::PlatformDisplayWayland(struct wl_display* wlDisplay)
+    : m_display(wlDisplay)
+    , m_registry(wl_display_get_registry(m_display))
+    , m_eglConfigChosen(false)
+{
+    wl_registry_add_listener(m_registry, &m_registryListener, this);
+    wl_display_roundtrip(m_display);
+
+    static const EGLint configAttributes[] = {
+        EGL_SURFACE_TYPE, EGL_WINDOW_BIT,
+        EGL_RED_SIZE, 1,
+        EGL_GREEN_SIZE, 1,
+        EGL_BLUE_SIZE, 1,
+        EGL_ALPHA_SIZE, 1,
+        EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,
+        EGL_NONE
+    };
+
+    m_eglDisplay = eglGetDisplay(m_display);
+    if (m_eglDisplay == EGL_NO_DISPLAY) {
+        g_warning("PlatformDisplayWayland initialization: failed to acquire EGL display.");
+        return;
+    }
+
+    if (eglInitialize(m_eglDisplay, 0, 0) == EGL_FALSE) {
+        g_warning("PlatformDisplayWayland initialization: failed to initialize the EGL display.");
+        return;
+    }
+
+    if (eglBindAPI(EGL_OPENGL_ES_API) == EGL_FALSE) {
+        g_warning("PlatformDisplayWayland initialization: failed to set EGL_OPENGL_ES_API as the rendering API.");
+        return;
+    }
+
+    EGLint numberOfConfigs;
+    if (!eglChooseConfig(m_eglDisplay, configAttributes, &m_eglConfig, 1, &numberOfConfigs) || numberOfConfigs != 1) {
+        g_warning("PlatformDisplayWayland initialization: failed to find the desired EGL configuration.");
+        return;
+    }
+
+    m_eglConfigChosen = true;
+}
+
+std::unique_ptr<WaylandSurface> PlatformDisplayWayland::createSurface(const IntSize& size, int widgetId)
+{
+    struct wl_surface* wlSurface = wl_compositor_create_surface(m_compositor);
+    // We keep the minimum size at 1x1px since Mesa returns null values in wl_egl_window_create() for zero width or height.
+    EGLNativeWindowType nativeWindow = wl_egl_window_create(wlSurface, std::max(1, size.width()), std::max(1, size.height()));
+
+    wl_webkitgtk_set_surface_for_widget(m_webkitgtk, wlSurface, widgetId);
+    wl_display_roundtrip(m_display);
+
+    return std::make_unique<WaylandSurface>(wlSurface, nativeWindow);
+}
+
+std::unique_ptr<GLContextEGL> PlatformDisplayWayland::createSharingGLContext()
+{
+    struct wl_surface* wlSurface = wl_compositor_create_surface(m_compositor);
+    EGLNativeWindowType nativeWindow = wl_egl_window_create(wlSurface, 1, 1);
+    return GLContextEGL::createWindowContext(nativeWindow, nullptr);
+}
+
+} // namespace WebCore
+
+#endif // PLATFORM(WAYLAND)

Copied: trunk/Source/WebCore/platform/graphics/wayland/PlatformDisplayWayland.h (from rev 183730, trunk/Source/WebCore/platform/graphics/wayland/WaylandDisplay.h) (0 => 183731)


--- trunk/Source/WebCore/platform/graphics/wayland/PlatformDisplayWayland.h	                        (rev 0)
+++ trunk/Source/WebCore/platform/graphics/wayland/PlatformDisplayWayland.h	2015-05-03 15:20:34 UTC (rev 183731)
@@ -0,0 +1,80 @@
+/*
+ * Copyright (C) 2014 Igalia S.L.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef  PlatformDisplayWayland_h
+#define  PlatformDisplayWayland_h
+
+#if PLATFORM(WAYLAND)
+
+#include "PlatformDisplay.h"
+#include "WebKitGtkWaylandClientProtocol.h"
+#include <memory>
+#include <wayland-client.h>
+#include <wayland-egl.h>
+#include <EGL/egl.h>
+
+namespace WebCore {
+
+class GLContextEGL;
+class IntSize;
+class WaylandSurface;
+
+class PlatformDisplayWayland final: public PlatformDisplay {
+public:
+    static std::unique_ptr<PlatformDisplayWayland> create();
+    virtual ~PlatformDisplayWayland();
+
+    struct wl_display* native() const { return m_display; }
+    EGLDisplay eglDisplay() const { return m_eglDisplay; }
+
+    std::unique_ptr<WaylandSurface> createSurface(const IntSize&, int widgetID);
+
+    std::unique_ptr<GLContextEGL> createSharingGLContext();
+
+private:
+    static const struct wl_registry_listener m_registryListener;
+    static void globalCallback(void* data, struct wl_registry*, uint32_t name, const char* interface, uint32_t version);
+    static void globalRemoveCallback(void* data, struct wl_registry*, uint32_t name);
+
+    PlatformDisplayWayland(struct wl_display*);
+    bool isInitialized() { return m_compositor && m_webkitgtk && m_eglDisplay != EGL_NO_DISPLAY && m_eglConfigChosen; }
+
+    Type type() const override { return PlatformDisplay::Type::Wayland; }
+
+    struct wl_display* m_display;
+    struct wl_registry* m_registry;
+    struct wl_compositor* m_compositor;
+    struct wl_webkitgtk* m_webkitgtk;
+
+    EGLDisplay m_eglDisplay;
+    EGLConfig m_eglConfig;
+    bool m_eglConfigChosen;
+};
+
+} // namespace WebCore
+
+#endif // PLATFORM(WAYLAND)
+
+#endif // PlatformDisplayWayland_h

Deleted: trunk/Source/WebCore/platform/graphics/wayland/WaylandDisplay.cpp (183730 => 183731)


--- trunk/Source/WebCore/platform/graphics/wayland/WaylandDisplay.cpp	2015-05-03 10:14:55 UTC (rev 183730)
+++ trunk/Source/WebCore/platform/graphics/wayland/WaylandDisplay.cpp	2015-05-03 15:20:34 UTC (rev 183731)
@@ -1,143 +0,0 @@
-/*
- * Copyright (C) 2014 Igalia S.L.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "WaylandDisplay.h"
-
-#if PLATFORM(WAYLAND)
-
-#include "GLContextEGL.h"
-#include "WaylandSurface.h"
-#include <cstring>
-#include <glib.h>
-
-namespace WebCore {
-
-const struct wl_registry_listener WaylandDisplay::m_registryListener = {
-    WaylandDisplay::globalCallback,
-    WaylandDisplay::globalRemoveCallback
-};
-
-void WaylandDisplay::globalCallback(void* data, struct wl_registry* registry, uint32_t name, const char* interface, uint32_t)
-{
-    auto display = static_cast<WaylandDisplay*>(data);
-    if (!std::strcmp(interface, "wl_compositor"))
-        display->m_compositor = static_cast<struct wl_compositor*>(wl_registry_bind(registry, name, &wl_compositor_interface, 1));
-    else if (!std::strcmp(interface, "wl_webkitgtk"))
-        display->m_webkitgtk = static_cast<struct wl_webkitgtk*>(wl_registry_bind(registry, name, &wl_webkitgtk_interface, 1));
-}
-
-void WaylandDisplay::globalRemoveCallback(void*, struct wl_registry*, uint32_t)
-{
-    // FIXME: if this can happen without the UI Process getting shut down
-    // we should probably destroy our cached display instance.
-}
-
-WaylandDisplay* WaylandDisplay::instance()
-{
-    static WaylandDisplay* display = nullptr;
-    static bool initialized = false;
-    if (initialized)
-        return display;
-
-    initialized = true;
-    struct wl_display* wlDisplay = wl_display_connect("webkitgtk-wayland-compositor-socket");
-    if (!wlDisplay)
-        return nullptr;
-
-    display = new WaylandDisplay(wlDisplay);
-    if (!display->isInitialized()) {
-        delete display;
-        return nullptr;
-    }
-
-    return display;
-}
-
-WaylandDisplay::WaylandDisplay(struct wl_display* wlDisplay)
-    : m_display(wlDisplay)
-    , m_registry(wl_display_get_registry(m_display))
-    , m_eglConfigChosen(false)
-{
-    wl_registry_add_listener(m_registry, &m_registryListener, this);
-    wl_display_roundtrip(m_display);
-
-    static const EGLint configAttributes[] = {
-        EGL_SURFACE_TYPE, EGL_WINDOW_BIT,
-        EGL_RED_SIZE, 1,
-        EGL_GREEN_SIZE, 1,
-        EGL_BLUE_SIZE, 1,
-        EGL_ALPHA_SIZE, 1,
-        EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,
-        EGL_NONE
-    };
-
-    m_eglDisplay = eglGetDisplay(m_display);
-    if (m_eglDisplay == EGL_NO_DISPLAY) {
-        g_warning("WaylandDisplay initialization: failed to acquire EGL display.");
-        return;
-    }
-
-    if (eglInitialize(m_eglDisplay, 0, 0) == EGL_FALSE) {
-        g_warning("WaylandDisplay initialization: failed to initialize the EGL display.");
-        return;
-    }
-
-    if (eglBindAPI(EGL_OPENGL_ES_API) == EGL_FALSE) {
-        g_warning("WaylandDisplay initialization: failed to set EGL_OPENGL_ES_API as the rendering API.");
-        return;
-    }
-
-    EGLint numberOfConfigs;
-    if (!eglChooseConfig(m_eglDisplay, configAttributes, &m_eglConfig, 1, &numberOfConfigs) || numberOfConfigs != 1) {
-        g_warning("WaylandDisplay initialization: failed to find the desired EGL configuration.");
-        return;
-    }
-
-    m_eglConfigChosen = true;
-}
-
-std::unique_ptr<WaylandSurface> WaylandDisplay::createSurface(const IntSize& size, int widgetId)
-{
-    struct wl_surface* wlSurface = wl_compositor_create_surface(m_compositor);
-    // We keep the minimum size at 1x1px since Mesa returns null values in wl_egl_window_create() for zero width or height.
-    EGLNativeWindowType nativeWindow = wl_egl_window_create(wlSurface, std::max(1, size.width()), std::max(1, size.height()));
-
-    wl_webkitgtk_set_surface_for_widget(m_webkitgtk, wlSurface, widgetId);
-    wl_display_roundtrip(m_display);
-
-    return std::make_unique<WaylandSurface>(wlSurface, nativeWindow);
-}
-
-std::unique_ptr<GLContextEGL> WaylandDisplay::createSharingGLContext()
-{
-    struct wl_surface* wlSurface = wl_compositor_create_surface(m_compositor);
-    EGLNativeWindowType nativeWindow = wl_egl_window_create(wlSurface, 1, 1);
-    return GLContextEGL::createWindowContext(nativeWindow, nullptr);
-}
-
-} // namespace WebCore
-
-#endif // PLATFORM(WAYLAND)

Deleted: trunk/Source/WebCore/platform/graphics/wayland/WaylandDisplay.h (183730 => 183731)


--- trunk/Source/WebCore/platform/graphics/wayland/WaylandDisplay.h	2015-05-03 10:14:55 UTC (rev 183730)
+++ trunk/Source/WebCore/platform/graphics/wayland/WaylandDisplay.h	2015-05-03 15:20:34 UTC (rev 183731)
@@ -1,77 +0,0 @@
-/*
- * Copyright (C) 2014 Igalia S.L.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef  WaylandDisplay_h
-#define  WaylandDisplay_h
-
-#if PLATFORM(WAYLAND)
-
-#include "WebKitGtkWaylandClientProtocol.h"
-#include <memory>
-#include <wayland-client.h>
-
-#include <wayland-egl.h>
-#include <EGL/egl.h>
-
-namespace WebCore {
-
-class GLContextEGL;
-class IntSize;
-class WaylandSurface;
-
-class WaylandDisplay {
-public:
-    static WaylandDisplay* instance();
-
-    struct wl_display* nativeDisplay() const { return m_display; }
-    EGLDisplay eglDisplay() const { return m_eglDisplay; }
-
-    std::unique_ptr<WaylandSurface> createSurface(const IntSize&, int widgetID);
-
-    std::unique_ptr<GLContextEGL> createSharingGLContext();
-
-private:
-    static const struct wl_registry_listener m_registryListener;
-    static void globalCallback(void* data, struct wl_registry*, uint32_t name, const char* interface, uint32_t version);
-    static void globalRemoveCallback(void* data, struct wl_registry*, uint32_t name);
-
-    WaylandDisplay(struct wl_display*);
-    bool isInitialized() { return m_compositor && m_webkitgtk && m_eglDisplay != EGL_NO_DISPLAY && m_eglConfigChosen; }
-
-    struct wl_display* m_display;
-    struct wl_registry* m_registry;
-    struct wl_compositor* m_compositor;
-    struct wl_webkitgtk* m_webkitgtk;
-
-    EGLDisplay m_eglDisplay;
-    EGLConfig m_eglConfig;
-    bool m_eglConfigChosen;
-};
-
-} // namespace WebCore
-
-#endif // PLATFORM(WAYLAND)
-
-#endif // WaylandDisplay_h

Added: trunk/Source/WebCore/platform/graphics/x11/PlatformDisplayX11.cpp (0 => 183731)


--- trunk/Source/WebCore/platform/graphics/x11/PlatformDisplayX11.cpp	                        (rev 0)
+++ trunk/Source/WebCore/platform/graphics/x11/PlatformDisplayX11.cpp	2015-05-03 15:20:34 UTC (rev 183731)
@@ -0,0 +1,55 @@
+/*
+ * Copyright (C) 2015 Igalia S.L
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1.  Redistributions of source code must retain the above copyright
+ *     notice, this list of conditions and the following disclaimer.
+ * 2.  Redistributions in binary form must reproduce the above copyright
+ *     notice, this list of conditions and the following disclaimer in the
+ *     documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "PlatformDisplayX11.h"
+
+#if PLATFORM(X11)
+#include <X11/Xlib.h>
+
+namespace WebCore {
+
+PlatformDisplayX11::PlatformDisplayX11()
+    : m_display(XOpenDisplay(nullptr))
+    , m_ownedDisplay(true)
+{
+}
+
+PlatformDisplayX11::PlatformDisplayX11(Display* display)
+    : m_display(display)
+    , m_ownedDisplay(false)
+{
+}
+
+PlatformDisplayX11::~PlatformDisplayX11()
+{
+    if (m_ownedDisplay)
+        XCloseDisplay(m_display);
+}
+
+} // namespace WebCore
+
+#endif // PLATFORM(X11)
+

Added: trunk/Source/WebCore/platform/graphics/x11/PlatformDisplayX11.h (0 => 183731)


--- trunk/Source/WebCore/platform/graphics/x11/PlatformDisplayX11.h	                        (rev 0)
+++ trunk/Source/WebCore/platform/graphics/x11/PlatformDisplayX11.h	2015-05-03 15:20:34 UTC (rev 183731)
@@ -0,0 +1,58 @@
+/*
+ * Copyright (C) 2015 Igalia S.L
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1.  Redistributions of source code must retain the above copyright
+ *     notice, this list of conditions and the following disclaimer.
+ * 2.  Redistributions in binary form must reproduce the above copyright
+ *     notice, this list of conditions and the following disclaimer in the
+ *     documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef PlatformDisplayX11_h
+#define PlatformDisplayX11_h
+
+#if PLATFORM(X11)
+
+#include "PlatformDisplay.h"
+
+typedef struct _XDisplay Display;
+
+namespace WebCore {
+
+class PlatformDisplayX11 final : public PlatformDisplay {
+public:
+    PlatformDisplayX11();
+    PlatformDisplayX11(Display*);
+    virtual ~PlatformDisplayX11();
+
+    Display* native() const { return m_display; }
+
+private:
+    virtual Type type() const override { return PlatformDisplay::Type::X11; }
+
+    Display* m_display;
+    bool m_ownedDisplay;
+};
+
+} // namespace WebCore
+
+SPECIALIZE_TYPE_TRAITS_PLATFORM_DISPLAY(PlatformDisplayX11, X11)
+
+#endif // PLATFORM(X11)
+
+#endif // PlatformDisplayX11

Modified: trunk/Source/WebCore/platform/gtk/GtkUtilities.cpp (183730 => 183731)


--- trunk/Source/WebCore/platform/gtk/GtkUtilities.cpp	2015-05-03 10:14:55 UTC (rev 183730)
+++ trunk/Source/WebCore/platform/gtk/GtkUtilities.cpp	2015-05-03 15:20:34 UTC (rev 183731)
@@ -24,13 +24,6 @@
 #include <wtf/gobject/GUniquePtr.h>
 #include <wtf/gobject/GlibUtilities.h>
 
-#if PLATFORM(X11)
-#include <gdk/gdkx.h>
-#endif
-#if PLATFORM(WAYLAND) && !defined(GTK_API_VERSION_2)
-#include <gdk/gdkwayland.h>
-#endif
-
 namespace WebCore {
 
 IntPoint convertWidgetPointToScreenPoint(GtkWidget* widget, const IntPoint& point)
@@ -61,28 +54,6 @@
     return gtk_widget_is_toplevel(widget) && GTK_IS_WINDOW(widget) && !GTK_IS_OFFSCREEN_WINDOW(widget);
 }
 
-DisplaySystemType getDisplaySystemType()
-{
-#if defined(GTK_API_VERSION_2)
-    return DisplaySystemType::X11;
-#else
-    static DisplaySystemType type = [] {
-        GdkDisplay* display = gdk_display_manager_get_default_display(gdk_display_manager_get());
-#if PLATFORM(X11)
-        if (GDK_IS_X11_DISPLAY(display))
-            return DisplaySystemType::X11;
-#endif
-#if PLATFORM(WAYLAND)
-        if (GDK_IS_WAYLAND_DISPLAY(display))
-            return DisplaySystemType::Wayland;
-#endif
-        ASSERT_NOT_REACHED();
-        return DisplaySystemType::X11;
-    }();
-    return type;
-#endif
-}
-
 #if defined(DEVELOPMENT_BUILD)
 static CString topLevelPath()
 {

Modified: trunk/Source/WebCore/platform/gtk/GtkUtilities.h (183730 => 183731)


--- trunk/Source/WebCore/platform/gtk/GtkUtilities.h	2015-05-03 10:14:55 UTC (rev 183730)
+++ trunk/Source/WebCore/platform/gtk/GtkUtilities.h	2015-05-03 15:20:34 UTC (rev 183731)
@@ -28,13 +28,6 @@
 IntPoint convertWidgetPointToScreenPoint(GtkWidget*, const IntPoint&);
 bool widgetIsOnscreenToplevelWindow(GtkWidget*);
 
-enum class DisplaySystemType {
-    X11,
-    Wayland
-};
-
-DisplaySystemType getDisplaySystemType();
-
 #if defined(DEVELOPMENT_BUILD)
 CString webkitBuildDirectory();
 #endif

Modified: trunk/Source/WebKit2/ChangeLog (183730 => 183731)


--- trunk/Source/WebKit2/ChangeLog	2015-05-03 10:14:55 UTC (rev 183730)
+++ trunk/Source/WebKit2/ChangeLog	2015-05-03 15:20:34 UTC (rev 183731)
@@ -1,5 +1,23 @@
 2015-05-03  Carlos Garcia Campos  <[email protected]>
 
+        [GTK][EFL] Unify platform display handling
+        https://bugs.webkit.org/show_bug.cgi?id=144517
+
+        Reviewed by Martin Robinson.
+
+        * UIProcess/API/gtk/WebKitWebViewBase.cpp:
+        (webkitWebViewBaseRealize): Use PlatformDisplay::sharedDisplay()
+        to checkt the display type.
+        (webkitWebViewBaseCreateWebPage): Ditto.
+        * UIProcess/cairo/BackingStoreCairo.cpp:
+        (WebKit::BackingStore::createBackend): Pass the native X11 shared
+        display to BackingStoreBackendCairoX11.
+        * WebProcess/Plugins/Netscape/x11/NetscapePluginX11.cpp:
+        (WebKit::NetscapePlugin::x11HostDisplay): Return the native X11
+        shared display.
+
+2015-05-03  Carlos Garcia Campos  <[email protected]>
+
         Unreviewed. Fix Debug build with NETWORK_CACHE enabled and CACHE_PARTITIONING disabled.
 
         * NetworkProcess/cache/NetworkCache.cpp:

Modified: trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewBase.cpp (183730 => 183731)


--- trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewBase.cpp	2015-05-03 10:14:55 UTC (rev 183730)
+++ trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewBase.cpp	2015-05-03 15:20:34 UTC (rev 183731)
@@ -54,6 +54,7 @@
 #include <WebCore/GtkVersioning.h>
 #include <WebCore/NotImplemented.h>
 #include <WebCore/PasteboardHelper.h>
+#include <WebCore/PlatformDisplay.h>
 #include <WebCore/RefPtrCairo.h>
 #include <WebCore/Region.h>
 #include <gdk/gdk.h>
@@ -320,8 +321,7 @@
     WebKitWebViewBasePrivate* priv = webView->priv;
 
 #if USE(REDIRECTED_XCOMPOSITE_WINDOW)
-    GdkDisplay* display = gdk_display_manager_get_default_display(gdk_display_manager_get());
-    if (GDK_IS_X11_DISPLAY(display)) {
+    if (PlatformDisplay::sharedDisplay().type() == PlatformDisplay::Type::X11) {
         priv->redirectedWindow = RedirectedXCompositeWindow::create(
             gtk_widget_get_parent_window(widget),
             [webView] {
@@ -1133,8 +1133,7 @@
 #if PLATFORM(WAYLAND)
     // FIXME: Accelerated compositing under Wayland is not yet supported.
     // https://bugs.webkit.org/show_bug.cgi?id=115803
-    GdkDisplay* display = gdk_display_manager_get_default_display(gdk_display_manager_get());
-    if (GDK_IS_WAYLAND_DISPLAY(display))
+    if (PlatformDisplay::sharedDisplay().type() == PlatformDisplay::Type::Wayland)
         preferences->setAcceleratedCompositingEnabled(false);
 #endif
 

Modified: trunk/Source/WebKit2/UIProcess/cairo/BackingStoreCairo.cpp (183730 => 183731)


--- trunk/Source/WebKit2/UIProcess/cairo/BackingStoreCairo.cpp	2015-05-03 10:14:55 UTC (rev 183730)
+++ trunk/Source/WebKit2/UIProcess/cairo/BackingStoreCairo.cpp	2015-05-03 15:20:34 UTC (rev 183731)
@@ -38,6 +38,7 @@
 
 #if PLATFORM(GTK) && PLATFORM(X11) && defined(GDK_WINDOWING_X11)
 #include <WebCore/BackingStoreBackendCairoX11.h>
+#include <WebCore/PlatformDisplayX11.h>
 #include <gdk/gdkx.h>
 #endif
 
@@ -48,11 +49,12 @@
 std::unique_ptr<BackingStoreBackendCairo> BackingStore::createBackend()
 {
 #if PLATFORM(GTK) && PLATFORM(X11)
-    GdkDisplay* display = gdk_display_manager_get_default_display(gdk_display_manager_get());
-    if (GDK_IS_X11_DISPLAY(display)) {
+    const auto& sharedDisplay = PlatformDisplay::sharedDisplay();
+    if (is<PlatformDisplayX11>(sharedDisplay)) {
         GdkVisual* visual = gtk_widget_get_visual(m_webPageProxy.viewWidget());
         GdkScreen* screen = gdk_visual_get_screen(visual);
-        return std::make_unique<BackingStoreBackendCairoX11>(GDK_SCREEN_XDISPLAY(screen), GDK_WINDOW_XID(gdk_screen_get_root_window(screen)),
+        ASSERT(downcast<PlatformDisplayX11>(sharedDisplay).native() == GDK_SCREEN_XDISPLAY(screen));
+        return std::make_unique<BackingStoreBackendCairoX11>(downcast<PlatformDisplayX11>(sharedDisplay).native(), GDK_WINDOW_XID(gdk_screen_get_root_window(screen)),
             GDK_VISUAL_XVISUAL(visual), gdk_visual_get_depth(visual), m_size, m_deviceScaleFactor);
     }
 #endif

Modified: trunk/Source/WebKit2/WebProcess/Plugins/Netscape/x11/NetscapePluginX11.cpp (183730 => 183731)


--- trunk/Source/WebKit2/WebProcess/Plugins/Netscape/x11/NetscapePluginX11.cpp	2015-05-03 10:14:55 UTC (rev 183730)
+++ trunk/Source/WebKit2/WebProcess/Plugins/Netscape/x11/NetscapePluginX11.cpp	2015-05-03 15:20:34 UTC (rev 183731)
@@ -33,6 +33,7 @@
 #include "WebEvent.h"
 #include <WebCore/GraphicsContext.h>
 #include <WebCore/NotImplemented.h>
+#include <WebCore/PlatformDisplayX11.h>
 
 #if PLATFORM(GTK)
 #include <gtk/gtk.h>
@@ -103,13 +104,7 @@
 
 Display* NetscapePlugin::x11HostDisplay()
 {
-#if PLATFORM(GTK)
-    return GDK_DISPLAY_XDISPLAY(gdk_display_get_default());
-#elif PLATFORM(EFL) && defined(HAVE_ECORE_X)
-    return static_cast<Display*>(ecore_x_display_get());
-#else
-    return 0;
-#endif
+    return downcast<PlatformDisplayX11>(PlatformDisplay::sharedDisplay()).native();
 }
 
 #if PLATFORM(GTK)
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to