<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[205116] trunk/Source</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/205116">205116</a></dd>
<dt>Author</dt> <dd>carlosgc@webkit.org</dd>
<dt>Date</dt> <dd>2016-08-29 02:33:40 -0700 (Mon, 29 Aug 2016)</dd>
</dl>

<h3>Log Message</h3>
<pre>[GTK] Accelerated compositing does not work in Wayland
https://bugs.webkit.org/show_bug.cgi?id=115803

Reviewed by Michael Catanzaro.

Source/WebCore:

The Wayland implementation in WebKit2 uses a nested display running in the UI process so that GL contexts created
in the web process need to be created in the nested display. We currently have a shared platform display that
should represent the connection to the actual display all applications connect to. This patch refactors the
GLContext API to ensure that GL contexts are always attached to a particular platform display. The create
methods receive an optional PlatformDisplay that will be used as the display of all GL operations of the created
GL context. The sharing GL context should also share the same display, it can't be global to the process, but to
the display, so it's now created on demand by the PlatformDisplay. In addition to the global shared display,
it's now possible to set a shared display for compositing that can be used when creating GL contexts. This makes
it possible to use a different display for compositing, connected to the nested display in wayland, even in non
wayland environments.
The patch also adds support for surfaceless EGL contexts that can be used for offscreen contexts. It also adds
support for offscreen wayland contexts, as a fallback in wayland in case surfaceless is not supported.
Some wayland code that is specific to the WebKit2 implementation has been moved to the WebKit2 layer.

* PlatformGTK.cmake:
* platform/graphics/GLContext.cpp:
(WebCore::initializeOpenGLShimsIfNeeded):
(WebCore::GLContext::createContextForWindow):
(WebCore::GLContext::createOffscreenContext):
(WebCore::GLContext::createSharingContext):
(WebCore::GLContext::GLContext):
(WebCore::GLContext::~GLContext):
(WebCore::GLContext::current):
(WebCore::activeContextList): Deleted.
* platform/graphics/GLContext.h:
(WebCore::GLContext::display):
* platform/graphics/GraphicsContext3DPrivate.cpp:
(WebCore::GraphicsContext3DPrivate::GraphicsContext3DPrivate):
(WebCore::GraphicsContext3DPrivate::platformContext):
(WebCore::GraphicsContext3DPrivate::paintToTextureMapper):
* platform/graphics/PlatformDisplay.cpp:
(WebCore::PlatformDisplay::createPlatformDisplay): Always use the default wayland display created by GTK+ for
the global shared display.
(WebCore::PlatformDisplay::sharedDisplayForCompositing):
(WebCore::PlatformDisplay::setSharedDisplayForCompositing):
(WebCore::PlatformDisplay::sharingGLContext):
(WebCore::eglDisplays): Helper HashSet to keep track of all PlatformDisplays with an EGL display intialized to
properly termimate them at exit.
(WebCore::PlatformDisplay::initializeEGLDisplay): Remove eglBindAPI() from display initialization, since it's
not a display initialization and it's thread specific, so it needs to be called on every thread where EGL is used.
(WebCore::PlatformDisplay::terminateEGLDisplay):
(WebCore::PlatformDisplay::eglDisplay): Deleted.
* platform/graphics/PlatformDisplay.h:
* platform/graphics/cairo/ImageBufferCairo.cpp:
(WebCore::ImageBufferData::~ImageBufferData):
(WebCore::ImageBufferData::createCompositorBuffer):
(WebCore::ImageBufferData::swapBuffersIfNeeded):
(WebCore::ImageBufferData::createCairoGLSurface):
(WebCore::ImageBufferData::paintToTextureMapper):
(WebCore::ImageBuffer::copyToPlatformTexture):
* platform/graphics/egl/GLContextEGL.cpp:
(WebCore::GLContextEGL::getEGLConfig):
(WebCore::GLContextEGL::createWindowContext):
(WebCore::GLContextEGL::createPbufferContext):
(WebCore::GLContextEGL::createSurfacelessContext):
(WebCore::GLContextEGL::createPixmapContext):
(WebCore::GLContextEGL::createWaylandContext):
(WebCore::GLContextEGL::createContext):
(WebCore::GLContextEGL::createSharingContext):
(WebCore::GLContextEGL::GLContextEGL):
(WebCore::GLContextEGL::~GLContextEGL):
(WebCore::GLContextEGL::defaultFrameBufferSize):
(WebCore::GLContextEGL::makeContextCurrent):
(WebCore::GLContextEGL::swapBuffers):
(WebCore::GLContextEGL::cairoDevice):
* platform/graphics/egl/GLContextEGL.h:
* platform/graphics/glx/GLContextGLX.cpp:
(WebCore::GLContextGLX::createWindowContext):
(WebCore::GLContextGLX::createPbufferContext):
(WebCore::GLContextGLX::createPixmapContext):
(WebCore::GLContextGLX::createContext):
(WebCore::GLContextGLX::createSharingContext):
(WebCore::GLContextGLX::GLContextGLX):
(WebCore::GLContextGLX::~GLContextGLX):
(WebCore::GLContextGLX::defaultFrameBufferSize):
(WebCore::GLContextGLX::makeContextCurrent):
(WebCore::GLContextGLX::swapBuffers):
(WebCore::GLContextGLX::cairoDevice):
(WebCore::GLContextGLX::waitNative): Deleted.
* platform/graphics/glx/GLContextGLX.h:
* platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.cpp:
(WebCore::MediaPlayerPrivateGStreamerBase::ensureGstGLContext):
(WebCore::MediaPlayerPrivateGStreamerBase::nativeImageForCurrentTime):
* platform/graphics/wayland/PlatformDisplayWayland.cpp:
(WebCore::PlatformDisplayWayland::PlatformDisplayWayland):
(WebCore::PlatformDisplayWayland::~PlatformDisplayWayland):
(WebCore::PlatformDisplayWayland::initialize):
(WebCore::PlatformDisplayWayland::registryGlobal):
(WebCore::PlatformDisplayWayland::createSurface):
* platform/graphics/wayland/PlatformDisplayWayland.h:
(WebCore::PlatformDisplayWayland::native): Deleted.
* platform/graphics/wayland/WaylandEventSource.cpp: Removed.
* platform/graphics/wayland/WaylandSurface.cpp: Removed.
* platform/graphics/wayland/WebKitGtkWaylandClientProtocol.xml: Removed.
* platform/graphics/wayland/WlUniquePtr.h: Make it possible to use std::unique_ptr with Wayland objects.
(WebCore::WlPtrDeleter::operator()):

Source/WebKit/win:

Update to the new GLContext API.

* WebCoreSupport/AcceleratedCompositingContext.cpp:
(AcceleratedCompositingContext::initialize):
(AcceleratedCompositingContext::acceleratedCompositingAvailable):

Source/WebKit2:

This is the initial implementation of accelerated compositing support in Wayland for the GTK+ port. It's based
on previous patches written by Iago Toral, Žan Doberšek, Emanuele Aina and Emilio Pozuelo Monfort.

The existing WebKitGTK+ Wayland interface previously added for this to WebCore has been moved to the WebKit2
layer, since it's actually specific to WebKit2, and it's now actually used. The UI process runs a nested Wayland
compositor that web processes connect to. Web processes create a Wayland surface in the nested compositor for
the web page, and using the WebKitGTK+ Wayland protocol interface they tell the nested compositor the web page
associated to the surface. A Wayland window is created for that surface that is then used as the native window
handle for compositing. To communicate with the nested compositor and to ensure all GL operations happen in the
nested compositor display, the web process creates a Wayland display that connects to the nested compositor,
uses the WebKitGTK+ Wayland interface and it's set as the global shared display for compositing.

The nested Wayland compositor creates a new display with a unique name that is sent to the web processes at
start up. It implements the Wayland surface interface to handle the Wayland buffers created for every surface
and scheduling redraws on the web pages when updates are available. It uses the WebKitGTK+ Wayland interface to
associate the surfaces to a particular web page. A texture is created for every surface and updated with the
Wayland buffer contents using an EGLImageKHR and eglImageTargetTexture2d API.

To abstract the platform differences and avoid ifdefs as much as possible, new abstract classes have been added
to represent the surfaces used in accelerated compositing. AcceleratedSurface is used by the web process and
represents the surface where contents are rendered into. The X11 implementation is the redirected XComposite
window, and the Wayland implementation is equivalent to the previous Wayland surface added to WebCore but never
used. In the UI process the web view creates an abstract AcceleratedBackingStore that is used to render the
AcceleratedSurface into the web view using cairo. The X11 implementation creates the cairo surface for the
redirected XComposite window pixmap and uses XDamage extension to schedule redraws. The Wayland implementation
asks the nested Wayland compositor for the texture associated to the web view page.

Accelerated compositing is now always enabled by default in both X11 and Wayland, unless it's explicitly
disabled by the user using the WEBKIT_DISABLE_COMPOSITING_MODE environment variable, or if any extension or
feature required by X11 or Wayland implementations are not available.

* PlatformGTK.cmake:
* Shared/CoordinatedGraphics/threadedcompositor/ThreadedCompositor.cpp:
(WebKit::ThreadedCompositor::glContext): Pass the shared display for compositing to GLContext::createContextForWindow()
* Shared/WebProcessCreationParameters.cpp:
(WebKit::WebProcessCreationParameters::encode): Encode wayland compositor display name.
(WebKit::WebProcessCreationParameters::decode): Decode wayland compositor display name.
* Shared/WebProcessCreationParameters.h: Add wayland compositor display name initial parameter.
* UIProcess/API/gtk/WebKitWebViewBase.cpp:
(webkitWebViewBaseDispose):
(webkitWebViewBaseDraw):
(webkitWebViewBaseCreateWebPage):
(webkitWebViewBaseEnterAcceleratedCompositingMode):
(webkitWebViewBaseUpdateAcceleratedCompositingMode):
(webkitWebViewBaseExitAcceleratedCompositingMode):
(webkitWebViewBasePageClosed):
* UIProcess/WebProcessPool.cpp:
(WebKit::WebProcessPool::createNewWebProcess): Initialize the wayland compositor display name initial parameter.
* UIProcess/gtk/AcceleratedBackingStore.cpp: Added.
(WebKit::AcceleratedBackingStore::create):
(WebKit::AcceleratedBackingStore::AcceleratedBackingStore):
(WebKit::AcceleratedBackingStore::~AcceleratedBackingStore):
(WebKit::AcceleratedBackingStore::paint):
* UIProcess/gtk/AcceleratedBackingStore.h: Added.
(WebKit::AcceleratedBackingStore::update):
* UIProcess/gtk/AcceleratedBackingStoreWayland.cpp: Added.
(WebKit::AcceleratedBackingStoreWayland::create):
(WebKit::AcceleratedBackingStoreWayland::AcceleratedBackingStoreWayland):
(WebKit::AcceleratedBackingStoreWayland::~AcceleratedBackingStoreWayland):
(WebKit::AcceleratedBackingStoreWayland::paint):
* UIProcess/gtk/AcceleratedBackingStoreWayland.h: Added.
* UIProcess/gtk/AcceleratedBackingStoreX11.cpp: Added.
(WebKit::XDamageNotifier::singleton):
(WebKit::XDamageNotifier::add):
(WebKit::XDamageNotifier::remove):
(WebKit::XDamageNotifier::filterXDamageEvent):
(WebKit::XDamageNotifier::notify):
(WebKit::AcceleratedBackingStoreX11::create):
(WebKit::AcceleratedBackingStoreX11::AcceleratedBackingStoreX11):
(WebKit::AcceleratedBackingStoreX11::~AcceleratedBackingStoreX11):
(WebKit::AcceleratedBackingStoreX11::update):
(WebKit::AcceleratedBackingStoreX11::paint):
* UIProcess/gtk/AcceleratedBackingStoreX11.h: Added.
* UIProcess/gtk/WaylandCompositor.cpp: Added.
(WebKit::WaylandCompositor::singleton):
(WebKit::WaylandCompositor::Buffer::getOrCreate):
(WebKit::WaylandCompositor::Buffer::Buffer):
(WebKit::WaylandCompositor::Buffer::~Buffer):
(WebKit::WaylandCompositor::Buffer::destroyListenerCallback):
(WebKit::WaylandCompositor::Buffer::use):
(WebKit::WaylandCompositor::Buffer::unuse):
(WebKit::WaylandCompositor::Buffer::createImage):
(WebKit::WaylandCompositor::Buffer::size):
(WebKit::WaylandCompositor::Surface::Surface):
(WebKit::WaylandCompositor::Surface::~Surface):
(WebKit::WaylandCompositor::Surface::makePendingBufferCurrent):
(WebKit::WaylandCompositor::Surface::attachBuffer):
(WebKit::WaylandCompositor::Surface::requestFrame):
(WebKit::WaylandCompositor::Surface::prepareTextureForPainting):
(WebKit::WaylandCompositor::Surface::commit):
(WebKit::WaylandCompositor::initializeEGL):
(WebKit::createWaylandLoopSource):
(WebKit::WaylandCompositor::WaylandCompositor):
(WebKit::WaylandCompositor::getTexture):
(WebKit::WaylandCompositor::bindSurfaceToWebPage):
(WebKit::WaylandCompositor::registerWebPage):
(WebKit::WaylandCompositor::unregisterWebPage):
* UIProcess/gtk/WaylandCompositor.h: Added.
(WebKit::WaylandCompositor::Buffer::createWeakPtr):
(WebKit::WaylandCompositor::Surface::setWebPage):
(WebKit::WaylandCompositor::isRunning):
(WebKit::WaylandCompositor::displayName):
* UIProcess/gtk/WebPreferencesGtk.cpp:
(WebKit::WebPreferences::platformInitializeStore):
* UIProcess/gtk/XDamageNotifier.cpp: Removed.
* WebProcess/WebPage/CoordinatedGraphics/ThreadedCoordinatedLayerTreeHost.cpp:
(WebKit::ThreadedCoordinatedLayerTreeHost::ThreadedCoordinatedLayerTreeHost):
(WebKit::ThreadedCoordinatedLayerTreeHost::invalidate):
(WebKit::ThreadedCoordinatedLayerTreeHost::deviceOrPageScaleFactorChanged):
(WebKit::ThreadedCoordinatedLayerTreeHost::sizeDidChange):
* WebProcess/WebPage/CoordinatedGraphics/ThreadedCoordinatedLayerTreeHost.h:
* WebProcess/WebPage/gtk/AcceleratedSurface.cpp: Added.
(WebKit::AcceleratedSurface::create):
(WebKit::AcceleratedSurface::AcceleratedSurface):
(WebKit::AcceleratedSurface::~AcceleratedSurface):
(WebKit::AcceleratedSurface::resize):
* WebProcess/WebPage/gtk/AcceleratedSurface.h: Added.
(WebKit::AcceleratedSurface::window):
(WebKit::AcceleratedSurface::surfaceID):
* WebProcess/WebPage/gtk/AcceleratedSurfaceWayland.cpp: Added.
(WebKit::waylandCompositorDisplay):
(WebKit::AcceleratedSurfaceWayland::create):
(WebKit::AcceleratedSurfaceWayland::AcceleratedSurfaceWayland):
(WebKit::AcceleratedSurfaceWayland::~AcceleratedSurfaceWayland):
(WebKit::AcceleratedSurfaceWayland::resize):
* WebProcess/WebPage/gtk/AcceleratedSurfaceWayland.h: Added.
* WebProcess/WebPage/gtk/AcceleratedSurfaceX11.cpp: Renamed from Source/WebKit2/WebProcess/WebPage/gtk/RedirectedXCompositeWindow.cpp.
(WebKit::AcceleratedSurfaceX11::create):
(WebKit::AcceleratedSurfaceX11::AcceleratedSurfaceX11):
(WebKit::AcceleratedSurfaceX11::~AcceleratedSurfaceX11):
(WebKit::AcceleratedSurfaceX11::resize):
* WebProcess/WebPage/gtk/AcceleratedSurfaceX11.h: Renamed from Source/WebKit2/WebProcess/WebPage/gtk/RedirectedXCompositeWindow.h.
* WebProcess/WebPage/gtk/LayerTreeHostGtk.cpp:
(WebKit::LayerTreeHostGtk::LayerTreeHostGtk):
(WebKit::LayerTreeHostGtk::makeContextCurrent):
(WebKit::LayerTreeHostGtk::invalidate):
(WebKit::LayerTreeHostGtk::sizeDidChange):
(WebKit::LayerTreeHostGtk::deviceOrPageScaleFactorChanged):
(WebKit::LayerTreeHostGtk::RenderFrameScheduler::RenderFrameScheduler): Deleted.
* WebProcess/WebPage/gtk/LayerTreeHostGtk.h:
* WebProcess/WebProcess.cpp:
(WebKit::WebProcess::initializeWebProcess): Initialize the wayland compositor display name.
* WebProcess/WebProcess.h:
(WebKit::WebProcess::waylandCompositorDisplayName): Return the wayland compositor display name.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCorePlatformGTKcmake">trunk/Source/WebCore/PlatformGTK.cmake</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicsGLContextcpp">trunk/Source/WebCore/platform/graphics/GLContext.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicsGLContexth">trunk/Source/WebCore/platform/graphics/GLContext.h</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicsGraphicsContext3DPrivatecpp">trunk/Source/WebCore/platform/graphics/GraphicsContext3DPrivate.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicsPlatformDisplaycpp">trunk/Source/WebCore/platform/graphics/PlatformDisplay.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicsPlatformDisplayh">trunk/Source/WebCore/platform/graphics/PlatformDisplay.h</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicscairoImageBufferCairocpp">trunk/Source/WebCore/platform/graphics/cairo/ImageBufferCairo.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicseglGLContextEGLcpp">trunk/Source/WebCore/platform/graphics/egl/GLContextEGL.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicseglGLContextEGLh">trunk/Source/WebCore/platform/graphics/egl/GLContextEGL.h</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicsglxGLContextGLXcpp">trunk/Source/WebCore/platform/graphics/glx/GLContextGLX.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicsglxGLContextGLXh">trunk/Source/WebCore/platform/graphics/glx/GLContextGLX.h</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicsgstreamerMediaPlayerPrivateGStreamerBasecpp">trunk/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicswaylandPlatformDisplayWaylandcpp">trunk/Source/WebCore/platform/graphics/wayland/PlatformDisplayWayland.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicswaylandPlatformDisplayWaylandh">trunk/Source/WebCore/platform/graphics/wayland/PlatformDisplayWayland.h</a></li>
<li><a href="#trunkSourceWebKitwinChangeLog">trunk/Source/WebKit/win/ChangeLog</a></li>
<li><a href="#trunkSourceWebKitwinWebCoreSupportAcceleratedCompositingContextcpp">trunk/Source/WebKit/win/WebCoreSupport/AcceleratedCompositingContext.cpp</a></li>
<li><a href="#trunkSourceWebKit2ChangeLog">trunk/Source/WebKit2/ChangeLog</a></li>
<li><a href="#trunkSourceWebKit2PlatformGTKcmake">trunk/Source/WebKit2/PlatformGTK.cmake</a></li>
<li><a href="#trunkSourceWebKit2SharedCoordinatedGraphicsthreadedcompositorThreadedCompositorcpp">trunk/Source/WebKit2/Shared/CoordinatedGraphics/threadedcompositor/ThreadedCompositor.cpp</a></li>
<li><a href="#trunkSourceWebKit2SharedCoordinatedGraphicsthreadedcompositorThreadedCompositorh">trunk/Source/WebKit2/Shared/CoordinatedGraphics/threadedcompositor/ThreadedCompositor.h</a></li>
<li><a href="#trunkSourceWebKit2SharedWebProcessCreationParameterscpp">trunk/Source/WebKit2/Shared/WebProcessCreationParameters.cpp</a></li>
<li><a href="#trunkSourceWebKit2SharedWebProcessCreationParametersh">trunk/Source/WebKit2/Shared/WebProcessCreationParameters.h</a></li>
<li><a href="#trunkSourceWebKit2UIProcessAPIgtkWebKitWebViewBasecpp">trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewBase.cpp</a></li>
<li><a href="#trunkSourceWebKit2UIProcessAcceleratedDrawingAreaProxycpp">trunk/Source/WebKit2/UIProcess/AcceleratedDrawingAreaProxy.cpp</a></li>
<li><a href="#trunkSourceWebKit2UIProcessWebProcessPoolcpp">trunk/Source/WebKit2/UIProcess/WebProcessPool.cpp</a></li>
<li><a href="#trunkSourceWebKit2UIProcessgtkWebPreferencesGtkcpp">trunk/Source/WebKit2/UIProcess/gtk/WebPreferencesGtk.cpp</a></li>
<li><a href="#trunkSourceWebKit2WebProcessWebPageCoordinatedGraphicsThreadedCoordinatedLayerTreeHostcpp">trunk/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/ThreadedCoordinatedLayerTreeHost.cpp</a></li>
<li><a href="#trunkSourceWebKit2WebProcessWebPageCoordinatedGraphicsThreadedCoordinatedLayerTreeHosth">trunk/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/ThreadedCoordinatedLayerTreeHost.h</a></li>
<li><a href="#trunkSourceWebKit2WebProcessWebPagegtkLayerTreeHostGtkcpp">trunk/Source/WebKit2/WebProcess/WebPage/gtk/LayerTreeHostGtk.cpp</a></li>
<li><a href="#trunkSourceWebKit2WebProcessWebPagegtkLayerTreeHostGtkh">trunk/Source/WebKit2/WebProcess/WebPage/gtk/LayerTreeHostGtk.h</a></li>
<li><a href="#trunkSourceWebKit2WebProcessWebProcesscpp">trunk/Source/WebKit2/WebProcess/WebProcess.cpp</a></li>
<li><a href="#trunkSourceWebKit2WebProcessWebProcessh">trunk/Source/WebKit2/WebProcess/WebProcess.h</a></li>
<li><a href="#trunkSourcecmakeOptionsGTKcmake">trunk/Source/cmake/OptionsGTK.cmake</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreplatformgraphicswaylandWlUniquePtrh">trunk/Source/WebCore/platform/graphics/wayland/WlUniquePtr.h</a></li>
<li><a href="#trunkSourceWebKit2SharedgtkWebKit2WaylandProtocolxml">trunk/Source/WebKit2/Shared/gtk/WebKit2WaylandProtocol.xml</a></li>
<li><a href="#trunkSourceWebKit2UIProcessgtkAcceleratedBackingStorecpp">trunk/Source/WebKit2/UIProcess/gtk/AcceleratedBackingStore.cpp</a></li>
<li><a href="#trunkSourceWebKit2UIProcessgtkAcceleratedBackingStoreh">trunk/Source/WebKit2/UIProcess/gtk/AcceleratedBackingStore.h</a></li>
<li><a href="#trunkSourceWebKit2UIProcessgtkAcceleratedBackingStoreWaylandcpp">trunk/Source/WebKit2/UIProcess/gtk/AcceleratedBackingStoreWayland.cpp</a></li>
<li><a href="#trunkSourceWebKit2UIProcessgtkAcceleratedBackingStoreWaylandh">trunk/Source/WebKit2/UIProcess/gtk/AcceleratedBackingStoreWayland.h</a></li>
<li><a href="#trunkSourceWebKit2UIProcessgtkAcceleratedBackingStoreX11cpp">trunk/Source/WebKit2/UIProcess/gtk/AcceleratedBackingStoreX11.cpp</a></li>
<li><a href="#trunkSourceWebKit2UIProcessgtkAcceleratedBackingStoreX11h">trunk/Source/WebKit2/UIProcess/gtk/AcceleratedBackingStoreX11.h</a></li>
<li><a href="#trunkSourceWebKit2UIProcessgtkWaylandCompositorcpp">trunk/Source/WebKit2/UIProcess/gtk/WaylandCompositor.cpp</a></li>
<li><a href="#trunkSourceWebKit2UIProcessgtkWaylandCompositorh">trunk/Source/WebKit2/UIProcess/gtk/WaylandCompositor.h</a></li>
<li><a href="#trunkSourceWebKit2WebProcessWebPagegtkAcceleratedSurfacecpp">trunk/Source/WebKit2/WebProcess/WebPage/gtk/AcceleratedSurface.cpp</a></li>
<li><a href="#trunkSourceWebKit2WebProcessWebPagegtkAcceleratedSurfaceh">trunk/Source/WebKit2/WebProcess/WebPage/gtk/AcceleratedSurface.h</a></li>
<li><a href="#trunkSourceWebKit2WebProcessWebPagegtkAcceleratedSurfaceWaylandcpp">trunk/Source/WebKit2/WebProcess/WebPage/gtk/AcceleratedSurfaceWayland.cpp</a></li>
<li><a href="#trunkSourceWebKit2WebProcessWebPagegtkAcceleratedSurfaceWaylandh">trunk/Source/WebKit2/WebProcess/WebPage/gtk/AcceleratedSurfaceWayland.h</a></li>
<li><a href="#trunkSourceWebKit2WebProcessWebPagegtkAcceleratedSurfaceX11cpp">trunk/Source/WebKit2/WebProcess/WebPage/gtk/AcceleratedSurfaceX11.cpp</a></li>
<li><a href="#trunkSourceWebKit2WebProcessWebPagegtkAcceleratedSurfaceX11h">trunk/Source/WebKit2/WebProcess/WebPage/gtk/AcceleratedSurfaceX11.h</a></li>
</ul>

<h3>Removed Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreplatformgraphicswaylandWaylandEventSourcecpp">trunk/Source/WebCore/platform/graphics/wayland/WaylandEventSource.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicswaylandWaylandEventSourceh">trunk/Source/WebCore/platform/graphics/wayland/WaylandEventSource.h</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicswaylandWaylandSurfacecpp">trunk/Source/WebCore/platform/graphics/wayland/WaylandSurface.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicswaylandWaylandSurfaceh">trunk/Source/WebCore/platform/graphics/wayland/WaylandSurface.h</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicswaylandWebKitGtkWaylandClientProtocolxml">trunk/Source/WebCore/platform/graphics/wayland/WebKitGtkWaylandClientProtocol.xml</a></li>
<li><a href="#trunkSourceWebKit2UIProcessgtkXDamageNotifiercpp">trunk/Source/WebKit2/UIProcess/gtk/XDamageNotifier.cpp</a></li>
<li><a href="#trunkSourceWebKit2UIProcessgtkXDamageNotifierh">trunk/Source/WebKit2/UIProcess/gtk/XDamageNotifier.h</a></li>
<li><a href="#trunkSourceWebKit2WebProcessWebPagegtkRedirectedXCompositeWindowcpp">trunk/Source/WebKit2/WebProcess/WebPage/gtk/RedirectedXCompositeWindow.cpp</a></li>
<li><a href="#trunkSourceWebKit2WebProcessWebPagegtkRedirectedXCompositeWindowh">trunk/Source/WebKit2/WebProcess/WebPage/gtk/RedirectedXCompositeWindow.h</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (205115 => 205116)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2016-08-29 09:18:06 UTC (rev 205115)
+++ trunk/Source/WebCore/ChangeLog        2016-08-29 09:33:40 UTC (rev 205116)
</span><span class="lines">@@ -1,3 +1,107 @@
</span><ins>+2016-08-16  Carlos Garcia Campos  &lt;cgarcia@igalia.com&gt;
+
+        [GTK] Accelerated compositing does not work in Wayland
+        https://bugs.webkit.org/show_bug.cgi?id=115803
+
+        Reviewed by Michael Catanzaro.
+
+        The Wayland implementation in WebKit2 uses a nested display running in the UI process so that GL contexts created
+        in the web process need to be created in the nested display. We currently have a shared platform display that
+        should represent the connection to the actual display all applications connect to. This patch refactors the
+        GLContext API to ensure that GL contexts are always attached to a particular platform display. The create
+        methods receive an optional PlatformDisplay that will be used as the display of all GL operations of the created
+        GL context. The sharing GL context should also share the same display, it can't be global to the process, but to
+        the display, so it's now created on demand by the PlatformDisplay. In addition to the global shared display,
+        it's now possible to set a shared display for compositing that can be used when creating GL contexts. This makes
+        it possible to use a different display for compositing, connected to the nested display in wayland, even in non
+        wayland environments.
+        The patch also adds support for surfaceless EGL contexts that can be used for offscreen contexts. It also adds
+        support for offscreen wayland contexts, as a fallback in wayland in case surfaceless is not supported.
+        Some wayland code that is specific to the WebKit2 implementation has been moved to the WebKit2 layer.
+
+        * PlatformGTK.cmake:
+        * platform/graphics/GLContext.cpp:
+        (WebCore::initializeOpenGLShimsIfNeeded):
+        (WebCore::GLContext::createContextForWindow):
+        (WebCore::GLContext::createOffscreenContext):
+        (WebCore::GLContext::createSharingContext):
+        (WebCore::GLContext::GLContext):
+        (WebCore::GLContext::~GLContext):
+        (WebCore::GLContext::current):
+        (WebCore::activeContextList): Deleted.
+        * platform/graphics/GLContext.h:
+        (WebCore::GLContext::display):
+        * platform/graphics/GraphicsContext3DPrivate.cpp:
+        (WebCore::GraphicsContext3DPrivate::GraphicsContext3DPrivate):
+        (WebCore::GraphicsContext3DPrivate::platformContext):
+        (WebCore::GraphicsContext3DPrivate::paintToTextureMapper):
+        * platform/graphics/PlatformDisplay.cpp:
+        (WebCore::PlatformDisplay::createPlatformDisplay): Always use the default wayland display created by GTK+ for
+        the global shared display.
+        (WebCore::PlatformDisplay::sharedDisplayForCompositing):
+        (WebCore::PlatformDisplay::setSharedDisplayForCompositing):
+        (WebCore::PlatformDisplay::sharingGLContext):
+        (WebCore::eglDisplays): Helper HashSet to keep track of all PlatformDisplays with an EGL display intialized to
+        properly termimate them at exit.
+        (WebCore::PlatformDisplay::initializeEGLDisplay): Remove eglBindAPI() from display initialization, since it's
+        not a display initialization and it's thread specific, so it needs to be called on every thread where EGL is used.
+        (WebCore::PlatformDisplay::terminateEGLDisplay):
+        (WebCore::PlatformDisplay::eglDisplay): Deleted.
+        * platform/graphics/PlatformDisplay.h:
+        * platform/graphics/cairo/ImageBufferCairo.cpp:
+        (WebCore::ImageBufferData::~ImageBufferData):
+        (WebCore::ImageBufferData::createCompositorBuffer):
+        (WebCore::ImageBufferData::swapBuffersIfNeeded):
+        (WebCore::ImageBufferData::createCairoGLSurface):
+        (WebCore::ImageBufferData::paintToTextureMapper):
+        (WebCore::ImageBuffer::copyToPlatformTexture):
+        * platform/graphics/egl/GLContextEGL.cpp:
+        (WebCore::GLContextEGL::getEGLConfig):
+        (WebCore::GLContextEGL::createWindowContext):
+        (WebCore::GLContextEGL::createPbufferContext):
+        (WebCore::GLContextEGL::createSurfacelessContext):
+        (WebCore::GLContextEGL::createPixmapContext):
+        (WebCore::GLContextEGL::createWaylandContext):
+        (WebCore::GLContextEGL::createContext):
+        (WebCore::GLContextEGL::createSharingContext):
+        (WebCore::GLContextEGL::GLContextEGL):
+        (WebCore::GLContextEGL::~GLContextEGL):
+        (WebCore::GLContextEGL::defaultFrameBufferSize):
+        (WebCore::GLContextEGL::makeContextCurrent):
+        (WebCore::GLContextEGL::swapBuffers):
+        (WebCore::GLContextEGL::cairoDevice):
+        * platform/graphics/egl/GLContextEGL.h:
+        * platform/graphics/glx/GLContextGLX.cpp:
+        (WebCore::GLContextGLX::createWindowContext):
+        (WebCore::GLContextGLX::createPbufferContext):
+        (WebCore::GLContextGLX::createPixmapContext):
+        (WebCore::GLContextGLX::createContext):
+        (WebCore::GLContextGLX::createSharingContext):
+        (WebCore::GLContextGLX::GLContextGLX):
+        (WebCore::GLContextGLX::~GLContextGLX):
+        (WebCore::GLContextGLX::defaultFrameBufferSize):
+        (WebCore::GLContextGLX::makeContextCurrent):
+        (WebCore::GLContextGLX::swapBuffers):
+        (WebCore::GLContextGLX::cairoDevice):
+        (WebCore::GLContextGLX::waitNative): Deleted.
+        * platform/graphics/glx/GLContextGLX.h:
+        * platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.cpp:
+        (WebCore::MediaPlayerPrivateGStreamerBase::ensureGstGLContext):
+        (WebCore::MediaPlayerPrivateGStreamerBase::nativeImageForCurrentTime):
+        * platform/graphics/wayland/PlatformDisplayWayland.cpp:
+        (WebCore::PlatformDisplayWayland::PlatformDisplayWayland):
+        (WebCore::PlatformDisplayWayland::~PlatformDisplayWayland):
+        (WebCore::PlatformDisplayWayland::initialize):
+        (WebCore::PlatformDisplayWayland::registryGlobal):
+        (WebCore::PlatformDisplayWayland::createSurface):
+        * platform/graphics/wayland/PlatformDisplayWayland.h:
+        (WebCore::PlatformDisplayWayland::native): Deleted.
+        * platform/graphics/wayland/WaylandEventSource.cpp: Removed.
+        * platform/graphics/wayland/WaylandSurface.cpp: Removed.
+        * platform/graphics/wayland/WebKitGtkWaylandClientProtocol.xml: Removed.
+        * platform/graphics/wayland/WlUniquePtr.h: Make it possible to use std::unique_ptr with Wayland objects.
+        (WebCore::WlPtrDeleter::operator()):
+
</ins><span class="cx"> 2016-08-29  Youenn Fablet  &lt;youenn@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         [Fetch API] Add support for BufferSource bodies
</span></span></pre></div>
<a id="trunkSourceWebCorePlatformGTKcmake"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/PlatformGTK.cmake (205115 => 205116)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/PlatformGTK.cmake        2016-08-29 09:18:06 UTC (rev 205115)
+++ trunk/Source/WebCore/PlatformGTK.cmake        2016-08-29 09:33:40 UTC (rev 205116)
</span><span class="lines">@@ -144,6 +144,8 @@
</span><span class="cx"> 
</span><span class="cx">     platform/graphics/opentype/OpenTypeVerticalData.cpp
</span><span class="cx"> 
</span><ins>+    platform/graphics/wayland/PlatformDisplayWayland.cpp
+
</ins><span class="cx">     platform/graphics/x11/PlatformDisplayX11.cpp
</span><span class="cx">     platform/graphics/x11/XUniqueResource.cpp
</span><span class="cx"> 
</span><span class="lines">@@ -348,24 +350,6 @@
</span><span class="cx"> endif ()
</span><span class="cx"> 
</span><span class="cx"> if (ENABLE_WAYLAND_TARGET)
</span><del>-    # Wayland protocol extension.
-    add_custom_command(
-        OUTPUT ${DERIVED_SOURCES_WEBCORE_DIR}/WebKitGtkWaylandClientProtocol.c
-        DEPENDS ${WEBCORE_DIR}/platform/graphics/wayland/WebKitGtkWaylandClientProtocol.xml
-        COMMAND wayland-scanner server-header &lt; ${WEBCORE_DIR}/platform/graphics/wayland/WebKitGtkWaylandClientProtocol.xml &gt; ${DERIVED_SOURCES_WEBCORE_DIR}/WebKitGtkWaylandServerProtocol.h
-        COMMAND wayland-scanner client-header &lt; ${WEBCORE_DIR}/platform/graphics/wayland/WebKitGtkWaylandClientProtocol.xml &gt; ${DERIVED_SOURCES_WEBCORE_DIR}/WebKitGtkWaylandClientProtocol.h
-        COMMAND wayland-scanner code &lt; ${WEBCORE_DIR}/platform/graphics/wayland/WebKitGtkWaylandClientProtocol.xml &gt; ${DERIVED_SOURCES_WEBCORE_DIR}/WebKitGtkWaylandClientProtocol.c
-    )
-
-    list(APPEND WebCore_SOURCES
-        platform/graphics/wayland/PlatformDisplayWayland.cpp
-        platform/graphics/wayland/WaylandEventSource.cpp
-        platform/graphics/wayland/WaylandSurface.cpp
-    )
-    list(APPEND WebCore_DERIVED_SOURCES
-        ${DERIVED_SOURCES_WEBCORE_DIR}/WebKitGtkWaylandClientProtocol.c
-    )
-
</del><span class="cx">     list(APPEND WebCore_SYSTEM_INCLUDE_DIRECTORIES
</span><span class="cx">         ${WAYLAND_INCLUDE_DIRS}
</span><span class="cx">     )
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsGLContextcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/GLContext.cpp (205115 => 205116)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/GLContext.cpp        2016-08-29 09:18:06 UTC (rev 205115)
+++ trunk/Source/WebCore/platform/graphics/GLContext.cpp        2016-08-29 09:33:40 UTC (rev 205116)
</span><span class="lines">@@ -19,10 +19,7 @@
</span><span class="cx"> #include &quot;config.h&quot;
</span><span class="cx"> 
</span><span class="cx"> #if ENABLE(GRAPHICS_CONTEXT_3D)
</span><del>-
</del><span class="cx"> #include &quot;GLContext.h&quot;
</span><del>-
-#include &quot;PlatformDisplay.h&quot;
</del><span class="cx"> #include &lt;wtf/ThreadSpecific.h&gt;
</span><span class="cx"> 
</span><span class="cx"> #if USE(EGL)
</span><span class="lines">@@ -57,12 +54,6 @@
</span><span class="cx">     return *ThreadGlobalGLContext::staticGLContext;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-GLContext* GLContext::sharingContext()
-{
-    DEPRECATED_DEFINE_STATIC_LOCAL(std::unique_ptr&lt;GLContext&gt;, sharing, (createOffscreenContext()));
-    return sharing.get();
-}
-
</del><span class="cx"> #if PLATFORM(X11)
</span><span class="cx"> // Because of driver bugs, exiting the program when there are active pbuffers
</span><span class="cx"> // can crash the X server (this has been observed with the official Nvidia drivers).
</span><span class="lines">@@ -111,12 +102,30 @@
</span><span class="cx"> }
</span><span class="cx"> #endif // PLATFORM(X11)
</span><span class="cx"> 
</span><ins>+static bool initializeOpenGLShimsIfNeeded()
+{
+#if USE(OPENGL_ES_2)
+    return true;
+#else
+    static bool initialized = false;
+    static bool success = true;
+    if (!initialized) {
+        success = initializeOpenGLShims();
+        initialized = true;
+    }
+    return success;
+#endif
+}
</ins><span class="cx"> 
</span><del>-std::unique_ptr&lt;GLContext&gt; GLContext::createContextForWindow(GLNativeWindowType windowHandle, GLContext* sharingContext)
</del><ins>+std::unique_ptr&lt;GLContext&gt; GLContext::createContextForWindow(GLNativeWindowType windowHandle, PlatformDisplay* platformDisplay)
</ins><span class="cx"> {
</span><del>-#if PLATFORM(WAYLAND) &amp;&amp; USE(EGL)
-    if (PlatformDisplay::sharedDisplay().type() == PlatformDisplay::Type::Wayland) {
-        if (auto eglContext = GLContextEGL::createContext(windowHandle, sharingContext))
</del><ins>+    if (!initializeOpenGLShimsIfNeeded())
+        return nullptr;
+
+    PlatformDisplay&amp; display = platformDisplay ? *platformDisplay : PlatformDisplay::sharedDisplay();
+#if PLATFORM(WAYLAND)
+    if (display.type() == PlatformDisplay::Type::Wayland) {
+        if (auto eglContext = GLContextEGL::createContext(windowHandle, display))
</ins><span class="cx">             return WTFMove(eglContext);
</span><span class="cx">         return nullptr;
</span><span class="cx">     }
</span><span class="lines">@@ -128,34 +137,60 @@
</span><span class="cx"> #else
</span><span class="cx">     XID GLXWindowHandle = static_cast&lt;XID&gt;(windowHandle);
</span><span class="cx"> #endif
</span><del>-    if (auto glxContext = GLContextGLX::createContext(GLXWindowHandle, sharingContext))
</del><ins>+    if (auto glxContext = GLContextGLX::createContext(GLXWindowHandle, display))
</ins><span class="cx">         return WTFMove(glxContext);
</span><span class="cx"> #endif
</span><span class="cx"> #if USE(EGL)
</span><del>-    if (auto eglContext = GLContextEGL::createContext(windowHandle, sharingContext))
</del><ins>+    if (auto eglContext = GLContextEGL::createContext(windowHandle, display))
</ins><span class="cx">         return WTFMove(eglContext);
</span><span class="cx"> #endif
</span><span class="cx">     return nullptr;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-GLContext::GLContext()
</del><ins>+std::unique_ptr&lt;GLContext&gt; GLContext::createOffscreenContext(PlatformDisplay* platformDisplay)
</ins><span class="cx"> {
</span><del>-#if PLATFORM(X11)
-    addActiveContext(this);
</del><ins>+    if (!initializeOpenGLShimsIfNeeded())
+        return nullptr;
+
+    return createContextForWindow(0, platformDisplay ? platformDisplay : &amp;PlatformDisplay::sharedDisplay());
+}
+
+std::unique_ptr&lt;GLContext&gt; GLContext::createSharingContext(PlatformDisplay&amp; display)
+{
+    if (!initializeOpenGLShimsIfNeeded())
+        return nullptr;
+
+#if USE(GLX)
+    if (display.type() == PlatformDisplay::Type::X11) {
+        if (auto glxContext = GLContextGLX::createSharingContext(display))
+            return WTFMove(glxContext);
+    }
</ins><span class="cx"> #endif
</span><ins>+
+#if USE(EGL) || PLATFORM(WAYLAND)
+    if (auto eglContext = GLContextEGL::createSharingContext(display))
+        return WTFMove(eglContext);
+#endif
+
+    return nullptr;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-std::unique_ptr&lt;GLContext&gt; GLContext::createOffscreenContext(GLContext* sharingContext)
</del><ins>+GLContext::GLContext(PlatformDisplay&amp; display)
+    : m_display(display)
</ins><span class="cx"> {
</span><del>-    return createContextForWindow(0, sharingContext);
</del><ins>+#if PLATFORM(X11)
+    if (display.type() == PlatformDisplay::Type::X11)
+        addActiveContext(this);
+#endif
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> GLContext::~GLContext()
</span><span class="cx"> {
</span><span class="cx">     if (this == currentContext()-&gt;context())
</span><del>-        currentContext()-&gt;setContext(0);
</del><ins>+        currentContext()-&gt;setContext(nullptr);
</ins><span class="cx"> #if PLATFORM(X11)
</span><del>-    removeActiveContext(this);
</del><ins>+    if (m_display.type() == PlatformDisplay::Type::X11)
+        removeActiveContext(this);
</ins><span class="cx"> #endif
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -165,7 +200,7 @@
</span><span class="cx">     return true;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-GLContext* GLContext::getCurrent()
</del><ins>+GLContext* GLContext::current()
</ins><span class="cx"> {
</span><span class="cx">     return currentContext()-&gt;context();
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsGLContexth"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/GLContext.h (205115 => 205116)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/GLContext.h        2016-08-29 09:18:06 UTC (rev 205115)
+++ trunk/Source/WebCore/platform/graphics/GLContext.h        2016-08-29 09:33:40 UTC (rev 205116)
</span><span class="lines">@@ -21,7 +21,7 @@
</span><span class="cx"> #define GLContext_h
</span><span class="cx"> 
</span><span class="cx"> #include &quot;GraphicsContext3D.h&quot;
</span><del>-#include &quot;Widget.h&quot;
</del><ins>+#include &quot;PlatformDisplay.h&quot;
</ins><span class="cx"> #include &lt;wtf/Noncopyable.h&gt;
</span><span class="cx"> 
</span><span class="cx"> #if USE(EGL) &amp;&amp; !PLATFORM(GTK)
</span><span class="lines">@@ -39,21 +39,18 @@
</span><span class="cx"> typedef struct _cairo_device cairo_device_t;
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><del>-#if PLATFORM(X11)
-typedef struct _XDisplay Display;
-#endif
-
</del><span class="cx"> namespace WebCore {
</span><span class="cx"> 
</span><span class="cx"> class GLContext {
</span><del>-    WTF_MAKE_NONCOPYABLE(GLContext);
</del><ins>+    WTF_MAKE_NONCOPYABLE(GLContext); WTF_MAKE_FAST_ALLOCATED;
</ins><span class="cx"> public:
</span><del>-    static std::unique_ptr&lt;GLContext&gt; createContextForWindow(GLNativeWindowType windowHandle, GLContext* sharingContext);
-    static std::unique_ptr&lt;GLContext&gt; createOffscreenContext(GLContext* sharing = 0);
-    static GLContext* getCurrent();
-    static GLContext* sharingContext();
</del><ins>+    static std::unique_ptr&lt;GLContext&gt; createContextForWindow(GLNativeWindowType windowHandle, PlatformDisplay* = nullptr);
+    static std::unique_ptr&lt;GLContext&gt; createOffscreenContext(PlatformDisplay* = nullptr);
+    static std::unique_ptr&lt;GLContext&gt; createSharingContext(PlatformDisplay&amp;);
+    static GLContext* current();
</ins><span class="cx"> 
</span><del>-    GLContext();
</del><ins>+    PlatformDisplay&amp; display() const { return m_display; }
+
</ins><span class="cx">     virtual ~GLContext();
</span><span class="cx">     virtual bool makeContextCurrent();
</span><span class="cx">     virtual void swapBuffers() = 0;
</span><span class="lines">@@ -60,6 +57,7 @@
</span><span class="cx">     virtual void waitNative() = 0;
</span><span class="cx">     virtual bool canRenderToDefaultFramebuffer() = 0;
</span><span class="cx">     virtual IntSize defaultFrameBufferSize() = 0;
</span><ins>+    virtual void swapInterval(int) = 0;
</ins><span class="cx"> 
</span><span class="cx">     virtual bool isEGLContext() const = 0;
</span><span class="cx"> 
</span><span class="lines">@@ -67,26 +65,21 @@
</span><span class="cx">     virtual cairo_device_t* cairoDevice() = 0;
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><del>-#if PLATFORM(X11)
-    static Display* sharedX11Display();
-    static void cleanupSharedX11Display();
</del><ins>+#if ENABLE(GRAPHICS_CONTEXT_3D)
+    virtual PlatformGraphicsContext3D platformContext() = 0;
</ins><span class="cx"> #endif
</span><span class="cx"> 
</span><ins>+#if PLATFORM(X11)
+private:
</ins><span class="cx">     static void addActiveContext(GLContext*);
</span><span class="cx">     static void removeActiveContext(GLContext*);
</span><span class="cx">     static void cleanupActiveContextsAtExit();
</span><del>-
-#if ENABLE(GRAPHICS_CONTEXT_3D)
-    virtual PlatformGraphicsContext3D platformContext() = 0;
</del><span class="cx"> #endif
</span><span class="cx"> 
</span><del>-    class Data {
-    public:
-        virtual ~Data() = default;
-    };
</del><ins>+protected:
+    GLContext(PlatformDisplay&amp;);
</ins><span class="cx"> 
</span><del>-protected:
-    std::unique_ptr&lt;Data&gt; m_contextData;
</del><ins>+    PlatformDisplay&amp; m_display;
</ins><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> } // namespace WebCore
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsGraphicsContext3DPrivatecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/GraphicsContext3DPrivate.cpp (205115 => 205116)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/GraphicsContext3DPrivate.cpp        2016-08-29 09:18:06 UTC (rev 205115)
+++ trunk/Source/WebCore/platform/graphics/GraphicsContext3DPrivate.cpp        2016-08-29 09:33:40 UTC (rev 205116)
</span><span class="lines">@@ -55,7 +55,7 @@
</span><span class="cx"> {
</span><span class="cx">     switch (renderStyle) {
</span><span class="cx">     case GraphicsContext3D::RenderOffscreen:
</span><del>-        m_glContext = GLContext::createOffscreenContext(GLContext::sharingContext());
</del><ins>+        m_glContext = GLContext::createOffscreenContext(&amp;PlatformDisplay::sharedDisplayForCompositing());
</ins><span class="cx">         break;
</span><span class="cx">     case GraphicsContext3D::RenderToCurrentGLContext:
</span><span class="cx">         break;
</span><span class="lines">@@ -85,7 +85,7 @@
</span><span class="cx"> 
</span><span class="cx"> PlatformGraphicsContext3D GraphicsContext3DPrivate::platformContext()
</span><span class="cx"> {
</span><del>-    return m_glContext ? m_glContext-&gt;platformContext() : GLContext::getCurrent()-&gt;platformContext();
</del><ins>+    return m_glContext ? m_glContext-&gt;platformContext() : GLContext::current()-&gt;platformContext();
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> #if USE(COORDINATED_GRAPHICS_THREADED)
</span><span class="lines">@@ -123,7 +123,7 @@
</span><span class="cx"> 
</span><span class="cx"> #if USE(TEXTURE_MAPPER_GL)
</span><span class="cx">     if (m_context-&gt;m_attrs.antialias &amp;&amp; m_context-&gt;m_state.boundFBO == m_context-&gt;m_multisampleFBO) {
</span><del>-        GLContext* previousActiveContext = GLContext::getCurrent();
</del><ins>+        GLContext* previousActiveContext = GLContext::current();
</ins><span class="cx">         if (previousActiveContext != m_glContext.get())
</span><span class="cx">             m_context-&gt;makeContextCurrent();
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsPlatformDisplaycpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/PlatformDisplay.cpp (205115 => 205116)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/PlatformDisplay.cpp        2016-08-29 09:18:06 UTC (rev 205115)
+++ trunk/Source/WebCore/platform/graphics/PlatformDisplay.cpp        2016-08-29 09:33:40 UTC (rev 205116)
</span><span class="lines">@@ -26,6 +26,7 @@
</span><span class="cx"> #include &quot;config.h&quot;
</span><span class="cx"> #include &quot;PlatformDisplay.h&quot;
</span><span class="cx"> 
</span><ins>+#include &quot;GLContext.h&quot;
</ins><span class="cx"> #include &lt;cstdlib&gt;
</span><span class="cx"> #include &lt;mutex&gt;
</span><span class="cx"> 
</span><span class="lines">@@ -59,6 +60,8 @@
</span><span class="cx"> 
</span><span class="cx"> #if USE(EGL)
</span><span class="cx"> #include &lt;EGL/egl.h&gt;
</span><ins>+#include &lt;wtf/HashSet.h&gt;
+#include &lt;wtf/NeverDestroyed.h&gt;
</ins><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="cx"> namespace WebCore {
</span><span class="lines">@@ -76,7 +79,7 @@
</span><span class="cx"> #endif
</span><span class="cx"> #if PLATFORM(WAYLAND)
</span><span class="cx">     if (GDK_IS_WAYLAND_DISPLAY(display))
</span><del>-        return PlatformDisplayWayland::create();
</del><ins>+        return std::make_unique&lt;PlatformDisplayWayland&gt;(gdk_wayland_display_get_wl_display(display));
</ins><span class="cx"> #endif
</span><span class="cx"> #endif
</span><span class="cx"> #elif PLATFORM(EFL) &amp;&amp; defined(HAVE_ECORE_X)
</span><span class="lines">@@ -103,6 +106,18 @@
</span><span class="cx">     return *display;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+static PlatformDisplay* s_sharedDisplayForCompositing;
+
+PlatformDisplay&amp; PlatformDisplay::sharedDisplayForCompositing()
+{
+    return s_sharedDisplayForCompositing ? *s_sharedDisplayForCompositing : sharedDisplay();
+}
+
+void PlatformDisplay::setSharedDisplayForCompositing(PlatformDisplay&amp; display)
+{
+    s_sharedDisplayForCompositing = &amp;display;
+}
+
</ins><span class="cx"> PlatformDisplay::PlatformDisplay()
</span><span class="cx"> #if USE(EGL)
</span><span class="cx">     : m_eglDisplay(EGL_NO_DISPLAY)
</span><span class="lines">@@ -117,7 +132,22 @@
</span><span class="cx"> #endif
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+#if !PLATFORM(EFL)
+GLContext* PlatformDisplay::sharingGLContext()
+{
+    if (!m_sharingGLContext)
+        m_sharingGLContext = GLContext::createSharingContext(*this);
+    return m_sharingGLContext.get();
+}
+#endif
+
</ins><span class="cx"> #if USE(EGL)
</span><ins>+static HashSet&lt;PlatformDisplay*&gt;&amp; eglDisplays()
+{
+    static NeverDestroyed&lt;HashSet&lt;PlatformDisplay*&gt;&gt; displays;
+    return displays;
+}
+
</ins><span class="cx"> EGLDisplay PlatformDisplay::eglDisplay() const
</span><span class="cx"> {
</span><span class="cx">     if (!m_eglDisplayInitialized)
</span><span class="lines">@@ -125,12 +155,20 @@
</span><span class="cx">     return m_eglDisplay;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+bool PlatformDisplay::eglCheckVersion(int major, int minor) const
+{
+    if (!m_eglDisplayInitialized)
+        const_cast&lt;PlatformDisplay*&gt;(this)-&gt;initializeEGLDisplay();
+
+    return (m_eglMajorVersion &gt; major) || ((m_eglMajorVersion == major) &amp;&amp; (m_eglMinorVersion &gt;= minor));
+}
+
</ins><span class="cx"> void PlatformDisplay::initializeEGLDisplay()
</span><span class="cx"> {
</span><span class="cx">     m_eglDisplayInitialized = true;
</span><span class="cx"> 
</span><span class="cx">     if (m_eglDisplay == EGL_NO_DISPLAY) {
</span><del>-// EGL is optionally soft linked on Windows.
</del><ins>+        // EGL is optionally soft linked on Windows.
</ins><span class="cx"> #if PLATFORM(WIN)
</span><span class="cx">         auto eglGetDisplay = eglGetDisplayPtr();
</span><span class="cx">         if (!eglGetDisplay)
</span><span class="lines">@@ -141,36 +179,41 @@
</span><span class="cx">             return;
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    if (eglInitialize(m_eglDisplay, 0, 0) == EGL_FALSE) {
</del><ins>+    EGLint majorVersion, minorVersion;
+    if (eglInitialize(m_eglDisplay, &amp;majorVersion, &amp;minorVersion) == EGL_FALSE) {
</ins><span class="cx">         LOG_ERROR(&quot;EGLDisplay Initialization failed.&quot;);
</span><span class="cx">         terminateEGLDisplay();
</span><span class="cx">         return;
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-#if USE(OPENGL_ES_2)
-    static const EGLenum eglAPIVersion = EGL_OPENGL_ES_API;
-#else
-    static const EGLenum eglAPIVersion = EGL_OPENGL_API;
-#endif
-    if (eglBindAPI(eglAPIVersion) == EGL_FALSE) {
-        LOG_ERROR(&quot;Failed to set EGL API(%d).&quot;, eglGetError());
-        terminateEGLDisplay();
-        return;
</del><ins>+    m_eglMajorVersion = majorVersion;
+    m_eglMinorVersion = minorVersion;
+
+    eglDisplays().add(this);
+
+    static bool eglAtexitHandlerInitialized = false;
+    if (!eglAtexitHandlerInitialized) {
+        // EGL registers atexit handlers to cleanup its global display list.
+        // Since the global PlatformDisplay instance is created before,
+        // when the PlatformDisplay destructor is called, EGL has already removed the
+        // display from the list, causing eglTerminate() to crash. So, here we register
+        // our own atexit handler, after EGL has been initialized and after the global
+        // instance has been created to ensure we call eglTerminate() before the other
+        // EGL atexit handlers and the PlatformDisplay destructor.
+        // See https://bugs.webkit.org/show_bug.cgi?id=157973.
+        eglAtexitHandlerInitialized = true;
+        std::atexit([] {
+            while (!eglDisplays().isEmpty()) {
+                auto* display = eglDisplays().takeAny();
+                display-&gt;terminateEGLDisplay();
+            }
+        });
</ins><span class="cx">     }
</span><del>-
-    // EGL registers atexit handlers to cleanup its global display list.
-    // Since the global PlatformDisplay instance is created before,
-    // when the PlatformDisplay destructor is called, EGL has already removed the
-    // display from the list, causing eglTerminate() to crash. So, here we register
-    // our own atexit handler, after EGL has been initialized and after the global
-    // instance has been created to ensure we call eglTerminate() before the other
-    // EGL atexit handlers and the PlatformDisplay destructor.
-    // See https://bugs.webkit.org/show_bug.cgi?id=157973.
-    std::atexit([] { PlatformDisplay::sharedDisplay().terminateEGLDisplay(); });
</del><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void PlatformDisplay::terminateEGLDisplay()
</span><span class="cx"> {
</span><ins>+    m_sharingGLContext = nullptr;
</ins><span class="cx">     ASSERT(m_eglDisplayInitialized);
</span><span class="cx">     if (m_eglDisplay == EGL_NO_DISPLAY)
</span><span class="cx">         return;
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsPlatformDisplayh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/PlatformDisplay.h (205115 => 205116)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/PlatformDisplay.h        2016-08-29 09:18:06 UTC (rev 205115)
+++ trunk/Source/WebCore/platform/graphics/PlatformDisplay.h        2016-08-29 09:33:40 UTC (rev 205116)
</span><span class="lines">@@ -35,10 +35,13 @@
</span><span class="cx"> 
</span><span class="cx"> namespace WebCore {
</span><span class="cx"> 
</span><ins>+class GLContext;
+
</ins><span class="cx"> class PlatformDisplay {
</span><span class="cx">     WTF_MAKE_NONCOPYABLE(PlatformDisplay); WTF_MAKE_FAST_ALLOCATED;
</span><span class="cx"> public:
</span><span class="cx">     static PlatformDisplay&amp; sharedDisplay();
</span><ins>+    static PlatformDisplay&amp; sharedDisplayForCompositing();
</ins><span class="cx">     virtual ~PlatformDisplay();
</span><span class="cx"> 
</span><span class="cx">     enum class Type {
</span><span class="lines">@@ -55,13 +58,22 @@
</span><span class="cx"> 
</span><span class="cx">     virtual Type type() const = 0;
</span><span class="cx"> 
</span><ins>+#if !PLATFORM(EFL)
+    // FIXME: This should not have any platform ifdef, but EFL has its own EGLContext class
+    // instead of using the GLContext common API.
+    GLContext* sharingGLContext();
+#endif
+
</ins><span class="cx"> #if USE(EGL)
</span><span class="cx">     EGLDisplay eglDisplay() const;
</span><ins>+    bool eglCheckVersion(int major, int minor) const;
</ins><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="cx"> protected:
</span><span class="cx">     PlatformDisplay();
</span><span class="cx"> 
</span><ins>+    static void setSharedDisplayForCompositing(PlatformDisplay&amp;);
+
</ins><span class="cx"> #if USE(EGL)
</span><span class="cx">     virtual void initializeEGLDisplay();
</span><span class="cx"> 
</span><span class="lines">@@ -75,7 +87,10 @@
</span><span class="cx">     void terminateEGLDisplay();
</span><span class="cx"> 
</span><span class="cx">     bool m_eglDisplayInitialized { false };
</span><ins>+    int m_eglMajorVersion { 0 };
+    int m_eglMinorVersion { 0 };
</ins><span class="cx"> #endif
</span><ins>+    std::unique_ptr&lt;GLContext&gt; m_sharingGLContext;
</ins><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> } // namespace WebCore
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicscairoImageBufferCairocpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/cairo/ImageBufferCairo.cpp (205115 => 205116)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/cairo/ImageBufferCairo.cpp        2016-08-29 09:18:06 UTC (rev 205115)
+++ trunk/Source/WebCore/platform/graphics/cairo/ImageBufferCairo.cpp        2016-08-29 09:33:40 UTC (rev 205116)
</span><span class="lines">@@ -88,8 +88,8 @@
</span><span class="cx">         return;
</span><span class="cx"> 
</span><span class="cx"> #if ENABLE(ACCELERATED_2D_CANVAS)
</span><del>-    GLContext* previousActiveContext = GLContext::getCurrent();
-    GLContext::sharingContext()-&gt;makeContextCurrent();
</del><ins>+    GLContext* previousActiveContext = GLContext::current();
+    PlatformDisplay::sharedDisplayForCompositing().sharingGLContext()-&gt;makeContextCurrent();
</ins><span class="cx"> 
</span><span class="cx">     if (m_texture)
</span><span class="cx">         glDeleteTextures(1, &amp;m_texture);
</span><span class="lines">@@ -108,7 +108,8 @@
</span><span class="cx"> #if USE(COORDINATED_GRAPHICS_THREADED)
</span><span class="cx"> void ImageBufferData::createCompositorBuffer()
</span><span class="cx"> {
</span><del>-    GLContext::sharingContext()-&gt;makeContextCurrent();
</del><ins>+    auto* context = PlatformDisplay::sharedDisplayForCompositing().sharingGLContext();
+    context-&gt;makeContextCurrent();
</ins><span class="cx"> 
</span><span class="cx">     glGenTextures(1, &amp;m_compositorTexture);
</span><span class="cx">     glBindTexture(GL_TEXTURE_2D, m_compositorTexture);
</span><span class="lines">@@ -119,8 +120,7 @@
</span><span class="cx">     glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
</span><span class="cx">     glTexImage2D(GL_TEXTURE_2D, 0 , GL_RGBA, m_size.width(), m_size.height(), 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
</span><span class="cx"> 
</span><del>-    cairo_device_t* device = GLContext::sharingContext()-&gt;cairoDevice();
-    m_compositorSurface = adoptRef(cairo_gl_surface_create_for_texture(device, CAIRO_CONTENT_COLOR_ALPHA, m_compositorTexture, m_size.width(), m_size.height()));
</del><ins>+    m_compositorSurface = adoptRef(cairo_gl_surface_create_for_texture(context-&gt;cairoDevice(), CAIRO_CONTENT_COLOR_ALPHA, m_compositorTexture, m_size.width(), m_size.height()));
</ins><span class="cx">     m_compositorCr = adoptRef(cairo_create(m_compositorSurface.get()));
</span><span class="cx">     cairo_set_antialias(m_compositorCr.get(), CAIRO_ANTIALIAS_NONE);
</span><span class="cx"> }
</span><span class="lines">@@ -127,7 +127,7 @@
</span><span class="cx"> 
</span><span class="cx"> void ImageBufferData::swapBuffersIfNeeded()
</span><span class="cx"> {
</span><del>-    GLContext* previousActiveContext = GLContext::getCurrent();
</del><ins>+    GLContext* previousActiveContext = GLContext::current();
</ins><span class="cx"> 
</span><span class="cx">     if (!m_compositorTexture) {
</span><span class="cx">         createCompositorBuffer();
</span><span class="lines">@@ -159,7 +159,8 @@
</span><span class="cx"> 
</span><span class="cx"> void ImageBufferData::createCairoGLSurface()
</span><span class="cx"> {
</span><del>-    GLContext::sharingContext()-&gt;makeContextCurrent();
</del><ins>+    auto* context = PlatformDisplay::sharedDisplayForCompositing().sharingGLContext();
+    context-&gt;makeContextCurrent();
</ins><span class="cx"> 
</span><span class="cx">     // We must generate the texture ourselves, because there is no Cairo API for extracting it
</span><span class="cx">     // from a pre-existing surface.
</span><span class="lines">@@ -174,7 +175,6 @@
</span><span class="cx"> 
</span><span class="cx">     glTexImage2D(GL_TEXTURE_2D, 0 /* level */, GL_RGBA, m_size.width(), m_size.height(), 0 /* border */, GL_RGBA, GL_UNSIGNED_BYTE, 0);
</span><span class="cx"> 
</span><del>-    GLContext* context = GLContext::sharingContext();
</del><span class="cx">     cairo_device_t* device = context-&gt;cairoDevice();
</span><span class="cx"> 
</span><span class="cx">     // Thread-awareness is a huge performance hit on non-Intel drivers.
</span><span class="lines">@@ -563,7 +563,7 @@
</span><span class="cx">     ASSERT(m_texture);
</span><span class="cx"> 
</span><span class="cx">     // Cairo may change the active context, so we make sure to change it back after flushing.
</span><del>-    GLContext* previousActiveContext = GLContext::getCurrent();
</del><ins>+    GLContext* previousActiveContext = GLContext::current();
</ins><span class="cx">     cairo_surface_flush(m_surface.get());
</span><span class="cx">     previousActiveContext-&gt;makeContextCurrent();
</span><span class="cx"> 
</span><span class="lines">@@ -609,7 +609,7 @@
</span><span class="cx"> 
</span><span class="cx">     cairo_surface_flush(m_data.m_surface.get());
</span><span class="cx"> 
</span><del>-    std::unique_ptr&lt;GLContext&gt; context = GLContext::createContextForWindow(0, GLContext::sharingContext());
</del><ins>+    std::unique_ptr&lt;GLContext&gt; context = GLContext::createOffscreenContext(&amp;PlatformDisplay::sharedDisplayForCompositing());
</ins><span class="cx">     context-&gt;makeContextCurrent();
</span><span class="cx">     uint32_t fbo;
</span><span class="cx">     glGenFramebuffers(1, &amp;fbo);
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicseglGLContextEGLcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/egl/GLContextEGL.cpp (205115 => 205116)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/egl/GLContextEGL.cpp        2016-08-29 09:18:06 UTC (rev 205115)
+++ trunk/Source/WebCore/platform/graphics/egl/GLContextEGL.cpp        2016-08-29 09:33:40 UTC (rev 205116)
</span><span class="lines">@@ -22,7 +22,6 @@
</span><span class="cx"> #if USE(EGL)
</span><span class="cx"> 
</span><span class="cx"> #include &quot;GraphicsContext3D.h&quot;
</span><del>-#include &quot;PlatformDisplay.h&quot;
</del><span class="cx"> 
</span><span class="cx"> #if USE(CAIRO)
</span><span class="cx"> #include &lt;cairo.h&gt;
</span><span class="lines">@@ -40,6 +39,11 @@
</span><span class="cx"> #include &lt;X11/Xlib.h&gt;
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><ins>+#if PLATFORM(WAYLAND)
+#include &quot;PlatformDisplayWayland.h&quot;
+#include &lt;wayland-egl.h&gt;
+#endif
+
</ins><span class="cx"> #if ENABLE(ACCELERATED_2D_CANVAS)
</span><span class="cx"> // cairo-gl.h includes some definitions from GLX that conflict with
</span><span class="cx"> // the ones provided by us. Since GLContextEGL doesn't use any GLX
</span><span class="lines">@@ -50,11 +54,6 @@
</span><span class="cx"> 
</span><span class="cx"> namespace WebCore {
</span><span class="cx"> 
</span><del>-static EGLDisplay sharedEGLDisplay()
-{
-    return PlatformDisplay::sharedDisplay().eglDisplay();
-}
-
</del><span class="cx"> static const EGLint gContextAttributes[] = {
</span><span class="cx"> #if USE(OPENGL_ES_2)
</span><span class="cx">     EGL_CONTEXT_CLIENT_VERSION, 2,
</span><span class="lines">@@ -62,7 +61,13 @@
</span><span class="cx">     EGL_NONE
</span><span class="cx"> };
</span><span class="cx"> 
</span><del>-static bool getEGLConfig(EGLConfig* config, GLContextEGL::EGLSurfaceType surfaceType)
</del><ins>+#if USE(OPENGL_ES_2)
+static const EGLenum gEGLAPIVersion = EGL_OPENGL_ES_API;
+#else
+static const EGLenum gEGLAPIVersion = EGL_OPENGL_API;
+#endif
+
+bool GLContextEGL::getEGLConfig(EGLDisplay display, EGLConfig* config, EGLSurfaceType surfaceType)
</ins><span class="cx"> {
</span><span class="cx">     EGLint attributeList[] = {
</span><span class="cx"> #if USE(OPENGL_ES_2)
</span><span class="lines">@@ -87,27 +92,23 @@
</span><span class="cx">         attributeList[13] = EGL_PIXMAP_BIT;
</span><span class="cx">         break;
</span><span class="cx">     case GLContextEGL::WindowSurface:
</span><ins>+    case GLContextEGL::Surfaceless:
</ins><span class="cx">         attributeList[13] = EGL_WINDOW_BIT;
</span><span class="cx">         break;
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     EGLint numberConfigsReturned;
</span><del>-    return eglChooseConfig(sharedEGLDisplay(), attributeList, config, 1, &amp;numberConfigsReturned) &amp;&amp; numberConfigsReturned;
</del><ins>+    return eglChooseConfig(display, attributeList, config, 1, &amp;numberConfigsReturned) &amp;&amp; numberConfigsReturned;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-std::unique_ptr&lt;GLContextEGL&gt; GLContextEGL::createWindowContext(EGLNativeWindowType window, GLContext* sharingContext, std::unique_ptr&lt;GLContext::Data&gt;&amp;&amp; contextData)
</del><ins>+std::unique_ptr&lt;GLContextEGL&gt; GLContextEGL::createWindowContext(EGLNativeWindowType window, PlatformDisplay&amp; platformDisplay, EGLContext sharingContext)
</ins><span class="cx"> {
</span><del>-    EGLContext eglSharingContext = sharingContext ? static_cast&lt;GLContextEGL*&gt;(sharingContext)-&gt;m_context : 0;
-
-    EGLDisplay display = sharedEGLDisplay();
-    if (display == EGL_NO_DISPLAY)
-        return nullptr;
-
</del><ins>+    EGLDisplay display = platformDisplay.eglDisplay();
</ins><span class="cx">     EGLConfig config;
</span><del>-    if (!getEGLConfig(&amp;config, WindowSurface))
</del><ins>+    if (!getEGLConfig(display, &amp;config, WindowSurface))
</ins><span class="cx">         return nullptr;
</span><span class="cx"> 
</span><del>-    EGLContext context = eglCreateContext(display, config, eglSharingContext, gContextAttributes);
</del><ins>+    EGLContext context = eglCreateContext(display, config, sharingContext, gContextAttributes);
</ins><span class="cx">     if (context == EGL_NO_CONTEXT)
</span><span class="cx">         return nullptr;
</span><span class="cx"> 
</span><span class="lines">@@ -117,19 +118,14 @@
</span><span class="cx">         return nullptr;
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    auto glContext = std::make_unique&lt;GLContextEGL&gt;(context, surface, WindowSurface);
-    glContext-&gt;m_contextData = WTFMove(contextData);
-    return glContext;
</del><ins>+    return std::unique_ptr&lt;GLContextEGL&gt;(new GLContextEGL(platformDisplay, context, surface, WindowSurface));
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-std::unique_ptr&lt;GLContextEGL&gt; GLContextEGL::createPbufferContext(EGLContext sharingContext)
</del><ins>+std::unique_ptr&lt;GLContextEGL&gt; GLContextEGL::createPbufferContext(PlatformDisplay&amp; platformDisplay, EGLContext sharingContext)
</ins><span class="cx"> {
</span><del>-    EGLDisplay display = sharedEGLDisplay();
-    if (display == EGL_NO_DISPLAY)
-        return nullptr;
-
</del><ins>+    EGLDisplay display = platformDisplay.eglDisplay();
</ins><span class="cx">     EGLConfig config;
</span><del>-    if (!getEGLConfig(&amp;config, PbufferSurface))
</del><ins>+    if (!getEGLConfig(display, &amp;config, PbufferSurface))
</ins><span class="cx">         return nullptr;
</span><span class="cx"> 
</span><span class="cx">     EGLContext context = eglCreateContext(display, config, sharingContext, gContextAttributes);
</span><span class="lines">@@ -143,18 +139,21 @@
</span><span class="cx">         return nullptr;
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    return std::make_unique&lt;GLContextEGL&gt;(context, surface, PbufferSurface);
</del><ins>+    return std::unique_ptr&lt;GLContextEGL&gt;(new GLContextEGL(platformDisplay, context, surface, PbufferSurface));
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-#if PLATFORM(X11)
-std::unique_ptr&lt;GLContextEGL&gt; GLContextEGL::createPixmapContext(EGLContext sharingContext)
</del><ins>+std::unique_ptr&lt;GLContextEGL&gt; GLContextEGL::createSurfacelessContext(PlatformDisplay&amp; platformDisplay, EGLContext sharingContext)
</ins><span class="cx"> {
</span><del>-    EGLDisplay display = sharedEGLDisplay();
</del><ins>+    EGLDisplay display = platformDisplay.eglDisplay();
</ins><span class="cx">     if (display == EGL_NO_DISPLAY)
</span><span class="cx">         return nullptr;
</span><span class="cx"> 
</span><ins>+    const char* extensions = eglQueryString(display, EGL_EXTENSIONS);
+    if (!strstr(extensions, &quot;EGL_KHR_surfaceless_context&quot;) &amp;&amp; !strstr(extensions, &quot;EGL_KHR_surfaceless_opengl&quot;))
+        return nullptr;
+
</ins><span class="cx">     EGLConfig config;
</span><del>-    if (!getEGLConfig(&amp;config, PixmapSurface))
</del><ins>+    if (!getEGLConfig(display, &amp;config, Surfaceless))
</ins><span class="cx">         return nullptr;
</span><span class="cx"> 
</span><span class="cx">     EGLContext context = eglCreateContext(display, config, sharingContext, gContextAttributes);
</span><span class="lines">@@ -161,6 +160,21 @@
</span><span class="cx">     if (context == EGL_NO_CONTEXT)
</span><span class="cx">         return nullptr;
</span><span class="cx"> 
</span><ins>+    return std::unique_ptr&lt;GLContextEGL&gt;(new GLContextEGL(platformDisplay, context, EGL_NO_SURFACE, Surfaceless));
+}
+
+#if PLATFORM(X11)
+std::unique_ptr&lt;GLContextEGL&gt; GLContextEGL::createPixmapContext(PlatformDisplay&amp; platformDisplay, EGLContext sharingContext)
+{
+    EGLDisplay display = platformDisplay.eglDisplay();
+    EGLConfig config;
+    if (!getEGLConfig(display, &amp;config, PixmapSurface))
+        return nullptr;
+
+    EGLContext context = eglCreateContext(display, config, sharingContext, gContextAttributes);
+    if (context == EGL_NO_CONTEXT)
+        return nullptr;
+
</ins><span class="cx">     EGLint depth;
</span><span class="cx">     if (!eglGetConfigAttrib(display, config, EGL_DEPTH_SIZE, &amp;depth)) {
</span><span class="cx">         eglDestroyContext(display, context);
</span><span class="lines">@@ -167,7 +181,7 @@
</span><span class="cx">         return nullptr;
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    Display* x11Display = downcast&lt;PlatformDisplayX11&gt;(PlatformDisplay::sharedDisplay()).native();
</del><ins>+    Display* x11Display = downcast&lt;PlatformDisplayX11&gt;(platformDisplay).native();
</ins><span class="cx">     XUniquePixmap pixmap = XCreatePixmap(x11Display, DefaultRootWindow(x11Display), 1, 1, depth);
</span><span class="cx">     if (!pixmap) {
</span><span class="cx">         eglDestroyContext(display, context);
</span><span class="lines">@@ -180,49 +194,107 @@
</span><span class="cx">         return nullptr;
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    return std::make_unique&lt;GLContextEGL&gt;(context, surface, WTFMove(pixmap));
</del><ins>+    return std::unique_ptr&lt;GLContextEGL&gt;(new GLContextEGL(platformDisplay, context, surface, WTFMove(pixmap)));
</ins><span class="cx"> }
</span><span class="cx"> #endif // PLATFORM(X11)
</span><span class="cx"> 
</span><del>-std::unique_ptr&lt;GLContextEGL&gt; GLContextEGL::createContext(EGLNativeWindowType window, GLContext* sharingContext)
</del><ins>+#if PLATFORM(WAYLAND)
+std::unique_ptr&lt;GLContextEGL&gt; GLContextEGL::createWaylandContext(PlatformDisplay&amp; platformDisplay, EGLContext sharingContext)
</ins><span class="cx"> {
</span><del>-    if (!sharedEGLDisplay())
</del><ins>+    EGLDisplay display = platformDisplay.eglDisplay();
+    EGLConfig config;
+    if (!getEGLConfig(display, &amp;config, WindowSurface))
</ins><span class="cx">         return nullptr;
</span><span class="cx"> 
</span><del>-    static bool initialized = false;
-    static bool success = true;
-    if (!initialized) {
-#if !USE(OPENGL_ES_2)
-        success = initializeOpenGLShims();
</del><ins>+    EGLContext context = eglCreateContext(display, config, sharingContext, gContextAttributes);
+    if (context == EGL_NO_CONTEXT)
+        return nullptr;
+
+    WlUniquePtr&lt;struct wl_surface&gt; wlSurface(downcast&lt;PlatformDisplayWayland&gt;(platformDisplay).createSurface());
+    if (!wlSurface) {
+        eglDestroyContext(display, context);
+        return nullptr;
+    }
+
+    EGLNativeWindowType window = wl_egl_window_create(wlSurface.get(), 1, 1);
+    EGLSurface surface = eglCreateWindowSurface(display, config, window, 0);
+    if (surface == EGL_NO_SURFACE) {
+        eglDestroyContext(display, context);
+        wl_egl_window_destroy(window);
+        return nullptr;
+    }
+
+    return std::unique_ptr&lt;GLContextEGL&gt;(new GLContextEGL(platformDisplay, context, surface, WTFMove(wlSurface), window));
+}
</ins><span class="cx"> #endif
</span><del>-        initialized = true;
</del><ins>+
+std::unique_ptr&lt;GLContextEGL&gt; GLContextEGL::createContext(EGLNativeWindowType window, PlatformDisplay&amp; platformDisplay)
+{
+    if (platformDisplay.eglDisplay() == EGL_NO_DISPLAY)
+        return nullptr;
+
+    if (eglBindAPI(gEGLAPIVersion) == EGL_FALSE)
+        return nullptr;
+
+    EGLContext eglSharingContext = platformDisplay.sharingGLContext() ? static_cast&lt;GLContextEGL*&gt;(platformDisplay.sharingGLContext())-&gt;m_context : EGL_NO_CONTEXT;
+    auto context = window ? createWindowContext(window, platformDisplay, eglSharingContext) : nullptr;
+    if (!context)
+        context = createSurfacelessContext(platformDisplay, eglSharingContext);
+    if (!context) {
+#if PLATFORM(X11)
+        if (platformDisplay.type() == PlatformDisplay::Type::X11)
+            context = createPixmapContext(platformDisplay, eglSharingContext);
+#endif
+#if PLATFORM(WAYLAND)
+        if (platformDisplay.type() == PlatformDisplay::Type::Wayland)
+            context = createWaylandContext(platformDisplay, eglSharingContext);
+#endif
</ins><span class="cx">     }
</span><del>-    if (!success)
</del><ins>+    if (!context)
+        context = createPbufferContext(platformDisplay, eglSharingContext);
+
+    return context;
+}
+
+std::unique_ptr&lt;GLContextEGL&gt; GLContextEGL::createSharingContext(PlatformDisplay&amp; platformDisplay)
+{
+    if (platformDisplay.eglDisplay() == EGL_NO_DISPLAY)
</ins><span class="cx">         return nullptr;
</span><span class="cx"> 
</span><del>-    EGLContext eglSharingContext = sharingContext ? static_cast&lt;GLContextEGL*&gt;(sharingContext)-&gt;m_context : 0;
-    auto context = window ? createWindowContext(window, sharingContext) : nullptr;
</del><ins>+    if (eglBindAPI(gEGLAPIVersion) == EGL_FALSE)
+        return nullptr;
+
+    auto context = createSurfacelessContext(platformDisplay);
+    if (!context) {
</ins><span class="cx"> #if PLATFORM(X11)
</span><del>-    if (!context)
-        context = createPixmapContext(eglSharingContext);
</del><ins>+        if (platformDisplay.type() == PlatformDisplay::Type::X11)
+            context = createPixmapContext(platformDisplay);
</ins><span class="cx"> #endif
</span><ins>+#if PLATFORM(WAYLAND)
+        if (platformDisplay.type() == PlatformDisplay::Type::Wayland)
+            context = createWaylandContext(platformDisplay);
+#endif
+    }
</ins><span class="cx">     if (!context)
</span><del>-        context = createPbufferContext(eglSharingContext);
</del><ins>+        context = createPbufferContext(platformDisplay);
</ins><span class="cx"> 
</span><span class="cx">     return context;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-GLContextEGL::GLContextEGL(EGLContext context, EGLSurface surface, EGLSurfaceType type)
-    : m_context(context)
</del><ins>+GLContextEGL::GLContextEGL(PlatformDisplay&amp; display, EGLContext context, EGLSurface surface, EGLSurfaceType type)
+    : GLContext(display)
+    , m_context(context)
</ins><span class="cx">     , m_surface(surface)
</span><span class="cx">     , m_type(type)
</span><span class="cx"> {
</span><span class="cx">     ASSERT(type != PixmapSurface);
</span><ins>+    ASSERT(type == Surfaceless || surface != EGL_NO_SURFACE);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> #if PLATFORM(X11)
</span><del>-GLContextEGL::GLContextEGL(EGLContext context, EGLSurface surface, XUniquePixmap&amp;&amp; pixmap)
-    : m_context(context)
</del><ins>+GLContextEGL::GLContextEGL(PlatformDisplay&amp; display, EGLContext context, EGLSurface surface, XUniquePixmap&amp;&amp; pixmap)
+    : GLContext(display)
+    , m_context(context)
</ins><span class="cx">     , m_surface(surface)
</span><span class="cx">     , m_type(PixmapSurface)
</span><span class="cx">     , m_pixmap(WTFMove(pixmap))
</span><span class="lines">@@ -230,6 +302,18 @@
</span><span class="cx"> }
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><ins>+#if PLATFORM(WAYLAND)
+GLContextEGL::GLContextEGL(PlatformDisplay&amp; display, EGLContext context, EGLSurface surface, WlUniquePtr&lt;struct wl_surface&gt;&amp;&amp; wlSurface, EGLNativeWindowType wlWindow)
+    : GLContext(display)
+    , m_context(context)
+    , m_surface(surface)
+    , m_type(WindowSurface)
+    , m_wlSurface(WTFMove(wlSurface))
+    , m_wlWindow(wlWindow)
+{
+}
+#endif
+
</ins><span class="cx"> GLContextEGL::~GLContextEGL()
</span><span class="cx"> {
</span><span class="cx"> #if USE(CAIRO)
</span><span class="lines">@@ -237,7 +321,7 @@
</span><span class="cx">         cairo_device_destroy(m_cairoDevice);
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><del>-    EGLDisplay display = sharedEGLDisplay();
</del><ins>+    EGLDisplay display = m_display.eglDisplay();
</ins><span class="cx">     if (m_context) {
</span><span class="cx">         glBindFramebuffer(GL_FRAMEBUFFER, 0);
</span><span class="cx">         eglMakeCurrent(display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
</span><span class="lines">@@ -246,6 +330,11 @@
</span><span class="cx"> 
</span><span class="cx">     if (m_surface)
</span><span class="cx">         eglDestroySurface(display, m_surface);
</span><ins>+
+#if PLATFORM(WAYLAND)
+    if (m_wlWindow)
+        wl_egl_window_destroy(m_wlWindow);
+#endif
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> bool GLContextEGL::canRenderToDefaultFramebuffer()
</span><span class="lines">@@ -258,9 +347,10 @@
</span><span class="cx">     if (!canRenderToDefaultFramebuffer())
</span><span class="cx">         return IntSize();
</span><span class="cx"> 
</span><ins>+    EGLDisplay display = m_display.eglDisplay();
</ins><span class="cx">     EGLint width, height;
</span><del>-    if (!eglQuerySurface(sharedEGLDisplay(), m_surface, EGL_WIDTH, &amp;width)
-        || !eglQuerySurface(sharedEGLDisplay(), m_surface, EGL_HEIGHT, &amp;height))
</del><ins>+    if (!eglQuerySurface(display, m_surface, EGL_WIDTH, &amp;width)
+        || !eglQuerySurface(display, m_surface, EGL_HEIGHT, &amp;height))
</ins><span class="cx">         return IntSize();
</span><span class="cx"> 
</span><span class="cx">     return IntSize(width, height);
</span><span class="lines">@@ -268,19 +358,19 @@
</span><span class="cx"> 
</span><span class="cx"> bool GLContextEGL::makeContextCurrent()
</span><span class="cx"> {
</span><del>-    ASSERT(m_context &amp;&amp; m_surface);
</del><ins>+    ASSERT(m_context);
</ins><span class="cx"> 
</span><span class="cx">     GLContext::makeContextCurrent();
</span><span class="cx">     if (eglGetCurrentContext() == m_context)
</span><span class="cx">         return true;
</span><span class="cx"> 
</span><del>-    return eglMakeCurrent(sharedEGLDisplay(), m_surface, m_surface, m_context);
</del><ins>+    return eglMakeCurrent(m_display.eglDisplay(), m_surface, m_surface, m_context);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void GLContextEGL::swapBuffers()
</span><span class="cx"> {
</span><span class="cx">     ASSERT(m_surface);
</span><del>-    eglSwapBuffers(sharedEGLDisplay(), m_surface);
</del><ins>+    eglSwapBuffers(m_display.eglDisplay(), m_surface);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void GLContextEGL::waitNative()
</span><span class="lines">@@ -288,6 +378,12 @@
</span><span class="cx">     eglWaitNative(EGL_CORE_NATIVE_ENGINE);
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void GLContextEGL::swapInterval(int interval)
+{
+    ASSERT(m_surface);
+    eglSwapInterval(m_display.eglDisplay(), interval);
+}
+
</ins><span class="cx"> #if USE(CAIRO)
</span><span class="cx"> cairo_device_t* GLContextEGL::cairoDevice()
</span><span class="cx"> {
</span><span class="lines">@@ -295,7 +391,7 @@
</span><span class="cx">         return m_cairoDevice;
</span><span class="cx"> 
</span><span class="cx"> #if ENABLE(ACCELERATED_2D_CANVAS)
</span><del>-    m_cairoDevice = cairo_egl_device_create(sharedEGLDisplay(), m_context);
</del><ins>+    m_cairoDevice = cairo_egl_device_create(m_display.eglDisplay(), m_context);
</ins><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="cx">     return m_cairoDevice;
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicseglGLContextEGLh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/egl/GLContextEGL.h (205115 => 205116)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/egl/GLContextEGL.h        2016-08-29 09:18:06 UTC (rev 205115)
+++ trunk/Source/WebCore/platform/graphics/egl/GLContextEGL.h        2016-08-29 09:33:40 UTC (rev 205116)
</span><span class="lines">@@ -29,49 +29,68 @@
</span><span class="cx"> #include &quot;XUniqueResource.h&quot;
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><ins>+#if PLATFORM(WAYLAND)
+#include &quot;WlUniquePtr.h&quot;
+#endif
+
</ins><span class="cx"> namespace WebCore {
</span><span class="cx"> 
</span><del>-class GLContextEGL : public GLContext {
</del><ins>+class GLContextEGL final : public GLContext {
</ins><span class="cx">     WTF_MAKE_NONCOPYABLE(GLContextEGL);
</span><span class="cx"> public:
</span><del>-    enum EGLSurfaceType { PbufferSurface, WindowSurface, PixmapSurface };
-    static std::unique_ptr&lt;GLContextEGL&gt; createContext(EGLNativeWindowType, GLContext* sharingContext = 0);
-    static std::unique_ptr&lt;GLContextEGL&gt; createWindowContext(EGLNativeWindowType, GLContext* sharingContext, std::unique_ptr&lt;GLContext::Data&gt;&amp;&amp; = nullptr);
</del><ins>+    static std::unique_ptr&lt;GLContextEGL&gt; createContext(EGLNativeWindowType, PlatformDisplay&amp;);
+    static std::unique_ptr&lt;GLContextEGL&gt; createSharingContext(PlatformDisplay&amp;);
</ins><span class="cx"> 
</span><del>-    GLContextEGL(EGLContext, EGLSurface, EGLSurfaceType);
-#if PLATFORM(X11)
-    GLContextEGL(EGLContext, EGLSurface, XUniquePixmap&amp;&amp;);
-#endif
</del><span class="cx">     virtual ~GLContextEGL();
</span><del>-    virtual bool makeContextCurrent();
-    virtual void swapBuffers();
-    virtual void waitNative();
-    virtual bool canRenderToDefaultFramebuffer();
-    virtual IntSize defaultFrameBufferSize();
</del><ins>+
+    bool makeContextCurrent() override;
+    void swapBuffers() override;
+    void waitNative() override;
+    bool canRenderToDefaultFramebuffer() override;
+    IntSize defaultFrameBufferSize() override;
+    void swapInterval(int) override;
</ins><span class="cx"> #if USE(CAIRO)
</span><del>-    virtual cairo_device_t* cairoDevice();
</del><ins>+    cairo_device_t* cairoDevice() override;
</ins><span class="cx"> #endif
</span><del>-    virtual bool isEGLContext() const { return true; }
</del><ins>+    bool isEGLContext() const override { return true; }
</ins><span class="cx"> 
</span><span class="cx"> #if ENABLE(GRAPHICS_CONTEXT_3D)
</span><del>-    virtual PlatformGraphicsContext3D platformContext();
</del><ins>+    PlatformGraphicsContext3D platformContext() override;
</ins><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="cx"> private:
</span><del>-    static std::unique_ptr&lt;GLContextEGL&gt; createPbufferContext(EGLContext sharingContext);
</del><ins>+    enum EGLSurfaceType { PbufferSurface, WindowSurface, PixmapSurface, Surfaceless };
+
+    GLContextEGL(PlatformDisplay&amp;, EGLContext, EGLSurface, EGLSurfaceType);
</ins><span class="cx"> #if PLATFORM(X11)
</span><del>-    static std::unique_ptr&lt;GLContextEGL&gt; createPixmapContext(EGLContext sharingContext);
</del><ins>+    GLContextEGL(PlatformDisplay&amp;, EGLContext, EGLSurface, XUniquePixmap&amp;&amp;);
</ins><span class="cx"> #endif
</span><ins>+#if PLATFORM(WAYLAND)
+    GLContextEGL(PlatformDisplay&amp;, EGLContext, EGLSurface, WlUniquePtr&lt;struct wl_surface&gt;&amp;&amp;, EGLNativeWindowType);
+#endif
</ins><span class="cx"> 
</span><del>-    static void addActiveContext(GLContextEGL*);
-    static void cleanupSharedEGLDisplay(void);
</del><ins>+    static std::unique_ptr&lt;GLContextEGL&gt; createWindowContext(EGLNativeWindowType, PlatformDisplay&amp;, EGLContext sharingContext = EGL_NO_CONTEXT);
+    static std::unique_ptr&lt;GLContextEGL&gt; createPbufferContext(PlatformDisplay&amp;, EGLContext sharingContext = EGL_NO_CONTEXT);
+    static std::unique_ptr&lt;GLContextEGL&gt; createSurfacelessContext(PlatformDisplay&amp;, EGLContext sharingContext = EGL_NO_CONTEXT);
+#if PLATFORM(X11)
+    static std::unique_ptr&lt;GLContextEGL&gt; createPixmapContext(PlatformDisplay&amp;, EGLContext sharingContext = EGL_NO_CONTEXT);
+#endif
+#if PLATFORM(WAYLAND)
+    static std::unique_ptr&lt;GLContextEGL&gt; createWaylandContext(PlatformDisplay&amp;, EGLContext sharingContext = EGL_NO_CONTEXT);
+#endif
</ins><span class="cx"> 
</span><del>-    EGLContext m_context;
-    EGLSurface m_surface;
</del><ins>+    static bool getEGLConfig(EGLDisplay, EGLConfig*, EGLSurfaceType);
+
+    EGLContext m_context { EGL_NO_CONTEXT };
+    EGLSurface m_surface { EGL_NO_SURFACE };
</ins><span class="cx">     EGLSurfaceType m_type;
</span><span class="cx"> #if PLATFORM(X11)
</span><span class="cx">     XUniquePixmap m_pixmap;
</span><span class="cx"> #endif
</span><ins>+#if PLATFORM(WAYLAND)
+    WlUniquePtr&lt;struct wl_surface&gt; m_wlSurface;
+    struct wl_egl_window* m_wlWindow { nullptr };
+#endif
</ins><span class="cx"> #if USE(CAIRO)
</span><span class="cx">     cairo_device_t* m_cairoDevice { nullptr };
</span><span class="cx"> #endif
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsglxGLContextGLXcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/glx/GLContextGLX.cpp (205115 => 205116)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/glx/GLContextGLX.cpp        2016-08-29 09:18:06 UTC (rev 205115)
+++ trunk/Source/WebCore/platform/graphics/glx/GLContextGLX.cpp        2016-08-29 09:33:40 UTC (rev 205116)
</span><span class="lines">@@ -32,9 +32,30 @@
</span><span class="cx"> 
</span><span class="cx"> namespace WebCore {
</span><span class="cx"> 
</span><del>-std::unique_ptr&lt;GLContextGLX&gt; GLContextGLX::createWindowContext(XID window, GLContext* sharingContext)
</del><ins>+#if !defined(PFNGLXSWAPINTERVALSGIPROC)
+typedef int (*PFNGLXSWAPINTERVALSGIPROC) (int);
+#endif
+
+static PFNGLXSWAPINTERVALSGIPROC glXSwapIntervalSGI;
+
+static bool hasSGISwapControlExtension(Display* display)
</ins><span class="cx"> {
</span><del>-    Display* display = downcast&lt;PlatformDisplayX11&gt;(PlatformDisplay::sharedDisplay()).native();
</del><ins>+    static bool initialized = false;
+    if (initialized)
+        return !!glXSwapIntervalSGI;
+
+    initialized = true;
+    const char* extensions = glXQueryExtensionsString(display, 0);
+    if (!strstr(extensions, &quot;GLX_SGI_swap_control&quot;))
+        return false;
+
+    glXSwapIntervalSGI = reinterpret_cast&lt;PFNGLXSWAPINTERVALSGIPROC&gt;(glXGetProcAddress(reinterpret_cast&lt;const unsigned char*&gt;(&quot;glXSwapIntervalSGI&quot;)));
+    return !!glXSwapIntervalSGI;
+}
+
+std::unique_ptr&lt;GLContextGLX&gt; GLContextGLX::createWindowContext(XID window, PlatformDisplay&amp; platformDisplay, GLXContext sharingContext)
+{
+    Display* display = downcast&lt;PlatformDisplayX11&gt;(platformDisplay).native();
</ins><span class="cx">     XWindowAttributes attributes;
</span><span class="cx">     if (!XGetWindowAttributes(display, window, &amp;attributes))
</span><span class="cx">         return nullptr;
</span><span class="lines">@@ -45,15 +66,14 @@
</span><span class="cx">     int numReturned = 0;
</span><span class="cx">     XUniquePtr&lt;XVisualInfo&gt; visualInfoList(XGetVisualInfo(display, VisualIDMask, &amp;visualInfo, &amp;numReturned));
</span><span class="cx"> 
</span><del>-    GLXContext glxSharingContext = sharingContext ? static_cast&lt;GLContextGLX*&gt;(sharingContext)-&gt;m_context.get() : nullptr;
-    XUniqueGLXContext context(glXCreateContext(display, visualInfoList.get(), glxSharingContext, True));
</del><ins>+    XUniqueGLXContext context(glXCreateContext(display, visualInfoList.get(), sharingContext, True));
</ins><span class="cx">     if (!context)
</span><span class="cx">         return nullptr;
</span><span class="cx"> 
</span><del>-    return std::make_unique&lt;GLContextGLX&gt;(WTFMove(context), window);
</del><ins>+    return std::unique_ptr&lt;GLContextGLX&gt;(new GLContextGLX(platformDisplay, WTFMove(context), window));
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-std::unique_ptr&lt;GLContextGLX&gt; GLContextGLX::createPbufferContext(GLXContext sharingContext)
</del><ins>+std::unique_ptr&lt;GLContextGLX&gt; GLContextGLX::createPbufferContext(PlatformDisplay&amp; platformDisplay, GLXContext sharingContext)
</ins><span class="cx"> {
</span><span class="cx">     static const int fbConfigAttributes[] = {
</span><span class="cx">         GLX_DRAWABLE_TYPE, GLX_PBUFFER_BIT,
</span><span class="lines">@@ -67,7 +87,7 @@
</span><span class="cx">     };
</span><span class="cx"> 
</span><span class="cx">     int returnedElements;
</span><del>-    Display* display = downcast&lt;PlatformDisplayX11&gt;(PlatformDisplay::sharedDisplay()).native();
</del><ins>+    Display* display = downcast&lt;PlatformDisplayX11&gt;(platformDisplay).native();
</ins><span class="cx">     XUniquePtr&lt;GLXFBConfig&gt; configs(glXChooseFBConfig(display, 0, fbConfigAttributes, &amp;returnedElements));
</span><span class="cx">     if (!returnedElements)
</span><span class="cx">         return nullptr;
</span><span class="lines">@@ -82,10 +102,10 @@
</span><span class="cx">     if (!context)
</span><span class="cx">         return nullptr;
</span><span class="cx"> 
</span><del>-    return std::make_unique&lt;GLContextGLX&gt;(WTFMove(context), WTFMove(pbuffer));
</del><ins>+    return std::unique_ptr&lt;GLContextGLX&gt;(new GLContextGLX(platformDisplay, WTFMove(context), WTFMove(pbuffer)));
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-std::unique_ptr&lt;GLContextGLX&gt; GLContextGLX::createPixmapContext(GLXContext sharingContext)
</del><ins>+std::unique_ptr&lt;GLContextGLX&gt; GLContextGLX::createPixmapContext(PlatformDisplay&amp; platformDisplay, GLXContext sharingContext)
</ins><span class="cx"> {
</span><span class="cx">     static int visualAttributes[] = {
</span><span class="cx">         GLX_RGBA,
</span><span class="lines">@@ -96,7 +116,7 @@
</span><span class="cx">         0
</span><span class="cx">     };
</span><span class="cx"> 
</span><del>-    Display* display = downcast&lt;PlatformDisplayX11&gt;(PlatformDisplay::sharedDisplay()).native();
</del><ins>+    Display* display = downcast&lt;PlatformDisplayX11&gt;(platformDisplay).native();
</ins><span class="cx">     XUniquePtr&lt;XVisualInfo&gt; visualInfo(glXChooseVisual(display, DefaultScreen(display), visualAttributes));
</span><span class="cx">     if (!visualInfo)
</span><span class="cx">         return nullptr;
</span><span class="lines">@@ -113,46 +133,46 @@
</span><span class="cx">     if (!glxPixmap)
</span><span class="cx">         return nullptr;
</span><span class="cx"> 
</span><del>-    return std::make_unique&lt;GLContextGLX&gt;(WTFMove(context), WTFMove(pixmap), WTFMove(glxPixmap));
</del><ins>+    return std::unique_ptr&lt;GLContextGLX&gt;(new GLContextGLX(platformDisplay, WTFMove(context), WTFMove(pixmap), WTFMove(glxPixmap)));
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-std::unique_ptr&lt;GLContextGLX&gt; GLContextGLX::createContext(XID window, GLContext* sharingContext)
</del><ins>+std::unique_ptr&lt;GLContextGLX&gt; GLContextGLX::createContext(XID window, PlatformDisplay&amp; platformDisplay)
</ins><span class="cx"> {
</span><del>-    static bool initialized = false;
-    static bool success = true;
-    if (!initialized) {
-        success = initializeOpenGLShims();
-        initialized = true;
-    }
-    if (!success)
-        return nullptr;
-
-    GLXContext glxSharingContext = sharingContext ? static_cast&lt;GLContextGLX*&gt;(sharingContext)-&gt;m_context.get() : nullptr;
-    auto context = window ? createWindowContext(window, sharingContext) : nullptr;
</del><ins>+    GLXContext glxSharingContext = platformDisplay.sharingGLContext() ? static_cast&lt;GLContextGLX*&gt;(platformDisplay.sharingGLContext())-&gt;m_context.get() : nullptr;
+    auto context = window ? createWindowContext(window, platformDisplay, glxSharingContext) : nullptr;
</ins><span class="cx">     if (!context)
</span><del>-        context = createPbufferContext(glxSharingContext);
</del><ins>+        context = createPbufferContext(platformDisplay, glxSharingContext);
</ins><span class="cx">     if (!context)
</span><del>-        context = createPixmapContext(glxSharingContext);
-    if (!context)
-        return nullptr;
</del><ins>+        context = createPixmapContext(platformDisplay, glxSharingContext);
</ins><span class="cx"> 
</span><span class="cx">     return context;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-GLContextGLX::GLContextGLX(XUniqueGLXContext&amp;&amp; context, XID window)
-    : m_context(WTFMove(context))
</del><ins>+std::unique_ptr&lt;GLContextGLX&gt; GLContextGLX::createSharingContext(PlatformDisplay&amp; platformDisplay)
+{
+    auto context = createPbufferContext(platformDisplay);
+    if (!context)
+        context = createPixmapContext(platformDisplay);
+    return context;
+}
+
+GLContextGLX::GLContextGLX(PlatformDisplay&amp; display, XUniqueGLXContext&amp;&amp; context, XID window)
+    : GLContext(display)
+    , m_context(WTFMove(context))
</ins><span class="cx">     , m_window(window)
</span><span class="cx"> {
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-GLContextGLX::GLContextGLX(XUniqueGLXContext&amp;&amp; context, XUniqueGLXPbuffer&amp;&amp; pbuffer)
-    : m_context(WTFMove(context))
</del><ins>+GLContextGLX::GLContextGLX(PlatformDisplay&amp; display, XUniqueGLXContext&amp;&amp; context, XUniqueGLXPbuffer&amp;&amp; pbuffer)
+    : GLContext(display)
+    , m_context(WTFMove(context))
</ins><span class="cx">     , m_pbuffer(WTFMove(pbuffer))
</span><span class="cx"> {
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-GLContextGLX::GLContextGLX(XUniqueGLXContext&amp;&amp; context, XUniquePixmap&amp;&amp; pixmap, XUniqueGLXPixmap&amp;&amp; glxPixmap)
-    : m_context(WTFMove(context))
</del><ins>+GLContextGLX::GLContextGLX(PlatformDisplay&amp; display, XUniqueGLXContext&amp;&amp; context, XUniquePixmap&amp;&amp; pixmap, XUniqueGLXPixmap&amp;&amp; glxPixmap)
+    : GLContext(display)
+    , m_context(WTFMove(context))
</ins><span class="cx">     , m_pixmap(WTFMove(pixmap))
</span><span class="cx">     , m_glxPixmap(WTFMove(glxPixmap))
</span><span class="cx"> {
</span><span class="lines">@@ -166,9 +186,8 @@
</span><span class="cx">     if (m_context) {
</span><span class="cx">         // This may be necessary to prevent crashes with NVidia's closed source drivers. Originally
</span><span class="cx">         // from Mozilla's 3D canvas implementation at: http://bitbucket.org/ilmari/canvas3d/
</span><del>-        Display* display = downcast&lt;PlatformDisplayX11&gt;(PlatformDisplay::sharedDisplay()).native();
</del><span class="cx">         glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
</span><del>-        glXMakeCurrent(display, None, None);
</del><ins>+        glXMakeCurrent(downcast&lt;PlatformDisplayX11&gt;(m_display).native(), None, None);
</ins><span class="cx">     }
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -185,8 +204,7 @@
</span><span class="cx">     int x, y;
</span><span class="cx">     Window rootWindow;
</span><span class="cx">     unsigned int width, height, borderWidth, depth;
</span><del>-    Display* display = downcast&lt;PlatformDisplayX11&gt;(PlatformDisplay::sharedDisplay()).native();
-    if (!XGetGeometry(display, m_window, &amp;rootWindow, &amp;x, &amp;y, &amp;width, &amp;height, &amp;borderWidth, &amp;depth))
</del><ins>+    if (!XGetGeometry(downcast&lt;PlatformDisplayX11&gt;(m_display).native(), m_window, &amp;rootWindow, &amp;x, &amp;y, &amp;width, &amp;height, &amp;borderWidth, &amp;depth))
</ins><span class="cx">         return IntSize();
</span><span class="cx"> 
</span><span class="cx">     return IntSize(width, height);
</span><span class="lines">@@ -200,7 +218,7 @@
</span><span class="cx">     if (glXGetCurrentContext() == m_context.get())
</span><span class="cx">         return true;
</span><span class="cx"> 
</span><del>-    Display* display = downcast&lt;PlatformDisplayX11&gt;(PlatformDisplay::sharedDisplay()).native();
</del><ins>+    Display* display = downcast&lt;PlatformDisplayX11&gt;(m_display).native();
</ins><span class="cx">     if (m_window)
</span><span class="cx">         return glXMakeCurrent(display, m_window, m_context.get());
</span><span class="cx"> 
</span><span class="lines">@@ -213,7 +231,7 @@
</span><span class="cx"> void GLContextGLX::swapBuffers()
</span><span class="cx"> {
</span><span class="cx">     if (m_window)
</span><del>-        glXSwapBuffers(downcast&lt;PlatformDisplayX11&gt;(PlatformDisplay::sharedDisplay()).native(), m_window);
</del><ins>+        glXSwapBuffers(downcast&lt;PlatformDisplayX11&gt;(m_display).native(), m_window);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void GLContextGLX::waitNative()
</span><span class="lines">@@ -221,6 +239,13 @@
</span><span class="cx">     glXWaitX();
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void GLContextGLX::swapInterval(int interval)
+{
+    if (!hasSGISwapControlExtension(downcast&lt;PlatformDisplayX11&gt;(m_display).native()))
+        return;
+    glXSwapIntervalSGI(interval);
+}
+
</ins><span class="cx"> cairo_device_t* GLContextGLX::cairoDevice()
</span><span class="cx"> {
</span><span class="cx">     if (m_cairoDevice)
</span><span class="lines">@@ -227,7 +252,7 @@
</span><span class="cx">         return m_cairoDevice;
</span><span class="cx"> 
</span><span class="cx"> #if ENABLE(ACCELERATED_2D_CANVAS) &amp;&amp; CAIRO_HAS_GLX_FUNCTIONS
</span><del>-    m_cairoDevice = cairo_glx_device_create(downcast&lt;PlatformDisplayX11&gt;(PlatformDisplay::sharedDisplay()).native(), m_context.get());
</del><ins>+    m_cairoDevice = cairo_glx_device_create(downcast&lt;PlatformDisplayX11&gt;(m_display).native(), m_context.get());
</ins><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="cx">     return m_cairoDevice;
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsglxGLContextGLXh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/glx/GLContextGLX.h (205115 => 205116)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/glx/GLContextGLX.h        2016-08-29 09:18:06 UTC (rev 205115)
+++ trunk/Source/WebCore/platform/graphics/glx/GLContextGLX.h        2016-08-29 09:33:40 UTC (rev 205116)
</span><span class="lines">@@ -32,32 +32,36 @@
</span><span class="cx"> 
</span><span class="cx"> namespace WebCore {
</span><span class="cx"> 
</span><del>-class GLContextGLX : public GLContext {
</del><ins>+class GLContextGLX final : public GLContext {
</ins><span class="cx">     WTF_MAKE_NONCOPYABLE(GLContextGLX);
</span><span class="cx"> public:
</span><del>-    static std::unique_ptr&lt;GLContextGLX&gt; createContext(XID window, GLContext* sharingContext);
-    static std::unique_ptr&lt;GLContextGLX&gt; createWindowContext(XID window, GLContext* sharingContext);
</del><ins>+    static std::unique_ptr&lt;GLContextGLX&gt; createContext(XID window, PlatformDisplay&amp;);
+    static std::unique_ptr&lt;GLContextGLX&gt; createSharingContext(PlatformDisplay&amp;);
</ins><span class="cx"> 
</span><del>-    GLContextGLX(XUniqueGLXContext&amp;&amp;, XID);
-    GLContextGLX(XUniqueGLXContext&amp;&amp;, XUniqueGLXPbuffer&amp;&amp;);
-    GLContextGLX(XUniqueGLXContext&amp;&amp;, XUniquePixmap&amp;&amp;, XUniqueGLXPixmap&amp;&amp;);
</del><span class="cx">     virtual ~GLContextGLX();
</span><del>-    virtual bool makeContextCurrent();
-    virtual void swapBuffers();
-    virtual void waitNative();
-    virtual bool canRenderToDefaultFramebuffer();
-    virtual IntSize defaultFrameBufferSize();
-    virtual cairo_device_t* cairoDevice();
-    virtual bool isEGLContext() const { return false; }
</del><span class="cx"> 
</span><ins>+    bool makeContextCurrent() override;
+    void swapBuffers() override;
+    void waitNative() override;
+    bool canRenderToDefaultFramebuffer() override;
+    IntSize defaultFrameBufferSize() override;
+    void swapInterval(int) override;
+    cairo_device_t* cairoDevice() override;
+    bool isEGLContext() const override { return false; }
+
</ins><span class="cx"> #if ENABLE(GRAPHICS_CONTEXT_3D)
</span><del>-    virtual PlatformGraphicsContext3D platformContext();
</del><ins>+    PlatformGraphicsContext3D platformContext() override;
</ins><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="cx"> private:
</span><del>-    static std::unique_ptr&lt;GLContextGLX&gt; createPbufferContext(GLXContext sharingContext);
-    static std::unique_ptr&lt;GLContextGLX&gt; createPixmapContext(GLXContext sharingContext);
</del><ins>+    GLContextGLX(PlatformDisplay&amp;, XUniqueGLXContext&amp;&amp;, XID);
+    GLContextGLX(PlatformDisplay&amp;, XUniqueGLXContext&amp;&amp;, XUniqueGLXPbuffer&amp;&amp;);
+    GLContextGLX(PlatformDisplay&amp;, XUniqueGLXContext&amp;&amp;, XUniquePixmap&amp;&amp;, XUniqueGLXPixmap&amp;&amp;);
</ins><span class="cx"> 
</span><ins>+    static std::unique_ptr&lt;GLContextGLX&gt; createWindowContext(XID window, PlatformDisplay&amp;, GLXContext sharingContext = nullptr);
+    static std::unique_ptr&lt;GLContextGLX&gt; createPbufferContext(PlatformDisplay&amp;, GLXContext sharingContext = nullptr);
+    static std::unique_ptr&lt;GLContextGLX&gt; createPixmapContext(PlatformDisplay&amp;, GLXContext sharingContext = nullptr);
+
</ins><span class="cx">     XUniqueGLXContext m_context;
</span><span class="cx">     XID m_window { 0 };
</span><span class="cx">     XUniqueGLXPbuffer m_pbuffer;
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsgstreamerMediaPlayerPrivateGStreamerBasecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.cpp (205115 => 205116)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.cpp        2016-08-29 09:18:06 UTC (rev 205115)
+++ trunk/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.cpp        2016-08-29 09:33:40 UTC (rev 205116)
</span><span class="lines">@@ -235,8 +235,8 @@
</span><span class="cx">     if (m_glContext)
</span><span class="cx">         return true;
</span><span class="cx"> 
</span><ins>+    const auto&amp; sharedDisplay = PlatformDisplay::sharedDisplayForCompositing();
</ins><span class="cx">     if (!m_glDisplay) {
</span><del>-        const auto&amp; sharedDisplay = PlatformDisplay::sharedDisplay();
</del><span class="cx"> #if PLATFORM(X11)
</span><span class="cx">         m_glDisplay = GST_GL_DISPLAY(gst_gl_display_x11_new_with_display(downcast&lt;PlatformDisplayX11&gt;(sharedDisplay).native()));
</span><span class="cx"> #elif PLATFORM(WAYLAND)
</span><span class="lines">@@ -244,7 +244,7 @@
</span><span class="cx"> #endif
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    GLContext* webkitContext = GLContext::sharingContext();
</del><ins>+    GLContext* webkitContext = sharedDisplay.sharingGLContext();
</ins><span class="cx">     // EGL and GLX are mutually exclusive, no need for ifdefs here.
</span><span class="cx">     GstGLPlatform glPlatform = webkitContext-&gt;isEGLContext() ? GST_GL_PLATFORM_EGL : GST_GL_PLATFORM_GLX;
</span><span class="cx"> 
</span><span class="lines">@@ -702,7 +702,7 @@
</span><span class="cx">     if (!gst_video_frame_map(&amp;videoFrame, &amp;videoInfo, buffer, static_cast&lt;GstMapFlags&gt;(GST_MAP_READ | GST_MAP_GL)))
</span><span class="cx">         return nullptr;
</span><span class="cx"> 
</span><del>-    GLContext* context = GLContext::sharingContext();
</del><ins>+    GLContext* context = PlatformDisplay::sharedDisplayForCompositing().sharingGLContext();
</ins><span class="cx">     context-&gt;makeContextCurrent();
</span><span class="cx">     cairo_device_t* device = context-&gt;cairoDevice();
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicswaylandPlatformDisplayWaylandcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/wayland/PlatformDisplayWayland.cpp (205115 => 205116)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/wayland/PlatformDisplayWayland.cpp        2016-08-29 09:18:06 UTC (rev 205115)
+++ trunk/Source/WebCore/platform/graphics/wayland/PlatformDisplayWayland.cpp        2016-08-29 09:33:40 UTC (rev 205116)
</span><span class="lines">@@ -29,128 +29,57 @@
</span><span class="cx"> #if PLATFORM(WAYLAND)
</span><span class="cx"> 
</span><span class="cx"> #include &quot;GLContextEGL.h&quot;
</span><del>-#include &quot;WaylandSurface.h&quot;
</del><span class="cx"> #include &lt;cstring&gt;
</span><del>-#include &lt;glib.h&gt;
</del><ins>+#include &lt;wayland-egl.h&gt;
</ins><span class="cx"> #include &lt;wtf/Assertions.h&gt;
</span><span class="cx"> 
</span><span class="cx"> namespace WebCore {
</span><span class="cx"> 
</span><del>-const struct wl_registry_listener PlatformDisplayWayland::m_registryListener = {
-    PlatformDisplayWayland::globalCallback,
-    PlatformDisplayWayland::globalRemoveCallback
</del><ins>+const struct wl_registry_listener PlatformDisplayWayland::s_registryListener = {
+    // globalCallback
+    [](void* data, struct wl_registry*, uint32_t name, const char* interface, uint32_t) {
+        static_cast&lt;PlatformDisplayWayland*&gt;(data)-&gt;registryGlobal(interface, name);
+    },
+    // globalRemoveCallback
+    [](void*, struct wl_registry*, uint32_t)
+    {
+    }
</ins><span class="cx"> };
</span><span class="cx"> 
</span><del>-void PlatformDisplayWayland::globalCallback(void* data, struct wl_registry* registry, uint32_t name, const char* interface, uint32_t)
</del><ins>+PlatformDisplayWayland::PlatformDisplayWayland(struct wl_display* display)
</ins><span class="cx"> {
</span><del>-    auto display = static_cast&lt;PlatformDisplayWayland*&gt;(data);
-    if (!std::strcmp(interface, &quot;wl_compositor&quot;))
-        display-&gt;m_compositor = static_cast&lt;struct wl_compositor*&gt;(wl_registry_bind(registry, name, &amp;wl_compositor_interface, 1));
-    else if (!std::strcmp(interface, &quot;wl_webkitgtk&quot;))
-        display-&gt;m_webkitgtk = static_cast&lt;struct wl_webkitgtk*&gt;(wl_registry_bind(registry, name, &amp;wl_webkitgtk_interface, 1));
</del><ins>+    initialize(display);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-void PlatformDisplayWayland::globalRemoveCallback(void*, struct wl_registry*, uint32_t)
</del><ins>+PlatformDisplayWayland::~PlatformDisplayWayland()
</ins><span class="cx"> {
</span><del>-    // FIXME: if this can happen without the UI Process getting shut down
-    // we should probably destroy our cached display instance.
</del><span class="cx"> }
</span><span class="cx"> 
</span><del>-std::unique_ptr&lt;PlatformDisplayWayland&gt; PlatformDisplayWayland::create()
</del><ins>+void PlatformDisplayWayland::initialize(wl_display* display)
</ins><span class="cx"> {
</span><del>-    struct wl_display* wlDisplay = wl_display_connect(nullptr);
-    if (!wlDisplay) {
-        WTFLogAlways(&quot;PlatformDisplayWayland initialization: failed to connect to the Wayland server socket. Check your WAYLAND_DISPLAY or WAYLAND_SOCKET environment variables.&quot;);
-        return nullptr;
-    }
-
-    auto display = std::unique_ptr&lt;PlatformDisplayWayland&gt;(new PlatformDisplayWayland(wlDisplay));
-    if (!display-&gt;isInitialized()) {
-        WTFLogAlways(&quot;PlatformDisplayWayland initialization: failed to complete the initialization of the display.&quot;);
-        return nullptr;
-    }
-
-    return 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, &amp;m_registryListener, this);
</del><ins>+    m_display = display;
+    m_registry.reset(wl_display_get_registry(m_display));
+    wl_registry_add_listener(m_registry.get(), &amp;s_registryListener, this);
</ins><span class="cx">     wl_display_roundtrip(m_display);
</span><span class="cx"> 
</span><del>-    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
-    };
-
</del><span class="cx">     m_eglDisplay = eglGetDisplay(m_display);
</span><span class="cx">     PlatformDisplay::initializeEGLDisplay();
</span><del>-    if (m_eglDisplay == EGL_NO_DISPLAY)
-        return;
-
-    EGLint numberOfConfigs;
-    if (!eglChooseConfig(m_eglDisplay, configAttributes, &amp;m_eglConfig, 1, &amp;numberOfConfigs) || numberOfConfigs != 1) {
-        g_warning(&quot;PlatformDisplayWayland initialization: failed to find the desired EGL configuration.&quot;);
-        return;
-    }
-
-    m_eglConfigChosen = true;
</del><span class="cx"> }
</span><span class="cx"> 
</span><del>-PlatformDisplayWayland::~PlatformDisplayWayland()
</del><ins>+void PlatformDisplayWayland::registryGlobal(const char* interface, uint32_t name)
</ins><span class="cx"> {
</span><del>-    if (m_webkitgtk)
-        wl_webkitgtk_destroy(m_webkitgtk);
-    if (m_compositor)
-        wl_compositor_destroy(m_compositor);
-    if (m_registry)
-        wl_registry_destroy(m_registry);
-    if (m_display)
-        wl_display_disconnect(m_display);
</del><ins>+    if (!std::strcmp(interface, &quot;wl_compositor&quot;))
+        m_compositor.reset(static_cast&lt;struct wl_compositor*&gt;(wl_registry_bind(m_registry.get(), name, &amp;wl_compositor_interface, 1)));
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-std::unique_ptr&lt;WaylandSurface&gt; PlatformDisplayWayland::createSurface(const IntSize&amp; size, int widgetId)
</del><ins>+WlUniquePtr&lt;struct wl_surface&gt; PlatformDisplayWayland::createSurface() const
</ins><span class="cx"> {
</span><del>-    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()));
</del><ins>+    if (!m_compositor)
+        return nullptr;
</ins><span class="cx"> 
</span><del>-    wl_webkitgtk_set_surface_for_widget(m_webkitgtk, wlSurface, widgetId);
-    wl_display_roundtrip(m_display);
-
-    return std::make_unique&lt;WaylandSurface&gt;(wlSurface, nativeWindow);
</del><ins>+    return WlUniquePtr&lt;struct wl_surface&gt;(wl_compositor_create_surface(m_compositor.get()));
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-std::unique_ptr&lt;GLContextEGL&gt; PlatformDisplayWayland::createSharingGLContext()
-{
-    class OffscreenContextData : public GLContext::Data {
-    public:
-        virtual ~OffscreenContextData()
-        {
-            wl_egl_window_destroy(nativeWindow);
-            wl_surface_destroy(surface);
-        }
-
-        struct wl_surface* surface;
-        EGLNativeWindowType nativeWindow;
-    };
-
-    auto contextData = std::make_unique&lt;OffscreenContextData&gt;();
-    contextData-&gt;surface = wl_compositor_create_surface(m_compositor);
-    contextData-&gt;nativeWindow = wl_egl_window_create(contextData-&gt;surface, 1, 1);
-
-    auto nativeWindow = contextData-&gt;nativeWindow;
-    return GLContextEGL::createWindowContext(nativeWindow, nullptr, WTFMove(contextData));
-}
-
</del><span class="cx"> } // namespace WebCore
</span><span class="cx"> 
</span><span class="cx"> #endif // PLATFORM(WAYLAND)
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicswaylandPlatformDisplayWaylandh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/wayland/PlatformDisplayWayland.h (205115 => 205116)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/wayland/PlatformDisplayWayland.h        2016-08-29 09:18:06 UTC (rev 205115)
+++ trunk/Source/WebCore/platform/graphics/wayland/PlatformDisplayWayland.h        2016-08-29 09:33:40 UTC (rev 205116)
</span><span class="lines">@@ -29,48 +29,34 @@
</span><span class="cx"> #if PLATFORM(WAYLAND)
</span><span class="cx"> 
</span><span class="cx"> #include &quot;PlatformDisplay.h&quot;
</span><del>-#include &quot;WebKitGtkWaylandClientProtocol.h&quot;
-#include &lt;memory&gt;
</del><ins>+#include &quot;WlUniquePtr.h&quot;
</ins><span class="cx"> #include &lt;wayland-client.h&gt;
</span><del>-#include &lt;wayland-egl.h&gt;
-#include &lt;EGL/egl.h&gt;
</del><span class="cx"> 
</span><span class="cx"> namespace WebCore {
</span><span class="cx"> 
</span><del>-class GLContextEGL;
-class IntSize;
-class WaylandSurface;
-
-class PlatformDisplayWayland final: public PlatformDisplay {
</del><ins>+class PlatformDisplayWayland : public PlatformDisplay {
</ins><span class="cx"> public:
</span><del>-    static std::unique_ptr&lt;PlatformDisplayWayland&gt; create();
</del><ins>+    PlatformDisplayWayland(struct wl_display*);
</ins><span class="cx">     virtual ~PlatformDisplayWayland();
</span><span class="cx"> 
</span><span class="cx">     struct wl_display* native() const { return m_display; }
</span><span class="cx"> 
</span><del>-    std::unique_ptr&lt;WaylandSurface&gt; createSurface(const IntSize&amp;, int widgetID);
</del><ins>+    WlUniquePtr&lt;struct wl_surface&gt; createSurface() const;
</ins><span class="cx"> 
</span><del>-    std::unique_ptr&lt;GLContextEGL&gt; createSharingGLContext();
-
</del><span class="cx"> private:
</span><del>-    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);
</del><ins>+    static const struct wl_registry_listener s_registryListener;
</ins><span class="cx"> 
</span><del>-    PlatformDisplayWayland(struct wl_display*);
</del><ins>+    Type type() const override { return PlatformDisplay::Type::Wayland; }
</ins><span class="cx"> 
</span><del>-    // FIXME: This should check also for m_webkitgtk once the UIProcess embedded Wayland subcompositer is implemented.
-    bool isInitialized() { return m_compositor &amp;&amp; m_eglDisplay != EGL_NO_DISPLAY &amp;&amp; m_eglConfigChosen; }
</del><ins>+protected:
+    PlatformDisplayWayland() = default;
+    void initialize(struct wl_display*);
</ins><span class="cx"> 
</span><del>-    Type type() const override { return PlatformDisplay::Type::Wayland; }
</del><ins>+    virtual void registryGlobal(const char* interface, uint32_t name);
</ins><span class="cx"> 
</span><span class="cx">     struct wl_display* m_display;
</span><del>-    struct wl_registry* m_registry;
-    struct wl_compositor* m_compositor;
-    struct wl_webkitgtk* m_webkitgtk;
-
-    EGLConfig m_eglConfig;
-    bool m_eglConfigChosen;
</del><ins>+    WlUniquePtr&lt;struct wl_registry&gt; m_registry;
+    WlUniquePtr&lt;struct wl_compositor&gt; m_compositor;
</ins><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> } // namespace WebCore
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicswaylandWaylandEventSourcecpp"></a>
<div class="delfile"><h4>Deleted: trunk/Source/WebCore/platform/graphics/wayland/WaylandEventSource.cpp (205115 => 205116)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/wayland/WaylandEventSource.cpp        2016-08-29 09:18:06 UTC (rev 205115)
+++ trunk/Source/WebCore/platform/graphics/wayland/WaylandEventSource.cpp        2016-08-29 09:33:40 UTC (rev 205116)
</span><span class="lines">@@ -1,119 +0,0 @@
</span><del>-/*
- * 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 &quot;config.h&quot;
-#include &quot;WaylandEventSource.h&quot;
-
-#if PLATFORM(WAYLAND)
-
-namespace WebCore {
-
-class GLibSource {
-public:
-    void initialize(struct wl_display*);
-
-    gboolean check();
-    gboolean dispatch();
-
-private:
-    GSource m_source;
-    GPollFD m_pollFileDescriptor;
-    struct wl_display* m_display;
-};
-
-void GLibSource::initialize(struct wl_display* display)
-{
-    m_display = display;
-    struct wl_event_loop* loop = wl_display_get_event_loop(display);
-    m_pollFileDescriptor.fd = wl_event_loop_get_fd(loop);
-    m_pollFileDescriptor.events = G_IO_IN | G_IO_ERR | G_IO_HUP;
-    g_source_add_poll(&amp;m_source, &amp;m_pollFileDescriptor);
-
-    g_source_set_name(&amp;m_source, &quot;Nested Wayland compositor display event source&quot;);
-    g_source_set_priority(&amp;m_source, G_PRIORITY_DEFAULT);
-    g_source_set_can_recurse(&amp;m_source, TRUE);
-    g_source_attach(&amp;m_source, nullptr);
-}
-
-gboolean GLibSource::check()
-{
-    return m_pollFileDescriptor.revents;
-}
-
-gboolean GLibSource::dispatch()
-{
-    if (m_pollFileDescriptor.revents &amp; G_IO_IN) {
-        struct wl_event_loop* loop = wl_display_get_event_loop(m_display);
-        wl_event_loop_dispatch(loop, -1);
-        wl_display_flush_clients(m_display);
-        m_pollFileDescriptor.revents = 0;
-    }
-
-    if (m_pollFileDescriptor.revents &amp; (G_IO_ERR | G_IO_HUP))
-        g_warning(&quot;Wayland Display Event Source: lost connection to nested Wayland compositor&quot;);
-
-    return TRUE;
-}
-
-static gboolean prepareCallback(GSource*, gint* timeout)
-{
-    *timeout = -1;
-    return FALSE;
-}
-
-static gboolean checkCallback(GSource* base)
-{
-    auto source = reinterpret_cast&lt;GLibSource*&gt;(base);
-    return source-&gt;check();
-}
-
-static gboolean dispatchCallback(GSource* base, GSourceFunc, gpointer)
-{
-    auto source = reinterpret_cast&lt;GLibSource*&gt;(base);
-    return source-&gt;dispatch();
-}
-
-static GSourceFuncs waylandGLibSourceFuncs = {
-    prepareCallback,
-    checkCallback,
-    dispatchCallback,
-    nullptr, // finalize
-    nullptr, // closure_callback
-    nullptr, // closure_marshall
-};
-
-GSource* WaylandEventSource::createDisplayEventSource(struct wl_display* display)
-{
-    GSource* base = g_source_new(&amp;waylandGLibSourceFuncs, sizeof(GLibSource));
-
-    auto source = reinterpret_cast&lt;GLibSource*&gt;(base);
-    source-&gt;initialize(display);
-
-    return base;
-}
-
-} // namespace WebCore
-
-#endif // PLATFORM(WAYLAND)
</del></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicswaylandWaylandEventSourceh"></a>
<div class="delfile"><h4>Deleted: trunk/Source/WebCore/platform/graphics/wayland/WaylandEventSource.h (205115 => 205116)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/wayland/WaylandEventSource.h        2016-08-29 09:18:06 UTC (rev 205115)
+++ trunk/Source/WebCore/platform/graphics/wayland/WaylandEventSource.h        2016-08-29 09:33:40 UTC (rev 205116)
</span><span class="lines">@@ -1,45 +0,0 @@
</span><del>-/*
- * 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 WaylandEventSource_h
-#define WaylandEventSource_h
-
-#if PLATFORM(WAYLAND)
-
-#include &lt;glib.h&gt;
-#include &lt;wayland-server.h&gt;
-
-namespace WebCore {
-
-class WaylandEventSource {
-public:
-    static GSource* createDisplayEventSource(struct wl_display*);
-};
-
-} // namespace WebCore
-
-#endif // PLATFORM(WAYLAND)
-
-#endif // WaylandEventSource_h
</del></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicswaylandWaylandSurfacecpp"></a>
<div class="delfile"><h4>Deleted: trunk/Source/WebCore/platform/graphics/wayland/WaylandSurface.cpp (205115 => 205116)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/wayland/WaylandSurface.cpp        2016-08-29 09:18:06 UTC (rev 205115)
+++ trunk/Source/WebCore/platform/graphics/wayland/WaylandSurface.cpp        2016-08-29 09:33:40 UTC (rev 205116)
</span><span class="lines">@@ -1,83 +0,0 @@
</span><del>-/*
- * 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 &quot;config.h&quot;
-#include &quot;WaylandSurface.h&quot;
-
-#if PLATFORM(WAYLAND)
-
-#include &quot;GLContextEGL.h&quot;
-#include &quot;IntSize.h&quot;
-#include &quot;PlatformDisplayWayland.h&quot;
-#include &lt;EGL/egl.h&gt;
-
-namespace WebCore {
-
-void frameCallback(void*, struct wl_callback* callback, uint32_t)
-{
-    if (callback)
-        wl_callback_destroy(callback);
-}
-
-static const struct wl_callback_listener frameListener = {
-    frameCallback
-};
-
-WaylandSurface::WaylandSurface(struct wl_surface* wlSurface, EGLNativeWindowType nativeWindow)
-    : m_wlSurface(wlSurface)
-    , m_nativeWindow(nativeWindow)
-{
-}
-
-WaylandSurface::~WaylandSurface()
-{
-    // The surface couldn't have been created in the first place if WaylandDisplay wasn't properly initialized.
-    const PlatformDisplayWayland&amp; waylandDisplay = downcast&lt;PlatformDisplayWayland&gt;(PlatformDisplay::sharedDisplay());
-    ASSERT(waylandDisplay.native());
-    eglMakeCurrent(waylandDisplay.native(), EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
-
-    wl_egl_window_destroy(m_nativeWindow);
-    wl_surface_destroy(m_wlSurface);
-}
-
-void WaylandSurface::resize(const IntSize&amp; size)
-{
-    wl_egl_window_resize(m_nativeWindow, size.width(), size.height(), 0, 0);
-}
-
-std::unique_ptr&lt;GLContextEGL&gt; WaylandSurface::createGLContext()
-{
-    return GLContextEGL::createWindowContext(m_nativeWindow, GLContext::sharingContext());
-}
-
-void WaylandSurface::requestFrame()
-{
-    struct wl_callback* frameCallback = wl_surface_frame(m_wlSurface);
-    wl_callback_add_listener(frameCallback, &amp;frameListener, this);
-}
-
-} // namespace WebCore
-
-#endif // PLATFORM(WAYLAND)
</del></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicswaylandWaylandSurfaceh"></a>
<div class="delfile"><h4>Deleted: trunk/Source/WebCore/platform/graphics/wayland/WaylandSurface.h (205115 => 205116)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/wayland/WaylandSurface.h        2016-08-29 09:18:06 UTC (rev 205115)
+++ trunk/Source/WebCore/platform/graphics/wayland/WaylandSurface.h        2016-08-29 09:33:40 UTC (rev 205116)
</span><span class="lines">@@ -1,64 +0,0 @@
</span><del>-/*
- * 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  WaylandSurface_h
-#define  WaylandSurface_h
-
-#if PLATFORM(WAYLAND)
-
-#include &lt;wayland-client.h&gt;
-
-#include &lt;wayland-egl.h&gt;
-#include &lt;EGL/eglplatform.h&gt;
-
-namespace WebCore {
-
-class GLContextEGL;
-class IntSize;
-
-class WaylandSurface {
-public:
-    WaylandSurface(struct wl_surface*, EGLNativeWindowType);
-    ~WaylandSurface();
-
-    struct wl_surface* surface() { return m_wlSurface; }
-    EGLNativeWindowType nativeWindowHandle() { return m_nativeWindow; }
-
-    void resize(const IntSize&amp;);
-
-    std::unique_ptr&lt;GLContextEGL&gt; createGLContext();
-
-    void requestFrame();
-
-private:
-    struct wl_surface* m_wlSurface;
-    EGLNativeWindowType m_nativeWindow;
-};
-
-} // namespace WebCore
-
-#endif // PLATFORM(WAYLAND)
-
-#endif // WaylandSurface_h
</del></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicswaylandWebKitGtkWaylandClientProtocolxml"></a>
<div class="delfile"><h4>Deleted: trunk/Source/WebCore/platform/graphics/wayland/WebKitGtkWaylandClientProtocol.xml (205115 => 205116)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/wayland/WebKitGtkWaylandClientProtocol.xml        2016-08-29 09:18:06 UTC (rev 205115)
+++ trunk/Source/WebCore/platform/graphics/wayland/WebKitGtkWaylandClientProtocol.xml        2016-08-29 09:33:40 UTC (rev 205116)
</span><span class="lines">@@ -1,37 +0,0 @@
</span><del>-&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
-&lt;protocol name=&quot;wl_webkitgtk&quot;&gt;
-
-  &lt;copyright&gt;
-    Copyright © 2014 Igalia S.L.
-
-    Permission to use, copy, modify, distribute, and sell this
-    software and its documentation for any purpose is hereby granted
-    without fee, provided that the above copyright notice appear in
-    all copies and that both that copyright notice and this permission
-    notice appear in supporting documentation, and that the name of
-    the copyright holders not be used in advertising or publicity
-    pertaining to distribution of the software without specific,
-    written prior permission.  The copyright holders make no
-    representations about the suitability of this software for any
-    purpose.  It is provided &quot;as is&quot; without express or implied
-    warranty.
-
-    THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
-    SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
-    FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY
-    SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
-    WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
-    AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
-    ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
-    THIS SOFTWARE.
-  &lt;/copyright&gt;
-
-  &lt;interface name=&quot;wl_webkitgtk&quot; version=&quot;1&quot;&gt;
-    &lt;request name=&quot;set_surface_for_widget&quot;&gt;
-      &lt;arg name=&quot;surface&quot; type=&quot;object&quot; interface=&quot;wl_surface&quot;/&gt;
-      &lt;arg name=&quot;id&quot; type=&quot;uint&quot;/&gt;
-    &lt;/request&gt;
-
-  &lt;/interface&gt;
-
-&lt;/protocol&gt;
</del></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicswaylandWlUniquePtrhfromrev205115trunkSourceWebCoreplatformgraphicswaylandWaylandEventSourceh"></a>
<div class="copfile"><h4>Copied: trunk/Source/WebCore/platform/graphics/wayland/WlUniquePtr.h (from rev 205115, trunk/Source/WebCore/platform/graphics/wayland/WaylandEventSource.h) (0 => 205116)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/wayland/WlUniquePtr.h                                (rev 0)
+++ trunk/Source/WebCore/platform/graphics/wayland/WlUniquePtr.h        2016-08-29 09:33:40 UTC (rev 205116)
</span><span class="lines">@@ -0,0 +1,61 @@
</span><ins>+/*
+ * Copyright (C) 2016 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.
+ */
+
+#pragma once
+
+#if PLATFORM(WAYLAND)
+#include &lt;wayland-client-protocol.h&gt;
+#include &lt;wayland-server.h&gt;
+
+namespace WebCore {
+
+template&lt;typename T&gt;
+struct WlPtrDeleter {
+};
+
+template&lt;typename T&gt;
+using WlUniquePtr = std::unique_ptr&lt;T, WlPtrDeleter&lt;T&gt;&gt;;
+
+#define FOR_EACH_WAYLAND_DELETER(macro) \
+    macro(struct wl_display, wl_display_destroy) \
+    macro(struct wl_global, wl_global_destroy) \
+    macro(struct wl_surface, wl_surface_destroy) \
+    macro(struct wl_compositor, wl_compositor_destroy) \
+    macro(struct wl_registry, wl_registry_destroy) \
+    macro(struct wl_proxy, wl_proxy_destroy)
+
+#define DEFINE_WAYLAND_DELETER(typeName, deleterFunc) \
+    template&lt;&gt; struct WlPtrDeleter&lt;typeName&gt; \
+    { \
+        void operator() (typeName* ptr) const { deleterFunc(ptr); } \
+    };
+
+FOR_EACH_WAYLAND_DELETER(DEFINE_WAYLAND_DELETER)
+#undef FOR_EACH_WAYLAND_DELETER
+#undef DEFINE_WAYLAND_DELETER
+
+} // namespace WebCore
+
+#endif // PLATFORM(WAYLAND)
</ins></span></pre></div>
<a id="trunkSourceWebKitwinChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/win/ChangeLog (205115 => 205116)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/win/ChangeLog        2016-08-29 09:18:06 UTC (rev 205115)
+++ trunk/Source/WebKit/win/ChangeLog        2016-08-29 09:33:40 UTC (rev 205116)
</span><span class="lines">@@ -1,3 +1,16 @@
</span><ins>+2016-08-16  Carlos Garcia Campos  &lt;cgarcia@igalia.com&gt;
+
+        [GTK] Accelerated compositing does not work in Wayland
+        https://bugs.webkit.org/show_bug.cgi?id=115803
+
+        Reviewed by Michael Catanzaro.
+
+        Update to the new GLContext API.
+
+        * WebCoreSupport/AcceleratedCompositingContext.cpp:
+        (AcceleratedCompositingContext::initialize):
+        (AcceleratedCompositingContext::acceleratedCompositingAvailable):
+
</ins><span class="cx"> 2016-08-21  Alex Christensen  &lt;achristensen@webkit.org&gt;
</span><span class="cx"> 
</span><span class="cx">         Use Document&amp; instead of Document* when getting cookies
</span></span></pre></div>
<a id="trunkSourceWebKitwinWebCoreSupportAcceleratedCompositingContextcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/win/WebCoreSupport/AcceleratedCompositingContext.cpp (205115 => 205116)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/win/WebCoreSupport/AcceleratedCompositingContext.cpp        2016-08-29 09:18:06 UTC (rev 205115)
+++ trunk/Source/WebKit/win/WebCoreSupport/AcceleratedCompositingContext.cpp        2016-08-29 09:33:40 UTC (rev 205116)
</span><span class="lines">@@ -102,7 +102,7 @@
</span><span class="cx"> 
</span><span class="cx">     // The creation of the TextureMapper needs an active OpenGL context.
</span><span class="cx">     if (!m_context)
</span><del>-        m_context = GLContext::createContextForWindow(m_window, GLContext::sharingContext());
</del><ins>+        m_context = GLContext::createContextForWindow(m_window);
</ins><span class="cx"> 
</span><span class="cx">     if (!m_context)
</span><span class="cx">         return;
</span><span class="lines">@@ -282,7 +282,7 @@
</span><span class="cx">         return false;
</span><span class="cx"> 
</span><span class="cx">     // Create GL context.
</span><del>-    std::unique_ptr&lt;WebCore::GLContext&gt; context = GLContext::createContextForWindow(testWindow, GLContext::sharingContext());
</del><ins>+    std::unique_ptr&lt;WebCore::GLContext&gt; context = GLContext::createContextForWindow(testWindow);
</ins><span class="cx"> 
</span><span class="cx">     if (!context) {
</span><span class="cx">         ::DestroyWindow(testWindow);
</span></span></pre></div>
<a id="trunkSourceWebKit2ChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/ChangeLog (205115 => 205116)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/ChangeLog        2016-08-29 09:18:06 UTC (rev 205115)
+++ trunk/Source/WebKit2/ChangeLog        2016-08-29 09:33:40 UTC (rev 205116)
</span><span class="lines">@@ -1,3 +1,155 @@
</span><ins>+2016-08-16  Carlos Garcia Campos  &lt;cgarcia@igalia.com&gt;
+
+        [GTK] Accelerated compositing does not work in Wayland
+        https://bugs.webkit.org/show_bug.cgi?id=115803
+
+        Reviewed by Michael Catanzaro.
+
+        This is the initial implementation of accelerated compositing support in Wayland for the GTK+ port. It's based
+        on previous patches written by Iago Toral, Žan Doberšek, Emanuele Aina and Emilio Pozuelo Monfort.
+
+        The existing WebKitGTK+ Wayland interface previously added for this to WebCore has been moved to the WebKit2
+        layer, since it's actually specific to WebKit2, and it's now actually used. The UI process runs a nested Wayland
+        compositor that web processes connect to. Web processes create a Wayland surface in the nested compositor for
+        the web page, and using the WebKitGTK+ Wayland protocol interface they tell the nested compositor the web page
+        associated to the surface. A Wayland window is created for that surface that is then used as the native window
+        handle for compositing. To communicate with the nested compositor and to ensure all GL operations happen in the
+        nested compositor display, the web process creates a Wayland display that connects to the nested compositor,
+        uses the WebKitGTK+ Wayland interface and it's set as the global shared display for compositing.
+
+        The nested Wayland compositor creates a new display with a unique name that is sent to the web processes at
+        start up. It implements the Wayland surface interface to handle the Wayland buffers created for every surface
+        and scheduling redraws on the web pages when updates are available. It uses the WebKitGTK+ Wayland interface to
+        associate the surfaces to a particular web page. A texture is created for every surface and updated with the
+        Wayland buffer contents using an EGLImageKHR and eglImageTargetTexture2d API.
+
+        To abstract the platform differences and avoid ifdefs as much as possible, new abstract classes have been added
+        to represent the surfaces used in accelerated compositing. AcceleratedSurface is used by the web process and
+        represents the surface where contents are rendered into. The X11 implementation is the redirected XComposite
+        window, and the Wayland implementation is equivalent to the previous Wayland surface added to WebCore but never
+        used. In the UI process the web view creates an abstract AcceleratedBackingStore that is used to render the
+        AcceleratedSurface into the web view using cairo. The X11 implementation creates the cairo surface for the
+        redirected XComposite window pixmap and uses XDamage extension to schedule redraws. The Wayland implementation
+        asks the nested Wayland compositor for the texture associated to the web view page.
+
+        Accelerated compositing is now always enabled by default in both X11 and Wayland, unless it's explicitly
+        disabled by the user using the WEBKIT_DISABLE_COMPOSITING_MODE environment variable, or if any extension or
+        feature required by X11 or Wayland implementations are not available.
+
+        * PlatformGTK.cmake:
+        * Shared/CoordinatedGraphics/threadedcompositor/ThreadedCompositor.cpp:
+        (WebKit::ThreadedCompositor::glContext): Pass the shared display for compositing to GLContext::createContextForWindow()
+        * Shared/WebProcessCreationParameters.cpp:
+        (WebKit::WebProcessCreationParameters::encode): Encode wayland compositor display name.
+        (WebKit::WebProcessCreationParameters::decode): Decode wayland compositor display name.
+        * Shared/WebProcessCreationParameters.h: Add wayland compositor display name initial parameter.
+        * UIProcess/API/gtk/WebKitWebViewBase.cpp:
+        (webkitWebViewBaseDispose):
+        (webkitWebViewBaseDraw):
+        (webkitWebViewBaseCreateWebPage):
+        (webkitWebViewBaseEnterAcceleratedCompositingMode):
+        (webkitWebViewBaseUpdateAcceleratedCompositingMode):
+        (webkitWebViewBaseExitAcceleratedCompositingMode):
+        (webkitWebViewBasePageClosed):
+        * UIProcess/WebProcessPool.cpp:
+        (WebKit::WebProcessPool::createNewWebProcess): Initialize the wayland compositor display name initial parameter.
+        * UIProcess/gtk/AcceleratedBackingStore.cpp: Added.
+        (WebKit::AcceleratedBackingStore::create):
+        (WebKit::AcceleratedBackingStore::AcceleratedBackingStore):
+        (WebKit::AcceleratedBackingStore::~AcceleratedBackingStore):
+        (WebKit::AcceleratedBackingStore::paint):
+        * UIProcess/gtk/AcceleratedBackingStore.h: Added.
+        (WebKit::AcceleratedBackingStore::update):
+        * UIProcess/gtk/AcceleratedBackingStoreWayland.cpp: Added.
+        (WebKit::AcceleratedBackingStoreWayland::create):
+        (WebKit::AcceleratedBackingStoreWayland::AcceleratedBackingStoreWayland):
+        (WebKit::AcceleratedBackingStoreWayland::~AcceleratedBackingStoreWayland):
+        (WebKit::AcceleratedBackingStoreWayland::paint):
+        * UIProcess/gtk/AcceleratedBackingStoreWayland.h: Added.
+        * UIProcess/gtk/AcceleratedBackingStoreX11.cpp: Added.
+        (WebKit::XDamageNotifier::singleton):
+        (WebKit::XDamageNotifier::add):
+        (WebKit::XDamageNotifier::remove):
+        (WebKit::XDamageNotifier::filterXDamageEvent):
+        (WebKit::XDamageNotifier::notify):
+        (WebKit::AcceleratedBackingStoreX11::create):
+        (WebKit::AcceleratedBackingStoreX11::AcceleratedBackingStoreX11):
+        (WebKit::AcceleratedBackingStoreX11::~AcceleratedBackingStoreX11):
+        (WebKit::AcceleratedBackingStoreX11::update):
+        (WebKit::AcceleratedBackingStoreX11::paint):
+        * UIProcess/gtk/AcceleratedBackingStoreX11.h: Added.
+        * UIProcess/gtk/WaylandCompositor.cpp: Added.
+        (WebKit::WaylandCompositor::singleton):
+        (WebKit::WaylandCompositor::Buffer::getOrCreate):
+        (WebKit::WaylandCompositor::Buffer::Buffer):
+        (WebKit::WaylandCompositor::Buffer::~Buffer):
+        (WebKit::WaylandCompositor::Buffer::destroyListenerCallback):
+        (WebKit::WaylandCompositor::Buffer::use):
+        (WebKit::WaylandCompositor::Buffer::unuse):
+        (WebKit::WaylandCompositor::Buffer::createImage):
+        (WebKit::WaylandCompositor::Buffer::size):
+        (WebKit::WaylandCompositor::Surface::Surface):
+        (WebKit::WaylandCompositor::Surface::~Surface):
+        (WebKit::WaylandCompositor::Surface::makePendingBufferCurrent):
+        (WebKit::WaylandCompositor::Surface::attachBuffer):
+        (WebKit::WaylandCompositor::Surface::requestFrame):
+        (WebKit::WaylandCompositor::Surface::prepareTextureForPainting):
+        (WebKit::WaylandCompositor::Surface::commit):
+        (WebKit::WaylandCompositor::initializeEGL):
+        (WebKit::createWaylandLoopSource):
+        (WebKit::WaylandCompositor::WaylandCompositor):
+        (WebKit::WaylandCompositor::getTexture):
+        (WebKit::WaylandCompositor::bindSurfaceToWebPage):
+        (WebKit::WaylandCompositor::registerWebPage):
+        (WebKit::WaylandCompositor::unregisterWebPage):
+        * UIProcess/gtk/WaylandCompositor.h: Added.
+        (WebKit::WaylandCompositor::Buffer::createWeakPtr):
+        (WebKit::WaylandCompositor::Surface::setWebPage):
+        (WebKit::WaylandCompositor::isRunning):
+        (WebKit::WaylandCompositor::displayName):
+        * UIProcess/gtk/WebPreferencesGtk.cpp:
+        (WebKit::WebPreferences::platformInitializeStore):
+        * UIProcess/gtk/XDamageNotifier.cpp: Removed.
+        * WebProcess/WebPage/CoordinatedGraphics/ThreadedCoordinatedLayerTreeHost.cpp:
+        (WebKit::ThreadedCoordinatedLayerTreeHost::ThreadedCoordinatedLayerTreeHost):
+        (WebKit::ThreadedCoordinatedLayerTreeHost::invalidate):
+        (WebKit::ThreadedCoordinatedLayerTreeHost::deviceOrPageScaleFactorChanged):
+        (WebKit::ThreadedCoordinatedLayerTreeHost::sizeDidChange):
+        * WebProcess/WebPage/CoordinatedGraphics/ThreadedCoordinatedLayerTreeHost.h:
+        * WebProcess/WebPage/gtk/AcceleratedSurface.cpp: Added.
+        (WebKit::AcceleratedSurface::create):
+        (WebKit::AcceleratedSurface::AcceleratedSurface):
+        (WebKit::AcceleratedSurface::~AcceleratedSurface):
+        (WebKit::AcceleratedSurface::resize):
+        * WebProcess/WebPage/gtk/AcceleratedSurface.h: Added.
+        (WebKit::AcceleratedSurface::window):
+        (WebKit::AcceleratedSurface::surfaceID):
+        * WebProcess/WebPage/gtk/AcceleratedSurfaceWayland.cpp: Added.
+        (WebKit::waylandCompositorDisplay):
+        (WebKit::AcceleratedSurfaceWayland::create):
+        (WebKit::AcceleratedSurfaceWayland::AcceleratedSurfaceWayland):
+        (WebKit::AcceleratedSurfaceWayland::~AcceleratedSurfaceWayland):
+        (WebKit::AcceleratedSurfaceWayland::resize):
+        * WebProcess/WebPage/gtk/AcceleratedSurfaceWayland.h: Added.
+        * WebProcess/WebPage/gtk/AcceleratedSurfaceX11.cpp: Renamed from Source/WebKit2/WebProcess/WebPage/gtk/RedirectedXCompositeWindow.cpp.
+        (WebKit::AcceleratedSurfaceX11::create):
+        (WebKit::AcceleratedSurfaceX11::AcceleratedSurfaceX11):
+        (WebKit::AcceleratedSurfaceX11::~AcceleratedSurfaceX11):
+        (WebKit::AcceleratedSurfaceX11::resize):
+        * WebProcess/WebPage/gtk/AcceleratedSurfaceX11.h: Renamed from Source/WebKit2/WebProcess/WebPage/gtk/RedirectedXCompositeWindow.h.
+        * WebProcess/WebPage/gtk/LayerTreeHostGtk.cpp:
+        (WebKit::LayerTreeHostGtk::LayerTreeHostGtk):
+        (WebKit::LayerTreeHostGtk::makeContextCurrent):
+        (WebKit::LayerTreeHostGtk::invalidate):
+        (WebKit::LayerTreeHostGtk::sizeDidChange):
+        (WebKit::LayerTreeHostGtk::deviceOrPageScaleFactorChanged):
+        (WebKit::LayerTreeHostGtk::RenderFrameScheduler::RenderFrameScheduler): Deleted.
+        * WebProcess/WebPage/gtk/LayerTreeHostGtk.h:
+        * WebProcess/WebProcess.cpp:
+        (WebKit::WebProcess::initializeWebProcess): Initialize the wayland compositor display name.
+        * WebProcess/WebProcess.h:
+        (WebKit::WebProcess::waylandCompositorDisplayName): Return the wayland compositor display name.
+
</ins><span class="cx"> 2016-08-27  Jonathan Bedard  &lt;jbedard@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         WTR needs an implementation of setAutomaticLinkDetectionEnabled
</span></span></pre></div>
<a id="trunkSourceWebKit2PlatformGTKcmake"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/PlatformGTK.cmake (205115 => 205116)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/PlatformGTK.cmake        2016-08-29 09:18:06 UTC (rev 205115)
+++ trunk/Source/WebKit2/PlatformGTK.cmake        2016-08-29 09:33:40 UTC (rev 205116)
</span><span class="lines">@@ -295,6 +295,9 @@
</span><span class="cx">     UIProcess/gstreamer/InstallMissingMediaPluginsPermissionRequest.cpp
</span><span class="cx">     UIProcess/gstreamer/WebPageProxyGStreamer.cpp
</span><span class="cx"> 
</span><ins>+    UIProcess/gtk/AcceleratedBackingStore.cpp
+    UIProcess/gtk/AcceleratedBackingStoreWayland.cpp
+    UIProcess/gtk/AcceleratedBackingStoreX11.cpp
</ins><span class="cx">     UIProcess/gtk/DragAndDropHandler.cpp
</span><span class="cx">     UIProcess/gtk/ExperimentalFeatures.cpp
</span><span class="cx">     UIProcess/gtk/GestureController.cpp
</span><span class="lines">@@ -301,7 +304,7 @@
</span><span class="cx">     UIProcess/gtk/InputMethodFilter.cpp
</span><span class="cx">     UIProcess/gtk/KeyBindingTranslator.cpp
</span><span class="cx">     UIProcess/gtk/TextCheckerGtk.cpp
</span><del>-    UIProcess/gtk/XDamageNotifier.cpp
</del><ins>+    UIProcess/gtk/WaylandCompositor.cpp
</ins><span class="cx">     UIProcess/gtk/WebColorPickerGtk.cpp
</span><span class="cx">     UIProcess/gtk/WebContextMenuProxyGtk.cpp
</span><span class="cx">     UIProcess/gtk/WebFullScreenClientGtk.cpp
</span><span class="lines">@@ -350,8 +353,10 @@
</span><span class="cx"> 
</span><span class="cx">     WebProcess/WebPage/gstreamer/WebPageGStreamer.cpp
</span><span class="cx"> 
</span><ins>+    WebProcess/WebPage/gtk/AcceleratedSurface.cpp
+    WebProcess/WebPage/gtk/AcceleratedSurfaceWayland.cpp
+    WebProcess/WebPage/gtk/AcceleratedSurfaceX11.cpp
</ins><span class="cx">     WebProcess/WebPage/gtk/PrinterListGtk.cpp
</span><del>-    WebProcess/WebPage/gtk/RedirectedXCompositeWindow.cpp
</del><span class="cx">     WebProcess/WebPage/gtk/WebInspectorUIGtk.cpp
</span><span class="cx">     WebProcess/WebPage/gtk/WebPageGtk.cpp
</span><span class="cx">     WebProcess/WebPage/gtk/WebPrintOperationGtk.cpp
</span><span class="lines">@@ -368,6 +373,7 @@
</span><span class="cx">     ${DERIVED_SOURCES_WEBKIT2GTK_DIR}/InspectorGResourceBundle.c
</span><span class="cx">     ${DERIVED_SOURCES_WEBKIT2GTK_DIR}/WebKit2InspectorGResourceBundle.c
</span><span class="cx">     ${DERIVED_SOURCES_WEBKIT2GTK_DIR}/WebKit2ResourcesGResourceBundle.c
</span><ins>+    ${DERIVED_SOURCES_WEBKIT2GTK_DIR}/WebKit2WaylandClientProtocol.c
</ins><span class="cx"> 
</span><span class="cx">     ${DERIVED_SOURCES_WEBKIT2GTK_API_DIR}/WebKitEnumTypes.cpp
</span><span class="cx">     ${DERIVED_SOURCES_WEBKIT2GTK_API_DIR}/WebKitMarshal.cpp
</span><span class="lines">@@ -684,6 +690,17 @@
</span><span class="cx">     VERBATIM
</span><span class="cx"> )
</span><span class="cx"> 
</span><ins>+if (ENABLE_WAYLAND_TARGET)
+    # Wayland protocol extension.
+    add_custom_command(
+        OUTPUT ${DERIVED_SOURCES_WEBKIT2GTK_DIR}/WebKit2WaylandClientProtocol.c
+        DEPENDS ${WEBKIT2_DIR}/Shared/gtk/WebKit2WaylandProtocol.xml
+        COMMAND wayland-scanner server-header &lt; ${WEBKIT2_DIR}/Shared/gtk/WebKit2WaylandProtocol.xml &gt; ${DERIVED_SOURCES_WEBKIT2GTK_DIR}/WebKit2WaylandServerProtocol.h
+        COMMAND wayland-scanner client-header &lt; ${WEBKIT2_DIR}/Shared/gtk/WebKit2WaylandProtocol.xml &gt; ${DERIVED_SOURCES_WEBKIT2GTK_DIR}/WebKit2WaylandClientProtocol.h
+        COMMAND wayland-scanner code &lt; ${WEBKIT2_DIR}/Shared/gtk/WebKit2WaylandProtocol.xml &gt; ${DERIVED_SOURCES_WEBKIT2GTK_DIR}/WebKit2WaylandClientProtocol.c
+    )
+endif ()
+
</ins><span class="cx"> if (ENABLE_PLUGIN_PROCESS_GTK2)
</span><span class="cx">     set(PluginProcessGTK2_EXECUTABLE_NAME WebKitPluginProcess2)
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebKit2SharedCoordinatedGraphicsthreadedcompositorThreadedCompositorcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/Shared/CoordinatedGraphics/threadedcompositor/ThreadedCompositor.cpp (205115 => 205116)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/Shared/CoordinatedGraphics/threadedcompositor/ThreadedCompositor.cpp        2016-08-29 09:18:06 UTC (rev 205115)
+++ trunk/Source/WebKit2/Shared/CoordinatedGraphics/threadedcompositor/ThreadedCompositor.cpp        2016-08-29 09:33:40 UTC (rev 205116)
</span><span class="lines">@@ -29,6 +29,7 @@
</span><span class="cx"> #if USE(COORDINATED_GRAPHICS_THREADED)
</span><span class="cx"> 
</span><span class="cx"> #include &quot;CompositingRunLoop.h&quot;
</span><ins>+#include &lt;WebCore/PlatformDisplay.h&gt;
</ins><span class="cx"> #include &lt;WebCore/TransformationMatrix.h&gt;
</span><span class="cx"> 
</span><span class="cx"> #if USE(OPENGL_ES_2)
</span><span class="lines">@@ -41,14 +42,15 @@
</span><span class="cx"> 
</span><span class="cx"> namespace WebKit {
</span><span class="cx"> 
</span><del>-Ref&lt;ThreadedCompositor&gt; ThreadedCompositor::create(Client* client, uint64_t nativeSurfaceHandle)
</del><ins>+Ref&lt;ThreadedCompositor&gt; ThreadedCompositor::create(Client* client, uint64_t nativeSurfaceHandle, ShouldDoFrameSync doFrameSync)
</ins><span class="cx"> {
</span><del>-    return adoptRef(*new ThreadedCompositor(client, nativeSurfaceHandle));
</del><ins>+    return adoptRef(*new ThreadedCompositor(client, nativeSurfaceHandle, doFrameSync));
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-ThreadedCompositor::ThreadedCompositor(Client* client, uint64_t nativeSurfaceHandle)
</del><ins>+ThreadedCompositor::ThreadedCompositor(Client* client, uint64_t nativeSurfaceHandle, ShouldDoFrameSync doFrameSync)
</ins><span class="cx">     : m_client(client)
</span><span class="cx">     , m_nativeSurfaceHandle(nativeSurfaceHandle)
</span><ins>+    , m_doFrameSync(doFrameSync)
</ins><span class="cx">     , m_compositingRunLoop(std::make_unique&lt;CompositingRunLoop&gt;([this] { renderLayerTree(); }))
</span><span class="cx"> {
</span><span class="cx">     m_compositingRunLoop-&gt;performTaskSync([this, protectedThis = makeRef(*this)] {
</span><span class="lines">@@ -164,34 +166,25 @@
</span><span class="cx">     m_compositingRunLoop-&gt;startUpdateTimer(CompositingRunLoop::Immediate);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-bool ThreadedCompositor::tryEnsureGLContext()
</del><ins>+bool ThreadedCompositor::makeContextCurrent()
</ins><span class="cx"> {
</span><del>-    if (!glContext())
</del><ins>+    if (m_context)
+        return m_context-&gt;makeContextCurrent();
+
+    if (!m_nativeSurfaceHandle)
</ins><span class="cx">         return false;
</span><span class="cx"> 
</span><del>-    glContext()-&gt;makeContextCurrent();
-    // The window size may be out of sync with the page size at this point, and getting
-    // the viewport parameters incorrect, means that the content will be misplaced. Thus
-    // we set the viewport parameters directly from the window size.
-    IntSize contextSize = glContext()-&gt;defaultFrameBufferSize();
-    if (m_viewportSize != contextSize) {
-        glViewport(0, 0, contextSize.width(), contextSize.height());
-        m_viewportSize = contextSize;
-    }
</del><ins>+    m_context = GLContext::createContextForWindow(reinterpret_cast&lt;GLNativeWindowType&gt;(m_nativeSurfaceHandle), &amp;PlatformDisplay::sharedDisplayForCompositing());
+    if (!m_context)
+        return false;
</ins><span class="cx"> 
</span><del>-    return true;
-}
</del><ins>+    if (!m_context-&gt;makeContextCurrent())
+        return false;
</ins><span class="cx"> 
</span><del>-GLContext* ThreadedCompositor::glContext()
-{
-    if (m_context)
-        return m_context.get();
</del><ins>+    if (m_doFrameSync == ShouldDoFrameSync::No)
+        m_context-&gt;swapInterval(0);
</ins><span class="cx"> 
</span><del>-    if (!m_nativeSurfaceHandle)
-        return nullptr;
-
-    m_context = GLContext::createContextForWindow(reinterpret_cast&lt;GLNativeWindowType&gt;(m_nativeSurfaceHandle), GLContext::sharingContext());
-    return m_context.get();
</del><ins>+    return true;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void ThreadedCompositor::forceRepaint()
</span><span class="lines">@@ -216,9 +209,18 @@
</span><span class="cx">     if (!m_scene || !m_scene-&gt;isActive())
</span><span class="cx">         return;
</span><span class="cx"> 
</span><del>-    if (!tryEnsureGLContext())
</del><ins>+    if (!makeContextCurrent())
</ins><span class="cx">         return;
</span><span class="cx"> 
</span><ins>+    // The window size may be out of sync with the page size at this point, and getting
+    // the viewport parameters incorrect, means that the content will be misplaced. Thus,
+    // we set the viewport parameters directly from the window size.
+    IntSize contextSize = m_context-&gt;defaultFrameBufferSize();
+    if (m_viewportSize != contextSize) {
+        glViewport(0, 0, contextSize.width(), contextSize.height());
+        m_viewportSize = contextSize;
+    }
+
</ins><span class="cx">     FloatRect clipRect(0, 0, m_viewportSize.width(), m_viewportSize.height());
</span><span class="cx"> 
</span><span class="cx">     TransformationMatrix viewportTransform;
</span><span class="lines">@@ -232,7 +234,7 @@
</span><span class="cx">     }
</span><span class="cx">     m_scene-&gt;paintToCurrentGLContext(viewportTransform, 1, clipRect, Color::transparent, !m_drawsBackground, scrollPostion);
</span><span class="cx"> 
</span><del>-    glContext()-&gt;swapBuffers();
</del><ins>+    m_context-&gt;swapBuffers();
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void ThreadedCompositor::updateSceneState(const CoordinatedGraphicsState&amp; state)
</span></span></pre></div>
<a id="trunkSourceWebKit2SharedCoordinatedGraphicsthreadedcompositorThreadedCompositorh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/Shared/CoordinatedGraphics/threadedcompositor/ThreadedCompositor.h (205115 => 205116)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/Shared/CoordinatedGraphics/threadedcompositor/ThreadedCompositor.h        2016-08-29 09:18:06 UTC (rev 205115)
+++ trunk/Source/WebKit2/Shared/CoordinatedGraphics/threadedcompositor/ThreadedCompositor.h        2016-08-29 09:33:40 UTC (rev 205116)
</span><span class="lines">@@ -57,7 +57,9 @@
</span><span class="cx">         virtual void commitScrollOffset(uint32_t layerID, const WebCore::IntSize&amp; offset) = 0;
</span><span class="cx">     };
</span><span class="cx"> 
</span><del>-    static Ref&lt;ThreadedCompositor&gt; create(Client*, uint64_t nativeSurfaceHandle = 0);
</del><ins>+    enum class ShouldDoFrameSync { No, Yes };
+
+    static Ref&lt;ThreadedCompositor&gt; create(Client*, uint64_t nativeSurfaceHandle = 0, ShouldDoFrameSync = ShouldDoFrameSync::Yes);
</ins><span class="cx">     virtual ~ThreadedCompositor();
</span><span class="cx"> 
</span><span class="cx">     void setNativeSurfaceHandleForCompositing(uint64_t);
</span><span class="lines">@@ -77,7 +79,7 @@
</span><span class="cx">     void forceRepaint();
</span><span class="cx"> 
</span><span class="cx"> private:
</span><del>-    ThreadedCompositor(Client*, uint64_t nativeSurfaceHandle);
</del><ins>+    ThreadedCompositor(Client*, uint64_t nativeSurfaceHandle, ShouldDoFrameSync);
</ins><span class="cx"> 
</span><span class="cx">     // CoordinatedGraphicsSceneClient
</span><span class="cx">     void renderNextFrame() override;
</span><span class="lines">@@ -90,8 +92,7 @@
</span><span class="cx">     void renderLayerTree();
</span><span class="cx">     void scheduleDisplayImmediately();
</span><span class="cx"> 
</span><del>-    bool tryEnsureGLContext();
-    WebCore::GLContext* glContext();
</del><ins>+    bool makeContextCurrent();
</ins><span class="cx"> 
</span><span class="cx">     Client* m_client { nullptr };
</span><span class="cx">     RefPtr&lt;CoordinatedGraphicsScene&gt; m_scene;
</span><span class="lines">@@ -102,6 +103,7 @@
</span><span class="cx">     float m_deviceScaleFactor { 1 };
</span><span class="cx">     bool m_drawsBackground { true };
</span><span class="cx">     uint64_t m_nativeSurfaceHandle;
</span><ins>+    ShouldDoFrameSync m_doFrameSync;
</ins><span class="cx"> 
</span><span class="cx">     std::unique_ptr&lt;CompositingRunLoop&gt; m_compositingRunLoop;
</span><span class="cx"> };
</span></span></pre></div>
<a id="trunkSourceWebKit2SharedWebProcessCreationParameterscpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/Shared/WebProcessCreationParameters.cpp (205115 => 205116)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/Shared/WebProcessCreationParameters.cpp        2016-08-29 09:18:06 UTC (rev 205115)
+++ trunk/Source/WebKit2/Shared/WebProcessCreationParameters.cpp        2016-08-29 09:33:40 UTC (rev 205116)
</span><span class="lines">@@ -145,6 +145,10 @@
</span><span class="cx"> #if OS(LINUX)
</span><span class="cx">     encoder &lt;&lt; memoryPressureMonitorHandle;
</span><span class="cx"> #endif
</span><ins>+
+#if PLATFORM(WAYLAND)
+    encoder &lt;&lt; waylandCompositorDisplayName;
+#endif
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> bool WebProcessCreationParameters::decode(IPC::Decoder&amp; decoder, WebProcessCreationParameters&amp; parameters)
</span><span class="lines">@@ -305,6 +309,11 @@
</span><span class="cx">         return false;
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><ins>+#if PLATFORM(WAYLAND)
+    if (!decoder.decode(parameters.waylandCompositorDisplayName))
+        return false;
+#endif
+
</ins><span class="cx">     return true;
</span><span class="cx"> }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebKit2SharedWebProcessCreationParametersh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/Shared/WebProcessCreationParameters.h (205115 => 205116)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/Shared/WebProcessCreationParameters.h        2016-08-29 09:18:06 UTC (rev 205115)
+++ trunk/Source/WebKit2/Shared/WebProcessCreationParameters.h        2016-08-29 09:33:40 UTC (rev 205116)
</span><span class="lines">@@ -170,6 +170,10 @@
</span><span class="cx"> #if OS(LINUX)
</span><span class="cx">     IPC::Attachment memoryPressureMonitorHandle;
</span><span class="cx"> #endif
</span><ins>+
+#if PLATFORM(WAYLAND)
+    String waylandCompositorDisplayName;
+#endif
</ins><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> } // namespace WebKit
</span></span></pre></div>
<a id="trunkSourceWebKit2SharedgtkWebKit2WaylandProtocolxmlfromrev205115trunkSourceWebCoreplatformgraphicswaylandWebKitGtkWaylandClientProtocolxml"></a>
<div class="copfile"><h4>Copied: trunk/Source/WebKit2/Shared/gtk/WebKit2WaylandProtocol.xml (from rev 205115, trunk/Source/WebCore/platform/graphics/wayland/WebKitGtkWaylandClientProtocol.xml) (0 => 205116)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/Shared/gtk/WebKit2WaylandProtocol.xml                                (rev 0)
+++ trunk/Source/WebKit2/Shared/gtk/WebKit2WaylandProtocol.xml        2016-08-29 09:33:40 UTC (rev 205116)
</span><span class="lines">@@ -0,0 +1,37 @@
</span><ins>+&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
+&lt;protocol name=&quot;wl_webkitgtk&quot;&gt;
+
+  &lt;copyright&gt;
+    Copyright © 2014 Igalia S.L.
+
+    Permission to use, copy, modify, distribute, and sell this
+    software and its documentation for any purpose is hereby granted
+    without fee, provided that the above copyright notice appear in
+    all copies and that both that copyright notice and this permission
+    notice appear in supporting documentation, and that the name of
+    the copyright holders not be used in advertising or publicity
+    pertaining to distribution of the software without specific,
+    written prior permission.  The copyright holders make no
+    representations about the suitability of this software for any
+    purpose.  It is provided &quot;as is&quot; without express or implied
+    warranty.
+
+    THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
+    SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
+    FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY
+    SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+    WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
+    AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+    ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
+    THIS SOFTWARE.
+  &lt;/copyright&gt;
+
+  &lt;interface name=&quot;wl_webkitgtk&quot; version=&quot;1&quot;&gt;
+    &lt;request name=&quot;bind_surface_to_page&quot;&gt;
+      &lt;arg name=&quot;surface&quot; type=&quot;object&quot; interface=&quot;wl_surface&quot;/&gt;
+      &lt;arg name=&quot;page_id&quot; type=&quot;uint&quot;/&gt;
+    &lt;/request&gt;
+
+  &lt;/interface&gt;
+
+&lt;/protocol&gt;
</ins></span></pre></div>
<a id="trunkSourceWebKit2UIProcessAPIgtkWebKitWebViewBasecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewBase.cpp (205115 => 205116)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewBase.cpp        2016-08-29 09:18:06 UTC (rev 205115)
+++ trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewBase.cpp        2016-08-29 09:33:40 UTC (rev 205116)
</span><span class="lines">@@ -30,6 +30,7 @@
</span><span class="cx"> #include &quot;WebKitWebViewBase.h&quot;
</span><span class="cx"> 
</span><span class="cx"> #include &quot;APIPageConfiguration.h&quot;
</span><ins>+#include &quot;AcceleratedBackingStore.h&quot;
</ins><span class="cx"> #include &quot;DrawingAreaProxyImpl.h&quot;
</span><span class="cx"> #include &quot;InputMethodFilter.h&quot;
</span><span class="cx"> #include &quot;KeyBindingTranslator.h&quot;
</span><span class="lines">@@ -72,23 +73,10 @@
</span><span class="cx"> #include &quot;WebFullScreenManagerProxy.h&quot;
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><del>-#if USE(REDIRECTED_XCOMPOSITE_WINDOW)
-#include &quot;XDamageNotifier.h&quot;
-#include &lt;WebCore/PlatformDisplayX11.h&gt;
-#include &lt;WebCore/XUniqueResource.h&gt;
-#include &lt;X11/Xlib.h&gt;
-#include &lt;X11/extensions/Xdamage.h&gt;
-#include &lt;cairo-xlib.h&gt;
-#endif
-
</del><span class="cx"> #if PLATFORM(X11)
</span><span class="cx"> #include &lt;gdk/gdkx.h&gt;
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><del>-#if PLATFORM(WAYLAND)
-#include &lt;gdk/gdkwayland.h&gt;
-#endif
-
</del><span class="cx"> // gtk_widget_get_scale_factor() appeared in GTK 3.10, but we also need
</span><span class="cx"> // to make sure we have cairo new enough to support cairo_surface_set_device_scale
</span><span class="cx"> #define HAVE_GTK_SCALE_FACTOR HAVE_CAIRO_SURFACE_SET_DEVICE_SCALE &amp;&amp; GTK_CHECK_VERSION(3, 10, 0)
</span><span class="lines">@@ -211,10 +199,7 @@
</span><span class="cx">     unsigned screenSaverCookie;
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><del>-#if USE(REDIRECTED_XCOMPOSITE_WINDOW)
-    RefPtr&lt;cairo_surface_t&gt; acceleratedCompositingSurface;
-    XUniqueDamage acceleratedCompositingSurfaceDamage;
-#endif
</del><ins>+    std::unique_ptr&lt;AcceleratedBackingStore&gt; acceleratedBackingStore;
</ins><span class="cx"> 
</span><span class="cx"> #if ENABLE(DRAG_SUPPORT)
</span><span class="cx">     std::unique_ptr&lt;DragAndDropHandler&gt; dragAndDropHandler;
</span><span class="lines">@@ -351,50 +336,6 @@
</span><span class="cx">         priv-&gt;toplevelWindowRealizedID = g_signal_connect_swapped(window, &quot;realize&quot;, G_CALLBACK(toplevelWindowRealized), webViewBase);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-#if USE(REDIRECTED_XCOMPOSITE_WINDOW)
-static void webkitWebViewBaseSetAcceleratedCompositingPixmap(WebKitWebViewBase* webView, Pixmap pixmap)
-{
-    if (PlatformDisplay::sharedDisplay().type() != PlatformDisplay::Type::X11)
-        return;
-
-    WebKitWebViewBasePrivate* priv = webView-&gt;priv;
-    if (priv-&gt;acceleratedCompositingSurface
-        &amp;&amp; cairo_xlib_surface_get_drawable(priv-&gt;acceleratedCompositingSurface.get()) == pixmap)
-        return;
-
-    if (priv-&gt;acceleratedCompositingSurface) {
-        if (priv-&gt;acceleratedCompositingSurfaceDamage) {
-            XDamageNotifier::singleton().remove(priv-&gt;acceleratedCompositingSurfaceDamage.get());
-            priv-&gt;acceleratedCompositingSurfaceDamage.reset();
-        }
-        priv-&gt;acceleratedCompositingSurface = nullptr;
-    }
-
-    if (!pixmap)
-        return;
-
-    DrawingAreaProxyImpl* drawingArea = static_cast&lt;DrawingAreaProxyImpl*&gt;(priv-&gt;pageProxy-&gt;drawingArea());
-    if (!drawingArea)
-        return;
-
-    IntSize size = drawingArea-&gt;size();
-    float deviceScaleFactor = priv-&gt;pageProxy-&gt;deviceScaleFactor();
-    size.scale(deviceScaleFactor);
-
-    Display* display = downcast&lt;PlatformDisplayX11&gt;(PlatformDisplay::sharedDisplay()).native();
-    ASSERT(downcast&lt;PlatformDisplayX11&gt;(PlatformDisplay::sharedDisplay()).native() == GDK_DISPLAY_XDISPLAY(gdk_display_get_default()));
-    GdkVisual* visual = gdk_screen_get_rgba_visual(gdk_screen_get_default());
-    if (!visual)
-        visual = gdk_screen_get_system_visual(gdk_screen_get_default());
-    priv-&gt;acceleratedCompositingSurface = adoptRef(cairo_xlib_surface_create(display, pixmap, GDK_VISUAL_XVISUAL(visual), size.width(), size.height()));
-    cairoSurfaceSetDeviceScale(priv-&gt;acceleratedCompositingSurface.get(), deviceScaleFactor, deviceScaleFactor);
-    priv-&gt;acceleratedCompositingSurfaceDamage = XDamageCreate(display, pixmap, XDamageReportNonEmpty);
-    XDamageNotifier::singleton().add(priv-&gt;acceleratedCompositingSurfaceDamage.get(), [webView] {
-        gtk_widget_queue_draw(GTK_WIDGET(webView));
-    });
-}
-#endif
-
</del><span class="cx"> static void webkitWebViewBaseRealize(GtkWidget* widget)
</span><span class="cx"> {
</span><span class="cx">     WebKitWebViewBase* webView = WEBKIT_WEB_VIEW_BASE(widget);
</span><span class="lines">@@ -564,9 +505,7 @@
</span><span class="cx">     g_cancellable_cancel(webView-&gt;priv-&gt;screenSaverInhibitCancellable.get());
</span><span class="cx">     webkitWebViewBaseSetToplevelOnScreenWindow(webView, nullptr);
</span><span class="cx">     webView-&gt;priv-&gt;pageProxy-&gt;close();
</span><del>-#if USE(REDIRECTED_XCOMPOSITE_WINDOW)
-    webkitWebViewBaseSetAcceleratedCompositingPixmap(webView, 0);
-#endif
</del><ins>+    webView-&gt;priv-&gt;acceleratedBackingStore = nullptr;
</ins><span class="cx">     G_OBJECT_CLASS(webkit_web_view_base_parent_class)-&gt;dispose(gobject);
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -585,55 +524,6 @@
</span><span class="cx">     priv-&gt;authenticationDialog = 0;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-static bool webkitWebViewRenderAcceleratedCompositingResults(WebKitWebViewBase* webViewBase, DrawingAreaProxyImpl* drawingArea, cairo_t* cr, GdkRectangle* clipRect)
-{
-#if USE(REDIRECTED_XCOMPOSITE_WINDOW)
-    ASSERT(drawingArea);
-
-    if (!drawingArea-&gt;isInAcceleratedCompositingMode())
-        return false;
-
-    WebKitWebViewBasePrivate* priv = WEBKIT_WEB_VIEW_BASE(webViewBase)-&gt;priv;
-    cairo_surface_t* surface = priv-&gt;acceleratedCompositingSurface.get();
-    cairo_save(cr);
-
-    if (!surface || !priv-&gt;pageProxy-&gt;drawsBackground()) {
-        const WebCore::Color&amp; color = priv-&gt;pageProxy-&gt;backgroundColor();
-        if (color.hasAlpha()) {
-            cairo_rectangle(cr, clipRect-&gt;x, clipRect-&gt;y, clipRect-&gt;width, clipRect-&gt;height);
-            cairo_set_operator(cr, CAIRO_OPERATOR_CLEAR);
-            cairo_fill(cr);
-        }
-
-        if (color.alpha() &gt; 0) {
-            setSourceRGBAFromColor(cr, color);
-            cairo_set_operator(cr, CAIRO_OPERATOR_SOURCE);
-            cairo_rectangle(cr, clipRect-&gt;x, clipRect-&gt;y, clipRect-&gt;width, clipRect-&gt;height);
-            cairo_fill(cr);
-        }
-    }
-
-    if (surface) {
-        // The surface can be modified by the web process at any time, so we mark it
-        // as dirty to ensure we always render the updated contents as soon as possible.
-        cairo_surface_mark_dirty(surface);
-        cairo_rectangle(cr, clipRect-&gt;x, clipRect-&gt;y, clipRect-&gt;width, clipRect-&gt;height);
-        cairo_set_source_surface(cr, surface, 0, 0);
-        cairo_set_operator(cr, CAIRO_OPERATOR_OVER);
-        cairo_fill(cr);
-    }
-
-    cairo_restore(cr);
-
-    return true;
-#else
-    UNUSED_PARAM(webViewBase);
-    UNUSED_PARAM(cr);
-    UNUSED_PARAM(clipRect);
-    return false;
-#endif
-}
-
</del><span class="cx"> static gboolean webkitWebViewBaseDraw(GtkWidget* widget, cairo_t* cr)
</span><span class="cx"> {
</span><span class="cx">     WebKitWebViewBase* webViewBase = WEBKIT_WEB_VIEW_BASE(widget);
</span><span class="lines">@@ -645,7 +535,9 @@
</span><span class="cx">     if (!gdk_cairo_get_clip_rectangle(cr, &amp;clipRect))
</span><span class="cx">         return FALSE;
</span><span class="cx"> 
</span><del>-    if (!webkitWebViewRenderAcceleratedCompositingResults(webViewBase, drawingArea, cr, &amp;clipRect)) {
</del><ins>+    if (webViewBase-&gt;priv-&gt;acceleratedBackingStore &amp;&amp; drawingArea-&gt;isInAcceleratedCompositingMode())
+        webViewBase-&gt;priv-&gt;acceleratedBackingStore-&gt;paint(cr, clipRect);
+    else {
</ins><span class="cx">         WebCore::Region unpaintedRegion; // This is simply unused.
</span><span class="cx">         drawingArea-&gt;paint(cr, clipRect, unpaintedRegion);
</span><span class="cx">     }
</span><span class="lines">@@ -1286,6 +1178,8 @@
</span><span class="cx">     priv-&gt;pageProxy = context-&gt;createWebPage(*priv-&gt;pageClient, WTFMove(configuration));
</span><span class="cx">     priv-&gt;pageProxy-&gt;initializeWebPage();
</span><span class="cx"> 
</span><ins>+    priv-&gt;acceleratedBackingStore = AcceleratedBackingStore::create(*priv-&gt;pageProxy);
+
</ins><span class="cx">     priv-&gt;inputMethodFilter.setPage(priv-&gt;pageProxy.get());
</span><span class="cx"> 
</span><span class="cx"> #if HAVE(GTK_SCALE_FACTOR)
</span><span class="lines">@@ -1566,29 +1460,20 @@
</span><span class="cx"> 
</span><span class="cx"> void webkitWebViewBaseEnterAcceleratedCompositingMode(WebKitWebViewBase* webkitWebViewBase, const LayerTreeContext&amp; layerTreeContext)
</span><span class="cx"> {
</span><del>-#if USE(REDIRECTED_XCOMPOSITE_WINDOW)
-    webkitWebViewBaseSetAcceleratedCompositingPixmap(webkitWebViewBase, layerTreeContext.contextID);
-#else
-    UNUSED_PARAM(webkitWebViewBase);
-#endif
</del><ins>+    if (webkitWebViewBase-&gt;priv-&gt;acceleratedBackingStore)
+        webkitWebViewBase-&gt;priv-&gt;acceleratedBackingStore-&gt;update(layerTreeContext);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void webkitWebViewBaseUpdateAcceleratedCompositingMode(WebKitWebViewBase* webkitWebViewBase, const LayerTreeContext&amp; layerTreeContext)
</span><span class="cx"> {
</span><del>-#if USE(REDIRECTED_XCOMPOSITE_WINDOW)
-    webkitWebViewBaseSetAcceleratedCompositingPixmap(webkitWebViewBase, layerTreeContext.contextID);
-#else
-    UNUSED_PARAM(webkitWebViewBase);
-#endif
</del><ins>+    if (webkitWebViewBase-&gt;priv-&gt;acceleratedBackingStore)
+        webkitWebViewBase-&gt;priv-&gt;acceleratedBackingStore-&gt;update(layerTreeContext);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void webkitWebViewBaseExitAcceleratedCompositingMode(WebKitWebViewBase* webkitWebViewBase)
</span><span class="cx"> {
</span><del>-#if USE(REDIRECTED_XCOMPOSITE_WINDOW)
-    webkitWebViewBaseSetAcceleratedCompositingPixmap(webkitWebViewBase, 0);
-#else
-    UNUSED_PARAM(webkitWebViewBase);
-#endif
</del><ins>+    if (webkitWebViewBase-&gt;priv-&gt;acceleratedBackingStore)
+        webkitWebViewBase-&gt;priv-&gt;acceleratedBackingStore-&gt;update(LayerTreeContext());
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void webkitWebViewBaseDidRelaunchWebProcess(WebKitWebViewBase* webkitWebViewBase)
</span><span class="lines">@@ -1616,9 +1501,9 @@
</span><span class="cx"> 
</span><span class="cx"> void webkitWebViewBasePageClosed(WebKitWebViewBase* webkitWebViewBase)
</span><span class="cx"> {
</span><del>-#if USE(REDIRECTED_XCOMPOSITE_WINDOW)
-    webkitWebViewBaseSetAcceleratedCompositingPixmap(webkitWebViewBase, 0);
-#elif PLATFORM(X11) &amp;&amp; USE(TEXTURE_MAPPER)
</del><ins>+    if (webkitWebViewBase-&gt;priv-&gt;acceleratedBackingStore)
+        webkitWebViewBase-&gt;priv-&gt;acceleratedBackingStore-&gt;update(LayerTreeContext());
+#if PLATFORM(X11) &amp;&amp; USE(TEXTURE_MAPPER) &amp;&amp; !USE(REDIRECTED_XCOMPOSITE_WINDOW)
</ins><span class="cx">     if (PlatformDisplay::sharedDisplay().type() != PlatformDisplay::Type::X11)
</span><span class="cx">         return;
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessAcceleratedDrawingAreaProxycpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/AcceleratedDrawingAreaProxy.cpp (205115 => 205116)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/AcceleratedDrawingAreaProxy.cpp        2016-08-29 09:18:06 UTC (rev 205115)
+++ trunk/Source/WebKit2/UIProcess/AcceleratedDrawingAreaProxy.cpp        2016-08-29 09:33:40 UTC (rev 205116)
</span><span class="lines">@@ -41,6 +41,11 @@
</span><span class="cx"> #include &quot;CoordinatedLayerTreeHostProxy.h&quot;
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><ins>+#if PLATFORM(WAYLAND)
+#include &quot;WaylandCompositor.h&quot;
+#include &lt;WebCore/PlatformDisplay.h&gt;
+#endif
+
</ins><span class="cx"> using namespace WebCore;
</span><span class="cx"> 
</span><span class="cx"> namespace WebKit {
</span><span class="lines">@@ -216,6 +221,13 @@
</span><span class="cx">     if (m_webPageProxy.process().state() == WebProcessProxy::State::Launching)
</span><span class="cx">         return;
</span><span class="cx"> 
</span><ins>+#if PLATFORM(WAYLAND)
+    // Never block the UI process in Wayland when waiting for DidUpdateBackingStoreState after a resize,
+    // because the nested compositor needs to handle the web process requests that happens while resizing.
+    if (PlatformDisplay::sharedDisplay().type() == PlatformDisplay::Type::Wayland &amp;&amp; WaylandCompositor::singleton().isRunning())
+        return;
+#endif
+
</ins><span class="cx">     // FIXME: waitForAndDispatchImmediately will always return the oldest DidUpdateBackingStoreState message that
</span><span class="cx">     // hasn't yet been processed. But it might be better to skip ahead to some other DidUpdateBackingStoreState
</span><span class="cx">     // message, if multiple DidUpdateBackingStoreState messages are waiting to be processed. For instance, we could
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessWebProcessPoolcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/WebProcessPool.cpp (205115 => 205116)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/WebProcessPool.cpp        2016-08-29 09:18:06 UTC (rev 205115)
+++ trunk/Source/WebKit2/UIProcess/WebProcessPool.cpp        2016-08-29 09:33:40 UTC (rev 205116)
</span><span class="lines">@@ -100,6 +100,11 @@
</span><span class="cx"> #include &quot;MemoryPressureMonitor.h&quot;
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><ins>+#if PLATFORM(WAYLAND)
+#include &quot;WaylandCompositor.h&quot;
+#include &lt;WebCore/PlatformDisplay.h&gt;
+#endif
+
</ins><span class="cx"> #ifndef NDEBUG
</span><span class="cx"> #include &lt;wtf/RefCountedLeakCounter.h&gt;
</span><span class="cx"> #endif
</span><span class="lines">@@ -639,6 +644,11 @@
</span><span class="cx">         parameters.memoryPressureMonitorHandle = MemoryPressureMonitor::singleton().createHandle();
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><ins>+#if PLATFORM(WAYLAND)
+    if (PlatformDisplay::sharedDisplay().type() == PlatformDisplay::Type::Wayland)
+        parameters.waylandCompositorDisplayName = WaylandCompositor::singleton().displayName();
+#endif
+
</ins><span class="cx">     parameters.resourceLoadStatisticsEnabled = resourceLoadStatisticsEnabled();
</span><span class="cx"> 
</span><span class="cx">     // Add any platform specific parameters
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessgtkAcceleratedBackingStorecpp"></a>
<div class="addfile"><h4>Added: trunk/Source/WebKit2/UIProcess/gtk/AcceleratedBackingStore.cpp (0 => 205116)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/gtk/AcceleratedBackingStore.cpp                                (rev 0)
+++ trunk/Source/WebKit2/UIProcess/gtk/AcceleratedBackingStore.cpp        2016-08-29 09:33:40 UTC (rev 205116)
</span><span class="lines">@@ -0,0 +1,85 @@
</span><ins>+/*
+ * Copyright (C) 2016 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 &quot;config.h&quot;
+#include &quot;AcceleratedBackingStore.h&quot;
+
+#include &quot;WebPageProxy.h&quot;
+#include &lt;WebCore/CairoUtilities.h&gt;
+#include &lt;WebCore/PlatformDisplay.h&gt;
+
+#if PLATFORM(WAYLAND)
+#include &quot;AcceleratedBackingStoreWayland.h&quot;
+#endif
+
+#if USE(REDIRECTED_XCOMPOSITE_WINDOW)
+#include &quot;AcceleratedBackingStoreX11.h&quot;
+#endif
+
+using namespace WebCore;
+
+namespace WebKit {
+
+std::unique_ptr&lt;AcceleratedBackingStore&gt; AcceleratedBackingStore::create(WebPageProxy&amp; webPage)
+{
+#if PLATFORM(WAYLAND)
+    if (PlatformDisplay::sharedDisplay().type() == PlatformDisplay::Type::Wayland)
+        return AcceleratedBackingStoreWayland::create(webPage);
+#endif
+#if USE(REDIRECTED_XCOMPOSITE_WINDOW)
+    if (PlatformDisplay::sharedDisplay().type() == PlatformDisplay::Type::X11)
+        return AcceleratedBackingStoreX11::create(webPage);
+#endif
+    return nullptr;
+}
+
+AcceleratedBackingStore::AcceleratedBackingStore(WebPageProxy&amp; webPage)
+    : m_webPage(webPage)
+{
+}
+
+bool AcceleratedBackingStore::paint(cairo_t* cr, const IntRect&amp; clipRect)
+{
+    if (m_webPage.drawsBackground())
+        return true;
+
+    const WebCore::Color&amp; color = m_webPage.backgroundColor();
+    if (color.hasAlpha()) {
+        cairo_rectangle(cr, clipRect.x(), clipRect.y(), clipRect.width(), clipRect.height());
+        cairo_set_operator(cr, CAIRO_OPERATOR_CLEAR);
+        cairo_fill(cr);
+    }
+
+    if (color.alpha() &gt; 0) {
+        setSourceRGBAFromColor(cr, color);
+        cairo_set_operator(cr, CAIRO_OPERATOR_SOURCE);
+        cairo_rectangle(cr, clipRect.x(), clipRect.y(), clipRect.width(), clipRect.height());
+        cairo_fill(cr);
+    }
+
+    return true;
+}
+
+} // namespace WebKit
</ins></span></pre></div>
<a id="trunkSourceWebKit2UIProcessgtkAcceleratedBackingStorehfromrev205115trunkSourceWebCoreplatformgraphicswaylandWaylandSurfaceh"></a>
<div class="copfile"><h4>Copied: trunk/Source/WebKit2/UIProcess/gtk/AcceleratedBackingStore.h (from rev 205115, trunk/Source/WebCore/platform/graphics/wayland/WaylandSurface.h) (0 => 205116)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/gtk/AcceleratedBackingStore.h                                (rev 0)
+++ trunk/Source/WebKit2/UIProcess/gtk/AcceleratedBackingStore.h        2016-08-29 09:33:40 UTC (rev 205116)
</span><span class="lines">@@ -0,0 +1,56 @@
</span><ins>+/*
+ * Copyright (C) 2016 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.
+ */
+
+#pragma once
+
+#include &lt;wtf/Noncopyable.h&gt;
+
+typedef struct _cairo cairo_t;
+
+namespace WebCore {
+class IntRect;
+}
+
+namespace WebKit {
+
+class LayerTreeContext;
+class WebPageProxy;
+
+class AcceleratedBackingStore {
+    WTF_MAKE_NONCOPYABLE(AcceleratedBackingStore); WTF_MAKE_FAST_ALLOCATED;
+public:
+    static std::unique_ptr&lt;AcceleratedBackingStore&gt; create(WebPageProxy&amp;);
+    virtual ~AcceleratedBackingStore() = default;
+
+    virtual void update(const LayerTreeContext&amp;) { }
+    virtual bool paint(cairo_t*, const WebCore::IntRect&amp;);
+
+protected:
+    AcceleratedBackingStore(WebPageProxy&amp;);
+
+    WebPageProxy&amp; m_webPage;
+};
+
+} // namespace WebKit
</ins></span></pre></div>
<a id="trunkSourceWebKit2UIProcessgtkAcceleratedBackingStoreWaylandcpp"></a>
<div class="addfile"><h4>Added: trunk/Source/WebKit2/UIProcess/gtk/AcceleratedBackingStoreWayland.cpp (0 => 205116)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/gtk/AcceleratedBackingStoreWayland.cpp                                (rev 0)
+++ trunk/Source/WebKit2/UIProcess/gtk/AcceleratedBackingStoreWayland.cpp        2016-08-29 09:33:40 UTC (rev 205116)
</span><span class="lines">@@ -0,0 +1,119 @@
</span><ins>+/*
+ * Copyright (C) 2016 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 &quot;config.h&quot;
+#include &quot;AcceleratedBackingStoreWayland.h&quot;
+
+#if PLATFORM(WAYLAND)
+
+#include &quot;WaylandCompositor.h&quot;
+#include &quot;WebPageProxy.h&quot;
+#include &lt;WebCore/CairoUtilities.h&gt;
+#include &lt;WebCore/RefPtrCairo.h&gt;
+
+#if USE(OPENGL_ES_2)
+#include &lt;GLES2/gl2.h&gt;
+#else
+#include &lt;WebCore/OpenGLShims.h&gt;
+#endif
+
+using namespace WebCore;
+
+namespace WebKit {
+
+std::unique_ptr&lt;AcceleratedBackingStoreWayland&gt; AcceleratedBackingStoreWayland::create(WebPageProxy&amp; webPage)
+{
+    if (!WaylandCompositor::singleton().isRunning())
+        return nullptr;
+    return std::unique_ptr&lt;AcceleratedBackingStoreWayland&gt;(new AcceleratedBackingStoreWayland(webPage));
+}
+
+AcceleratedBackingStoreWayland::AcceleratedBackingStoreWayland(WebPageProxy&amp; webPage)
+    : AcceleratedBackingStore(webPage)
+{
+    WaylandCompositor::singleton().registerWebPage(m_webPage);
+}
+
+AcceleratedBackingStoreWayland::~AcceleratedBackingStoreWayland()
+{
+    WaylandCompositor::singleton().unregisterWebPage(m_webPage);
+}
+
+bool AcceleratedBackingStoreWayland::paint(cairo_t* cr, const IntRect&amp; clipRect)
+{
+    GLuint texture;
+    IntSize textureSize;
+    if (!WaylandCompositor::singleton().getTexture(m_webPage, texture, textureSize))
+        return false;
+
+    cairo_save(cr);
+    AcceleratedBackingStore::paint(cr, clipRect);
+
+#if 0
+    // FIXME: Use this when GTK+ &gt;= 3.16. GTK+ expects the Y axis to be inverted to what we get, so we need to flip it somehow.
+    gdk_cairo_draw_from_gl(cr, gtk_widget_get_window(m_webPage.viewWidget()), texture, GL_TEXTURE, 1, clipRect.x(), clipRect.y(), clipRect.width(), clipRect.height());
+#else
+    IntSize size = textureSize;
+    float deviceScaleFactor = m_webPage.deviceScaleFactor();
+    size.scale(deviceScaleFactor);
+
+    if (!m_surface || cairo_image_surface_get_width(m_surface.get()) != size.width() || cairo_image_surface_get_height(m_surface.get()) != size.height())
+        m_surface = adoptRef(cairo_image_surface_create(CAIRO_FORMAT_ARGB32, size.width(), size.height()));
+    cairoSurfaceSetDeviceScale(m_surface.get(), deviceScaleFactor, deviceScaleFactor);
+
+    GLuint fb;
+    glGenFramebuffers(1, &amp;fb);
+    glBindFramebuffer(GL_FRAMEBUFFER, fb);
+    glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture, 0);
+
+    glPixelStorei(GL_PACK_ALIGNMENT, 4);
+    glPixelStorei(GL_PACK_ROW_LENGTH, cairo_image_surface_get_stride(m_surface.get()) / 4);
+#if USE(OPENGL_ES_2)
+    glReadPixels(0, 0, textureSize.width(), textureSize.height(), GL_RGBA, GL_UNSIGNED_BYTE, cairo_image_surface_get_data(m_surface.get()));
+#else
+    glReadPixels(0, 0, textureSize.width(), textureSize.height(), GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, cairo_image_surface_get_data(m_surface.get()));
+#endif
+    glPixelStorei(GL_PACK_ROW_LENGTH, 0);
+
+    glBindFramebuffer(GL_FRAMEBUFFER, 0);
+    glDeleteFramebuffers(1, &amp;fb);
+
+    // The surface can be modified by the web process at any time, so we mark it
+    // as dirty to ensure we always render the updated contents as soon as possible.
+    cairo_surface_mark_dirty(m_surface.get());
+    cairo_rectangle(cr, clipRect.x(), clipRect.y(), clipRect.width(), clipRect.height());
+    cairo_set_source_surface(cr, m_surface.get(), 0, 0);
+    cairo_set_operator(cr, CAIRO_OPERATOR_OVER);
+    cairo_fill(cr);
+#endif
+
+    cairo_restore(cr);
+
+    return true;
+}
+
+} // namespace WebKit
+
+#endif // PLATFORM(WAYLAND)
</ins></span></pre></div>
<a id="trunkSourceWebKit2UIProcessgtkAcceleratedBackingStoreWaylandhfromrev205115trunkSourceWebCoreplatformgraphicswaylandWaylandEventSourceh"></a>
<div class="copfile"><h4>Copied: trunk/Source/WebKit2/UIProcess/gtk/AcceleratedBackingStoreWayland.h (from rev 205115, trunk/Source/WebCore/platform/graphics/wayland/WaylandEventSource.h) (0 => 205116)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/gtk/AcceleratedBackingStoreWayland.h                                (rev 0)
+++ trunk/Source/WebKit2/UIProcess/gtk/AcceleratedBackingStoreWayland.h        2016-08-29 09:33:40 UTC (rev 205116)
</span><span class="lines">@@ -0,0 +1,54 @@
</span><ins>+/*
+ * Copyright (C) 2016 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.
+ */
+
+#pragma once
+
+#include &quot;AcceleratedBackingStore.h&quot;
+
+#if PLATFORM(WAYLAND)
+
+#include &lt;WebCore/RefPtrCairo.h&gt;
+
+namespace WebKit {
+
+class WebPageProxy;
+
+class AcceleratedBackingStoreWayland final : public AcceleratedBackingStore {
+    WTF_MAKE_NONCOPYABLE(AcceleratedBackingStoreWayland); WTF_MAKE_FAST_ALLOCATED;
+public:
+    static std::unique_ptr&lt;AcceleratedBackingStoreWayland&gt; create(WebPageProxy&amp;);
+    ~AcceleratedBackingStoreWayland();
+
+private:
+    AcceleratedBackingStoreWayland(WebPageProxy&amp;);
+
+    bool paint(cairo_t*, const WebCore::IntRect&amp;) override;
+
+    RefPtr&lt;cairo_surface_t&gt; m_surface;
+};
+
+} // namespace WebKit
+
+#endif // PLATFORM(WAYLAND)
</ins></span></pre></div>
<a id="trunkSourceWebKit2UIProcessgtkAcceleratedBackingStoreX11cpp"></a>
<div class="addfile"><h4>Added: trunk/Source/WebKit2/UIProcess/gtk/AcceleratedBackingStoreX11.cpp (0 => 205116)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/gtk/AcceleratedBackingStoreX11.cpp                                (rev 0)
+++ trunk/Source/WebKit2/UIProcess/gtk/AcceleratedBackingStoreX11.cpp        2016-08-29 09:33:40 UTC (rev 205116)
</span><span class="lines">@@ -0,0 +1,185 @@
</span><ins>+/*
+ * Copyright (C) 2016 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 &quot;config.h&quot;
+#include &quot;AcceleratedBackingStoreX11.h&quot;
+
+#if USE(REDIRECTED_XCOMPOSITE_WINDOW)
+
+#include &quot;DrawingAreaProxyImpl.h&quot;
+#include &quot;LayerTreeContext.h&quot;
+#include &quot;WebPageProxy.h&quot;
+#include &lt;WebCore/CairoUtilities.h&gt;
+#include &lt;WebCore/PlatformDisplayX11.h&gt;
+#include &lt;X11/Xlib.h&gt;
+#include &lt;X11/extensions/Xdamage.h&gt;
+#include &lt;cairo-xlib.h&gt;
+#include &lt;gdk/gdkx.h&gt;
+#include &lt;wtf/HashMap.h&gt;
+#include &lt;wtf/NeverDestroyed.h&gt;
+
+using namespace WebCore;
+
+namespace WebKit {
+
+static Optional&lt;int&gt; s_damageEventBase;
+
+class XDamageNotifier {
+    WTF_MAKE_NONCOPYABLE(XDamageNotifier);
+    friend class NeverDestroyed&lt;XDamageNotifier&gt;;
+public:
+    static XDamageNotifier&amp; singleton()
+    {
+        static NeverDestroyed&lt;XDamageNotifier&gt; notifier;
+        return notifier;
+    }
+
+    void add(Damage damage, std::function&lt;void()&gt;&amp;&amp; notifyFunction)
+    {
+        if (m_notifyFunctions.isEmpty())
+            gdk_window_add_filter(nullptr, reinterpret_cast&lt;GdkFilterFunc&gt;(&amp;filterXDamageEvent), this);
+        m_notifyFunctions.add(damage, WTFMove(notifyFunction));
+    }
+
+    void remove(Damage damage)
+    {
+        m_notifyFunctions.remove(damage);
+        if (m_notifyFunctions.isEmpty())
+            gdk_window_remove_filter(nullptr, reinterpret_cast&lt;GdkFilterFunc&gt;(&amp;filterXDamageEvent), this);
+    }
+
+private:
+    XDamageNotifier() = default;
+
+    static GdkFilterReturn filterXDamageEvent(GdkXEvent* event, GdkEvent*, XDamageNotifier* notifier)
+    {
+        auto* xEvent = static_cast&lt;XEvent*&gt;(event);
+        if (xEvent-&gt;type != s_damageEventBase.value() + XDamageNotify)
+            return GDK_FILTER_CONTINUE;
+
+        auto* damageEvent = reinterpret_cast&lt;XDamageNotifyEvent*&gt;(xEvent);
+        if (notifier-&gt;notify(damageEvent-&gt;damage)) {
+            XDamageSubtract(xEvent-&gt;xany.display, damageEvent-&gt;damage, None, None);
+            return GDK_FILTER_REMOVE;
+        }
+
+        return GDK_FILTER_CONTINUE;
+    }
+
+    bool notify(Damage damage) const
+    {
+        if (const auto&amp; notifyFunction = m_notifyFunctions.get(damage)) {
+            notifyFunction();
+            return true;
+        }
+        return false;
+    }
+
+    HashMap&lt;Damage, std::function&lt;void()&gt;&gt; m_notifyFunctions;
+};
+
+std::unique_ptr&lt;AcceleratedBackingStoreX11&gt; AcceleratedBackingStoreX11::create(WebPageProxy&amp; webPage)
+{
+    auto&amp; display = downcast&lt;PlatformDisplayX11&gt;(PlatformDisplay::sharedDisplay());
+    if (!display.supportsXComposite() || !display.supportsXDamage(s_damageEventBase))
+        return nullptr;
+    return std::unique_ptr&lt;AcceleratedBackingStoreX11&gt;(new AcceleratedBackingStoreX11(webPage));
+}
+
+AcceleratedBackingStoreX11::AcceleratedBackingStoreX11(WebPageProxy&amp; webPage)
+    : AcceleratedBackingStore(webPage)
+{
+}
+
+AcceleratedBackingStoreX11::~AcceleratedBackingStoreX11()
+{
+    if (m_damage) {
+        XDamageNotifier::singleton().remove(m_damage.get());
+        m_damage.reset();
+    }
+}
+
+void AcceleratedBackingStoreX11::update(const LayerTreeContext&amp; layerTreeContext)
+{
+    Pixmap pixmap = layerTreeContext.contextID;
+    if (m_surface &amp;&amp; cairo_xlib_surface_get_drawable(m_surface.get()) == pixmap)
+        return;
+
+    if (m_surface) {
+        if (m_damage) {
+            XDamageNotifier::singleton().remove(m_damage.get());
+            m_damage.reset();
+        }
+        m_surface = nullptr;
+    }
+
+    if (!pixmap)
+        return;
+
+    DrawingAreaProxyImpl* drawingArea = static_cast&lt;DrawingAreaProxyImpl*&gt;(m_webPage.drawingArea());
+    if (!drawingArea)
+        return;
+
+    IntSize size = drawingArea-&gt;size();
+    float deviceScaleFactor = m_webPage.deviceScaleFactor();
+    size.scale(deviceScaleFactor);
+
+    Display* display = downcast&lt;PlatformDisplayX11&gt;(PlatformDisplay::sharedDisplay()).native();
+    ASSERT(downcast&lt;PlatformDisplayX11&gt;(PlatformDisplay::sharedDisplay()).native() == GDK_DISPLAY_XDISPLAY(gdk_display_get_default()));
+    GdkVisual* visual = gdk_screen_get_rgba_visual(gdk_screen_get_default());
+    if (!visual)
+        visual = gdk_screen_get_system_visual(gdk_screen_get_default());
+    m_surface = adoptRef(cairo_xlib_surface_create(display, pixmap, GDK_VISUAL_XVISUAL(visual), size.width(), size.height()));
+    cairoSurfaceSetDeviceScale(m_surface.get(), deviceScaleFactor, deviceScaleFactor);
+    m_damage = XDamageCreate(display, pixmap, XDamageReportNonEmpty);
+    XDamageNotifier::singleton().add(m_damage.get(), [this] {
+        gtk_widget_queue_draw(m_webPage.viewWidget());
+    });
+}
+
+bool AcceleratedBackingStoreX11::paint(cairo_t* cr, const IntRect&amp; clipRect)
+{
+    if (!m_surface)
+        return false;
+
+    cairo_save(cr);
+    AcceleratedBackingStore::paint(cr, clipRect);
+
+    // The surface can be modified by the web process at any time, so we mark it
+    // as dirty to ensure we always render the updated contents as soon as possible.
+    cairo_surface_mark_dirty(m_surface.get());
+    cairo_rectangle(cr, clipRect.x(), clipRect.y(), clipRect.width(), clipRect.height());
+    cairo_set_source_surface(cr, m_surface.get(), 0, 0);
+    cairo_set_operator(cr, CAIRO_OPERATOR_OVER);
+    cairo_fill(cr);
+
+    cairo_restore(cr);
+
+    return true;
+}
+
+} // namespace WebKit
+
+#endif // USE(REDIRECTED_XCOMPOSITE_WINDOW)
</ins></span></pre></div>
<a id="trunkSourceWebKit2UIProcessgtkAcceleratedBackingStoreX11hfromrev205115trunkSourceWebCoreplatformgraphicswaylandWaylandSurfaceh"></a>
<div class="copfile"><h4>Copied: trunk/Source/WebKit2/UIProcess/gtk/AcceleratedBackingStoreX11.h (from rev 205115, trunk/Source/WebCore/platform/graphics/wayland/WaylandSurface.h) (0 => 205116)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/gtk/AcceleratedBackingStoreX11.h                                (rev 0)
+++ trunk/Source/WebKit2/UIProcess/gtk/AcceleratedBackingStoreX11.h        2016-08-29 09:33:40 UTC (rev 205116)
</span><span class="lines">@@ -0,0 +1,57 @@
</span><ins>+/*
+ * Copyright (C) 2016 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.
+ */
+
+#pragma once
+
+#include &quot;AcceleratedBackingStore.h&quot;
+
+#if USE(REDIRECTED_XCOMPOSITE_WINDOW)
+
+#include &lt;WebCore/RefPtrCairo.h&gt;
+#include &lt;WebCore/XUniqueResource.h&gt;
+
+namespace WebKit {
+
+class WebPageProxy;
+
+class AcceleratedBackingStoreX11 final : public AcceleratedBackingStore {
+    WTF_MAKE_NONCOPYABLE(AcceleratedBackingStoreX11); WTF_MAKE_FAST_ALLOCATED;
+public:
+    static std::unique_ptr&lt;AcceleratedBackingStoreX11&gt; create(WebPageProxy&amp;);
+    ~AcceleratedBackingStoreX11();
+
+private:
+    AcceleratedBackingStoreX11(WebPageProxy&amp;);
+
+    void update(const LayerTreeContext&amp;) override;
+    bool paint(cairo_t*, const WebCore::IntRect&amp;) override;
+
+    RefPtr&lt;cairo_surface_t&gt; m_surface;
+    WebCore::XUniqueDamage m_damage;
+};
+
+} // namespace WebKit
+
+#endif // USE(REDIRECTED_XCOMPOSITE_WINDOW)
</ins></span></pre></div>
<a id="trunkSourceWebKit2UIProcessgtkWaylandCompositorcpp"></a>
<div class="addfile"><h4>Added: trunk/Source/WebKit2/UIProcess/gtk/WaylandCompositor.cpp (0 => 205116)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/gtk/WaylandCompositor.cpp                                (rev 0)
+++ trunk/Source/WebKit2/UIProcess/gtk/WaylandCompositor.cpp        2016-08-29 09:33:40 UTC (rev 205116)
</span><span class="lines">@@ -0,0 +1,515 @@
</span><ins>+/*
+ * Copyright (C) 2016 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 &quot;config.h&quot;
+#include &quot;WaylandCompositor.h&quot;
+
+#if PLATFORM(WAYLAND)
+
+#include &quot;WebKit2WaylandServerProtocol.h&quot;
+#include &lt;EGL/egl.h&gt;
+#include &lt;EGL/eglext.h&gt;
+#include &lt;WebCore/GLContext.h&gt;
+#include &lt;WebCore/PlatformDisplayWayland.h&gt;
+#include &lt;WebCore/Region.h&gt;
+#include &lt;WebCore/UUID.h&gt;
+#include &lt;wayland-server-protocol.h&gt;
+
+#if USE(OPENGL_ES_2)
+#include &lt;GLES2/gl2.h&gt;
+#include &lt;GLES2/gl2ext.h&gt;
+#else
+#include &lt;WebCore/OpenGLShims.h&gt;
+#endif
+
+using namespace WebCore;
+
+namespace WebKit {
+
+#if !defined(PFNEGLBINDWAYLANDDISPLAYWL)
+typedef EGLBoolean (*PFNEGLBINDWAYLANDDISPLAYWL) (EGLDisplay, struct wl_display*);
+#endif
+
+#if !defined(PFNEGLUNBINDWAYLANDDISPLAYWL)
+typedef EGLBoolean (*PFNEGLUNBINDWAYLANDDISPLAYWL) (EGLDisplay, struct wl_display*);
+#endif
+
+#if !defined(PFNEGLQUERYWAYLANDBUFFERWL)
+typedef EGLBoolean (*PFNEGLQUERYWAYLANDBUFFERWL) (EGLDisplay, struct wl_resource*, EGLint attribute, EGLint* value);
+#endif
+
+#if !defined(PFNEGLCREATEIMAGEKHRPROC)
+typedef EGLImageKHR (*PFNEGLCREATEIMAGEKHRPROC) (EGLDisplay, EGLContext, EGLenum target, EGLClientBuffer, const EGLint* attribList);
+#endif
+
+#if !defined(PFNEGLDESTROYIMAGEKHRPROC)
+typedef EGLBoolean (*PFNEGLDESTROYIMAGEKHRPROC) (EGLDisplay, EGLImageKHR);
+#endif
+
+#if !defined(PFNGLEGLIMAGETARGETTEXTURE2DOESPROC)
+typedef void (*PFNGLEGLIMAGETARGETTEXTURE2DOESPROC) (GLenum target, GLeglImageOES);
+#endif
+
+static PFNEGLBINDWAYLANDDISPLAYWL eglBindWaylandDisplay;
+static PFNEGLUNBINDWAYLANDDISPLAYWL eglUnbindWaylandDisplay;
+static PFNEGLQUERYWAYLANDBUFFERWL eglQueryWaylandBuffer;
+static PFNEGLCREATEIMAGEKHRPROC eglCreateImage;
+static PFNEGLDESTROYIMAGEKHRPROC eglDestroyImage;
+static PFNGLEGLIMAGETARGETTEXTURE2DOESPROC eglImageTargetTexture2D;
+
+WaylandCompositor&amp; WaylandCompositor::singleton()
+{
+    static NeverDestroyed&lt;WaylandCompositor&gt; waylandCompositor;
+    return waylandCompositor;
+}
+
+WaylandCompositor::Buffer* WaylandCompositor::Buffer::getOrCreate(struct wl_resource* resource)
+{
+    if (struct wl_listener* listener = wl_resource_get_destroy_listener(resource, destroyListenerCallback)) {
+        WaylandCompositor::Buffer* buffer;
+        return wl_container_of(listener, buffer, m_destroyListener);
+    }
+
+    return new WaylandCompositor::Buffer(resource);
+}
+
+WaylandCompositor::Buffer::Buffer(struct wl_resource* resource)
+    : m_resource(resource)
+    , m_weakPtrFactory(this)
+{
+    wl_list_init(&amp;m_destroyListener.link);
+    m_destroyListener.notify = destroyListenerCallback;
+    wl_resource_add_destroy_listener(m_resource, &amp;m_destroyListener);
+}
+
+WaylandCompositor::Buffer::~Buffer()
+{
+    wl_list_remove(&amp;m_destroyListener.link);
+}
+
+void WaylandCompositor::Buffer::destroyListenerCallback(struct wl_listener* listener, void*)
+{
+    WaylandCompositor::Buffer* buffer;
+    buffer = wl_container_of(listener, buffer, m_destroyListener);
+    delete buffer;
+}
+
+void WaylandCompositor::Buffer::use()
+{
+    m_busyCount++;
+}
+
+void WaylandCompositor::Buffer::unuse()
+{
+    m_busyCount--;
+    if (!m_busyCount)
+        wl_resource_queue_event(m_resource, WL_BUFFER_RELEASE);
+}
+
+EGLImageKHR WaylandCompositor::Buffer::createImage() const
+{
+    return static_cast&lt;EGLImageKHR*&gt;(eglCreateImage(PlatformDisplay::sharedDisplay().eglDisplay(), EGL_NO_CONTEXT, EGL_WAYLAND_BUFFER_WL, m_resource, nullptr));
+}
+
+IntSize WaylandCompositor::Buffer::size() const
+{
+    EGLDisplay eglDisplay = PlatformDisplay::sharedDisplay().eglDisplay();
+    int width, height;
+    eglQueryWaylandBuffer(eglDisplay, m_resource, EGL_WIDTH, &amp;width);
+    eglQueryWaylandBuffer(eglDisplay, m_resource, EGL_HEIGHT, &amp;height);
+
+    return { width, height };
+}
+
+WaylandCompositor::Surface::Surface()
+    : m_image(EGL_NO_IMAGE_KHR)
+{
+    glGenTextures(1, &amp;m_texture);
+    glBindTexture(GL_TEXTURE_2D, m_texture);
+    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
+    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
+    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
+    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
+}
+
+WaylandCompositor::Surface::~Surface()
+{
+    // Destroy pending frame callbacks.
+    auto list = WTFMove(m_frameCallbackList);
+    for (auto* resource : list)
+        wl_resource_destroy(resource);
+
+    if (m_buffer)
+        m_buffer-&gt;unuse();
+
+    if (m_image != EGL_NO_IMAGE_KHR)
+        eglDestroyImage(PlatformDisplay::sharedDisplay().eglDisplay(), m_image);
+
+    glDeleteTextures(1, &amp;m_texture);
+}
+
+void WaylandCompositor::Surface::makePendingBufferCurrent()
+{
+    if (m_pendingBuffer == m_buffer)
+        return;
+
+    if (m_buffer)
+        m_buffer-&gt;unuse();
+
+    if (m_pendingBuffer)
+        m_pendingBuffer-&gt;use();
+
+    m_buffer = m_pendingBuffer;
+}
+
+void WaylandCompositor::Surface::attachBuffer(struct wl_resource* buffer)
+{
+    if (m_pendingBuffer)
+        m_pendingBuffer = nullptr;
+
+    if (buffer) {
+        auto* compositorBuffer = WaylandCompositor::Buffer::getOrCreate(buffer);
+        m_pendingBuffer = compositorBuffer-&gt;createWeakPtr();
+    }
+}
+
+void WaylandCompositor::Surface::requestFrame(struct wl_resource* resource)
+{
+    wl_resource_set_implementation(resource, nullptr, this, [](struct wl_resource* resource) {
+        auto* surface = static_cast&lt;WaylandCompositor::Surface*&gt;(wl_resource_get_user_data(resource));
+        if (size_t item = surface-&gt;m_frameCallbackList.find(resource) != notFound)
+            surface-&gt;m_frameCallbackList.remove(item);
+    });
+    m_frameCallbackList.append(resource);
+}
+
+bool WaylandCompositor::Surface::prepareTextureForPainting(unsigned&amp; texture, IntSize&amp; textureSize)
+{
+    if (m_image == EGL_NO_IMAGE_KHR)
+        return false;
+
+    glBindTexture(GL_TEXTURE_2D, m_texture);
+    eglImageTargetTexture2D(GL_TEXTURE_2D, m_image);
+
+    texture = m_texture;
+    textureSize = m_buffer-&gt;size();
+    return true;
+}
+
+bool WaylandCompositor::Surface::commit()
+{
+    EGLDisplay eglDisplay = PlatformDisplay::sharedDisplay().eglDisplay();
+    if (m_image != EGL_NO_IMAGE_KHR)
+        eglDestroyImage(eglDisplay, m_image);
+    m_image = m_pendingBuffer-&gt;createImage();
+    if (m_image == EGL_NO_IMAGE_KHR)
+        return false;
+
+    makePendingBufferCurrent();
+    if (m_webPage)
+        m_webPage-&gt;setViewNeedsDisplay(IntRect(IntPoint::zero(), m_webPage-&gt;viewSize()));
+
+    auto list = WTFMove(m_frameCallbackList);
+    for (auto* resource : list) {
+        wl_callback_send_done(resource, 0);
+        wl_resource_destroy(resource);
+    }
+
+    return true;
+}
+
+static const struct wl_surface_interface surfaceInterface = {
+    // destroyCallback
+    [](struct wl_client*, struct wl_resource* resource)
+    {
+        wl_resource_destroy(resource);
+    },
+    // attachCallback
+    [](struct wl_client* client, struct wl_resource* resource, struct wl_resource* buffer, int32_t sx, int32_t sy)
+    {
+        auto* surface = static_cast&lt;WaylandCompositor::Surface*&gt;(wl_resource_get_user_data(resource));
+        if (!surface)
+            return;
+
+        EGLint format;
+        if (!eglQueryWaylandBuffer(PlatformDisplay::sharedDisplay().eglDisplay(), buffer, EGL_TEXTURE_FORMAT, &amp;format)
+            || (format != EGL_TEXTURE_RGB &amp;&amp; format != EGL_TEXTURE_RGBA))
+            return;
+
+        surface-&gt;attachBuffer(buffer);
+    },
+    // damageCallback
+    [](struct wl_client*, struct wl_resource*, int32_t, int32_t, int32_t, int32_t) { },
+    // frameCallback
+    [](struct wl_client* client, struct wl_resource* resource, uint32_t id)
+    {
+        auto* surface = static_cast&lt;WaylandCompositor::Surface*&gt;(wl_resource_get_user_data(resource));
+        if (!surface)
+            return;
+
+        if (struct wl_resource* callbackResource = wl_resource_create(client, &amp;wl_callback_interface, 1, id))
+            surface-&gt;requestFrame(callbackResource);
+        else
+            wl_client_post_no_memory(client);
+    },
+    // setOpaqueRegionCallback
+    [](struct wl_client*, struct wl_resource*, struct wl_resource*) { },
+    // setInputRegionCallback
+    [](struct wl_client*, struct wl_resource*, struct wl_resource*) { },
+    // commitCallback
+    [](struct wl_client* client, struct wl_resource* resource)
+    {
+        auto* surface = static_cast&lt;WaylandCompositor::Surface*&gt;(wl_resource_get_user_data(resource));
+        if (!surface)
+            return;
+
+        if (surface-&gt;commit())
+            wl_display_flush_clients(wl_client_get_display(client));
+    },
+    // setBufferTransformCallback
+    [](struct wl_client*, struct wl_resource*, int32_t) { },
+    // setBufferScaleCallback
+    [](struct wl_client*, struct wl_resource*, int32_t) { }
+};
+
+static const struct wl_compositor_interface compositorInterface = {
+    // createSurfaceCallback
+    [](struct wl_client* client, struct wl_resource* resource, uint32_t id)
+    {
+        if (struct wl_resource* surfaceResource = wl_resource_create(client, &amp;wl_surface_interface, 1, id)) {
+            wl_resource_set_implementation(surfaceResource, &amp;surfaceInterface, new WaylandCompositor::Surface(),
+                [](struct wl_resource* resource) {
+                    auto* surface = static_cast&lt;WaylandCompositor::Surface*&gt;(wl_resource_get_user_data(resource));
+                    delete surface;
+                });
+        } else
+            wl_client_post_no_memory(client);
+    },
+    // createRegionCallback
+    [](struct wl_client*, struct wl_resource*, uint32_t) { }
+};
+
+static const struct wl_webkitgtk_interface webkitgtkInterface = {
+    // bindSurfaceToPageCallback
+    [](struct wl_client*, struct wl_resource* resource, struct wl_resource* surfaceResource, uint32_t pageID)
+    {
+        auto* surface = static_cast&lt;WaylandCompositor::Surface*&gt;(wl_resource_get_user_data(surfaceResource));
+        if (!surface)
+            return;
+
+        auto* compositor = static_cast&lt;WaylandCompositor*&gt;(wl_resource_get_user_data(resource));
+        compositor-&gt;bindSurfaceToWebPage(surface, pageID);
+    }
+};
+
+bool WaylandCompositor::initializeEGL()
+{
+    if (PlatformDisplay::sharedDisplay().eglCheckVersion(1, 5)) {
+        eglCreateImage = reinterpret_cast&lt;PFNEGLCREATEIMAGEKHRPROC&gt;(eglGetProcAddress(&quot;eglCreateImage&quot;));
+        eglDestroyImage = reinterpret_cast&lt;PFNEGLDESTROYIMAGEKHRPROC&gt;(eglGetProcAddress(&quot;eglDestroyImage&quot;));
+    } else {
+        const char* extensions = eglQueryString(PlatformDisplay::sharedDisplay().eglDisplay(), EGL_EXTENSIONS);
+        if (strstr(extensions, &quot;EGL_KHR_image_base&quot;)) {
+            eglCreateImage = reinterpret_cast&lt;PFNEGLCREATEIMAGEKHRPROC&gt;(eglGetProcAddress(&quot;eglCreateImageKHR&quot;));
+            eglDestroyImage = reinterpret_cast&lt;PFNEGLDESTROYIMAGEKHRPROC&gt;(eglGetProcAddress(&quot;eglDestroyImageKHR&quot;));
+        }
+    }
+    if (!eglCreateImage || !eglDestroyImage) {
+        WTFLogAlways(&quot;WaylandCompositor requires eglCreateImage and eglDestroyImage.&quot;);
+        return false;
+    }
+
+    eglImageTargetTexture2D = reinterpret_cast&lt;PFNGLEGLIMAGETARGETTEXTURE2DOESPROC&gt;(eglGetProcAddress(&quot;glEGLImageTargetTexture2DOES&quot;));
+    if (!eglImageTargetTexture2D) {
+        WTFLogAlways(&quot;WaylandCompositor requires glEGLImageTargetTexture.&quot;);
+        return false;
+    }
+
+    eglQueryWaylandBuffer = reinterpret_cast&lt;PFNEGLQUERYWAYLANDBUFFERWL&gt;(eglGetProcAddress(&quot;eglQueryWaylandBufferWL&quot;));
+    if (!eglQueryWaylandBuffer) {
+        WTFLogAlways(&quot;WaylandCompositor requires eglQueryWaylandBuffer.&quot;);
+        return false;
+    }
+
+    eglBindWaylandDisplay = reinterpret_cast&lt;PFNEGLBINDWAYLANDDISPLAYWL&gt;(eglGetProcAddress(&quot;eglBindWaylandDisplayWL&quot;));
+    eglUnbindWaylandDisplay = reinterpret_cast&lt;PFNEGLUNBINDWAYLANDDISPLAYWL&gt;(eglGetProcAddress(&quot;eglUnbindWaylandDisplayWL&quot;));
+    if (!eglBindWaylandDisplay || !eglUnbindWaylandDisplay) {
+        WTFLogAlways(&quot;WaylandCompositor requires eglBindWaylandDisplayWL and eglUnbindWaylandDisplayWL.&quot;);
+        return false;
+    }
+
+    m_eglContext = GLContext::createOffscreenContext();
+    if (!m_eglContext)
+        return false;
+
+    if (!m_eglContext-&gt;makeContextCurrent())
+        return false;
+
+    return true;
+}
+
+typedef struct {
+    GSource source;
+    gpointer fdTag;
+    struct wl_display* display;
+} WaylandLoopSource;
+
+static const unsigned waylandLoopSourceCondition = G_IO_IN | G_IO_HUP | G_IO_ERR;
+
+static GSourceFuncs waylandLoopSourceFunctions = {
+    // prepare
+    [](GSource *source, int *timeout) -&gt; gboolean
+    {
+        *timeout = -1;
+        auto* wlLoopSource = reinterpret_cast&lt;WaylandLoopSource*&gt;(source);
+        wl_display_flush_clients(wlLoopSource-&gt;display);
+        return FALSE;
+    },
+    nullptr, // check
+    // dispatch
+    [](GSource* source, GSourceFunc callback, gpointer userData) -&gt; gboolean
+    {
+        auto* wlLoopSource = reinterpret_cast&lt;WaylandLoopSource*&gt;(source);
+        unsigned events = g_source_query_unix_fd(source, wlLoopSource-&gt;fdTag) &amp; waylandLoopSourceCondition;
+        if (events &amp; G_IO_HUP || events &amp; G_IO_ERR) {
+            WTFLogAlways(&quot;Wayland Display Event Source: lost connection to nested Wayland compositor&quot;);
+            return G_SOURCE_REMOVE;
+        }
+
+        if (events &amp; G_IO_IN)
+            wl_event_loop_dispatch(wl_display_get_event_loop(wlLoopSource-&gt;display), 0);
+        return G_SOURCE_CONTINUE;
+    },
+    nullptr, // finalize
+    nullptr, // closure_callback
+    nullptr, // closure_marshall
+};
+
+static GRefPtr&lt;GSource&gt; createWaylandLoopSource(struct wl_display* display)
+{
+    GRefPtr&lt;GSource&gt; source = adoptGRef(g_source_new(&amp;waylandLoopSourceFunctions, sizeof(WaylandLoopSource)));
+    g_source_set_name(source.get(), &quot;Nested Wayland compositor display event source&quot;);
+    g_source_set_priority(source.get(), G_PRIORITY_DEFAULT + 1);
+
+    auto* wlLoopSource = reinterpret_cast&lt;WaylandLoopSource*&gt;(source.get());
+    wlLoopSource-&gt;display = display;
+    wlLoopSource-&gt;fdTag = g_source_add_unix_fd(source.get(), wl_event_loop_get_fd(wl_display_get_event_loop(display)), static_cast&lt;GIOCondition&gt;(waylandLoopSourceCondition));
+    g_source_attach(source.get(), nullptr);
+
+    return source;
+}
+
+WaylandCompositor::WaylandCompositor()
+{
+    WlUniquePtr&lt;struct wl_display&gt; display(wl_display_create());
+    if (!display) {
+        WTFLogAlways(&quot;Nested Wayland compositor could not create display object&quot;);
+        return;
+    }
+
+    String displayName = &quot;webkitgtk-wayland-compositor-&quot; + createCanonicalUUIDString();
+    if (wl_display_add_socket(display.get(), displayName.utf8().data()) == -1) {
+        WTFLogAlways(&quot;Nested Wayland compositor could not create display socket&quot;);
+        return;
+    }
+
+    WlUniquePtr&lt;struct wl_global&gt; compositorGlobal(wl_global_create(display.get(), &amp;wl_compositor_interface, wl_compositor_interface.version, this,
+        [](struct wl_client* client, void* data, uint32_t version, uint32_t id) {
+            if (struct wl_resource* resource = wl_resource_create(client, &amp;wl_compositor_interface, std::min(static_cast&lt;int&gt;(version), 3), id))
+                wl_resource_set_implementation(resource, &amp;compositorInterface, static_cast&lt;WaylandCompositor*&gt;(data), nullptr);
+            else
+                wl_client_post_no_memory(client);
+        }));
+    if (!compositorGlobal) {
+        WTFLogAlways(&quot;Nested Wayland compositor could not register compositor global&quot;);
+        return;
+    }
+
+    WlUniquePtr&lt;struct wl_global&gt; webkitgtkGlobal(wl_global_create(display.get(), &amp;wl_webkitgtk_interface, 1, this,
+        [](struct wl_client* client, void* data, uint32_t version, uint32_t id) {
+            if (struct wl_resource* resource = wl_resource_create(client, &amp;wl_webkitgtk_interface, 1, id))
+                wl_resource_set_implementation(resource, &amp;webkitgtkInterface, static_cast&lt;WaylandCompositor*&gt;(data), nullptr);
+            else
+                wl_client_post_no_memory(client);
+        }));
+    if (!webkitgtkGlobal) {
+        WTFLogAlways(&quot;Nested Wayland compositor could not register webkitgtk global&quot;);
+        return;
+    }
+
+    if (!initializeEGL()) {
+        WTFLogAlways(&quot;Nested Wayland compositor could not initialize EGL&quot;);
+        return;
+    }
+
+    if (!eglBindWaylandDisplay(PlatformDisplay::sharedDisplay().eglDisplay(), display.get())) {
+        WTFLogAlways(&quot;Nested Wayland compositor could not bind nested display&quot;);
+        return;
+    }
+
+    m_displayName = WTFMove(displayName);
+    m_display = WTFMove(display);
+    m_compositorGlobal = WTFMove(compositorGlobal);
+    m_webkitgtkGlobal = WTFMove(webkitgtkGlobal);
+    m_eventSource = createWaylandLoopSource(m_display.get());
+}
+
+bool WaylandCompositor::getTexture(WebPageProxy&amp; webPage, unsigned&amp; texture, IntSize&amp; textureSize)
+{
+    if (auto* surface = m_pageMap.get(&amp;webPage))
+        return surface-&gt;prepareTextureForPainting(texture, textureSize);
+    return false;
+}
+
+void WaylandCompositor::bindSurfaceToWebPage(WaylandCompositor::Surface* surface, uint64_t pageID)
+{
+    WebPageProxy* webPage = nullptr;
+    for (auto* page : m_pageMap.keys()) {
+        if (page-&gt;pageID() == pageID) {
+            webPage = page;
+            break;
+        }
+    }
+    if (!webPage)
+        return;
+
+    surface-&gt;setWebPage(webPage);
+    m_pageMap.set(webPage, surface);
+}
+
+void WaylandCompositor::registerWebPage(WebPageProxy&amp; webPage)
+{
+    m_pageMap.add(&amp;webPage, nullptr);
+}
+
+void WaylandCompositor::unregisterWebPage(WebPageProxy&amp; webPage)
+{
+    if (auto* surface = m_pageMap.take(&amp;webPage))
+        surface-&gt;setWebPage(nullptr);
+}
+
+} // namespace WebKit
+
+#endif // PLATFORM(WAYLAND)
</ins></span></pre></div>
<a id="trunkSourceWebKit2UIProcessgtkWaylandCompositorh"></a>
<div class="addfile"><h4>Added: trunk/Source/WebKit2/UIProcess/gtk/WaylandCompositor.h (0 => 205116)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/gtk/WaylandCompositor.h                                (rev 0)
+++ trunk/Source/WebKit2/UIProcess/gtk/WaylandCompositor.h        2016-08-29 09:33:40 UTC (rev 205116)
</span><span class="lines">@@ -0,0 +1,129 @@
</span><ins>+/*
+ * Copyright (C) 2016 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.
+ */
+
+#pragma once
+
+#if PLATFORM(WAYLAND)
+
+#include &quot;WebPageProxy.h&quot;
+#include &lt;WebCore/RefPtrCairo.h&gt;
+#include &lt;WebCore/WlUniquePtr.h&gt;
+#include &lt;wtf/HashMap.h&gt;
+#include &lt;wtf/NeverDestroyed.h&gt;
+#include &lt;wtf/Noncopyable.h&gt;
+#include &lt;wtf/WeakPtr.h&gt;
+#include &lt;wtf/glib/GRefPtr.h&gt;
+#include &lt;wtf/text/WTFString.h&gt;
+
+typedef void *EGLImageKHR;
+
+namespace WebCore {
+class GLContext;
+}
+
+namespace WebKit {
+
+class WebPageProxy;
+
+class WaylandCompositor {
+    WTF_MAKE_NONCOPYABLE(WaylandCompositor);
+    friend class NeverDestroyed&lt;WaylandCompositor&gt;;
+public:
+    static WaylandCompositor&amp; singleton();
+
+    class Buffer {
+        WTF_MAKE_NONCOPYABLE(Buffer); WTF_MAKE_FAST_ALLOCATED;
+    public:
+        static Buffer* getOrCreate(struct wl_resource*);
+        ~Buffer();
+
+        void use();
+        void unuse();
+
+        EGLImageKHR createImage() const;
+        WebCore::IntSize size() const;
+
+        WeakPtr&lt;Buffer&gt; createWeakPtr() { return m_weakPtrFactory.createWeakPtr(); }
+
+    private:
+        Buffer(struct wl_resource*);
+        static void destroyListenerCallback(struct wl_listener*, void*);
+
+        struct wl_resource* m_resource { nullptr };
+        struct wl_listener m_destroyListener;
+        uint32_t m_busyCount { 0 };
+        WeakPtrFactory&lt;Buffer&gt; m_weakPtrFactory;
+    };
+
+    class Surface {
+        WTF_MAKE_NONCOPYABLE(Surface); WTF_MAKE_FAST_ALLOCATED;
+    public:
+        Surface();
+        ~Surface();
+
+        void attachBuffer(struct wl_resource*);
+        void requestFrame(struct wl_resource*);
+        bool commit();
+
+        void setWebPage(WebPageProxy* webPage) { m_webPage = webPage; }
+        bool prepareTextureForPainting(unsigned&amp;, WebCore::IntSize&amp;);
+
+    private:
+        void makePendingBufferCurrent();
+
+        WeakPtr&lt;Buffer&gt; m_buffer;
+        WeakPtr&lt;Buffer&gt; m_pendingBuffer;
+        unsigned m_texture;
+        EGLImageKHR m_image;
+        Vector&lt;wl_resource*&gt; m_frameCallbackList;
+        WebPageProxy* m_webPage { nullptr };
+    };
+
+    bool isRunning() const { return !!m_display; }
+    String displayName() const { return m_displayName; }
+
+    void bindSurfaceToWebPage(Surface*, uint64_t pageID);
+    void registerWebPage(WebPageProxy&amp;);
+    void unregisterWebPage(WebPageProxy&amp;);
+
+    bool getTexture(WebPageProxy&amp;, unsigned&amp;, WebCore::IntSize&amp;);
+
+private:
+    WaylandCompositor();
+
+    bool initializeEGL();
+
+    String m_displayName;
+    WebCore::WlUniquePtr&lt;struct wl_display&gt; m_display;
+    WebCore::WlUniquePtr&lt;struct wl_global&gt; m_compositorGlobal;
+    WebCore::WlUniquePtr&lt;struct wl_global&gt; m_webkitgtkGlobal;
+    GRefPtr&lt;GSource&gt; m_eventSource;
+    std::unique_ptr&lt;WebCore::GLContext&gt; m_eglContext;
+    HashMap&lt;WebPageProxy*, Surface*&gt; m_pageMap;
+};
+
+} // namespace WebKit
+
+#endif // PLATFORM(WAYLAND)
</ins></span></pre></div>
<a id="trunkSourceWebKit2UIProcessgtkWebPreferencesGtkcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/gtk/WebPreferencesGtk.cpp (205115 => 205116)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/gtk/WebPreferencesGtk.cpp        2016-08-29 09:18:06 UTC (rev 205115)
+++ trunk/Source/WebKit2/UIProcess/gtk/WebPreferencesGtk.cpp        2016-08-29 09:33:40 UTC (rev 205116)
</span><span class="lines">@@ -27,31 +27,52 @@
</span><span class="cx"> #include &quot;config.h&quot;
</span><span class="cx"> #include &quot;WebPreferences.h&quot;
</span><span class="cx"> 
</span><ins>+#include &quot;WaylandCompositor.h&quot;
</ins><span class="cx"> #include &lt;WebCore/NotImplemented.h&gt;
</span><span class="cx"> #include &lt;WebCore/PlatformDisplay.h&gt;
</span><span class="cx"> 
</span><ins>+#if USE(REDIRECTED_XCOMPOSITE_WINDOW)
+#include &lt;WebCore/PlatformDisplayX11.h&gt;
+#endif
+
+using namespace WebCore;
+
</ins><span class="cx"> namespace WebKit {
</span><span class="cx"> 
</span><span class="cx"> void WebPreferences::platformInitializeStore()
</span><span class="cx"> {
</span><del>-#if PLATFORM(WAYLAND)
-    if (WebCore::PlatformDisplay::sharedDisplay().type() == WebCore::PlatformDisplay::Type::Wayland) {
-        // FIXME: Accelerated compositing under Wayland is not yet supported.
-        // https://bugs.webkit.org/show_bug.cgi?id=115803
-        setAcceleratedCompositingEnabled(false);
-    }
-#endif
-#if USE(COORDINATED_GRAPHICS_THREADED)
-    setForceCompositingMode(true);
-#endif
</del><span class="cx"> #if !ENABLE(OPENGL)
</span><span class="cx">     setAcceleratedCompositingEnabled(false);
</span><span class="cx"> #else
</span><ins>+#if USE(COORDINATED_GRAPHICS_THREADED)
+    setForceCompositingMode(true);
+#else
</ins><span class="cx">     if (getenv(&quot;WEBKIT_FORCE_COMPOSITING_MODE&quot;))
</span><span class="cx">         setForceCompositingMode(true);
</span><del>-    if (getenv(&quot;WEBKIT_DISABLE_COMPOSITING_MODE&quot;))
</del><ins>+#endif
+
+    if (getenv(&quot;WEBKIT_DISABLE_COMPOSITING_MODE&quot;)) {
</ins><span class="cx">         setAcceleratedCompositingEnabled(false);
</span><ins>+        return;
+    }
+
+#if USE(REDIRECTED_XCOMPOSITE_WINDOW)
+    if (PlatformDisplay::sharedDisplay().type() == PlatformDisplay::Type::X11) {
+        auto&amp; display = downcast&lt;PlatformDisplayX11&gt;(PlatformDisplay::sharedDisplay());
+        Optional&lt;int&gt; damageBase;
+        if (!display.supportsXComposite() || !display.supportsXDamage(damageBase))
+            setAcceleratedCompositingEnabled(false);
+    }
</ins><span class="cx"> #endif
</span><ins>+
+#if PLATFORM(WAYLAND)
+    if (PlatformDisplay::sharedDisplay().type() == PlatformDisplay::Type::Wayland) {
+        if (!WaylandCompositor::singleton().isRunning())
+            setAcceleratedCompositingEnabled(false);
+    }
+#endif
+
+#endif // ENABLE(OPENGL)
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void WebPreferences::platformUpdateStringValueForKey(const String&amp;, const String&amp;)
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessgtkXDamageNotifiercpp"></a>
<div class="delfile"><h4>Deleted: trunk/Source/WebKit2/UIProcess/gtk/XDamageNotifier.cpp (205115 => 205116)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/gtk/XDamageNotifier.cpp        2016-08-29 09:18:06 UTC (rev 205115)
+++ trunk/Source/WebKit2/UIProcess/gtk/XDamageNotifier.cpp        2016-08-29 09:33:40 UTC (rev 205116)
</span><span class="lines">@@ -1,100 +0,0 @@
</span><del>-/*
- * Copyright (C) 2016 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 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 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 &quot;config.h&quot;
-#include &quot;XDamageNotifier.h&quot;
-
-#if PLATFORM(X11)
-
-#include &lt;WebCore/PlatformDisplayX11.h&gt;
-#include &lt;X11/Xlib.h&gt;
-#include &lt;X11/extensions/Xdamage.h&gt;
-#include &lt;gdk/gdkx.h&gt;
-
-using namespace WebCore;
-
-namespace WebKit {
-
-static Optional&lt;int&gt; s_damageEventBase;
-
-XDamageNotifier&amp; XDamageNotifier::singleton()
-{
-    static NeverDestroyed&lt;XDamageNotifier&gt; notifier;
-    return notifier;
-}
-
-XDamageNotifier::XDamageNotifier()
-{
-    downcast&lt;PlatformDisplayX11&gt;(PlatformDisplay::sharedDisplay()).supportsXDamage(s_damageEventBase);
-}
-
-void XDamageNotifier::add(Damage damage, std::function&lt;void()&gt;&amp;&amp; notifyFunction)
-{
-    if (!s_damageEventBase)
-        return;
-
-    if (m_notifyFunctions.isEmpty())
-        gdk_window_add_filter(nullptr, reinterpret_cast&lt;GdkFilterFunc&gt;(&amp;filterXDamageEvent), this);
-    m_notifyFunctions.add(damage, WTFMove(notifyFunction));
-}
-
-void XDamageNotifier::remove(Damage damage)
-{
-    if (!s_damageEventBase)
-        return;
-
-    m_notifyFunctions.remove(damage);
-    if (m_notifyFunctions.isEmpty())
-        gdk_window_remove_filter(nullptr, reinterpret_cast&lt;GdkFilterFunc&gt;(&amp;filterXDamageEvent), this);
-}
-
-GdkFilterReturn XDamageNotifier::filterXDamageEvent(GdkXEvent* event, GdkEvent*, XDamageNotifier* notifier)
-{
-    ASSERT(s_damageEventBase);
-    auto* xEvent = static_cast&lt;XEvent*&gt;(event);
-    if (xEvent-&gt;type != s_damageEventBase.value() + XDamageNotify)
-        return GDK_FILTER_CONTINUE;
-
-    auto* damageEvent = reinterpret_cast&lt;XDamageNotifyEvent*&gt;(xEvent);
-    if (notifier-&gt;notify(damageEvent-&gt;damage)) {
-        XDamageSubtract(xEvent-&gt;xany.display, damageEvent-&gt;damage, None, None);
-        return GDK_FILTER_REMOVE;
-    }
-
-    return GDK_FILTER_CONTINUE;
-}
-
-bool XDamageNotifier::notify(Damage damage) const
-{
-    if (const auto&amp; notifyFunction = m_notifyFunctions.get(damage)) {
-        notifyFunction();
-        return true;
-    }
-    return false;
-}
-
-} // namespace WebCore
-
-#endif // PLATFORM(X11)
</del></span></pre></div>
<a id="trunkSourceWebKit2UIProcessgtkXDamageNotifierh"></a>
<div class="delfile"><h4>Deleted: trunk/Source/WebKit2/UIProcess/gtk/XDamageNotifier.h (205115 => 205116)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/gtk/XDamageNotifier.h        2016-08-29 09:18:06 UTC (rev 205115)
+++ trunk/Source/WebKit2/UIProcess/gtk/XDamageNotifier.h        2016-08-29 09:33:40 UTC (rev 205116)
</span><span class="lines">@@ -1,60 +0,0 @@
</span><del>-/*
- * Copyright (C) 2016 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 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 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.
- */
-
-#pragma once
-
-#if PLATFORM(X11)
-
-#include &lt;gdk/gdkx.h&gt;
-#include &lt;wtf/FastMalloc.h&gt;
-#include &lt;wtf/HashMap.h&gt;
-#include &lt;wtf/NeverDestroyed.h&gt;
-#include &lt;wtf/Noncopyable.h&gt;
-
-typedef unsigned long Damage;
-
-namespace WebKit {
-
-class XDamageNotifier {
-    WTF_MAKE_NONCOPYABLE(XDamageNotifier); WTF_MAKE_FAST_ALLOCATED;
-    friend class NeverDestroyed&lt;XDamageNotifier&gt;;
-public:
-    static XDamageNotifier&amp; singleton();
-
-    void add(Damage, std::function&lt;void()&gt;&amp;&amp;);
-    void remove(Damage);
-
-private:
-    XDamageNotifier();
-
-    static GdkFilterReturn filterXDamageEvent(GdkXEvent*, GdkEvent*, XDamageNotifier*);
-    bool notify(Damage) const;
-
-    HashMap&lt;Damage, std::function&lt;void()&gt;&gt; m_notifyFunctions;
-};
-
-} // namespace WebKit
-
-#endif // PLATFORM(X11)
</del></span></pre></div>
<a id="trunkSourceWebKit2WebProcessWebPageCoordinatedGraphicsThreadedCoordinatedLayerTreeHostcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/ThreadedCoordinatedLayerTreeHost.cpp (205115 => 205116)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/ThreadedCoordinatedLayerTreeHost.cpp        2016-08-29 09:18:06 UTC (rev 205115)
+++ trunk/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/ThreadedCoordinatedLayerTreeHost.cpp        2016-08-29 09:33:40 UTC (rev 205116)
</span><span class="lines">@@ -30,14 +30,12 @@
</span><span class="cx"> #include &quot;ThreadedCoordinatedLayerTreeHost.h&quot;
</span><span class="cx"> 
</span><span class="cx"> #if USE(COORDINATED_GRAPHICS_THREADED)
</span><ins>+
+#include &quot;AcceleratedSurface.h&quot;
</ins><span class="cx"> #include &quot;WebPage.h&quot;
</span><span class="cx"> #include &lt;WebCore/FrameView.h&gt;
</span><span class="cx"> #include &lt;WebCore/MainFrame.h&gt;
</span><span class="cx"> 
</span><del>-#if USE(REDIRECTED_XCOMPOSITE_WINDOW)
-#include &quot;RedirectedXCompositeWindow.h&quot;
-#endif
-
</del><span class="cx"> using namespace WebCore;
</span><span class="cx"> 
</span><span class="cx"> namespace WebKit {
</span><span class="lines">@@ -54,17 +52,16 @@
</span><span class="cx"> ThreadedCoordinatedLayerTreeHost::ThreadedCoordinatedLayerTreeHost(WebPage&amp; webPage)
</span><span class="cx">     : CoordinatedLayerTreeHost(webPage)
</span><span class="cx">     , m_compositorClient(*this)
</span><del>-#if USE(REDIRECTED_XCOMPOSITE_WINDOW)
-    , m_redirectedWindow(RedirectedXCompositeWindow::create(webPage))
-    , m_compositor(ThreadedCompositor::create(&amp;m_compositorClient, m_redirectedWindow ? m_redirectedWindow-&gt;window() : 0))
-#else
-    , m_compositor(ThreadedCompositor::create(&amp;m_compositorClient))
-#endif
</del><ins>+    , m_surface(AcceleratedSurface::create(webPage))
</ins><span class="cx"> {
</span><del>-#if USE(REDIRECTED_XCOMPOSITE_WINDOW)
-    if (m_redirectedWindow)
-        m_layerTreeContext.contextID = m_redirectedWindow-&gt;pixmap();
-#endif
</del><ins>+    if (m_surface) {
+        // Do not do frame sync when rendering offscreen in the web process to ensure that SwapBuffers never blocks.
+        // Rendering to the actual screen will happen later anyway since the UI process schedules a redraw for every update,
+        // the compositor will take care of syncing to vblank.
+        m_compositor = ThreadedCompositor::create(&amp;m_compositorClient, m_surface-&gt;window(), ThreadedCompositor::ShouldDoFrameSync::No);
+        m_layerTreeContext.contextID = m_surface-&gt;surfaceID();
+    } else
+        m_compositor = ThreadedCompositor::create(&amp;m_compositorClient);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void ThreadedCoordinatedLayerTreeHost::invalidate()
</span><span class="lines">@@ -71,9 +68,7 @@
</span><span class="cx"> {
</span><span class="cx">     m_compositor-&gt;invalidate();
</span><span class="cx">     CoordinatedLayerTreeHost::invalidate();
</span><del>-#if USE(REDIRECTED_XCOMPOSITE_WINDOW)
-    m_redirectedWindow = nullptr;
-#endif
</del><ins>+    m_surface = nullptr;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void ThreadedCoordinatedLayerTreeHost::forceRepaint()
</span><span class="lines">@@ -95,12 +90,8 @@
</span><span class="cx"> 
</span><span class="cx"> void ThreadedCoordinatedLayerTreeHost::deviceOrPageScaleFactorChanged()
</span><span class="cx"> {
</span><del>-#if USE(REDIRECTED_XCOMPOSITE_WINDOW)
-    if (m_redirectedWindow) {
-        m_redirectedWindow-&gt;resize(m_webPage.size());
-        m_layerTreeContext.contextID = m_redirectedWindow-&gt;pixmap();
-    }
-#endif
</del><ins>+    if (m_surface &amp;&amp; m_surface-&gt;resize(m_webPage.size()))
+        m_layerTreeContext.contextID = m_surface-&gt;surfaceID();
</ins><span class="cx"> 
</span><span class="cx">     CoordinatedLayerTreeHost::deviceOrPageScaleFactorChanged();
</span><span class="cx">     m_compositor-&gt;setDeviceScaleFactor(m_webPage.deviceScaleFactor());
</span><span class="lines">@@ -114,12 +105,9 @@
</span><span class="cx"> 
</span><span class="cx"> void ThreadedCoordinatedLayerTreeHost::sizeDidChange(const IntSize&amp; size)
</span><span class="cx"> {
</span><del>-#if USE(REDIRECTED_XCOMPOSITE_WINDOW)
-    if (m_redirectedWindow) {
-        m_redirectedWindow-&gt;resize(size);
-        m_layerTreeContext.contextID = m_redirectedWindow-&gt;pixmap();
-    }
-#endif
</del><ins>+    if (m_surface &amp;&amp; m_surface-&gt;resize(size))
+        m_layerTreeContext.contextID = m_surface-&gt;surfaceID();
+
</ins><span class="cx">     CoordinatedLayerTreeHost::sizeDidChange(size);
</span><span class="cx">     m_compositor-&gt;didChangeViewportSize(size);
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcessWebPageCoordinatedGraphicsThreadedCoordinatedLayerTreeHosth"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/ThreadedCoordinatedLayerTreeHost.h (205115 => 205116)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/ThreadedCoordinatedLayerTreeHost.h        2016-08-29 09:18:06 UTC (rev 205115)
+++ trunk/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/ThreadedCoordinatedLayerTreeHost.h        2016-08-29 09:33:40 UTC (rev 205116)
</span><span class="lines">@@ -41,7 +41,7 @@
</span><span class="cx"> 
</span><span class="cx"> namespace WebKit {
</span><span class="cx"> 
</span><del>-class RedirectedXCompositeWindow;
</del><ins>+class AcceleratedSurface;
</ins><span class="cx"> class WebPage;
</span><span class="cx"> 
</span><span class="cx"> class ThreadedCoordinatedLayerTreeHost final : public CoordinatedLayerTreeHost {
</span><span class="lines">@@ -105,9 +105,7 @@
</span><span class="cx">     void commitSceneState(const WebCore::CoordinatedGraphicsState&amp;) override;
</span><span class="cx"> 
</span><span class="cx">     CompositorClient m_compositorClient;
</span><del>-#if USE(REDIRECTED_XCOMPOSITE_WINDOW)
-    std::unique_ptr&lt;RedirectedXCompositeWindow&gt; m_redirectedWindow;
-#endif
</del><ins>+    std::unique_ptr&lt;AcceleratedSurface&gt; m_surface;
</ins><span class="cx">     RefPtr&lt;ThreadedCompositor&gt; m_compositor;
</span><span class="cx">     float m_lastScaleFactor { 1 };
</span><span class="cx">     WebCore::IntPoint m_prevScrollPosition;
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcessWebPagegtkAcceleratedSurfacecppfromrev205115trunkSourceWebKit2WebProcessWebPagegtkRedirectedXCompositeWindowh"></a>
<div class="copfile"><h4>Copied: trunk/Source/WebKit2/WebProcess/WebPage/gtk/AcceleratedSurface.cpp (from rev 205115, trunk/Source/WebKit2/WebProcess/WebPage/gtk/RedirectedXCompositeWindow.h) (0 => 205116)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/WebPage/gtk/AcceleratedSurface.cpp                                (rev 0)
+++ trunk/Source/WebKit2/WebProcess/WebPage/gtk/AcceleratedSurface.cpp        2016-08-29 09:33:40 UTC (rev 205116)
</span><span class="lines">@@ -0,0 +1,74 @@
</span><ins>+/*
+ * Copyright (C) 2016 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 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 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 &quot;config.h&quot;
+#include &quot;AcceleratedSurface.h&quot;
+
+#include &lt;WebCore/PlatformDisplay.h&gt;
+
+#if PLATFORM(WAYLAND)
+#include &quot;AcceleratedSurfaceWayland.h&quot;
+#endif
+
+#if USE(REDIRECTED_XCOMPOSITE_WINDOW)
+#include &quot;AcceleratedSurfaceX11.h&quot;
+#endif
+
+using namespace WebCore;
+
+namespace WebKit {
+
+std::unique_ptr&lt;AcceleratedSurface&gt; AcceleratedSurface::create(WebPage&amp; webPage)
+{
+#if PLATFORM(WAYLAND)
+    if (PlatformDisplay::sharedDisplay().type() == PlatformDisplay::Type::Wayland)
+        return AcceleratedSurfaceWayland::create(webPage);
+#endif
+#if USE(REDIRECTED_XCOMPOSITE_WINDOW)
+    if (PlatformDisplay::sharedDisplay().type() == PlatformDisplay::Type::X11)
+        return AcceleratedSurfaceX11::create(webPage);
+#endif
+    return nullptr;
+}
+
+AcceleratedSurface::AcceleratedSurface(WebPage&amp; webPage)
+    : m_webPage(webPage)
+    , m_size(webPage.size())
+{
+    m_size.scale(m_webPage.deviceScaleFactor());
+}
+
+bool AcceleratedSurface::resize(const IntSize&amp; size)
+{
+    IntSize scaledSize(size);
+    scaledSize.scale(m_webPage.deviceScaleFactor());
+    if (scaledSize == m_size)
+        return false;
+
+    m_size = scaledSize;
+    return true;
+}
+
+} // namespace WebKit
</ins></span></pre></div>
<a id="trunkSourceWebKit2WebProcessWebPagegtkAcceleratedSurfacehfromrev205115trunkSourceWebKit2UIProcessgtkXDamageNotifierh"></a>
<div class="copfile"><h4>Copied: trunk/Source/WebKit2/WebProcess/WebPage/gtk/AcceleratedSurface.h (from rev 205115, trunk/Source/WebKit2/UIProcess/gtk/XDamageNotifier.h) (0 => 205116)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/WebPage/gtk/AcceleratedSurface.h                                (rev 0)
+++ trunk/Source/WebKit2/WebProcess/WebPage/gtk/AcceleratedSurface.h        2016-08-29 09:33:40 UTC (rev 205116)
</span><span class="lines">@@ -0,0 +1,52 @@
</span><ins>+/*
+ * Copyright (C) 2016 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 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 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.
+ */
+
+#pragma once
+
+#include &lt;WebCore/IntSize.h&gt;
+#include &lt;wtf/Noncopyable.h&gt;
+
+namespace WebKit {
+
+class WebPage;
+
+class AcceleratedSurface {
+    WTF_MAKE_NONCOPYABLE(AcceleratedSurface); WTF_MAKE_FAST_ALLOCATED;
+public:
+    static std::unique_ptr&lt;AcceleratedSurface&gt; create(WebPage&amp;);
+    virtual ~AcceleratedSurface() = default;
+
+    virtual uint64_t window() const { ASSERT_NOT_REACHED(); return 0; }
+    virtual uint64_t surfaceID() const { ASSERT_NOT_REACHED(); return 0; };
+    virtual bool resize(const WebCore::IntSize&amp;);
+
+protected:
+    AcceleratedSurface(WebPage&amp;);
+
+    WebPage&amp; m_webPage;
+    WebCore::IntSize m_size;
+};
+
+} // namespace WebKit
</ins></span></pre></div>
<a id="trunkSourceWebKit2WebProcessWebPagegtkAcceleratedSurfaceWaylandcpp"></a>
<div class="addfile"><h4>Added: trunk/Source/WebKit2/WebProcess/WebPage/gtk/AcceleratedSurfaceWayland.cpp (0 => 205116)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/WebPage/gtk/AcceleratedSurfaceWayland.cpp                                (rev 0)
+++ trunk/Source/WebKit2/WebProcess/WebPage/gtk/AcceleratedSurfaceWayland.cpp        2016-08-29 09:33:40 UTC (rev 205116)
</span><span class="lines">@@ -0,0 +1,117 @@
</span><ins>+/*
+ * Copyright (C) 2016 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 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 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 &quot;config.h&quot;
+#include &quot;AcceleratedSurfaceWayland.h&quot;
+
+#if PLATFORM(WAYLAND)
+
+#include &quot;WebKit2WaylandClientProtocol.h&quot;
+#include &quot;WebProcess.h&quot;
+#include &lt;WebCore/PlatformDisplayWayland.h&gt;
+#include &lt;cstring&gt;
+#include &lt;wayland-egl.h&gt;
+#include &lt;wtf/NeverDestroyed.h&gt;
+
+using namespace WebCore;
+
+namespace WebKit {
+
+class WaylandCompositorDisplay final : public PlatformDisplayWayland {
+    WTF_MAKE_NONCOPYABLE(WaylandCompositorDisplay);
+public:
+    static std::unique_ptr&lt;WaylandCompositorDisplay&gt; create()
+    {
+        struct wl_display* display = wl_display_connect(WebProcess::singleton().waylandCompositorDisplayName().utf8().data());
+        if (!display) {
+            WTFLogAlways(&quot;PlatformDisplayWayland initialization: failed to connect to the Wayland display: %s&quot;, WebProcess::singleton().waylandCompositorDisplayName().utf8().data());
+            return nullptr;
+        }
+
+        return std::unique_ptr&lt;WaylandCompositorDisplay&gt;(new WaylandCompositorDisplay(display));
+    }
+
+    void bindSurfaceToPage(struct wl_surface* surface, WebPage&amp; page)
+    {
+        if (!m_webkitgtk)
+            return;
+
+        wl_webkitgtk_bind_surface_to_page(reinterpret_cast&lt;struct wl_webkitgtk*&gt;(m_webkitgtk.get()), surface, page.pageID());
+        wl_display_roundtrip(m_display);
+    }
+
+private:
+    WaylandCompositorDisplay(struct wl_display* display)
+    {
+        initialize(display);
+        PlatformDisplay::setSharedDisplayForCompositing(*this);
+    }
+
+    void registryGlobal(const char* interface, uint32_t name) override
+    {
+        PlatformDisplayWayland::registryGlobal(interface, name);
+        if (!std::strcmp(interface, &quot;wl_webkitgtk&quot;))
+            m_webkitgtk.reset(static_cast&lt;struct wl_proxy*&gt;(wl_registry_bind(m_registry.get(), name, &amp;wl_webkitgtk_interface, 1)));
+    }
+
+    WlUniquePtr&lt;struct wl_proxy&gt; m_webkitgtk;
+};
+
+static std::unique_ptr&lt;WaylandCompositorDisplay&gt;&amp; waylandCompositorDisplay()
+{
+    static NeverDestroyed&lt;std::unique_ptr&lt;WaylandCompositorDisplay&gt;&gt; waylandDisplay(WaylandCompositorDisplay::create());
+    return waylandDisplay;
+}
+
+std::unique_ptr&lt;AcceleratedSurfaceWayland&gt; AcceleratedSurfaceWayland::create(WebPage&amp; webPage)
+{
+    return waylandCompositorDisplay() ? std::unique_ptr&lt;AcceleratedSurfaceWayland&gt;(new AcceleratedSurfaceWayland(webPage)) : nullptr;
+}
+
+AcceleratedSurfaceWayland::AcceleratedSurfaceWayland(WebPage&amp; webPage)
+    : AcceleratedSurface(webPage)
+    , m_surface(waylandCompositorDisplay()-&gt;createSurface())
+    , m_window(wl_egl_window_create(m_surface.get(), std::max(1, m_size.width()), std::max(1, m_size.height())))
+{
+    waylandCompositorDisplay()-&gt;bindSurfaceToPage(m_surface.get(), m_webPage);
+}
+
+AcceleratedSurfaceWayland::~AcceleratedSurfaceWayland()
+{
+    wl_egl_window_destroy(m_window);
+}
+
+bool AcceleratedSurfaceWayland::resize(const IntSize&amp; size)
+{
+    if (!AcceleratedSurface::resize(size))
+        return false;
+
+    wl_egl_window_resize(m_window, m_size.width(), m_size.height(), 0, 0);
+    return true;
+}
+
+} // namespace WebKit
+
+#endif // PLATFORM(WAYLAND)
</ins></span></pre></div>
<a id="trunkSourceWebKit2WebProcessWebPagegtkAcceleratedSurfaceWaylandhfromrev205115trunkSourceWebKit2UIProcessgtkXDamageNotifierh"></a>
<div class="copfile"><h4>Copied: trunk/Source/WebKit2/WebProcess/WebPage/gtk/AcceleratedSurfaceWayland.h (from rev 205115, trunk/Source/WebKit2/UIProcess/gtk/XDamageNotifier.h) (0 => 205116)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/WebPage/gtk/AcceleratedSurfaceWayland.h                                (rev 0)
+++ trunk/Source/WebKit2/WebProcess/WebPage/gtk/AcceleratedSurfaceWayland.h        2016-08-29 09:33:40 UTC (rev 205116)
</span><span class="lines">@@ -0,0 +1,56 @@
</span><ins>+/*
+ * Copyright (C) 2016 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 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 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.
+ */
+
+#pragma once
+
+#if PLATFORM(WAYLAND)
+
+#include &quot;AcceleratedSurface.h&quot;
+#include &quot;WebPage.h&quot;
+#include &lt;WebCore/WlUniquePtr.h&gt;
+#include &lt;wayland-egl.h&gt;
+
+namespace WebKit {
+
+class AcceleratedSurfaceWayland final : public AcceleratedSurface {
+    WTF_MAKE_NONCOPYABLE(AcceleratedSurfaceWayland); WTF_MAKE_FAST_ALLOCATED;
+public:
+    static std::unique_ptr&lt;AcceleratedSurfaceWayland&gt; create(WebPage&amp;);
+    ~AcceleratedSurfaceWayland();
+
+    uint64_t window() const override { return reinterpret_cast&lt;uint64_t&gt;(m_window); }
+    uint64_t surfaceID() const override { return m_webPage.pageID(); }
+    bool resize(const WebCore::IntSize&amp;) override;
+
+private:
+    AcceleratedSurfaceWayland(WebPage&amp;);
+
+    WebCore::WlUniquePtr&lt;struct wl_surface&gt; m_surface;
+    struct wl_egl_window* m_window { nullptr };
+};
+
+} // namespace WebKit
+
+#endif // PLATFORM(WAYLAND)
</ins></span></pre></div>
<a id="trunkSourceWebKit2WebProcessWebPagegtkAcceleratedSurfaceX11cppfromrev205115trunkSourceWebKit2WebProcessWebPagegtkRedirectedXCompositeWindowcpp"></a>
<div class="copfile"><h4>Copied: trunk/Source/WebKit2/WebProcess/WebPage/gtk/AcceleratedSurfaceX11.cpp (from rev 205115, trunk/Source/WebKit2/WebProcess/WebPage/gtk/RedirectedXCompositeWindow.cpp) (0 => 205116)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/WebPage/gtk/AcceleratedSurfaceX11.cpp                                (rev 0)
+++ trunk/Source/WebKit2/WebProcess/WebPage/gtk/AcceleratedSurfaceX11.cpp        2016-08-29 09:33:40 UTC (rev 205116)
</span><span class="lines">@@ -0,0 +1,137 @@
</span><ins>+/*
+ * Copyright (C) 2012-2016 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 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 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 &quot;config.h&quot;
+#include &quot;AcceleratedSurfaceX11.h&quot;
+
+#if USE(REDIRECTED_XCOMPOSITE_WINDOW)
+
+#include &quot;WebPage.h&quot;
+#include &lt;WebCore/PlatformDisplayX11.h&gt;
+#include &lt;X11/Xlib.h&gt;
+#include &lt;X11/extensions/Xcomposite.h&gt;
+#include &lt;gdk/gdkx.h&gt;
+#include &lt;wtf/RunLoop.h&gt;
+
+using namespace WebCore;
+
+namespace WebKit {
+
+std::unique_ptr&lt;AcceleratedSurfaceX11&gt; AcceleratedSurfaceX11::create(WebPage&amp; webPage)
+{
+    if (!downcast&lt;PlatformDisplayX11&gt;(PlatformDisplay::sharedDisplay()).supportsXComposite())
+        return nullptr;
+    return std::unique_ptr&lt;AcceleratedSurfaceX11&gt;(new AcceleratedSurfaceX11(webPage));
+}
+
+AcceleratedSurfaceX11::AcceleratedSurfaceX11(WebPage&amp; webPage)
+    : AcceleratedSurface(webPage)
+    , m_display(downcast&lt;PlatformDisplayX11&gt;(PlatformDisplay::sharedDisplay()).native())
+{
+    Screen* screen = DefaultScreenOfDisplay(m_display);
+
+    ASSERT(downcast&lt;PlatformDisplayX11&gt;(PlatformDisplay::sharedDisplay()).native() == m_display);
+    GdkVisual* visual = gdk_screen_get_rgba_visual(gdk_screen_get_default());
+    if (!visual)
+        visual = gdk_screen_get_system_visual(gdk_screen_get_default());
+
+    XUniqueColormap colormap(XCreateColormap(m_display, RootWindowOfScreen(screen), GDK_VISUAL_XVISUAL(visual), AllocNone));
+
+    XSetWindowAttributes windowAttributes;
+    windowAttributes.override_redirect = True;
+    windowAttributes.colormap = colormap.get();
+
+    // CWBorderPixel must be present when the depth doesn't match the parent's one.
+    // See http://cgit.freedesktop.org/xorg/xserver/tree/dix/window.c?id=xorg-server-1.16.0#n703.
+    windowAttributes.border_pixel = 0;
+
+    m_parentWindow = XCreateWindow(m_display,
+        RootWindowOfScreen(screen),
+        -1, -1, 1, 1,
+        0,
+        gdk_visual_get_depth(visual),
+        InputOutput,
+        GDK_VISUAL_XVISUAL(visual),
+        CWOverrideRedirect | CWColormap | CWBorderPixel,
+        &amp;windowAttributes);
+    XMapWindow(m_display, m_parentWindow.get());
+
+    windowAttributes.event_mask = StructureNotifyMask;
+    windowAttributes.override_redirect = False;
+
+    // Create the window of at last 1x1 since X doesn't allow to create empty windows.
+    m_window = XCreateWindow(m_display,
+        m_parentWindow.get(),
+        0, 0,
+        std::max(1, m_size.width()),
+        std::max(1, m_size.height()),
+        0,
+        CopyFromParent,
+        InputOutput,
+        CopyFromParent,
+        CWEventMask,
+        &amp;windowAttributes);
+    XMapWindow(m_display, m_window.get());
+
+    while (1) {
+        XEvent event;
+        XWindowEvent(m_display, m_window.get(), StructureNotifyMask, &amp;event);
+        if (event.type == MapNotify &amp;&amp; event.xmap.window == m_window.get())
+            break;
+    }
+    XSelectInput(m_display, m_window.get(), NoEventMask);
+    XCompositeRedirectWindow(m_display, m_window.get(), CompositeRedirectManual);
+    m_pixmap = XCompositeNameWindowPixmap(m_display, m_window.get());
+}
+
+AcceleratedSurfaceX11::~AcceleratedSurfaceX11()
+{
+    ASSERT(m_display);
+    ASSERT(m_window);
+    ASSERT(m_parentWindow);
+
+    // Explicitly reset these because we need to ensure it happens in this order.
+    m_window.reset();
+    m_parentWindow.reset();
+}
+
+bool AcceleratedSurfaceX11::resize(const IntSize&amp; size)
+{
+    if (!AcceleratedSurface::resize(size))
+        return false;
+
+    // Resize the window to at last 1x1 since X doesn't allow to create empty windows.
+    XResizeWindow(m_display, m_window.get(), std::max(1, m_size.width()), std::max(1, m_size.height()));
+    XFlush(m_display);
+
+    // Release the previous pixmap later to give some time to the UI process to update.
+    RunLoop::main().dispatchAfter(std::chrono::seconds(5), [pixmap = WTFMove(m_pixmap)] { });
+    m_pixmap = XCompositeNameWindowPixmap(m_display, m_window.get());
+    return true;
+}
+
+} // namespace WebCore
+
+#endif // USE(REDIRECTED_XCOMPOSITE_WINDOW)
</ins></span></pre></div>
<a id="trunkSourceWebKit2WebProcessWebPagegtkAcceleratedSurfaceX11hfromrev205115trunkSourceWebKit2WebProcessWebPagegtkRedirectedXCompositeWindowh"></a>
<div class="copfile"><h4>Copied: trunk/Source/WebKit2/WebProcess/WebPage/gtk/AcceleratedSurfaceX11.h (from rev 205115, trunk/Source/WebKit2/WebProcess/WebPage/gtk/RedirectedXCompositeWindow.h) (0 => 205116)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/WebPage/gtk/AcceleratedSurfaceX11.h                                (rev 0)
+++ trunk/Source/WebKit2/WebProcess/WebPage/gtk/AcceleratedSurfaceX11.h        2016-08-29 09:33:40 UTC (rev 205116)
</span><span class="lines">@@ -0,0 +1,62 @@
</span><ins>+/*
+ * Copyright (C) 2012-2016 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 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 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.
+ */
+
+#pragma once
+
+#if USE(REDIRECTED_XCOMPOSITE_WINDOW)
+
+#include &quot;AcceleratedSurface.h&quot;
+#include &lt;WebCore/XUniqueResource.h&gt;
+
+typedef struct _XDisplay Display;
+typedef unsigned long Pixmap;
+typedef unsigned long Window;
+
+namespace WebKit {
+
+class WebPage;
+
+class AcceleratedSurfaceX11 final : public AcceleratedSurface {
+    WTF_MAKE_NONCOPYABLE(AcceleratedSurfaceX11); WTF_MAKE_FAST_ALLOCATED;
+public:
+    static std::unique_ptr&lt;AcceleratedSurfaceX11&gt; create(WebPage&amp;);
+    ~AcceleratedSurfaceX11();
+
+    uint64_t window() const override { return m_window.get(); }
+    uint64_t surfaceID() const override { return m_pixmap.get(); }
+    bool resize(const WebCore::IntSize&amp;) override;
+
+private:
+    AcceleratedSurfaceX11(WebPage&amp;);
+
+    Display* m_display { nullptr };
+    WebCore::XUniqueWindow m_window;
+    WebCore::XUniqueWindow m_parentWindow;
+    WebCore::XUniquePixmap m_pixmap;
+};
+
+} // namespace WebKit
+
+#endif // USE(REDIRECTED_XCOMPOSITE_WINDOW)
</ins></span></pre></div>
<a id="trunkSourceWebKit2WebProcessWebPagegtkLayerTreeHostGtkcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/WebPage/gtk/LayerTreeHostGtk.cpp (205115 => 205116)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/WebPage/gtk/LayerTreeHostGtk.cpp        2016-08-29 09:18:06 UTC (rev 205115)
+++ trunk/Source/WebKit2/WebProcess/WebPage/gtk/LayerTreeHostGtk.cpp        2016-08-29 09:33:40 UTC (rev 205116)
</span><span class="lines">@@ -29,6 +29,7 @@
</span><span class="cx"> 
</span><span class="cx"> #if USE(TEXTURE_MAPPER_GL)
</span><span class="cx"> 
</span><ins>+#include &quot;AcceleratedSurface.h&quot;
</ins><span class="cx"> #include &quot;DrawingAreaImpl.h&quot;
</span><span class="cx"> #include &quot;TextureMapperGL.h&quot;
</span><span class="cx"> #include &quot;WebPage.h&quot;
</span><span class="lines">@@ -46,21 +47,9 @@
</span><span class="cx"> #include &lt;WebCore/MainFrame.h&gt;
</span><span class="cx"> #include &lt;WebCore/Page.h&gt;
</span><span class="cx"> #include &lt;WebCore/Settings.h&gt;
</span><ins>+#include &lt;gdk/gdk.h&gt;
</ins><span class="cx"> #include &lt;wtf/CurrentTime.h&gt;
</span><span class="cx"> 
</span><del>-#include &lt;gdk/gdk.h&gt;
-#if defined(GDK_WINDOWING_X11)
-#define Region XRegion
-#define Font XFont
-#define Cursor XCursor
-#define Screen XScreen
-#include &lt;gdk/gdkx.h&gt;
-#endif
-
-#if USE(REDIRECTED_XCOMPOSITE_WINDOW)
-#include &quot;RedirectedXCompositeWindow.h&quot;
-#endif
-
</del><span class="cx"> using namespace WebCore;
</span><span class="cx"> 
</span><span class="cx"> namespace WebKit {
</span><span class="lines">@@ -137,9 +126,7 @@
</span><span class="cx"> 
</span><span class="cx"> LayerTreeHostGtk::LayerTreeHostGtk(WebPage&amp; webPage)
</span><span class="cx">     : LayerTreeHost(webPage)
</span><del>-#if USE(REDIRECTED_XCOMPOSITE_WINDOW)
-    , m_redirectedWindow(RedirectedXCompositeWindow::create(webPage))
-#endif
</del><ins>+    , m_surface(AcceleratedSurface::create(webPage))
</ins><span class="cx">     , m_renderFrameScheduler(std::bind(&amp;LayerTreeHostGtk::renderFrame, this))
</span><span class="cx"> {
</span><span class="cx">     m_rootLayer = GraphicsLayer::create(graphicsLayerFactory(), *this);
</span><span class="lines">@@ -167,34 +154,37 @@
</span><span class="cx">     m_rootLayer-&gt;addChild(m_nonCompositedContentLayer.get());
</span><span class="cx">     m_nonCompositedContentLayer-&gt;setNeedsDisplay();
</span><span class="cx"> 
</span><del>-#if USE(REDIRECTED_XCOMPOSITE_WINDOW)
-    if (m_redirectedWindow) {
</del><ins>+    if (m_surface) {
</ins><span class="cx">         createTextureMapper();
</span><del>-        m_layerTreeContext.contextID = m_redirectedWindow-&gt;pixmap();
</del><ins>+        m_layerTreeContext.contextID = m_surface-&gt;surfaceID();
</ins><span class="cx">     }
</span><del>-#endif
</del><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> bool LayerTreeHostGtk::makeContextCurrent()
</span><span class="cx"> {
</span><del>-#if USE(REDIRECTED_XCOMPOSITE_WINDOW)
-    uint64_t nativeHandle = m_redirectedWindow ? m_redirectedWindow-&gt;window() : m_layerTreeContext.contextID;
-#else
-    uint64_t nativeHandle = m_layerTreeContext.contextID;
-#endif
-
</del><ins>+    uint64_t nativeHandle = m_surface ? m_surface-&gt;window() : m_layerTreeContext.contextID;
</ins><span class="cx">     if (!nativeHandle) {
</span><span class="cx">         m_context = nullptr;
</span><span class="cx">         return false;
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    if (!m_context) {
-        m_context = GLContext::createContextForWindow(reinterpret_cast&lt;GLNativeWindowType&gt;(nativeHandle), GLContext::sharingContext());
-        if (!m_context)
-            return false;
-    }
</del><ins>+    if (m_context)
+        return m_context-&gt;makeContextCurrent();
</ins><span class="cx"> 
</span><del>-    return m_context-&gt;makeContextCurrent();
</del><ins>+    m_context = GLContext::createContextForWindow(reinterpret_cast&lt;GLNativeWindowType&gt;(nativeHandle), &amp;PlatformDisplay::sharedDisplayForCompositing());
+    if (!m_context)
+        return false;
+
+    if (!m_context-&gt;makeContextCurrent())
+        return false;
+
+    // Do not do frame sync when rendering offscreen in the web process to ensure that SwapBuffers never blocks.
+    // Rendering to the actual screen will happen later anyway since the UI process schedules a redraw for every update,
+    // the compositor will take care of syncing to vblank.
+    if (m_surface)
+        m_context-&gt;swapInterval(0);
+
+    return true;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> LayerTreeHostGtk::~LayerTreeHostGtk()
</span><span class="lines">@@ -229,9 +219,7 @@
</span><span class="cx">     m_context = nullptr;
</span><span class="cx">     LayerTreeHost::invalidate();
</span><span class="cx"> 
</span><del>-#if USE(REDIRECTED_XCOMPOSITE_WINDOW)
-    m_redirectedWindow = nullptr;
-#endif
</del><ins>+    m_surface = nullptr;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void LayerTreeHostGtk::setNonCompositedContentsNeedDisplay()
</span><span class="lines">@@ -271,12 +259,8 @@
</span><span class="cx">         m_nonCompositedContentLayer-&gt;setNeedsDisplayInRect(FloatRect(0, oldSize.height(), newSize.width(), newSize.height() - oldSize.height()));
</span><span class="cx">     m_nonCompositedContentLayer-&gt;setNeedsDisplay();
</span><span class="cx"> 
</span><del>-#if USE(REDIRECTED_XCOMPOSITE_WINDOW)
-    if (m_redirectedWindow) {
-        m_redirectedWindow-&gt;resize(newSize);
-        m_layerTreeContext.contextID = m_redirectedWindow-&gt;pixmap();
-    }
-#endif
</del><ins>+    if (m_surface &amp;&amp; m_surface-&gt;resize(newSize))
+        m_layerTreeContext.contextID = m_surface-&gt;surfaceID();
</ins><span class="cx"> 
</span><span class="cx">     compositeLayersToContext(ForResize);
</span><span class="cx"> }
</span><span class="lines">@@ -283,12 +267,8 @@
</span><span class="cx"> 
</span><span class="cx"> void LayerTreeHostGtk::deviceOrPageScaleFactorChanged()
</span><span class="cx"> {
</span><del>-#if USE(REDIRECTED_XCOMPOSITE_WINDOW)
-    if (m_redirectedWindow) {
-        m_redirectedWindow-&gt;resize(m_webPage.size());
-        m_layerTreeContext.contextID = m_redirectedWindow-&gt;pixmap();
-    }
-#endif
</del><ins>+    if (m_surface &amp;&amp; m_surface-&gt;resize(m_webPage.size()))
+        m_layerTreeContext.contextID = m_surface-&gt;surfaceID();
</ins><span class="cx"> 
</span><span class="cx">     // Other layers learn of the scale factor change via WebPage::setDeviceScaleFactor.
</span><span class="cx">     m_nonCompositedContentLayer-&gt;deviceOrPageScaleFactorChanged();
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcessWebPagegtkLayerTreeHostGtkh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/WebPage/gtk/LayerTreeHostGtk.h (205115 => 205116)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/WebPage/gtk/LayerTreeHostGtk.h        2016-08-29 09:18:06 UTC (rev 205115)
+++ trunk/Source/WebKit2/WebProcess/WebPage/gtk/LayerTreeHostGtk.h        2016-08-29 09:33:40 UTC (rev 205116)
</span><span class="lines">@@ -39,7 +39,7 @@
</span><span class="cx"> 
</span><span class="cx"> namespace WebKit {
</span><span class="cx"> 
</span><del>-class RedirectedXCompositeWindow;
</del><ins>+class AcceleratedSurface;
</ins><span class="cx"> 
</span><span class="cx"> class LayerTreeHostGtk final : public LayerTreeHost, WebCore::GraphicsLayerClient {
</span><span class="cx"> public:
</span><span class="lines">@@ -109,9 +109,7 @@
</span><span class="cx">     std::unique_ptr&lt;WebCore::TextureMapper&gt; m_textureMapper;
</span><span class="cx">     std::unique_ptr&lt;WebCore::GLContext&gt; m_context;
</span><span class="cx">     WebCore::TransformationMatrix m_scaleMatrix;
</span><del>-#if USE(REDIRECTED_XCOMPOSITE_WINDOW)
-    std::unique_ptr&lt;RedirectedXCompositeWindow&gt; m_redirectedWindow;
-#endif
</del><ins>+    std::unique_ptr&lt;AcceleratedSurface&gt; m_surface;
</ins><span class="cx">     RenderFrameScheduler m_renderFrameScheduler;
</span><span class="cx"> };
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcessWebPagegtkRedirectedXCompositeWindowcpp"></a>
<div class="delfile"><h4>Deleted: trunk/Source/WebKit2/WebProcess/WebPage/gtk/RedirectedXCompositeWindow.cpp (205115 => 205116)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/WebPage/gtk/RedirectedXCompositeWindow.cpp        2016-08-29 09:18:06 UTC (rev 205115)
+++ trunk/Source/WebKit2/WebProcess/WebPage/gtk/RedirectedXCompositeWindow.cpp        2016-08-29 09:33:40 UTC (rev 205116)
</span><span class="lines">@@ -1,143 +0,0 @@
</span><del>-/*
- * Copyright (C) 2012-2016 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 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 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 &quot;config.h&quot;
-#include &quot;RedirectedXCompositeWindow.h&quot;
-
-#if USE(REDIRECTED_XCOMPOSITE_WINDOW)
-
-#include &quot;WebPage.h&quot;
-#include &lt;WebCore/PlatformDisplayX11.h&gt;
-#include &lt;X11/Xlib.h&gt;
-#include &lt;X11/extensions/Xcomposite.h&gt;
-#include &lt;gdk/gdkx.h&gt;
-#include &lt;wtf/RunLoop.h&gt;
-
-using namespace WebCore;
-
-namespace WebKit {
-
-std::unique_ptr&lt;RedirectedXCompositeWindow&gt; RedirectedXCompositeWindow::create(WebPage&amp; webPage)
-{
-    if (!downcast&lt;PlatformDisplayX11&gt;(PlatformDisplay::sharedDisplay()).supportsXComposite())
-        return nullptr;
-    return std::unique_ptr&lt;RedirectedXCompositeWindow&gt;(new RedirectedXCompositeWindow(webPage));
-}
-
-RedirectedXCompositeWindow::RedirectedXCompositeWindow(WebPage&amp; webPage)
-    : m_webPage(webPage)
-    , m_display(downcast&lt;PlatformDisplayX11&gt;(PlatformDisplay::sharedDisplay()).native())
-    , m_size(webPage.size())
-{
-    m_size.scale(m_webPage.deviceScaleFactor());
-
-    Screen* screen = DefaultScreenOfDisplay(m_display);
-
-    ASSERT(downcast&lt;PlatformDisplayX11&gt;(PlatformDisplay::sharedDisplay()).native() == m_display);
-    GdkVisual* visual = gdk_screen_get_rgba_visual(gdk_screen_get_default());
-    if (!visual)
-        visual = gdk_screen_get_system_visual(gdk_screen_get_default());
-
-    XUniqueColormap colormap(XCreateColormap(m_display, RootWindowOfScreen(screen), GDK_VISUAL_XVISUAL(visual), AllocNone));
-
-    XSetWindowAttributes windowAttributes;
-    windowAttributes.override_redirect = True;
-    windowAttributes.colormap = colormap.get();
-
-    // CWBorderPixel must be present when the depth doesn't match the parent's one.
-    // See http://cgit.freedesktop.org/xorg/xserver/tree/dix/window.c?id=xorg-server-1.16.0#n703.
-    windowAttributes.border_pixel = 0;
-
-    m_parentWindow = XCreateWindow(m_display,
-        RootWindowOfScreen(screen),
-        -1, -1, 1, 1,
-        0,
-        gdk_visual_get_depth(visual),
-        InputOutput,
-        GDK_VISUAL_XVISUAL(visual),
-        CWOverrideRedirect | CWColormap | CWBorderPixel,
-        &amp;windowAttributes);
-    XMapWindow(m_display, m_parentWindow.get());
-
-    windowAttributes.event_mask = StructureNotifyMask;
-    windowAttributes.override_redirect = False;
-
-    // Create the window of at last 1x1 since X doesn't allow to create empty windows.
-    m_window = XCreateWindow(m_display,
-        m_parentWindow.get(),
-        0, 0,
-        std::max(1, m_size.width()),
-        std::max(1, m_size.height()),
-        0,
-        CopyFromParent,
-        InputOutput,
-        CopyFromParent,
-        CWEventMask,
-        &amp;windowAttributes);
-    XMapWindow(m_display, m_window.get());
-
-    while (1) {
-        XEvent event;
-        XWindowEvent(m_display, m_window.get(), StructureNotifyMask, &amp;event);
-        if (event.type == MapNotify &amp;&amp; event.xmap.window == m_window.get())
-            break;
-    }
-    XSelectInput(m_display, m_window.get(), NoEventMask);
-    XCompositeRedirectWindow(m_display, m_window.get(), CompositeRedirectManual);
-    m_pixmap = XCompositeNameWindowPixmap(m_display, m_window.get());
-}
-
-RedirectedXCompositeWindow::~RedirectedXCompositeWindow()
-{
-    ASSERT(m_display);
-    ASSERT(m_window);
-    ASSERT(m_parentWindow);
-
-    // Explicitly reset these because we need to ensure it happens in this order.
-    m_window.reset();
-    m_parentWindow.reset();
-}
-
-void RedirectedXCompositeWindow::resize(const IntSize&amp; size)
-{
-    IntSize scaledSize(size);
-    scaledSize.scale(m_webPage.deviceScaleFactor());
-    if (scaledSize == m_size)
-        return;
-
-    m_size = scaledSize;
-
-    // Resize the window to at last 1x1 since X doesn't allow to create empty windows.
-    XResizeWindow(m_display, m_window.get(), std::max(1, m_size.width()), std::max(1, m_size.height()));
-    XFlush(m_display);
-
-    // Release the previous pixmap later to give some time to the UI process to update.
-    RunLoop::main().dispatchAfter(std::chrono::seconds(5), [pixmap = WTFMove(m_pixmap)] { });
-    m_pixmap = XCompositeNameWindowPixmap(m_display, m_window.get());
-}
-
-} // namespace WebCore
-
-#endif // USE(REDIRECTED_XCOMPOSITE_WINDOW)
</del></span></pre></div>
<a id="trunkSourceWebKit2WebProcessWebPagegtkRedirectedXCompositeWindowh"></a>
<div class="delfile"><h4>Deleted: trunk/Source/WebKit2/WebProcess/WebPage/gtk/RedirectedXCompositeWindow.h (205115 => 205116)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/WebPage/gtk/RedirectedXCompositeWindow.h        2016-08-29 09:18:06 UTC (rev 205115)
+++ trunk/Source/WebKit2/WebProcess/WebPage/gtk/RedirectedXCompositeWindow.h        2016-08-29 09:33:40 UTC (rev 205116)
</span><span class="lines">@@ -1,65 +0,0 @@
</span><del>-/*
- * Copyright (C) 2012-2016 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 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 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.
- */
-
-#pragma once
-
-#if USE(REDIRECTED_XCOMPOSITE_WINDOW)
-
-#include &lt;WebCore/IntSize.h&gt;
-#include &lt;WebCore/XUniqueResource.h&gt;
-#include &lt;wtf/Noncopyable.h&gt;
-
-typedef struct _XDisplay Display;
-typedef unsigned long Pixmap;
-typedef unsigned long Window;
-
-namespace WebKit {
-
-class WebPage;
-
-class RedirectedXCompositeWindow {
-    WTF_MAKE_NONCOPYABLE(RedirectedXCompositeWindow); WTF_MAKE_FAST_ALLOCATED;
-public:
-    static std::unique_ptr&lt;RedirectedXCompositeWindow&gt; create(WebPage&amp;);
-    ~RedirectedXCompositeWindow();
-
-    Window window() const { return m_window.get(); }
-    Pixmap pixmap() const { return m_pixmap.get(); }
-    void resize(const WebCore::IntSize&amp;);
-
-private:
-    RedirectedXCompositeWindow(WebPage&amp;);
-
-    WebPage&amp; m_webPage;
-    Display* m_display { nullptr };
-    WebCore::IntSize m_size;
-    WebCore::XUniqueWindow m_window;
-    WebCore::XUniqueWindow m_parentWindow;
-    WebCore::XUniquePixmap m_pixmap;
-};
-
-} // namespace WebKit
-
-#endif // USE(REDIRECTED_XCOMPOSITE_WINDOW)
</del></span></pre></div>
<a id="trunkSourceWebKit2WebProcessWebProcesscpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/WebProcess.cpp (205115 => 205116)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/WebProcess.cpp        2016-08-29 09:18:06 UTC (rev 205115)
+++ trunk/Source/WebKit2/WebProcess/WebProcess.cpp        2016-08-29 09:33:40 UTC (rev 205116)
</span><span class="lines">@@ -300,6 +300,10 @@
</span><span class="cx">     m_applicationCacheStorage-&gt;setDefaultOriginQuota(25ULL * 1024 * 1024);
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><ins>+#if PLATFORM(WAYLAND)
+    m_waylandCompositorDisplayName = parameters.waylandCompositorDisplayName;
+#endif
+
</ins><span class="cx"> #if ENABLE(VIDEO)
</span><span class="cx">     if (!parameters.mediaCacheDirectory.isEmpty())
</span><span class="cx">         WebCore::HTMLMediaElement::setMediaCacheDirectory(parameters.mediaCacheDirectory);
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcessWebProcessh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/WebProcess.h (205115 => 205116)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/WebProcess.h        2016-08-29 09:18:06 UTC (rev 205115)
+++ trunk/Source/WebKit2/WebProcess/WebProcess.h        2016-08-29 09:33:40 UTC (rev 205116)
</span><span class="lines">@@ -198,6 +198,10 @@
</span><span class="cx">     void resetAllGeolocationPermissions();
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><ins>+#if PLATFORM(WAYLAND)
+    String waylandCompositorDisplayName() const { return m_waylandCompositorDisplayName; }
+#endif
+
</ins><span class="cx">     RefPtr&lt;API::Object&gt; transformHandlesToObjects(API::Object*);
</span><span class="cx">     static RefPtr&lt;API::Object&gt; transformObjectsToHandles(API::Object*);
</span><span class="cx"> 
</span><span class="lines">@@ -401,6 +405,10 @@
</span><span class="cx">     bool m_suppressMemoryPressureHandler { false };
</span><span class="cx"> 
</span><span class="cx">     HashMap&lt;WebCore::UserGestureToken *, uint64_t&gt; m_userGestureTokens;
</span><ins>+
+#if PLATFORM(WAYLAND)
+    String m_waylandCompositorDisplayName;
+#endif
</ins><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> } // namespace WebKit
</span></span></pre></div>
<a id="trunkSourcecmakeOptionsGTKcmake"></a>
<div class="modfile"><h4>Modified: trunk/Source/cmake/OptionsGTK.cmake (205115 => 205116)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/cmake/OptionsGTK.cmake        2016-08-29 09:18:06 UTC (rev 205115)
+++ trunk/Source/cmake/OptionsGTK.cmake        2016-08-29 09:33:40 UTC (rev 205116)
</span><span class="lines">@@ -389,10 +389,14 @@
</span><span class="cx">         message(FATAL_ERROR &quot;Recompile GTK+ with Wayland backend to use ENABLE_WAYLAND_TARGET&quot;)
</span><span class="cx">     endif ()
</span><span class="cx"> 
</span><del>-    if (ENABLE_WAYLAND_TARGET AND GTK3_VERSION VERSION_LESS 3.12)
</del><ins>+    if (GTK3_VERSION VERSION_LESS 3.12)
</ins><span class="cx">         message(FATAL_ERROR &quot;GTK+ 3.12 is required to use ENABLE_WAYLAND_TARGET&quot;)
</span><span class="cx">     endif ()
</span><span class="cx"> 
</span><ins>+    if (NOT EGL_FOUND)
+        message(FATAL_ERROR &quot;EGL is required to use ENABLE_WAYLAND_TARGET&quot;)
+    endif ()
+
</ins><span class="cx">     find_package(Wayland REQUIRED)
</span><span class="cx"> endif ()
</span><span class="cx"> 
</span></span></pre>
</div>
</div>

</body>
</html>