<!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>[204013] 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/204013">204013</a></dd>
<dt>Author</dt> <dd>carlosgc@webkit.org</dd>
<dt>Date</dt> <dd>2016-08-01 23:42:18 -0700 (Mon, 01 Aug 2016)</dd>
</dl>

<h3>Log Message</h3>
<pre>[GTK] Move the redirected XComposite window to the web process
https://bugs.webkit.org/show_bug.cgi?id=160389

Reviewed by Žan Doberšek.

Source/WebCore:

Add helper methods to PlatformDisplayX11 to query X extensions supported by the display.

* platform/graphics/x11/PlatformDisplayX11.cpp:
(WebCore::PlatformDisplayX11::supportsXComposite):
(WebCore::PlatformDisplayX11::supportsXDamage):
* platform/graphics/x11/PlatformDisplayX11.h:

Source/WebKit2:

In the current code, the UI process creates the redirected window that the web process uses to render
accelerated contents. The redirected window is sent to the web process as native surface handle, and using
XDamage extension the UI process takes a pixmap of the redirected window to render into the widget when there
are updates. This requires several points of synchronization between UI and web processes. When the web view is
resized, the UI process first resizes the redirected window and then sends a new backing store ID to the web
process. The time between the redirected window is resized and the web process renders the new contents the UI
process keeps rendering the previous contents with the previous size in the new window with the new size. This
makes the resize process slow, and it produces rendering artifacts quite often. The redirected window is created
when the web view is realized, to be able to inherit the XVisual from the parent window, and the native window
handle is sent to the web process. The time until the window is realized, the web process doesn't have a context
to render into, so the UI process simply renders an empty page. When the web view is unrealized, for example if
the web view is reparented, the redirected window is destroyed, and a sync message is sent to the web process to
destroy the current gl context and stop drawing. This needs to happen synchronously, because the UI process
can't remove the redirected window until the web process has stopped rendering into it. This makes also the
reparenting process quite unstable and risky.
To all those synchronization points we now have to add the synchronization with the compositing thread when
using the threaded compositor. The threaded compositor made resizing, reparenting, etc. even worse. We can't
avoid the synchronization with the threaded compositor, but we can reduce the synchronization points and improve
the current ones by moving the redirected window to the web process. In this case is web process who creates the
redirected window, so we can be sure that it always has a valid native surface handle to render into. This means
we no longer need the IPC message to send the native surface handle from the UI process to the web process, nor
the sync message to destroy it either. This also means we no longer need to wait until the view is realized to
start rendering accelerated contents, and we don't need to stop when it's unrealized either. We don't really
need to inherit the XVisual from the parent window if the redirected window always uses always a RGBA visual
when available. That way we always render into a transparent window that is composed into the web view
widget. And when the web view is resized, we no longer need to destroy the GL context either, because we use the
same redirected window as the native handle, but create a new pixmap that is what we send to the UI process as
layer tree context ID. The layer tree context ID is already sent to the UI process by the drawing area as part
of the backing store update process, so we don't need any new IPC message for this. When the web view is
resized, the UI process sends a backing store state update message to the web process that updates its size,
relayouts and then renders the new contents, so that when the update backing store state reply gets to the UI
process, we already have a new pixmap with the new contents updated. This makes resizing smooth again, and
avoids flickering and rendering artifacts. And finally all this also prevents several race conditions that were
causing X errors and web process crashes.

* PlatformGTK.cmake:
* Shared/CoordinatedGraphics/threadedcompositor/ThreadedCompositor.cpp:
(WebKit::ThreadedCompositor::create): Make it possible to optionally pass a native surface handle for
compositing to the ThreadedCompositor contructor.
(WebKit::ThreadedCompositor::ThreadedCompositor): Initialize the native surface handle and make the scene active
after the thread initialization if we already have a valid handle.
* Shared/CoordinatedGraphics/threadedcompositor/ThreadedCompositor.h:
* UIProcess/API/gtk/PageClientImpl.cpp:
(WebKit::PageClientImpl::enterAcceleratedCompositingMode): Pass the layer tree context ID to the web view.
(WebKit::PageClientImpl::updateAcceleratedCompositingMode): Notify the web view about the update.
(WebKit::PageClientImpl::willEnterAcceleratedCompositingMode): Deleted.
* UIProcess/API/gtk/PageClientImpl.h:
* UIProcess/API/gtk/WebKitWebViewBase.cpp:
(webkitWebViewBaseSetAcceleratedCompositingPixmap): Helper function to update the pixmap used to render the
accelerated contents.
(webkitWebViewBaseRealize): Remove the code to create the redirected window.
(webkitWebViewBaseUnrealize): Remove the code to destroy the redirected window.
(webkitWebViewBaseDispose): Reset the accelerated compositing pixmap.
(webkitWebViewRenderAcceleratedCompositingResults): Use the accelerated compositing pixmap surface.
(webkitWebViewBaseSizeAllocate): Remove the code to resize the redirected window.
(webkitWebViewBaseEnterAcceleratedCompositingMode): Update the accelerated compositing pixmap.
(webkitWebViewBaseUpdateAcceleratedCompositingMode): Ditto.
(webkitWebViewBaseExitAcceleratedCompositingMode): Reset the accelerated compositing pixmap.
(webkitWebViewBaseDidRelaunchWebProcess): Remove the code to send native surface handle to the web process.
(webkitWebViewBasePageClosed): Reset the accelerated compositing pixmap.
(_WebKitWebViewBasePrivate::updateViewStateTimerFired): Deleted.
* UIProcess/API/gtk/WebKitWebViewBasePrivate.h:
* UIProcess/DrawingAreaProxy.h:
* UIProcess/DrawingAreaProxy.messages.in:
* UIProcess/DrawingAreaProxyImpl.cpp:
(WebKit::DrawingAreaProxyImpl::didUpdateBackingStoreState): Handle the case when the layer tree context ID
changes without leaving the accelerated compositing mode, calling updateAcceleratedCompositingMode().
(WebKit::DrawingAreaProxyImpl::exitAcceleratedCompositingMode): Let the web view know we are leaving accelerated
compositing mode even when it's forced, since in case of web process crash we need to leave the accelerated
compositing mode in the UI process.
(WebKit::DrawingAreaProxyImpl::willEnterAcceleratedCompositingMode): This message was added only to prepare the
redirected window when the web process was about to enter accelerated compositing mode, so it's no longer needed.
(WebKit::DrawingAreaProxyImpl::setNativeSurfaceHandleForCompositing): This is now only used when building
without redirected XComposite window support.
* UIProcess/DrawingAreaProxyImpl.h:
* UIProcess/PageClient.h:
* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::willEnterAcceleratedCompositingMode): Deleted.
* UIProcess/WebPageProxy.h:
* UIProcess/efl/WebView.h:
* UIProcess/gtk/RedirectedXCompositeWindow.cpp: Removed.
* UIProcess/gtk/XDamageNotifier.cpp: Helper class to be notified about XDamage events.
(WebKit::XDamageNotifier::singleton):
(WebKit::XDamageNotifier::XDamageNotifier):
(WebKit::XDamageNotifier::add):
(WebKit::XDamageNotifier::remove):
(WebKit::XDamageNotifier::filterXDamageEvent):
(WebKit::XDamageNotifier::notify):
* UIProcess/gtk/XDamageNotifier.h: Added.
* UIProcess/ios/PageClientImplIOS.h:
* UIProcess/ios/PageClientImplIOS.mm:
(WebKit::PageClientImpl::willEnterAcceleratedCompositingMode): Deleted.
* UIProcess/mac/PageClientImpl.h:
* UIProcess/mac/PageClientImpl.mm:
(WebKit::PageClientImpl::willEnterAcceleratedCompositingMode): Deleted.
* WebProcess/WebPage/AcceleratedDrawingArea.cpp:
(WebKit::AcceleratedDrawingArea::enterAcceleratedCompositingMode): Remove code to send
WillEnterAcceleratedCompositingMode message.
(WebKit::AcceleratedDrawingArea::setNativeSurfaceHandleForCompositing): This is now only used when building
without redirected XComposite window support.
* WebProcess/WebPage/AcceleratedDrawingArea.h:
* WebProcess/WebPage/CoordinatedGraphics/ThreadedCoordinatedLayerTreeHost.cpp:
(WebKit::ThreadedCoordinatedLayerTreeHost::ThreadedCoordinatedLayerTreeHost): Create a redirected window and
pass the window ID as native surface handle to the threaded compositor. Use the redirected window pixmap as
layer tree context.
(WebKit::ThreadedCoordinatedLayerTreeHost::invalidate): Destroy the redirected window.
(WebKit::ThreadedCoordinatedLayerTreeHost::deviceOrPageScaleFactorChanged): Resize the redirected window and
update the layer tree context.
(WebKit::ThreadedCoordinatedLayerTreeHost::sizeDidChange): Ditto.
* WebProcess/WebPage/CoordinatedGraphics/ThreadedCoordinatedLayerTreeHost.h:
* WebProcess/WebPage/DrawingArea.h:
* WebProcess/WebPage/DrawingArea.messages.in:
* WebProcess/WebPage/gtk/LayerTreeHostGtk.cpp:
(WebKit::LayerTreeHostGtk::LayerTreeHostGtk): Create a redirected window and texture mapper that uses the window
ID as native surface handle. Use the redirected window pixmap as layer tree context.
(WebKit::LayerTreeHostGtk::makeContextCurrent): Use the redirected window as native handle.
(WebKit::LayerTreeHostGtk::invalidate): Destroy the redirected window.
(WebKit::LayerTreeHostGtk::sizeDidChange): Resize the redirected window and update the layer tree context.
(WebKit::LayerTreeHostGtk::deviceOrPageScaleFactorChanged): Ditto.
(WebKit::LayerTreeHostGtk::createTextureMapper): Helper function to create the texture mapper.
(WebKit::LayerTreeHostGtk::setNativeSurfaceHandleForCompositing): Use createTextureMapper().
* WebProcess/WebPage/gtk/LayerTreeHostGtk.h:
* WebProcess/WebPage/gtk/RedirectedXCompositeWindow.cpp: Added.
(WebKit::RedirectedXCompositeWindow::create):
(WebKit::RedirectedXCompositeWindow::RedirectedXCompositeWindow):
(WebKit::RedirectedXCompositeWindow::~RedirectedXCompositeWindow):
(WebKit::RedirectedXCompositeWindow::resize):
* WebProcess/WebPage/gtk/RedirectedXCompositeWindow.h: Renamed from Source/WebKit2/UIProcess/gtk/RedirectedXCompositeWindow.h.
(WebKit::RedirectedXCompositeWindow::window):
(WebKit::RedirectedXCompositeWindow::pixmap):</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicsx11PlatformDisplayX11cpp">trunk/Source/WebCore/platform/graphics/x11/PlatformDisplayX11.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicsx11PlatformDisplayX11h">trunk/Source/WebCore/platform/graphics/x11/PlatformDisplayX11.h</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="#trunkSourceWebKit2UIProcessAPIgtkPageClientImplcpp">trunk/Source/WebKit2/UIProcess/API/gtk/PageClientImpl.cpp</a></li>
<li><a href="#trunkSourceWebKit2UIProcessAPIgtkPageClientImplh">trunk/Source/WebKit2/UIProcess/API/gtk/PageClientImpl.h</a></li>
<li><a href="#trunkSourceWebKit2UIProcessAPIgtkWebKitWebViewBasecpp">trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewBase.cpp</a></li>
<li><a href="#trunkSourceWebKit2UIProcessAPIgtkWebKitWebViewBasePrivateh">trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewBasePrivate.h</a></li>
<li><a href="#trunkSourceWebKit2UIProcessDrawingAreaProxyh">trunk/Source/WebKit2/UIProcess/DrawingAreaProxy.h</a></li>
<li><a href="#trunkSourceWebKit2UIProcessDrawingAreaProxymessagesin">trunk/Source/WebKit2/UIProcess/DrawingAreaProxy.messages.in</a></li>
<li><a href="#trunkSourceWebKit2UIProcessDrawingAreaProxyImplcpp">trunk/Source/WebKit2/UIProcess/DrawingAreaProxyImpl.cpp</a></li>
<li><a href="#trunkSourceWebKit2UIProcessDrawingAreaProxyImplh">trunk/Source/WebKit2/UIProcess/DrawingAreaProxyImpl.h</a></li>
<li><a href="#trunkSourceWebKit2UIProcessPageClienth">trunk/Source/WebKit2/UIProcess/PageClient.h</a></li>
<li><a href="#trunkSourceWebKit2UIProcessWebPageProxycpp">trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp</a></li>
<li><a href="#trunkSourceWebKit2UIProcessWebPageProxyh">trunk/Source/WebKit2/UIProcess/WebPageProxy.h</a></li>
<li><a href="#trunkSourceWebKit2UIProcesseflWebViewh">trunk/Source/WebKit2/UIProcess/efl/WebView.h</a></li>
<li><a href="#trunkSourceWebKit2UIProcessiosPageClientImplIOSh">trunk/Source/WebKit2/UIProcess/ios/PageClientImplIOS.h</a></li>
<li><a href="#trunkSourceWebKit2UIProcessiosPageClientImplIOSmm">trunk/Source/WebKit2/UIProcess/ios/PageClientImplIOS.mm</a></li>
<li><a href="#trunkSourceWebKit2UIProcessmacPageClientImplh">trunk/Source/WebKit2/UIProcess/mac/PageClientImpl.h</a></li>
<li><a href="#trunkSourceWebKit2UIProcessmacPageClientImplmm">trunk/Source/WebKit2/UIProcess/mac/PageClientImpl.mm</a></li>
<li><a href="#trunkSourceWebKit2WebProcessWebPageAcceleratedDrawingAreacpp">trunk/Source/WebKit2/WebProcess/WebPage/AcceleratedDrawingArea.cpp</a></li>
<li><a href="#trunkSourceWebKit2WebProcessWebPageAcceleratedDrawingAreah">trunk/Source/WebKit2/WebProcess/WebPage/AcceleratedDrawingArea.h</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="#trunkSourceWebKit2WebProcessWebPageDrawingAreah">trunk/Source/WebKit2/WebProcess/WebPage/DrawingArea.h</a></li>
<li><a href="#trunkSourceWebKit2WebProcessWebPageDrawingAreamessagesin">trunk/Source/WebKit2/WebProcess/WebPage/DrawingArea.messages.in</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>
</ul>

<h3>Added Paths</h3>
<ul>
<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>

<h3>Removed Paths</h3>
<ul>
<li><a href="#trunkSourceWebKit2UIProcessgtkRedirectedXCompositeWindowcpp">trunk/Source/WebKit2/UIProcess/gtk/RedirectedXCompositeWindow.cpp</a></li>
<li><a href="#trunkSourceWebKit2UIProcessgtkRedirectedXCompositeWindowh">trunk/Source/WebKit2/UIProcess/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 (204012 => 204013)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2016-08-02 06:00:17 UTC (rev 204012)
+++ trunk/Source/WebCore/ChangeLog        2016-08-02 06:42:18 UTC (rev 204013)
</span><span class="lines">@@ -1,3 +1,17 @@
</span><ins>+2016-08-01  Carlos Garcia Campos  &lt;cgarcia@igalia.com&gt;
+
+        [GTK] Move the redirected XComposite window to the web process
+        https://bugs.webkit.org/show_bug.cgi?id=160389
+
+        Reviewed by Žan Doberšek.
+
+        Add helper methods to PlatformDisplayX11 to query X extensions supported by the display.
+
+        * platform/graphics/x11/PlatformDisplayX11.cpp:
+        (WebCore::PlatformDisplayX11::supportsXComposite):
+        (WebCore::PlatformDisplayX11::supportsXDamage):
+        * platform/graphics/x11/PlatformDisplayX11.h:
+
</ins><span class="cx"> 2016-08-01  Andreas Kling  &lt;akling@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Shrink MediaQuerySets to fit after parsing.
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsx11PlatformDisplayX11cpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/x11/PlatformDisplayX11.cpp (204012 => 204013)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/x11/PlatformDisplayX11.cpp        2016-08-02 06:00:17 UTC (rev 204012)
+++ trunk/Source/WebCore/platform/graphics/x11/PlatformDisplayX11.cpp        2016-08-02 06:42:18 UTC (rev 204013)
</span><span class="lines">@@ -28,6 +28,10 @@
</span><span class="cx"> 
</span><span class="cx"> #if PLATFORM(X11)
</span><span class="cx"> #include &lt;X11/Xlib.h&gt;
</span><ins>+#include &lt;X11/extensions/Xcomposite.h&gt;
+#if PLATFORM(GTK)
+#include &lt;X11/extensions/Xdamage.h&gt;
+#endif
</ins><span class="cx"> 
</span><span class="cx"> #if USE(EGL)
</span><span class="cx"> #include &lt;EGL/egl.h&gt;
</span><span class="lines">@@ -61,6 +65,32 @@
</span><span class="cx"> }
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><ins>+bool PlatformDisplayX11::supportsXComposite() const
+{
+    if (!m_supportsXComposite) {
+        int eventBase, errorBase;
+        m_supportsXComposite = XCompositeQueryExtension(m_display, &amp;eventBase, &amp;errorBase);
+    }
+    return m_supportsXComposite.value();
+}
+
+bool PlatformDisplayX11::supportsXDamage(Optional&lt;int&gt;&amp; damageEventBase) const
+{
+    if (!m_supportsXDamage) {
+#if PLATFORM(GTK)
+        int eventBase, errorBase;
+        m_supportsXDamage = XDamageQueryExtension(m_display, &amp;eventBase, &amp;errorBase);
+        if (m_supportsXDamage.value())
+            m_damageEventBase = eventBase;
+#else
+        m_supportsXDamage = false;
+#endif
+    }
+
+    damageEventBase = m_damageEventBase;
+    return m_supportsXDamage.value();
+}
+
</ins><span class="cx"> } // namespace WebCore
</span><span class="cx"> 
</span><span class="cx"> #endif // PLATFORM(X11)
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsx11PlatformDisplayX11h"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/x11/PlatformDisplayX11.h (204012 => 204013)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/x11/PlatformDisplayX11.h        2016-08-02 06:00:17 UTC (rev 204012)
+++ trunk/Source/WebCore/platform/graphics/x11/PlatformDisplayX11.h        2016-08-02 06:42:18 UTC (rev 204013)
</span><span class="lines">@@ -29,6 +29,7 @@
</span><span class="cx"> #if PLATFORM(X11)
</span><span class="cx"> 
</span><span class="cx"> #include &quot;PlatformDisplay.h&quot;
</span><ins>+#include &lt;wtf/Optional.h&gt;
</ins><span class="cx"> 
</span><span class="cx"> typedef struct _XDisplay Display;
</span><span class="cx"> 
</span><span class="lines">@@ -41,6 +42,8 @@
</span><span class="cx">     virtual ~PlatformDisplayX11();
</span><span class="cx"> 
</span><span class="cx">     Display* native() const { return m_display; }
</span><ins>+    bool supportsXComposite() const;
+    bool supportsXDamage(Optional&lt;int&gt;&amp; damageEventBase) const;
</ins><span class="cx"> 
</span><span class="cx"> private:
</span><span class="cx">     Type type() const override { return PlatformDisplay::Type::X11; }
</span><span class="lines">@@ -51,6 +54,9 @@
</span><span class="cx"> 
</span><span class="cx">     Display* m_display;
</span><span class="cx">     bool m_ownedDisplay;
</span><ins>+    mutable Optional&lt;bool&gt; m_supportsXComposite;
+    mutable Optional&lt;bool&gt; m_supportsXDamage;
+    mutable Optional&lt;int&gt; m_damageEventBase;
</ins><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> } // namespace WebCore
</span></span></pre></div>
<a id="trunkSourceWebKit2ChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/ChangeLog (204012 => 204013)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/ChangeLog        2016-08-02 06:00:17 UTC (rev 204012)
+++ trunk/Source/WebKit2/ChangeLog        2016-08-02 06:42:18 UTC (rev 204013)
</span><span class="lines">@@ -1,5 +1,143 @@
</span><span class="cx"> 2016-08-01  Carlos Garcia Campos  &lt;cgarcia@igalia.com&gt;
</span><span class="cx"> 
</span><ins>+        [GTK] Move the redirected XComposite window to the web process
+        https://bugs.webkit.org/show_bug.cgi?id=160389
+
+        Reviewed by Žan Doberšek.
+
+        In the current code, the UI process creates the redirected window that the web process uses to render
+        accelerated contents. The redirected window is sent to the web process as native surface handle, and using
+        XDamage extension the UI process takes a pixmap of the redirected window to render into the widget when there
+        are updates. This requires several points of synchronization between UI and web processes. When the web view is
+        resized, the UI process first resizes the redirected window and then sends a new backing store ID to the web
+        process. The time between the redirected window is resized and the web process renders the new contents the UI
+        process keeps rendering the previous contents with the previous size in the new window with the new size. This
+        makes the resize process slow, and it produces rendering artifacts quite often. The redirected window is created
+        when the web view is realized, to be able to inherit the XVisual from the parent window, and the native window
+        handle is sent to the web process. The time until the window is realized, the web process doesn't have a context
+        to render into, so the UI process simply renders an empty page. When the web view is unrealized, for example if
+        the web view is reparented, the redirected window is destroyed, and a sync message is sent to the web process to
+        destroy the current gl context and stop drawing. This needs to happen synchronously, because the UI process
+        can't remove the redirected window until the web process has stopped rendering into it. This makes also the
+        reparenting process quite unstable and risky.
+        To all those synchronization points we now have to add the synchronization with the compositing thread when
+        using the threaded compositor. The threaded compositor made resizing, reparenting, etc. even worse. We can't
+        avoid the synchronization with the threaded compositor, but we can reduce the synchronization points and improve
+        the current ones by moving the redirected window to the web process. In this case is web process who creates the
+        redirected window, so we can be sure that it always has a valid native surface handle to render into. This means
+        we no longer need the IPC message to send the native surface handle from the UI process to the web process, nor
+        the sync message to destroy it either. This also means we no longer need to wait until the view is realized to
+        start rendering accelerated contents, and we don't need to stop when it's unrealized either. We don't really
+        need to inherit the XVisual from the parent window if the redirected window always uses always a RGBA visual
+        when available. That way we always render into a transparent window that is composed into the web view
+        widget. And when the web view is resized, we no longer need to destroy the GL context either, because we use the
+        same redirected window as the native handle, but create a new pixmap that is what we send to the UI process as
+        layer tree context ID. The layer tree context ID is already sent to the UI process by the drawing area as part
+        of the backing store update process, so we don't need any new IPC message for this. When the web view is
+        resized, the UI process sends a backing store state update message to the web process that updates its size,
+        relayouts and then renders the new contents, so that when the update backing store state reply gets to the UI
+        process, we already have a new pixmap with the new contents updated. This makes resizing smooth again, and
+        avoids flickering and rendering artifacts. And finally all this also prevents several race conditions that were
+        causing X errors and web process crashes.
+
+        * PlatformGTK.cmake:
+        * Shared/CoordinatedGraphics/threadedcompositor/ThreadedCompositor.cpp:
+        (WebKit::ThreadedCompositor::create): Make it possible to optionally pass a native surface handle for
+        compositing to the ThreadedCompositor contructor.
+        (WebKit::ThreadedCompositor::ThreadedCompositor): Initialize the native surface handle and make the scene active
+        after the thread initialization if we already have a valid handle.
+        * Shared/CoordinatedGraphics/threadedcompositor/ThreadedCompositor.h:
+        * UIProcess/API/gtk/PageClientImpl.cpp:
+        (WebKit::PageClientImpl::enterAcceleratedCompositingMode): Pass the layer tree context ID to the web view.
+        (WebKit::PageClientImpl::updateAcceleratedCompositingMode): Notify the web view about the update.
+        (WebKit::PageClientImpl::willEnterAcceleratedCompositingMode): Deleted.
+        * UIProcess/API/gtk/PageClientImpl.h:
+        * UIProcess/API/gtk/WebKitWebViewBase.cpp:
+        (webkitWebViewBaseSetAcceleratedCompositingPixmap): Helper function to update the pixmap used to render the
+        accelerated contents.
+        (webkitWebViewBaseRealize): Remove the code to create the redirected window.
+        (webkitWebViewBaseUnrealize): Remove the code to destroy the redirected window.
+        (webkitWebViewBaseDispose): Reset the accelerated compositing pixmap.
+        (webkitWebViewRenderAcceleratedCompositingResults): Use the accelerated compositing pixmap surface.
+        (webkitWebViewBaseSizeAllocate): Remove the code to resize the redirected window.
+        (webkitWebViewBaseEnterAcceleratedCompositingMode): Update the accelerated compositing pixmap.
+        (webkitWebViewBaseUpdateAcceleratedCompositingMode): Ditto.
+        (webkitWebViewBaseExitAcceleratedCompositingMode): Reset the accelerated compositing pixmap.
+        (webkitWebViewBaseDidRelaunchWebProcess): Remove the code to send native surface handle to the web process.
+        (webkitWebViewBasePageClosed): Reset the accelerated compositing pixmap.
+        (_WebKitWebViewBasePrivate::updateViewStateTimerFired): Deleted.
+        * UIProcess/API/gtk/WebKitWebViewBasePrivate.h:
+        * UIProcess/DrawingAreaProxy.h:
+        * UIProcess/DrawingAreaProxy.messages.in:
+        * UIProcess/DrawingAreaProxyImpl.cpp:
+        (WebKit::DrawingAreaProxyImpl::didUpdateBackingStoreState): Handle the case when the layer tree context ID
+        changes without leaving the accelerated compositing mode, calling updateAcceleratedCompositingMode().
+        (WebKit::DrawingAreaProxyImpl::exitAcceleratedCompositingMode): Let the web view know we are leaving accelerated
+        compositing mode even when it's forced, since in case of web process crash we need to leave the accelerated
+        compositing mode in the UI process.
+        (WebKit::DrawingAreaProxyImpl::willEnterAcceleratedCompositingMode): This message was added only to prepare the
+        redirected window when the web process was about to enter accelerated compositing mode, so it's no longer needed.
+        (WebKit::DrawingAreaProxyImpl::setNativeSurfaceHandleForCompositing): This is now only used when building
+        without redirected XComposite window support.
+        * UIProcess/DrawingAreaProxyImpl.h:
+        * UIProcess/PageClient.h:
+        * UIProcess/WebPageProxy.cpp:
+        (WebKit::WebPageProxy::willEnterAcceleratedCompositingMode): Deleted.
+        * UIProcess/WebPageProxy.h:
+        * UIProcess/efl/WebView.h:
+        * UIProcess/gtk/RedirectedXCompositeWindow.cpp: Removed.
+        * UIProcess/gtk/XDamageNotifier.cpp: Helper class to be notified about XDamage events.
+        (WebKit::XDamageNotifier::singleton):
+        (WebKit::XDamageNotifier::XDamageNotifier):
+        (WebKit::XDamageNotifier::add):
+        (WebKit::XDamageNotifier::remove):
+        (WebKit::XDamageNotifier::filterXDamageEvent):
+        (WebKit::XDamageNotifier::notify):
+        * UIProcess/gtk/XDamageNotifier.h: Added.
+        * UIProcess/ios/PageClientImplIOS.h:
+        * UIProcess/ios/PageClientImplIOS.mm:
+        (WebKit::PageClientImpl::willEnterAcceleratedCompositingMode): Deleted.
+        * UIProcess/mac/PageClientImpl.h:
+        * UIProcess/mac/PageClientImpl.mm:
+        (WebKit::PageClientImpl::willEnterAcceleratedCompositingMode): Deleted.
+        * WebProcess/WebPage/AcceleratedDrawingArea.cpp:
+        (WebKit::AcceleratedDrawingArea::enterAcceleratedCompositingMode): Remove code to send
+        WillEnterAcceleratedCompositingMode message.
+        (WebKit::AcceleratedDrawingArea::setNativeSurfaceHandleForCompositing): This is now only used when building
+        without redirected XComposite window support.
+        * WebProcess/WebPage/AcceleratedDrawingArea.h:
+        * WebProcess/WebPage/CoordinatedGraphics/ThreadedCoordinatedLayerTreeHost.cpp:
+        (WebKit::ThreadedCoordinatedLayerTreeHost::ThreadedCoordinatedLayerTreeHost): Create a redirected window and
+        pass the window ID as native surface handle to the threaded compositor. Use the redirected window pixmap as
+        layer tree context.
+        (WebKit::ThreadedCoordinatedLayerTreeHost::invalidate): Destroy the redirected window.
+        (WebKit::ThreadedCoordinatedLayerTreeHost::deviceOrPageScaleFactorChanged): Resize the redirected window and
+        update the layer tree context.
+        (WebKit::ThreadedCoordinatedLayerTreeHost::sizeDidChange): Ditto.
+        * WebProcess/WebPage/CoordinatedGraphics/ThreadedCoordinatedLayerTreeHost.h:
+        * WebProcess/WebPage/DrawingArea.h:
+        * WebProcess/WebPage/DrawingArea.messages.in:
+        * WebProcess/WebPage/gtk/LayerTreeHostGtk.cpp:
+        (WebKit::LayerTreeHostGtk::LayerTreeHostGtk): Create a redirected window and texture mapper that uses the window
+        ID as native surface handle. Use the redirected window pixmap as layer tree context.
+        (WebKit::LayerTreeHostGtk::makeContextCurrent): Use the redirected window as native handle.
+        (WebKit::LayerTreeHostGtk::invalidate): Destroy the redirected window.
+        (WebKit::LayerTreeHostGtk::sizeDidChange): Resize the redirected window and update the layer tree context.
+        (WebKit::LayerTreeHostGtk::deviceOrPageScaleFactorChanged): Ditto.
+        (WebKit::LayerTreeHostGtk::createTextureMapper): Helper function to create the texture mapper.
+        (WebKit::LayerTreeHostGtk::setNativeSurfaceHandleForCompositing): Use createTextureMapper().
+        * WebProcess/WebPage/gtk/LayerTreeHostGtk.h:
+        * WebProcess/WebPage/gtk/RedirectedXCompositeWindow.cpp: Added.
+        (WebKit::RedirectedXCompositeWindow::create):
+        (WebKit::RedirectedXCompositeWindow::RedirectedXCompositeWindow):
+        (WebKit::RedirectedXCompositeWindow::~RedirectedXCompositeWindow):
+        (WebKit::RedirectedXCompositeWindow::resize):
+        * WebProcess/WebPage/gtk/RedirectedXCompositeWindow.h: Renamed from Source/WebKit2/UIProcess/gtk/RedirectedXCompositeWindow.h.
+        (WebKit::RedirectedXCompositeWindow::window):
+        (WebKit::RedirectedXCompositeWindow::pixmap):
+
+2016-08-01  Carlos Garcia Campos  &lt;cgarcia@igalia.com&gt;
+
</ins><span class="cx">         Database Process: ASSERTION FAILED: filePaths.size() == result.handles().size() with SANDBOX_EXTENSIONS disabled
</span><span class="cx">         https://bugs.webkit.org/show_bug.cgi?id=160398
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebKit2PlatformGTKcmake"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/PlatformGTK.cmake (204012 => 204013)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/PlatformGTK.cmake        2016-08-02 06:00:17 UTC (rev 204012)
+++ trunk/Source/WebKit2/PlatformGTK.cmake        2016-08-02 06:42:18 UTC (rev 204013)
</span><span class="lines">@@ -299,8 +299,8 @@
</span><span class="cx">     UIProcess/gtk/GestureController.cpp
</span><span class="cx">     UIProcess/gtk/InputMethodFilter.cpp
</span><span class="cx">     UIProcess/gtk/KeyBindingTranslator.cpp
</span><del>-    UIProcess/gtk/RedirectedXCompositeWindow.cpp
</del><span class="cx">     UIProcess/gtk/TextCheckerGtk.cpp
</span><ins>+    UIProcess/gtk/XDamageNotifier.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,6 +350,7 @@
</span><span class="cx">     WebProcess/WebPage/gstreamer/WebPageGStreamer.cpp
</span><span class="cx"> 
</span><span class="cx">     WebProcess/WebPage/gtk/PrinterListGtk.cpp
</span><ins>+    WebProcess/WebPage/gtk/RedirectedXCompositeWindow.cpp
</ins><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></pre></div>
<a id="trunkSourceWebKit2SharedCoordinatedGraphicsthreadedcompositorThreadedCompositorcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/Shared/CoordinatedGraphics/threadedcompositor/ThreadedCompositor.cpp (204012 => 204013)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/Shared/CoordinatedGraphics/threadedcompositor/ThreadedCompositor.cpp        2016-08-02 06:00:17 UTC (rev 204012)
+++ trunk/Source/WebKit2/Shared/CoordinatedGraphics/threadedcompositor/ThreadedCompositor.cpp        2016-08-02 06:42:18 UTC (rev 204013)
</span><span class="lines">@@ -41,18 +41,20 @@
</span><span class="cx"> 
</span><span class="cx"> namespace WebKit {
</span><span class="cx"> 
</span><del>-Ref&lt;ThreadedCompositor&gt; ThreadedCompositor::create(Client* client)
</del><ins>+Ref&lt;ThreadedCompositor&gt; ThreadedCompositor::create(Client* client, uint64_t nativeSurfaceHandle)
</ins><span class="cx"> {
</span><del>-    return adoptRef(*new ThreadedCompositor(client));
</del><ins>+    return adoptRef(*new ThreadedCompositor(client, nativeSurfaceHandle));
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-ThreadedCompositor::ThreadedCompositor(Client* client)
</del><ins>+ThreadedCompositor::ThreadedCompositor(Client* client, uint64_t nativeSurfaceHandle)
</ins><span class="cx">     : m_client(client)
</span><ins>+    , m_nativeSurfaceHandle(nativeSurfaceHandle)
</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="cx">         m_scene = adoptRef(new CoordinatedGraphicsScene(this));
</span><span class="cx">         m_viewportController = std::make_unique&lt;SimpleViewportController&gt;(this);
</span><ins>+        m_scene-&gt;setActive(!!m_nativeSurfaceHandle);
</ins><span class="cx">     });
</span><span class="cx"> }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebKit2SharedCoordinatedGraphicsthreadedcompositorThreadedCompositorh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/Shared/CoordinatedGraphics/threadedcompositor/ThreadedCompositor.h (204012 => 204013)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/Shared/CoordinatedGraphics/threadedcompositor/ThreadedCompositor.h        2016-08-02 06:00:17 UTC (rev 204012)
+++ trunk/Source/WebKit2/Shared/CoordinatedGraphics/threadedcompositor/ThreadedCompositor.h        2016-08-02 06:42:18 UTC (rev 204013)
</span><span class="lines">@@ -57,7 +57,7 @@
</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*);
</del><ins>+    static Ref&lt;ThreadedCompositor&gt; create(Client*, uint64_t nativeSurfaceHandle = 0);
</ins><span class="cx">     virtual ~ThreadedCompositor();
</span><span class="cx"> 
</span><span class="cx">     void setNativeSurfaceHandleForCompositing(uint64_t);
</span><span class="lines">@@ -77,7 +77,7 @@
</span><span class="cx">     void forceRepaint();
</span><span class="cx"> 
</span><span class="cx"> private:
</span><del>-    ThreadedCompositor(Client*);
</del><ins>+    ThreadedCompositor(Client*, uint64_t nativeSurfaceHandle);
</ins><span class="cx"> 
</span><span class="cx">     // CoordinatedGraphicsSceneClient
</span><span class="cx">     void renderNextFrame() override;
</span><span class="lines">@@ -101,7 +101,7 @@
</span><span class="cx">     WebCore::IntSize m_viewportSize;
</span><span class="cx">     float m_deviceScaleFactor { 1 };
</span><span class="cx">     bool m_drawsBackground { true };
</span><del>-    uint64_t m_nativeSurfaceHandle { 0 };
</del><ins>+    uint64_t m_nativeSurfaceHandle;
</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="trunkSourceWebKit2UIProcessAPIgtkPageClientImplcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/API/gtk/PageClientImpl.cpp (204012 => 204013)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/API/gtk/PageClientImpl.cpp        2016-08-02 06:00:17 UTC (rev 204012)
+++ trunk/Source/WebKit2/UIProcess/API/gtk/PageClientImpl.cpp        2016-08-02 06:42:18 UTC (rev 204013)
</span><span class="lines">@@ -216,9 +216,9 @@
</span><span class="cx">     return WebColorPickerGtk::create(*page, color, rect);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void PageClientImpl::enterAcceleratedCompositingMode(const LayerTreeContext&amp;)
</del><ins>+void PageClientImpl::enterAcceleratedCompositingMode(const LayerTreeContext&amp; layerTreeContext)
</ins><span class="cx"> {
</span><del>-    webkitWebViewBaseEnterAcceleratedCompositingMode(WEBKIT_WEB_VIEW_BASE(m_viewWidget));
</del><ins>+    webkitWebViewBaseEnterAcceleratedCompositingMode(WEBKIT_WEB_VIEW_BASE(m_viewWidget), layerTreeContext);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void PageClientImpl::exitAcceleratedCompositingMode()
</span><span class="lines">@@ -226,16 +226,11 @@
</span><span class="cx">     webkitWebViewBaseExitAcceleratedCompositingMode(WEBKIT_WEB_VIEW_BASE(m_viewWidget));
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void PageClientImpl::willEnterAcceleratedCompositingMode()
</del><ins>+void PageClientImpl::updateAcceleratedCompositingMode(const LayerTreeContext&amp; layerTreeContext)
</ins><span class="cx"> {
</span><del>-    webkitWebViewBaseWillEnterAcceleratedCompositingMode(WEBKIT_WEB_VIEW_BASE(m_viewWidget));
</del><ins>+    webkitWebViewBaseUpdateAcceleratedCompositingMode(WEBKIT_WEB_VIEW_BASE(m_viewWidget), layerTreeContext);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-void PageClientImpl::updateAcceleratedCompositingMode(const LayerTreeContext&amp;)
-{
-    notImplemented();
-}
-
</del><span class="cx"> void PageClientImpl::pageClosed()
</span><span class="cx"> {
</span><span class="cx">     webkitWebViewBasePageClosed(WEBKIT_WEB_VIEW_BASE(m_viewWidget));
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessAPIgtkPageClientImplh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/API/gtk/PageClientImpl.h (204012 => 204013)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/API/gtk/PageClientImpl.h        2016-08-02 06:00:17 UTC (rev 204012)
+++ trunk/Source/WebKit2/UIProcess/API/gtk/PageClientImpl.h        2016-08-02 06:42:18 UTC (rev 204013)
</span><span class="lines">@@ -92,7 +92,6 @@
</span><span class="cx">     void enterAcceleratedCompositingMode(const LayerTreeContext&amp;) override;
</span><span class="cx">     void exitAcceleratedCompositingMode() override;
</span><span class="cx">     void updateAcceleratedCompositingMode(const LayerTreeContext&amp;) override;
</span><del>-    void willEnterAcceleratedCompositingMode() override;
</del><span class="cx"> 
</span><span class="cx">     void handleDownloadRequest(DownloadProxy*) override;
</span><span class="cx">     void didChangeContentSize(const WebCore::IntSize&amp;) override;
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessAPIgtkWebKitWebViewBasecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewBase.cpp (204012 => 204013)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewBase.cpp        2016-08-02 06:00:17 UTC (rev 204012)
+++ trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewBase.cpp        2016-08-02 06:42:18 UTC (rev 204013)
</span><span class="lines">@@ -37,7 +37,6 @@
</span><span class="cx"> #include &quot;NativeWebMouseEvent.h&quot;
</span><span class="cx"> #include &quot;NativeWebWheelEvent.h&quot;
</span><span class="cx"> #include &quot;PageClientImpl.h&quot;
</span><del>-#include &quot;RedirectedXCompositeWindow.h&quot;
</del><span class="cx"> #include &quot;ViewState.h&quot;
</span><span class="cx"> #include &quot;WebEventFactory.h&quot;
</span><span class="cx"> #include &quot;WebFullScreenClientGtk.h&quot;
</span><span class="lines">@@ -73,6 +72,15 @@
</span><span class="cx"> #include &quot;WebFullScreenManagerProxy.h&quot;
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><ins>+#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
+
</ins><span class="cx"> #if PLATFORM(X11)
</span><span class="cx"> #include &lt;gdk/gdkx.h&gt;
</span><span class="cx"> #endif
</span><span class="lines">@@ -151,9 +159,6 @@
</span><span class="cx"> struct _WebKitWebViewBasePrivate {
</span><span class="cx">     _WebKitWebViewBasePrivate()
</span><span class="cx">         : updateViewStateTimer(RunLoop::main(), this, &amp;_WebKitWebViewBasePrivate::updateViewStateTimerFired)
</span><del>-#if USE(REDIRECTED_XCOMPOSITE_WINDOW)
-        , clearRedirectedWindowSoonTimer(RunLoop::main(), this, &amp;_WebKitWebViewBasePrivate::clearRedirectedWindowSoonTimerFired)
-#endif
</del><span class="cx">     {
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="lines">@@ -165,14 +170,6 @@
</span><span class="cx">         viewStateFlagsToUpdate = ViewState::NoFlags;
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-#if USE(REDIRECTED_XCOMPOSITE_WINDOW)
-    void clearRedirectedWindowSoonTimerFired()
-    {
-        if (redirectedWindow)
-            redirectedWindow-&gt;resize(IntSize());
-    }
-#endif
-
</del><span class="cx">     WebKitWebViewChildrenMap children;
</span><span class="cx">     std::unique_ptr&lt;PageClientImpl&gt; pageClient;
</span><span class="cx">     RefPtr&lt;WebPageProxy&gt; pageProxy;
</span><span class="lines">@@ -215,8 +212,8 @@
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="cx"> #if USE(REDIRECTED_XCOMPOSITE_WINDOW)
</span><del>-    std::unique_ptr&lt;RedirectedXCompositeWindow&gt; redirectedWindow;
-    RunLoop::Timer&lt;WebKitWebViewBasePrivate&gt; clearRedirectedWindowSoonTimer;
</del><ins>+    RefPtr&lt;cairo_surface_t&gt; acceleratedCompositingSurface;
+    XUniqueDamage acceleratedCompositingSurfaceDamage;
</ins><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="cx"> #if ENABLE(DRAG_SUPPORT)
</span><span class="lines">@@ -355,13 +352,46 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> #if USE(REDIRECTED_XCOMPOSITE_WINDOW)
</span><del>-static void webkitWebViewBaseResizeRedirectedWindow(WebKitWebViewBase* webView)
</del><ins>+static void webkitWebViewBaseSetAcceleratedCompositingPixmap(WebKitWebViewBase* webView, Pixmap pixmap)
</ins><span class="cx"> {
</span><ins>+    if (PlatformDisplay::sharedDisplay().type() != PlatformDisplay::Type::X11)
+        return;
+
</ins><span class="cx">     WebKitWebViewBasePrivate* priv = webView-&gt;priv;
</span><ins>+    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;
+
</ins><span class="cx">     DrawingAreaProxyImpl* drawingArea = static_cast&lt;DrawingAreaProxyImpl*&gt;(priv-&gt;pageProxy-&gt;drawingArea());
</span><span class="cx">     if (!drawingArea)
</span><span class="cx">         return;
</span><del>-    priv-&gt;redirectedWindow-&gt;resize(drawingArea-&gt;size());
</del><ins>+
+    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));
+    });
</ins><span class="cx"> }
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="lines">@@ -370,26 +400,6 @@
</span><span class="cx">     WebKitWebViewBase* webView = WEBKIT_WEB_VIEW_BASE(widget);
</span><span class="cx">     WebKitWebViewBasePrivate* priv = webView-&gt;priv;
</span><span class="cx"> 
</span><del>-#if USE(REDIRECTED_XCOMPOSITE_WINDOW)
-    if (PlatformDisplay::sharedDisplay().type() == PlatformDisplay::Type::X11) {
-        ASSERT(!priv-&gt;redirectedWindow);
-        DrawingAreaProxyImpl* drawingArea = static_cast&lt;DrawingAreaProxyImpl*&gt;(priv-&gt;pageProxy-&gt;drawingArea());
-        priv-&gt;redirectedWindow = RedirectedXCompositeWindow::create(
-            *priv-&gt;pageProxy,
-            drawingArea &amp;&amp; drawingArea-&gt;isInAcceleratedCompositingMode() ? drawingArea-&gt;size() : IntSize(),
-            [webView] {
-                DrawingAreaProxyImpl* drawingArea = static_cast&lt;DrawingAreaProxyImpl*&gt;(webView-&gt;priv-&gt;pageProxy-&gt;drawingArea());
-                if (drawingArea &amp;&amp; drawingArea-&gt;isInAcceleratedCompositingMode())
-                    gtk_widget_queue_draw(GTK_WIDGET(webView));
-            });
-        if (priv-&gt;redirectedWindow &amp;&amp; drawingArea) {
-            drawingArea-&gt;setNativeSurfaceHandleForCompositing(priv-&gt;redirectedWindow-&gt;windowID());
-            if (drawingArea-&gt;isInAcceleratedCompositingMode())
-                webkitWebViewBaseResizeRedirectedWindow(webView);
-        }
-    }
-#endif
-
</del><span class="cx">     gtk_widget_set_realized(widget, TRUE);
</span><span class="cx"> 
</span><span class="cx">     GtkAllocation allocation;
</span><span class="lines">@@ -439,13 +449,10 @@
</span><span class="cx"> static void webkitWebViewBaseUnrealize(GtkWidget* widget)
</span><span class="cx"> {
</span><span class="cx">     WebKitWebViewBase* webView = WEBKIT_WEB_VIEW_BASE(widget);
</span><del>-#if USE(TEXTURE_MAPPER) &amp;&amp; PLATFORM(X11)
</del><ins>+#if USE(TEXTURE_MAPPER) &amp;&amp; PLATFORM(X11) &amp;&amp; !USE(REDIRECTED_XCOMPOSITE_WINDOW)
</ins><span class="cx">     if (DrawingAreaProxyImpl* drawingArea = static_cast&lt;DrawingAreaProxyImpl*&gt;(webView-&gt;priv-&gt;pageProxy-&gt;drawingArea()))
</span><span class="cx">         drawingArea-&gt;destroyNativeSurfaceHandleForCompositing();
</span><span class="cx"> #endif
</span><del>-#if USE(REDIRECTED_XCOMPOSITE_WINDOW)
-    webView-&gt;priv-&gt;redirectedWindow = nullptr;
-#endif
</del><span class="cx">     gtk_im_context_set_client_window(webView-&gt;priv-&gt;inputMethodFilter.context(), nullptr);
</span><span class="cx"> 
</span><span class="cx">     GTK_WIDGET_CLASS(webkit_web_view_base_parent_class)-&gt;unrealize(widget);
</span><span class="lines">@@ -557,6 +564,9 @@
</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><ins>+#if USE(REDIRECTED_XCOMPOSITE_WINDOW)
+    webkitWebViewBaseSetAcceleratedCompositingPixmap(webView, 0);
+#endif
</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">@@ -577,38 +587,33 @@
</span><span class="cx"> 
</span><span class="cx"> static bool webkitWebViewRenderAcceleratedCompositingResults(WebKitWebViewBase* webViewBase, DrawingAreaProxyImpl* drawingArea, cairo_t* cr, GdkRectangle* clipRect)
</span><span class="cx"> {
</span><del>-#if USE(TEXTURE_MAPPER) &amp;&amp; USE(REDIRECTED_XCOMPOSITE_WINDOW)
</del><ins>+#if USE(REDIRECTED_XCOMPOSITE_WINDOW)
</ins><span class="cx">     ASSERT(drawingArea);
</span><span class="cx"> 
</span><span class="cx">     if (!drawingArea-&gt;isInAcceleratedCompositingMode())
</span><span class="cx">         return false;
</span><span class="cx"> 
</span><del>-    // To avoid flashes when initializing accelerated compositing for the first
-    // time, we wait until we know there's a frame ready before rendering.
-    WebKitWebViewBasePrivate* priv = webViewBase-&gt;priv;
-    if (!priv-&gt;redirectedWindow)
-        return false;
</del><ins>+    WebKitWebViewBasePrivate* priv = WEBKIT_WEB_VIEW_BASE(webViewBase)-&gt;priv;
+    cairo_surface_t* surface = priv-&gt;acceleratedCompositingSurface.get();
+    cairo_save(cr);
</ins><span class="cx"> 
</span><del>-    webkitWebViewBaseResizeRedirectedWindow(webViewBase);
-    if (cairo_surface_t* surface = priv-&gt;redirectedWindow-&gt;surface()) {
-        cairo_save(cr);
</del><ins>+    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);
+        }
</ins><span class="cx"> 
</span><del>-        if (!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);
-            }
</del><ins>+        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);
</ins><span class="cx">         }
</span><ins>+    }
</ins><span class="cx"> 
</span><ins>+    if (surface) {
</ins><span class="cx">         // The surface can be modified by the web process at any time, so we mark it
</span><span class="cx">         // as dirty to ensure we always render the updated contents as soon as possible.
</span><span class="cx">         cairo_surface_mark_dirty(surface);
</span><span class="lines">@@ -616,10 +621,10 @@
</span><span class="cx">         cairo_set_source_surface(cr, surface, 0, 0);
</span><span class="cx">         cairo_set_operator(cr, CAIRO_OPERATOR_OVER);
</span><span class="cx">         cairo_fill(cr);
</span><del>-
-        cairo_restore(cr);
</del><span class="cx">     }
</span><span class="cx"> 
</span><ins>+    cairo_restore(cr);
+
</ins><span class="cx">     return true;
</span><span class="cx"> #else
</span><span class="cx">     UNUSED_PARAM(webViewBase);
</span><span class="lines">@@ -717,22 +722,8 @@
</span><span class="cx">         gtk_widget_size_allocate(priv-&gt;authenticationDialog, &amp;childAllocation);
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    DrawingAreaProxyImpl* drawingArea = static_cast&lt;DrawingAreaProxyImpl*&gt;(priv-&gt;pageProxy-&gt;drawingArea());
-    if (!drawingArea)
-        return;
-
-
-#if USE(REDIRECTED_XCOMPOSITE_WINDOW)
-    if (priv-&gt;redirectedWindow &amp;&amp; drawingArea-&gt;isInAcceleratedCompositingMode()) {
-        // We don't use webkitWebViewBaseResizeRedirectedWindow here, because we want to update the
-        // redirected window size before the drawing area, because on resize the drawing area sends
-        // the UpdateBackingStoreState message to the web process and waits for its reply. We want
-        // the web process to use the new xwindow size when UpdateBackingStoreState message arrives.
-        priv-&gt;redirectedWindow-&gt;resize(viewRect.size());
-    }
-#endif
-
-    drawingArea-&gt;setSize(viewRect.size(), IntSize(), IntSize());
</del><ins>+    if (DrawingAreaProxyImpl* drawingArea = static_cast&lt;DrawingAreaProxyImpl*&gt;(priv-&gt;pageProxy-&gt;drawingArea()))
+        drawingArea-&gt;setSize(viewRect.size(), IntSize(), IntSize());
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> static void webkitWebViewBaseGetPreferredWidth(GtkWidget* widget, gint* minimumSize, gint* naturalSize)
</span><span class="lines">@@ -1284,10 +1275,6 @@
</span><span class="cx"> #if HAVE(GTK_SCALE_FACTOR)
</span><span class="cx"> static void deviceScaleFactorChanged(WebKitWebViewBase* webkitWebViewBase)
</span><span class="cx"> {
</span><del>-#if USE(REDIRECTED_XCOMPOSITE_WINDOW)
-    if (webkitWebViewBase-&gt;priv-&gt;redirectedWindow)
-        webkitWebViewBaseResizeRedirectedWindow(webkitWebViewBase);
-#endif
</del><span class="cx">     webkitWebViewBase-&gt;priv-&gt;pageProxy-&gt;setIntrinsicDeviceScaleFactor(gtk_widget_get_scale_factor(GTK_WIDGET(webkitWebViewBase)));
</span><span class="cx"> }
</span><span class="cx"> #endif // HAVE(GTK_SCALE_FACTOR)
</span><span class="lines">@@ -1577,37 +1564,19 @@
</span><span class="cx">     webkitWebViewBase-&gt;priv-&gt;clickCounter.reset();
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-#if USE(REDIRECTED_XCOMPOSITE_WINDOW)
-static void webkitWebViewBaseClearRedirectedWindowSoon(WebKitWebViewBase* webkitWebViewBase)
</del><ins>+void webkitWebViewBaseEnterAcceleratedCompositingMode(WebKitWebViewBase* webkitWebViewBase, const LayerTreeContext&amp; layerTreeContext)
</ins><span class="cx"> {
</span><del>-    static const double clearRedirectedWindowSoonDelay = 2;
-    webkitWebViewBase-&gt;priv-&gt;clearRedirectedWindowSoonTimer.startOneShot(clearRedirectedWindowSoonDelay);
-}
-#endif
-
-void webkitWebViewBaseWillEnterAcceleratedCompositingMode(WebKitWebViewBase* webkitWebViewBase)
-{
</del><span class="cx"> #if USE(REDIRECTED_XCOMPOSITE_WINDOW)
</span><del>-    WebKitWebViewBasePrivate* priv = webkitWebViewBase-&gt;priv;
-    if (!priv-&gt;redirectedWindow)
-        return;
-    DrawingAreaProxyImpl* drawingArea = static_cast&lt;DrawingAreaProxyImpl*&gt;(priv-&gt;pageProxy-&gt;drawingArea());
-    if (!drawingArea)
-        return;
-
-    webkitWebViewBaseResizeRedirectedWindow(webkitWebViewBase);
-
-    // Clear the redirected window if we don't enter AC mode in the end.
-    webkitWebViewBaseClearRedirectedWindowSoon(webkitWebViewBase);
</del><ins>+    webkitWebViewBaseSetAcceleratedCompositingPixmap(webkitWebViewBase, layerTreeContext.contextID);
</ins><span class="cx"> #else
</span><span class="cx">     UNUSED_PARAM(webkitWebViewBase);
</span><span class="cx"> #endif
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void webkitWebViewBaseEnterAcceleratedCompositingMode(WebKitWebViewBase* webkitWebViewBase)
</del><ins>+void webkitWebViewBaseUpdateAcceleratedCompositingMode(WebKitWebViewBase* webkitWebViewBase, const LayerTreeContext&amp; layerTreeContext)
</ins><span class="cx"> {
</span><span class="cx"> #if USE(REDIRECTED_XCOMPOSITE_WINDOW)
</span><del>-    webkitWebViewBase-&gt;priv-&gt;clearRedirectedWindowSoonTimer.stop();
</del><ins>+    webkitWebViewBaseSetAcceleratedCompositingPixmap(webkitWebViewBase, layerTreeContext.contextID);
</ins><span class="cx"> #else
</span><span class="cx">     UNUSED_PARAM(webkitWebViewBase);
</span><span class="cx"> #endif
</span><span class="lines">@@ -1616,10 +1585,7 @@
</span><span class="cx"> void webkitWebViewBaseExitAcceleratedCompositingMode(WebKitWebViewBase* webkitWebViewBase)
</span><span class="cx"> {
</span><span class="cx"> #if USE(REDIRECTED_XCOMPOSITE_WINDOW)
</span><del>-    // Resize the window later to ensure we have already rendered the
-    // non composited contents and avoid flickering. We can also avoid the
-    // window resize entirely if we switch back to AC mode quickly.
-    webkitWebViewBaseClearRedirectedWindowSoon(webkitWebViewBase);
</del><ins>+    webkitWebViewBaseSetAcceleratedCompositingPixmap(webkitWebViewBase, 0);
</ins><span class="cx"> #else
</span><span class="cx">     UNUSED_PARAM(webkitWebViewBase);
</span><span class="cx"> #endif
</span><span class="lines">@@ -1630,7 +1596,7 @@
</span><span class="cx">     // Queue a resize to ensure the new DrawingAreaProxy is resized.
</span><span class="cx">     gtk_widget_queue_resize_no_redraw(GTK_WIDGET(webkitWebViewBase));
</span><span class="cx"> 
</span><del>-#if PLATFORM(X11) &amp;&amp; USE(TEXTURE_MAPPER)
</del><ins>+#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 class="lines">@@ -1637,15 +1603,11 @@
</span><span class="cx">     WebKitWebViewBasePrivate* priv = webkitWebViewBase-&gt;priv;
</span><span class="cx">     DrawingAreaProxyImpl* drawingArea = static_cast&lt;DrawingAreaProxyImpl*&gt;(priv-&gt;pageProxy-&gt;drawingArea());
</span><span class="cx">     ASSERT(drawingArea);
</span><del>-#if USE(REDIRECTED_XCOMPOSITE_WINDOW)
-    if (!priv-&gt;redirectedWindow)
-        return;
-    uint64_t windowID = priv-&gt;redirectedWindow-&gt;windowID();
-#else
</del><ins>+
</ins><span class="cx">     if (!gtk_widget_get_realized(GTK_WIDGET(webkitWebViewBase)))
</span><span class="cx">         return;
</span><ins>+
</ins><span class="cx">     uint64_t windowID = GDK_WINDOW_XID(gtk_widget_get_window(GTK_WIDGET(webkitWebViewBase)));
</span><del>-#endif
</del><span class="cx">     drawingArea-&gt;setNativeSurfaceHandleForCompositing(windowID);
</span><span class="cx"> #else
</span><span class="cx">     UNUSED_PARAM(webkitWebViewBase);
</span><span class="lines">@@ -1654,7 +1616,9 @@
</span><span class="cx"> 
</span><span class="cx"> void webkitWebViewBasePageClosed(WebKitWebViewBase* webkitWebViewBase)
</span><span class="cx"> {
</span><del>-#if PLATFORM(X11) &amp;&amp; USE(TEXTURE_MAPPER)
</del><ins>+#if USE(REDIRECTED_XCOMPOSITE_WINDOW)
+    webkitWebViewBaseSetAcceleratedCompositingPixmap(webkitWebViewBase, 0);
+#elif PLATFORM(X11) &amp;&amp; USE(TEXTURE_MAPPER)
</ins><span class="cx">     if (PlatformDisplay::sharedDisplay().type() != PlatformDisplay::Type::X11)
</span><span class="cx">         return;
</span><span class="cx"> 
</span><span class="lines">@@ -1665,9 +1629,5 @@
</span><span class="cx">     DrawingAreaProxyImpl* drawingArea = static_cast&lt;DrawingAreaProxyImpl*&gt;(priv-&gt;pageProxy-&gt;drawingArea());
</span><span class="cx">     ASSERT(drawingArea);
</span><span class="cx">     drawingArea-&gt;destroyNativeSurfaceHandleForCompositing();
</span><del>-
-#if USE(REDIRECTED_XCOMPOSITE_WINDOW)
-    priv-&gt;redirectedWindow = nullptr;
</del><span class="cx"> #endif
</span><del>-#endif // PLATFORM(X11) &amp;&amp; USE(TEXTURE_MAPPER)
</del><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessAPIgtkWebKitWebViewBasePrivateh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewBasePrivate.h (204012 => 204013)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewBasePrivate.h        2016-08-02 06:00:17 UTC (rev 204012)
+++ trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewBasePrivate.h        2016-08-02 06:42:18 UTC (rev 204013)
</span><span class="lines">@@ -71,8 +71,8 @@
</span><span class="cx"> void webkitWebViewBaseCancelAuthenticationDialog(WebKitWebViewBase*);
</span><span class="cx"> void webkitWebViewBaseAddWebInspector(WebKitWebViewBase*, GtkWidget* inspector, WebKit::AttachmentSide);
</span><span class="cx"> void webkitWebViewBaseResetClickCounter(WebKitWebViewBase*);
</span><del>-void webkitWebViewBaseWillEnterAcceleratedCompositingMode(WebKitWebViewBase*);
-void webkitWebViewBaseEnterAcceleratedCompositingMode(WebKitWebViewBase*);
</del><ins>+void webkitWebViewBaseEnterAcceleratedCompositingMode(WebKitWebViewBase*, const WebKit::LayerTreeContext&amp;);
+void webkitWebViewBaseUpdateAcceleratedCompositingMode(WebKitWebViewBase*, const WebKit::LayerTreeContext&amp;);
</ins><span class="cx"> void webkitWebViewBaseExitAcceleratedCompositingMode(WebKitWebViewBase*);
</span><span class="cx"> void webkitWebViewBaseDidRelaunchWebProcess(WebKitWebViewBase*);
</span><span class="cx"> void webkitWebViewBasePageClosed(WebKitWebViewBase*);
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessDrawingAreaProxyh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/DrawingAreaProxy.h (204012 => 204013)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/DrawingAreaProxy.h        2016-08-02 06:00:17 UTC (rev 204012)
+++ trunk/Source/WebKit2/UIProcess/DrawingAreaProxy.h        2016-08-02 06:42:18 UTC (rev 204013)
</span><span class="lines">@@ -130,7 +130,6 @@
</span><span class="cx">     virtual void enterAcceleratedCompositingMode(uint64_t /* backingStoreStateID */, const LayerTreeContext&amp;) { }
</span><span class="cx">     virtual void exitAcceleratedCompositingMode(uint64_t /* backingStoreStateID */, const UpdateInfo&amp;) { }
</span><span class="cx">     virtual void updateAcceleratedCompositingMode(uint64_t /* backingStoreStateID */, const LayerTreeContext&amp;) { }
</span><del>-    virtual void willEnterAcceleratedCompositingMode(uint64_t /* backingStoreStateID */) { }
</del><span class="cx"> #if PLATFORM(COCOA)
</span><span class="cx">     virtual void didUpdateGeometry() { }
</span><span class="cx">     virtual void intrinsicContentSizeDidChange(const WebCore::IntSize&amp;) { }
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessDrawingAreaProxymessagesin"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/DrawingAreaProxy.messages.in (204012 => 204013)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/DrawingAreaProxy.messages.in        2016-08-02 06:00:17 UTC (rev 204012)
+++ trunk/Source/WebKit2/UIProcess/DrawingAreaProxy.messages.in        2016-08-02 06:42:18 UTC (rev 204013)
</span><span class="lines">@@ -26,7 +26,6 @@
</span><span class="cx">     EnterAcceleratedCompositingMode(uint64_t backingStoreStateID, WebKit::LayerTreeContext context)
</span><span class="cx">     ExitAcceleratedCompositingMode(uint64_t backingStoreStateID, WebKit::UpdateInfo updateInfo)
</span><span class="cx">     UpdateAcceleratedCompositingMode(uint64_t backingStoreStateID, WebKit::LayerTreeContext context)
</span><del>-    WillEnterAcceleratedCompositingMode(uint64_t backingStoreStateID)
</del><span class="cx"> 
</span><span class="cx"> #if PLATFORM(COCOA)
</span><span class="cx">     // Used by TiledCoreAnimationDrawingAreaProxy.
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessDrawingAreaProxyImplcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/DrawingAreaProxyImpl.cpp (204012 => 204013)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/DrawingAreaProxyImpl.cpp        2016-08-02 06:00:17 UTC (rev 204012)
+++ trunk/Source/WebKit2/UIProcess/DrawingAreaProxyImpl.cpp        2016-08-02 06:42:18 UTC (rev 204013)
</span><span class="lines">@@ -157,15 +157,16 @@
</span><span class="cx">     m_webPageProxy.process().responsivenessTimer().stop();
</span><span class="cx"> 
</span><span class="cx">     if (layerTreeContext != m_layerTreeContext) {
</span><del>-        if (!m_layerTreeContext.isEmpty()) {
</del><ins>+        if (layerTreeContext.isEmpty() &amp;&amp; !m_layerTreeContext.isEmpty()) {
</ins><span class="cx">             exitAcceleratedCompositingMode();
</span><span class="cx">             ASSERT(m_layerTreeContext.isEmpty());
</span><del>-        }
-
-        if (!layerTreeContext.isEmpty()) {
</del><ins>+        } else if (!layerTreeContext.isEmpty() &amp;&amp; m_layerTreeContext.isEmpty()) {
</ins><span class="cx">             enterAcceleratedCompositingMode(layerTreeContext);
</span><span class="cx">             ASSERT(layerTreeContext == m_layerTreeContext);
</span><del>-        }            
</del><ins>+        } else {
+            updateAcceleratedCompositingMode(layerTreeContext);
+            ASSERT(layerTreeContext == m_layerTreeContext);
+        }
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     if (m_nextBackingStoreStateID != m_currentBackingStoreStateID)
</span><span class="lines">@@ -173,7 +174,7 @@
</span><span class="cx">     else {
</span><span class="cx">         m_hasReceivedFirstUpdate = true;
</span><span class="cx"> 
</span><del>-#if USE(TEXTURE_MAPPER) &amp;&amp; PLATFORM(GTK)
</del><ins>+#if USE(TEXTURE_MAPPER) &amp;&amp; PLATFORM(GTK) &amp;&amp; !USE(REDIRECTED_XCOMPOSITE_WINDOW)
</ins><span class="cx">         if (m_pendingNativeSurfaceHandleForCompositing) {
</span><span class="cx">             setNativeSurfaceHandleForCompositing(m_pendingNativeSurfaceHandleForCompositing);
</span><span class="cx">             m_pendingNativeSurfaceHandleForCompositing = 0;
</span><span class="lines">@@ -221,15 +222,6 @@
</span><span class="cx">     updateAcceleratedCompositingMode(layerTreeContext);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void DrawingAreaProxyImpl::willEnterAcceleratedCompositingMode(uint64_t backingStoreStateID)
-{
-    // WillEnterAcceleratedCompositingMode message is sent when the LayerTreeHost is created in the Web Process.
-    // This can happen while there's still a DidUpdateBackingStoreState pending, in which case we are receiving
-    // here the new backingStoreStateID, but m_currentBackingStoreStateID hasn't been updated yet.
-    ASSERT_ARG(backingStoreStateID, backingStoreStateID &lt;= m_nextBackingStoreStateID);
-    m_webPageProxy.willEnterAcceleratedCompositingMode();
-}
-
</del><span class="cx"> void DrawingAreaProxyImpl::incorporateUpdate(const UpdateInfo&amp; updateInfo)
</span><span class="cx"> {
</span><span class="cx">     ASSERT(!isInAcceleratedCompositingMode());
</span><span class="lines">@@ -315,7 +307,7 @@
</span><span class="cx">     m_webPageProxy.enterAcceleratedCompositingMode(layerTreeContext);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-#if USE(TEXTURE_MAPPER) &amp;&amp; PLATFORM(GTK)
</del><ins>+#if USE(TEXTURE_MAPPER) &amp;&amp; PLATFORM(GTK) &amp;&amp; !USE(REDIRECTED_XCOMPOSITE_WINDOW)
</ins><span class="cx"> void DrawingAreaProxyImpl::setNativeSurfaceHandleForCompositing(uint64_t handle)
</span><span class="cx"> {
</span><span class="cx">     if (!m_hasReceivedFirstUpdate) {
</span><span class="lines">@@ -351,8 +343,7 @@
</span><span class="cx">     ASSERT(isInAcceleratedCompositingMode());
</span><span class="cx"> 
</span><span class="cx">     m_layerTreeContext = LayerTreeContext();
</span><del>-    if (!alwaysUseCompositing())
-        m_webPageProxy.exitAcceleratedCompositingMode();
</del><ins>+    m_webPageProxy.exitAcceleratedCompositingMode();
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void DrawingAreaProxyImpl::updateAcceleratedCompositingMode(const LayerTreeContext&amp; layerTreeContext)
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessDrawingAreaProxyImplh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/DrawingAreaProxyImpl.h (204012 => 204013)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/DrawingAreaProxyImpl.h        2016-08-02 06:00:17 UTC (rev 204012)
+++ trunk/Source/WebKit2/UIProcess/DrawingAreaProxyImpl.h        2016-08-02 06:42:18 UTC (rev 204013)
</span><span class="lines">@@ -48,7 +48,7 @@
</span><span class="cx"> 
</span><span class="cx">     bool hasReceivedFirstUpdate() const { return m_hasReceivedFirstUpdate; }
</span><span class="cx"> 
</span><del>-#if USE(TEXTURE_MAPPER) &amp;&amp; PLATFORM(GTK)
</del><ins>+#if USE(TEXTURE_MAPPER) &amp;&amp; PLATFORM(GTK) &amp;&amp; !USE(REDIRECTED_XCOMPOSITE_WINDOW)
</ins><span class="cx">     void setNativeSurfaceHandleForCompositing(uint64_t);
</span><span class="cx">     void destroyNativeSurfaceHandleForCompositing();
</span><span class="cx"> #endif
</span><span class="lines">@@ -69,7 +69,6 @@
</span><span class="cx">     void enterAcceleratedCompositingMode(uint64_t backingStoreStateID, const LayerTreeContext&amp;) override;
</span><span class="cx">     void exitAcceleratedCompositingMode(uint64_t backingStoreStateID, const UpdateInfo&amp;) override;
</span><span class="cx">     void updateAcceleratedCompositingMode(uint64_t backingStoreStateID, const LayerTreeContext&amp;) override;
</span><del>-    void willEnterAcceleratedCompositingMode(uint64_t backingStoreStateID) override;
</del><span class="cx"> 
</span><span class="cx">     void incorporateUpdate(const UpdateInfo&amp;);
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessPageClienth"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/PageClient.h (204012 => 204013)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/PageClient.h        2016-08-02 06:00:17 UTC (rev 204012)
+++ trunk/Source/WebKit2/UIProcess/PageClient.h        2016-08-02 06:42:18 UTC (rev 204013)
</span><span class="lines">@@ -235,7 +235,6 @@
</span><span class="cx">     virtual void enterAcceleratedCompositingMode(const LayerTreeContext&amp;) = 0;
</span><span class="cx">     virtual void exitAcceleratedCompositingMode() = 0;
</span><span class="cx">     virtual void updateAcceleratedCompositingMode(const LayerTreeContext&amp;) = 0;
</span><del>-    virtual void willEnterAcceleratedCompositingMode() = 0;
</del><span class="cx"> 
</span><span class="cx"> #if PLATFORM(MAC)
</span><span class="cx">     virtual void pluginFocusOrWindowFocusChanged(uint64_t pluginComplexTextInputIdentifier, bool pluginHasFocusAndWindowHasFocus) = 0;
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessWebPageProxycpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp (204012 => 204013)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp        2016-08-02 06:00:17 UTC (rev 204012)
+++ trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp        2016-08-02 06:42:18 UTC (rev 204013)
</span><span class="lines">@@ -5465,11 +5465,6 @@
</span><span class="cx">     m_pageClient.updateAcceleratedCompositingMode(layerTreeContext);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void WebPageProxy::willEnterAcceleratedCompositingMode()
-{
-    m_pageClient.willEnterAcceleratedCompositingMode();
-}
-
</del><span class="cx"> void WebPageProxy::backForwardClear()
</span><span class="cx"> {
</span><span class="cx">     m_backForwardList-&gt;clear();
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessWebPageProxyh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/WebPageProxy.h (204012 => 204013)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/WebPageProxy.h        2016-08-02 06:00:17 UTC (rev 204012)
+++ trunk/Source/WebKit2/UIProcess/WebPageProxy.h        2016-08-02 06:42:18 UTC (rev 204013)
</span><span class="lines">@@ -824,7 +824,6 @@
</span><span class="cx">     virtual void enterAcceleratedCompositingMode(const LayerTreeContext&amp;);
</span><span class="cx">     virtual void exitAcceleratedCompositingMode();
</span><span class="cx">     virtual void updateAcceleratedCompositingMode(const LayerTreeContext&amp;);
</span><del>-    void willEnterAcceleratedCompositingMode();
</del><span class="cx"> 
</span><span class="cx">     enum UndoOrRedo { Undo, Redo };
</span><span class="cx">     void addEditCommand(WebEditCommandProxy*);
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcesseflWebViewh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/efl/WebView.h (204012 => 204013)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/efl/WebView.h        2016-08-02 06:00:17 UTC (rev 204012)
+++ trunk/Source/WebKit2/UIProcess/efl/WebView.h        2016-08-02 06:42:18 UTC (rev 204013)
</span><span class="lines">@@ -221,7 +221,6 @@
</span><span class="cx">     void enterAcceleratedCompositingMode(const LayerTreeContext&amp;) override;
</span><span class="cx">     void exitAcceleratedCompositingMode() override;
</span><span class="cx">     void updateAcceleratedCompositingMode(const LayerTreeContext&amp;) override;
</span><del>-    void willEnterAcceleratedCompositingMode() override { }
</del><span class="cx"> 
</span><span class="cx"> #if ENABLE(FULLSCREEN_API)
</span><span class="cx">     WebFullScreenManagerProxyClient&amp; fullScreenManagerProxyClient() override;
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessgtkRedirectedXCompositeWindowcpp"></a>
<div class="delfile"><h4>Deleted: trunk/Source/WebKit2/UIProcess/gtk/RedirectedXCompositeWindow.cpp (204012 => 204013)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/gtk/RedirectedXCompositeWindow.cpp        2016-08-02 06:00:17 UTC (rev 204012)
+++ trunk/Source/WebKit2/UIProcess/gtk/RedirectedXCompositeWindow.cpp        2016-08-02 06:42:18 UTC (rev 204013)
</span><span class="lines">@@ -1,292 +0,0 @@
</span><del>-/*
- * Copyright (C) 2012,2014 Igalia S.L.
- * All rights reserved.
- *
- * 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;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/Xcomposite.h&gt;
-#include &lt;X11/extensions/Xdamage.h&gt;
-#include &lt;cairo-xlib.h&gt;
-#include &lt;gdk/gdkx.h&gt;
-#include &lt;glib.h&gt;
-#include &lt;gtk/gtk.h&gt;
-#include &lt;wtf/HashMap.h&gt;
-#include &lt;wtf/NeverDestroyed.h&gt;
-
-using namespace WebCore;
-
-namespace WebKit {
-
-class XDamageNotifier {
-    WTF_MAKE_NONCOPYABLE(XDamageNotifier);
-    WTF_MAKE_FAST_ALLOCATED;
-public:
-    static int s_damageEventBase;
-
-    XDamageNotifier()
-    {
-    }
-
-    void add(Window window, 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(window, WTFMove(notifyFunction));
-    }
-
-    void remove(Window window)
-    {
-        m_notifyFunctions.remove(window);
-        if (m_notifyFunctions.isEmpty())
-            gdk_window_remove_filter(nullptr, reinterpret_cast&lt;GdkFilterFunc&gt;(&amp;filterXDamageEvent), this);
-    }
-
-private:
-    static GdkFilterReturn filterXDamageEvent(GdkXEvent* event, GdkEvent*, XDamageNotifier* notifier)
-    {
-        return notifier-&gt;filterXEvent(static_cast&lt;XEvent*&gt;(event));
-    }
-
-    GdkFilterReturn filterXEvent(XEvent* event) const
-    {
-        if (event-&gt;type != s_damageEventBase + XDamageNotify)
-            return GDK_FILTER_CONTINUE;
-
-        XDamageNotifyEvent* damageEvent = reinterpret_cast&lt;XDamageNotifyEvent*&gt;(event);
-        if (const auto&amp; notifyFunction = m_notifyFunctions.get(damageEvent-&gt;drawable)) {
-            notifyFunction();
-            XDamageSubtract(event-&gt;xany.display, damageEvent-&gt;damage, None, None);
-            return GDK_FILTER_REMOVE;
-        }
-
-        return GDK_FILTER_CONTINUE;
-    }
-
-    HashMap&lt;Window, std::function&lt;void()&gt;&gt; m_notifyFunctions;
-};
-
-int XDamageNotifier::s_damageEventBase = 0;
-
-static XDamageNotifier&amp; xDamageNotifier()
-{
-    static NeverDestroyed&lt;XDamageNotifier&gt; notifier;
-    return notifier;
-}
-
-static bool supportsXDamageAndXComposite(GdkWindow* window)
-{
-    static bool initialized = false;
-    static bool hasExtensions = false;
-
-    if (initialized)
-        return hasExtensions;
-
-    initialized = true;
-    Display* display = GDK_DISPLAY_XDISPLAY(gdk_window_get_display(window));
-
-    int errorBase;
-    if (!XDamageQueryExtension(display, &amp;XDamageNotifier::s_damageEventBase, &amp;errorBase))
-        return false;
-
-    int eventBase;
-    if (!XCompositeQueryExtension(display, &amp;eventBase, &amp;errorBase))
-        return false;
-
-    // We need to support XComposite version 0.2.
-    int major, minor;
-    XCompositeQueryVersion(display, &amp;major, &amp;minor);
-    if (major &lt; 0 || (!major &amp;&amp; minor &lt; 2))
-        return false;
-
-    hasExtensions = true;
-    return true;
-}
-
-std::unique_ptr&lt;RedirectedXCompositeWindow&gt; RedirectedXCompositeWindow::create(WebPageProxy&amp; webPage, const IntSize&amp; initialSize, std::function&lt;void()&gt;&amp;&amp; damageNotify)
-{
-    GdkWindow* parentWindow = gtk_widget_get_parent_window(webPage.viewWidget());
-    ASSERT(GDK_IS_WINDOW(parentWindow));
-    if (!supportsXDamageAndXComposite(parentWindow))
-        return nullptr;
-    return std::unique_ptr&lt;RedirectedXCompositeWindow&gt;(new RedirectedXCompositeWindow(webPage, initialSize, WTFMove(damageNotify)));
-}
-
-RedirectedXCompositeWindow::RedirectedXCompositeWindow(WebPageProxy&amp; webPage, const IntSize&amp; initialSize, std::function&lt;void()&gt;&amp;&amp; damageNotify)
-    : m_webPage(webPage)
-    , m_display(GDK_DISPLAY_XDISPLAY(gdk_window_get_display(gtk_widget_get_parent_window(webPage.viewWidget()))))
-    , m_size(initialSize)
-{
-    m_size.scale(m_webPage.deviceScaleFactor());
-
-    ASSERT(downcast&lt;PlatformDisplayX11&gt;(PlatformDisplay::sharedDisplay()).native() == m_display);
-    Screen* screen = DefaultScreenOfDisplay(m_display);
-
-    GdkVisual* visual = gdk_window_get_visual(gtk_widget_get_parent_window(webPage.viewWidget()));
-    XUniqueColormap colormap(XCreateColormap(m_display, RootWindowOfScreen(screen), GDK_VISUAL_XVISUAL(visual), AllocNone));
-
-    // This is based on code from Chromium: src/content/common/gpu/image_transport_surface_linux.cc
-    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),
-        WidthOfScreen(screen) + 1, 0, 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());
-
-    xDamageNotifier().add(m_window.get(), WTFMove(damageNotify));
-
-    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);
-    if (!m_size.isEmpty())
-        createNewPixampAndPixampSurface();
-    m_damage = XDamageCreate(m_display, m_window.get(), XDamageReportNonEmpty);
-}
-
-RedirectedXCompositeWindow::~RedirectedXCompositeWindow()
-{
-    ASSERT(m_display);
-    ASSERT(m_damage);
-    ASSERT(m_window);
-    ASSERT(m_parentWindow);
-
-    xDamageNotifier().remove(m_window.get());
-
-    // Explicitly reset these because we need to ensure it happens in this order.
-    m_damage.reset();
-    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;
-
-    // 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, scaledSize.width()), std::max(1, scaledSize.height()));
-    XFlush(m_display);
-
-    m_size = scaledSize;
-    if (m_size.isEmpty())
-        cleanupPixmapAndPixmapSurface();
-    else
-        createNewPixampAndPixampSurface();
-}
-
-void RedirectedXCompositeWindow::cleanupPixmapAndPixmapSurface()
-{
-    if (!m_pixmap)
-        return;
-
-    m_surface = nullptr;
-    m_pixmap.reset();
-}
-
-void RedirectedXCompositeWindow::createNewPixampAndPixampSurface()
-{
-    // This should never be called with an empty size (not in Accelerated Compositing mode).
-    ASSERT(!m_size.isEmpty());
-    XUniquePixmap newPixmap(XCompositeNameWindowPixmap(m_display, m_window.get()));
-    if (!newPixmap) {
-        cleanupPixmapAndPixmapSurface();
-        return;
-    }
-
-    XWindowAttributes windowAttributes;
-    if (!XGetWindowAttributes(m_display, m_window.get(), &amp;windowAttributes)) {
-        cleanupPixmapAndPixmapSurface();
-        return;
-    }
-
-    RefPtr&lt;cairo_surface_t&gt; newSurface = adoptRef(cairo_xlib_surface_create(m_display, newPixmap.get(), windowAttributes.visual, m_size.width(), m_size.height()));
-    cairoSurfaceSetDeviceScale(newSurface.get(), m_webPage.deviceScaleFactor(), m_webPage.deviceScaleFactor());
-
-    RefPtr&lt;cairo_t&gt; cr = adoptRef(cairo_create(newSurface.get()));
-    if (!m_webPage.drawsBackground())
-        cairo_set_operator(cr.get(), CAIRO_OPERATOR_CLEAR);
-    else
-        setSourceRGBAFromColor(cr.get(), m_webPage.backgroundColor());
-    cairo_paint(cr.get());
-
-    // Nvidia drivers seem to prepare their redirected window pixmap asynchronously, so for a few fractions
-    // of a second after each resize, while doing continuous resizing (which constantly destroys and creates
-    // pixmap window-backings), the pixmap memory is uninitialized. To work around this issue, paint the old
-    // pixmap to the new one to properly initialize it.
-    if (m_surface) {
-        cairo_set_operator(cr.get(), CAIRO_OPERATOR_OVER);
-        cairo_set_source_surface(cr.get(), m_surface.get(), 0, 0);
-        cairo_paint(cr.get());
-    }
-
-    cleanupPixmapAndPixmapSurface();
-    m_pixmap = WTFMove(newPixmap);
-    m_surface = WTFMove(newSurface);
-}
-
-} // namespace WebCore
-
-#endif // USE(REDIRECTED_XCOMPOSITE_WINDOW)
</del></span></pre></div>
<a id="trunkSourceWebKit2UIProcessgtkRedirectedXCompositeWindowh"></a>
<div class="delfile"><h4>Deleted: trunk/Source/WebKit2/UIProcess/gtk/RedirectedXCompositeWindow.h (204012 => 204013)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/gtk/RedirectedXCompositeWindow.h        2016-08-02 06:00:17 UTC (rev 204012)
+++ trunk/Source/WebKit2/UIProcess/gtk/RedirectedXCompositeWindow.h        2016-08-02 06:42:18 UTC (rev 204013)
</span><span class="lines">@@ -1,74 +0,0 @@
</span><del>-/*
- * Copyright (C) 2012 Igalia S.L.
- * All rights reserved.
- *
- * 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.
- */
-
-#ifndef  RedirectedXCompositeWindow_h
-#define  RedirectedXCompositeWindow_h
-
-#if USE(REDIRECTED_XCOMPOSITE_WINDOW)
-
-#include &lt;WebCore/IntSize.h&gt;
-#include &lt;WebCore/RefPtrCairo.h&gt;
-#include &lt;WebCore/XUniqueResource.h&gt;
-#include &lt;functional&gt;
-
-typedef struct _GdkWindow GdkWindow;
-typedef struct _XDisplay Display;
-typedef unsigned long Window;
-
-namespace WebKit {
-
-class WebPageProxy;
-
-class RedirectedXCompositeWindow {
-    WTF_MAKE_NONCOPYABLE(RedirectedXCompositeWindow); WTF_MAKE_FAST_ALLOCATED;
-public:
-    static std::unique_ptr&lt;RedirectedXCompositeWindow&gt; create(WebPageProxy&amp;, const WebCore::IntSize&amp;, std::function&lt;void ()&gt;&amp;&amp; damageNotify);
-    ~RedirectedXCompositeWindow();
-
-    Window windowID() const { return m_window.get(); }
-    void resize(const WebCore::IntSize&amp;);
-    cairo_surface_t* surface() const { return m_surface.get(); };
-
-private:
-    RedirectedXCompositeWindow(WebPageProxy&amp;, const WebCore::IntSize&amp;, std::function&lt;void ()&gt;&amp;&amp; damageNotify);
-    void createNewPixampAndPixampSurface();
-    void cleanupPixmapAndPixmapSurface();
-
-    WebPageProxy&amp; m_webPage;
-    Display* m_display { nullptr };
-    WebCore::IntSize m_size;
-    WebCore::XUniqueWindow m_window;
-    WebCore::XUniqueWindow m_parentWindow;
-    WebCore::XUniquePixmap m_pixmap;
-    WebCore::XUniqueDamage m_damage;
-    RefPtr&lt;cairo_surface_t&gt; m_surface;
-};
-
-} // namespace WebKit
-
-#endif // USE(REDIRECTED_XCOMPOSITE_WINDOW)
-
-#endif // RedirectedXCompositeWindow_h
</del></span></pre></div>
<a id="trunkSourceWebKit2UIProcessgtkXDamageNotifiercpp"></a>
<div class="addfile"><h4>Added: trunk/Source/WebKit2/UIProcess/gtk/XDamageNotifier.cpp (0 => 204013)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/gtk/XDamageNotifier.cpp                                (rev 0)
+++ trunk/Source/WebKit2/UIProcess/gtk/XDamageNotifier.cpp        2016-08-02 06:42:18 UTC (rev 204013)
</span><span class="lines">@@ -0,0 +1,100 @@
</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;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)
</ins></span></pre></div>
<a id="trunkSourceWebKit2UIProcessgtkXDamageNotifierh"></a>
<div class="addfile"><h4>Added: trunk/Source/WebKit2/UIProcess/gtk/XDamageNotifier.h (0 => 204013)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/gtk/XDamageNotifier.h                                (rev 0)
+++ trunk/Source/WebKit2/UIProcess/gtk/XDamageNotifier.h        2016-08-02 06:42:18 UTC (rev 204013)
</span><span class="lines">@@ -0,0 +1,60 @@
</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(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)
</ins></span></pre></div>
<a id="trunkSourceWebKit2UIProcessiosPageClientImplIOSh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/ios/PageClientImplIOS.h (204012 => 204013)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/ios/PageClientImplIOS.h        2016-08-02 06:00:17 UTC (rev 204012)
+++ trunk/Source/WebKit2/UIProcess/ios/PageClientImplIOS.h        2016-08-02 06:42:18 UTC (rev 204013)
</span><span class="lines">@@ -103,7 +103,6 @@
</span><span class="cx">     void enterAcceleratedCompositingMode(const LayerTreeContext&amp;) override;
</span><span class="cx">     void exitAcceleratedCompositingMode() override;
</span><span class="cx">     void updateAcceleratedCompositingMode(const LayerTreeContext&amp;) override;
</span><del>-    void willEnterAcceleratedCompositingMode() override;
</del><span class="cx">     void setAcceleratedCompositingRootLayer(LayerOrView *) override;
</span><span class="cx">     LayerOrView *acceleratedCompositingRootLayer() const override;
</span><span class="cx">     LayerHostingMode viewLayerHostingMode() override { return LayerHostingMode::OutOfProcess; }
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessiosPageClientImplIOSmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/ios/PageClientImplIOS.mm (204012 => 204013)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/ios/PageClientImplIOS.mm        2016-08-02 06:00:17 UTC (rev 204012)
+++ trunk/Source/WebKit2/UIProcess/ios/PageClientImplIOS.mm        2016-08-02 06:42:18 UTC (rev 204013)
</span><span class="lines">@@ -456,10 +456,6 @@
</span><span class="cx"> {
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void PageClientImpl::willEnterAcceleratedCompositingMode()
-{
-}
-
</del><span class="cx"> void PageClientImpl::setAcceleratedCompositingRootLayer(LayerOrView *rootLayer)
</span><span class="cx"> {
</span><span class="cx">     [m_contentView _setAcceleratedCompositingRootView:rootLayer];
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessmacPageClientImplh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/mac/PageClientImpl.h (204012 => 204013)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/mac/PageClientImpl.h        2016-08-02 06:00:17 UTC (rev 204012)
+++ trunk/Source/WebKit2/UIProcess/mac/PageClientImpl.h        2016-08-02 06:42:18 UTC (rev 204013)
</span><span class="lines">@@ -138,7 +138,6 @@
</span><span class="cx">     void enterAcceleratedCompositingMode(const LayerTreeContext&amp;) override;
</span><span class="cx">     void exitAcceleratedCompositingMode() override;
</span><span class="cx">     void updateAcceleratedCompositingMode(const LayerTreeContext&amp;) override;
</span><del>-    void willEnterAcceleratedCompositingMode() override;
</del><span class="cx"> 
</span><span class="cx">     PassRefPtr&lt;ViewSnapshot&gt; takeViewSnapshot() override;
</span><span class="cx">     void wheelEventWasNotHandledByWebCore(const NativeWebWheelEvent&amp;) override;
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessmacPageClientImplmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/mac/PageClientImpl.mm (204012 => 204013)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/mac/PageClientImpl.mm        2016-08-02 06:00:17 UTC (rev 204012)
+++ trunk/Source/WebKit2/UIProcess/mac/PageClientImpl.mm        2016-08-02 06:42:18 UTC (rev 204013)
</span><span class="lines">@@ -480,10 +480,6 @@
</span><span class="cx">     m_impl-&gt;setAcceleratedCompositingRootLayer(renderLayer);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void PageClientImpl::willEnterAcceleratedCompositingMode()
-{
-}
-
</del><span class="cx"> void PageClientImpl::setAcceleratedCompositingRootLayer(CALayer *rootLayer)
</span><span class="cx"> {
</span><span class="cx">     m_impl-&gt;setAcceleratedCompositingRootLayer(rootLayer);
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcessWebPageAcceleratedDrawingAreacpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/WebPage/AcceleratedDrawingArea.cpp (204012 => 204013)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/WebPage/AcceleratedDrawingArea.cpp        2016-08-02 06:00:17 UTC (rev 204012)
+++ trunk/Source/WebKit2/WebProcess/WebPage/AcceleratedDrawingArea.cpp        2016-08-02 06:42:18 UTC (rev 204013)
</span><span class="lines">@@ -318,11 +318,9 @@
</span><span class="cx">     m_exitCompositingTimer.stop();
</span><span class="cx">     m_wantsToExitAcceleratedCompositingMode = false;
</span><span class="cx"> 
</span><del>-    m_webPage.send(Messages::DrawingAreaProxy::WillEnterAcceleratedCompositingMode(m_backingStoreStateID));
-
</del><span class="cx">     ASSERT(!m_layerTreeHost);
</span><span class="cx">     m_layerTreeHost = LayerTreeHost::create(m_webPage);
</span><del>-#if PLATFORM(GTK) &amp;&amp; USE(TEXTURE_MAPPER)
</del><ins>+#if PLATFORM(GTK) &amp;&amp; USE(TEXTURE_MAPPER) &amp;&amp; !USE(REDIRECTED_XCOMPOSITE_WINDOW)
</ins><span class="cx">     if (m_nativeSurfaceHandleForCompositing)
</span><span class="cx">         m_layerTreeHost-&gt;setNativeSurfaceHandleForCompositing(m_nativeSurfaceHandleForCompositing);
</span><span class="cx"> #endif
</span><span class="lines">@@ -354,7 +352,7 @@
</span><span class="cx"> }
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><del>-#if PLATFORM(GTK) &amp;&amp; USE(TEXTURE_MAPPER)
</del><ins>+#if PLATFORM(GTK) &amp;&amp; USE(TEXTURE_MAPPER) &amp;&amp; !USE(REDIRECTED_XCOMPOSITE_WINDOW)
</ins><span class="cx"> void AcceleratedDrawingArea::setNativeSurfaceHandleForCompositing(uint64_t handle)
</span><span class="cx"> {
</span><span class="cx">     m_nativeSurfaceHandleForCompositing = handle;
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcessWebPageAcceleratedDrawingAreah"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/WebPage/AcceleratedDrawingArea.h (204012 => 204013)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/WebPage/AcceleratedDrawingArea.h        2016-08-02 06:00:17 UTC (rev 204012)
+++ trunk/Source/WebKit2/WebProcess/WebPage/AcceleratedDrawingArea.h        2016-08-02 06:42:18 UTC (rev 204013)
</span><span class="lines">@@ -63,7 +63,7 @@
</span><span class="cx">     void didReceiveCoordinatedLayerTreeHostMessage(IPC::Connection&amp;, IPC::MessageDecoder&amp;) override;
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><del>-#if PLATFORM(GTK) &amp;&amp; USE(TEXTURE_MAPPER)
</del><ins>+#if PLATFORM(GTK) &amp;&amp; USE(TEXTURE_MAPPER) &amp;&amp; !USE(REDIRECTED_XCOMPOSITE_WINDOW)
</ins><span class="cx">     void setNativeSurfaceHandleForCompositing(uint64_t) override;
</span><span class="cx">     void destroyNativeSurfaceHandleForCompositing(bool&amp;) override;
</span><span class="cx"> #endif
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcessWebPageCoordinatedGraphicsThreadedCoordinatedLayerTreeHostcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/ThreadedCoordinatedLayerTreeHost.cpp (204012 => 204013)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/ThreadedCoordinatedLayerTreeHost.cpp        2016-08-02 06:00:17 UTC (rev 204012)
+++ trunk/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/ThreadedCoordinatedLayerTreeHost.cpp        2016-08-02 06:42:18 UTC (rev 204013)
</span><span class="lines">@@ -34,6 +34,10 @@
</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><ins>+#if USE(REDIRECTED_XCOMPOSITE_WINDOW)
+#include &quot;RedirectedXCompositeWindow.h&quot;
+#endif
+
</ins><span class="cx"> using namespace WebCore;
</span><span class="cx"> 
</span><span class="cx"> namespace WebKit {
</span><span class="lines">@@ -50,8 +54,17 @@
</span><span class="cx"> ThreadedCoordinatedLayerTreeHost::ThreadedCoordinatedLayerTreeHost(WebPage&amp; webPage)
</span><span class="cx">     : CoordinatedLayerTreeHost(webPage)
</span><span class="cx">     , m_compositorClient(*this)
</span><ins>+#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
</ins><span class="cx">     , m_compositor(ThreadedCompositor::create(&amp;m_compositorClient))
</span><ins>+#endif
</ins><span class="cx"> {
</span><ins>+#if USE(REDIRECTED_XCOMPOSITE_WINDOW)
+    if (m_redirectedWindow)
+        m_layerTreeContext.contextID = m_redirectedWindow-&gt;pixmap();
+#endif
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void ThreadedCoordinatedLayerTreeHost::invalidate()
</span><span class="lines">@@ -58,6 +71,9 @@
</span><span class="cx"> {
</span><span class="cx">     m_compositor-&gt;invalidate();
</span><span class="cx">     CoordinatedLayerTreeHost::invalidate();
</span><ins>+#if USE(REDIRECTED_XCOMPOSITE_WINDOW)
+    m_redirectedWindow = nullptr;
+#endif
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void ThreadedCoordinatedLayerTreeHost::forceRepaint()
</span><span class="lines">@@ -79,6 +95,13 @@
</span><span class="cx"> 
</span><span class="cx"> void ThreadedCoordinatedLayerTreeHost::deviceOrPageScaleFactorChanged()
</span><span class="cx"> {
</span><ins>+#if USE(REDIRECTED_XCOMPOSITE_WINDOW)
+    if (m_redirectedWindow) {
+        m_redirectedWindow-&gt;resize(m_webPage.size());
+        m_layerTreeContext.contextID = m_redirectedWindow-&gt;pixmap();
+    }
+#endif
+
</ins><span class="cx">     CoordinatedLayerTreeHost::deviceOrPageScaleFactorChanged();
</span><span class="cx">     m_compositor-&gt;setDeviceScaleFactor(m_webPage.deviceScaleFactor());
</span><span class="cx"> }
</span><span class="lines">@@ -91,6 +114,12 @@
</span><span class="cx"> 
</span><span class="cx"> void ThreadedCoordinatedLayerTreeHost::sizeDidChange(const IntSize&amp; size)
</span><span class="cx"> {
</span><ins>+#if USE(REDIRECTED_XCOMPOSITE_WINDOW)
+    if (m_redirectedWindow) {
+        m_redirectedWindow-&gt;resize(size);
+        m_layerTreeContext.contextID = m_redirectedWindow-&gt;pixmap();
+    }
+#endif
</ins><span class="cx">     CoordinatedLayerTreeHost::sizeDidChange(size);
</span><span class="cx">     m_compositor-&gt;didChangeViewportSize(size);
</span><span class="cx"> }
</span><span class="lines">@@ -105,7 +134,7 @@
</span><span class="cx">     m_webPage.scalePage(scale, origin);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-#if PLATFORM(GTK)
</del><ins>+#if PLATFORM(GTK) &amp;&amp; !USE(REDIRECTED_XCOMPOSITE_WINDOW)
</ins><span class="cx"> void ThreadedCoordinatedLayerTreeHost::setNativeSurfaceHandleForCompositing(uint64_t handle)
</span><span class="cx"> {
</span><span class="cx">     m_layerTreeContext.contextID = handle;
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcessWebPageCoordinatedGraphicsThreadedCoordinatedLayerTreeHosth"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/ThreadedCoordinatedLayerTreeHost.h (204012 => 204013)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/ThreadedCoordinatedLayerTreeHost.h        2016-08-02 06:00:17 UTC (rev 204012)
+++ trunk/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/ThreadedCoordinatedLayerTreeHost.h        2016-08-02 06:42:18 UTC (rev 204013)
</span><span class="lines">@@ -41,6 +41,7 @@
</span><span class="cx"> 
</span><span class="cx"> namespace WebKit {
</span><span class="cx"> 
</span><ins>+class RedirectedXCompositeWindow;
</ins><span class="cx"> class WebPage;
</span><span class="cx"> 
</span><span class="cx"> class ThreadedCoordinatedLayerTreeHost final : public CoordinatedLayerTreeHost {
</span><span class="lines">@@ -64,7 +65,7 @@
</span><span class="cx">     void forceRepaint() override;
</span><span class="cx">     bool forceRepaintAsync(uint64_t callbackID) override { return false; }
</span><span class="cx"> 
</span><del>-#if PLATFORM(GTK)
</del><ins>+#if PLATFORM(GTK) &amp;&amp; !USE(REDIRECTED_XCOMPOSITE_WINDOW)
</ins><span class="cx">     void setNativeSurfaceHandleForCompositing(uint64_t) override;
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="lines">@@ -103,10 +104,13 @@
</span><span class="cx">     void didFlushRootLayer(const WebCore::FloatRect&amp;) override { }
</span><span class="cx">     void commitSceneState(const WebCore::CoordinatedGraphicsState&amp;) override;
</span><span class="cx"> 
</span><del>-    WebCore::IntPoint m_prevScrollPosition;
</del><span class="cx">     CompositorClient m_compositorClient;
</span><ins>+#if USE(REDIRECTED_XCOMPOSITE_WINDOW)
+    std::unique_ptr&lt;RedirectedXCompositeWindow&gt; m_redirectedWindow;
+#endif
</ins><span class="cx">     RefPtr&lt;ThreadedCompositor&gt; m_compositor;
</span><span class="cx">     float m_lastScaleFactor { 1 };
</span><ins>+    WebCore::IntPoint m_prevScrollPosition;
</ins><span class="cx">     WebCore::IntPoint m_lastScrollPosition;
</span><span class="cx"> };
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcessWebPageDrawingAreah"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/WebPage/DrawingArea.h (204012 => 204013)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/WebPage/DrawingArea.h        2016-08-02 06:00:17 UTC (rev 204012)
+++ trunk/Source/WebKit2/WebProcess/WebPage/DrawingArea.h        2016-08-02 06:42:18 UTC (rev 204013)
</span><span class="lines">@@ -146,7 +146,7 @@
</span><span class="cx">     DrawingAreaType m_type;
</span><span class="cx">     WebPage&amp; m_webPage;
</span><span class="cx"> 
</span><del>-#if PLATFORM(GTK) &amp;&amp; USE(TEXTURE_MAPPER)
</del><ins>+#if PLATFORM(GTK) &amp;&amp; USE(TEXTURE_MAPPER) &amp;&amp; !USE(REDIRECTED_XCOMPOSITE_WINDOW)
</ins><span class="cx">     uint64_t m_nativeSurfaceHandleForCompositing { 0 };
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="lines">@@ -172,7 +172,7 @@
</span><span class="cx">     virtual void addTransactionCallbackID(uint64_t callbackID) { ASSERT_NOT_REACHED(); }
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><del>-#if USE(TEXTURE_MAPPER) &amp;&amp; PLATFORM(GTK)
</del><ins>+#if USE(TEXTURE_MAPPER) &amp;&amp; PLATFORM(GTK) &amp;&amp; !USE(REDIRECTED_XCOMPOSITE_WINDOW)
</ins><span class="cx">     virtual void setNativeSurfaceHandleForCompositing(uint64_t) = 0;
</span><span class="cx">     virtual void destroyNativeSurfaceHandleForCompositing(bool&amp;) = 0;
</span><span class="cx"> #endif
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcessWebPageDrawingAreamessagesin"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/WebPage/DrawingArea.messages.in (204012 => 204013)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/WebPage/DrawingArea.messages.in        2016-08-02 06:00:17 UTC (rev 204012)
+++ trunk/Source/WebKit2/WebProcess/WebPage/DrawingArea.messages.in        2016-08-02 06:42:18 UTC (rev 204013)
</span><span class="lines">@@ -40,7 +40,7 @@
</span><span class="cx">     AddTransactionCallbackID(uint64_t callbackID)
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><del>-#if USE(TEXTURE_MAPPER) &amp;&amp; PLATFORM(GTK)
</del><ins>+#if USE(TEXTURE_MAPPER) &amp;&amp; PLATFORM(GTK) &amp;&amp; !USE(REDIRECTED_XCOMPOSITE_WINDOW)
</ins><span class="cx">     SetNativeSurfaceHandleForCompositing(uint64_t handle)
</span><span class="cx">     DestroyNativeSurfaceHandleForCompositing() -&gt; (bool handled)
</span><span class="cx"> #endif
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcessWebPagegtkLayerTreeHostGtkcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/WebPage/gtk/LayerTreeHostGtk.cpp (204012 => 204013)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/WebPage/gtk/LayerTreeHostGtk.cpp        2016-08-02 06:00:17 UTC (rev 204012)
+++ trunk/Source/WebKit2/WebProcess/WebPage/gtk/LayerTreeHostGtk.cpp        2016-08-02 06:42:18 UTC (rev 204013)
</span><span class="lines">@@ -57,6 +57,10 @@
</span><span class="cx"> #include &lt;gdk/gdkx.h&gt;
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><ins>+#if USE(REDIRECTED_XCOMPOSITE_WINDOW)
+#include &quot;RedirectedXCompositeWindow.h&quot;
+#endif
+
</ins><span class="cx"> using namespace WebCore;
</span><span class="cx"> 
</span><span class="cx"> namespace WebKit {
</span><span class="lines">@@ -133,6 +137,9 @@
</span><span class="cx"> 
</span><span class="cx"> LayerTreeHostGtk::LayerTreeHostGtk(WebPage&amp; webPage)
</span><span class="cx">     : LayerTreeHost(webPage)
</span><ins>+#if USE(REDIRECTED_XCOMPOSITE_WINDOW)
+    , m_redirectedWindow(RedirectedXCompositeWindow::create(webPage))
+#endif
</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">@@ -159,17 +166,30 @@
</span><span class="cx"> 
</span><span class="cx">     m_rootLayer-&gt;addChild(m_nonCompositedContentLayer.get());
</span><span class="cx">     m_nonCompositedContentLayer-&gt;setNeedsDisplay();
</span><ins>+
+#if USE(REDIRECTED_XCOMPOSITE_WINDOW)
+    if (m_redirectedWindow) {
+        createTextureMapper();
+        m_layerTreeContext.contextID = m_redirectedWindow-&gt;pixmap();
+    }
+#endif
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> bool LayerTreeHostGtk::makeContextCurrent()
</span><span class="cx"> {
</span><del>-    if (!m_layerTreeContext.contextID) {
</del><ins>+#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
+
+    if (!nativeHandle) {
</ins><span class="cx">         m_context = nullptr;
</span><span class="cx">         return false;
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     if (!m_context) {
</span><del>-        m_context = GLContext::createContextForWindow(reinterpret_cast&lt;GLNativeWindowType&gt;(m_layerTreeContext.contextID), GLContext::sharingContext());
</del><ins>+        m_context = GLContext::createContextForWindow(reinterpret_cast&lt;GLNativeWindowType&gt;(nativeHandle), GLContext::sharingContext());
</ins><span class="cx">         if (!m_context)
</span><span class="cx">             return false;
</span><span class="cx">     }
</span><span class="lines">@@ -208,6 +228,10 @@
</span><span class="cx"> 
</span><span class="cx">     m_context = nullptr;
</span><span class="cx">     LayerTreeHost::invalidate();
</span><ins>+
+#if USE(REDIRECTED_XCOMPOSITE_WINDOW)
+    m_redirectedWindow = nullptr;
+#endif
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void LayerTreeHostGtk::setNonCompositedContentsNeedDisplay()
</span><span class="lines">@@ -247,11 +271,25 @@
</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><ins>+#if USE(REDIRECTED_XCOMPOSITE_WINDOW)
+    if (m_redirectedWindow) {
+        m_redirectedWindow-&gt;resize(newSize);
+        m_layerTreeContext.contextID = m_redirectedWindow-&gt;pixmap();
+    }
+#endif
+
</ins><span class="cx">     compositeLayersToContext(ForResize);
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void LayerTreeHostGtk::deviceOrPageScaleFactorChanged()
</span><span class="cx"> {
</span><ins>+#if USE(REDIRECTED_XCOMPOSITE_WINDOW)
+    if (m_redirectedWindow) {
+        m_redirectedWindow-&gt;resize(m_webPage.size());
+        m_layerTreeContext.contextID = m_redirectedWindow-&gt;pixmap();
+    }
+#endif
+
</ins><span class="cx">     // Other layers learn of the scale factor change via WebPage::setDeviceScaleFactor.
</span><span class="cx">     m_nonCompositedContentLayer-&gt;deviceOrPageScaleFactorChanged();
</span><span class="cx"> 
</span><span class="lines">@@ -377,11 +415,8 @@
</span><span class="cx">         m_rootLayer-&gt;addChild(m_viewOverlayRootLayer);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void LayerTreeHostGtk::setNativeSurfaceHandleForCompositing(uint64_t handle)
</del><ins>+void LayerTreeHostGtk::createTextureMapper()
</ins><span class="cx"> {
</span><del>-    cancelPendingLayerFlush();
-    m_layerTreeContext.contextID = handle;
-
</del><span class="cx">     // The creation of the TextureMapper needs an active OpenGL context.
</span><span class="cx">     if (!makeContextCurrent())
</span><span class="cx">         return;
</span><span class="lines">@@ -391,9 +426,18 @@
</span><span class="cx">     m_textureMapper = TextureMapper::create();
</span><span class="cx">     static_cast&lt;TextureMapperGL*&gt;(m_textureMapper.get())-&gt;setEnableEdgeDistanceAntialiasing(true);
</span><span class="cx">     downcast&lt;GraphicsLayerTextureMapper&gt;(*m_rootLayer).layer().setTextureMapper(m_textureMapper.get());
</span><ins>+}
</ins><span class="cx"> 
</span><ins>+#if !USE(REDIRECTED_XCOMPOSITE_WINDOW)
+void LayerTreeHostGtk::setNativeSurfaceHandleForCompositing(uint64_t handle)
+{
+    cancelPendingLayerFlush();
+    m_layerTreeContext.contextID = handle;
+
+    createTextureMapper();
</ins><span class="cx">     scheduleLayerFlush();
</span><span class="cx"> }
</span><ins>+#endif
</ins><span class="cx"> 
</span><span class="cx"> } // namespace WebKit
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcessWebPagegtkLayerTreeHostGtkh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/WebPage/gtk/LayerTreeHostGtk.h (204012 => 204013)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/WebPage/gtk/LayerTreeHostGtk.h        2016-08-02 06:00:17 UTC (rev 204012)
+++ trunk/Source/WebKit2/WebProcess/WebPage/gtk/LayerTreeHostGtk.h        2016-08-02 06:42:18 UTC (rev 204013)
</span><span class="lines">@@ -39,6 +39,8 @@
</span><span class="cx"> 
</span><span class="cx"> namespace WebKit {
</span><span class="cx"> 
</span><ins>+class RedirectedXCompositeWindow;
+
</ins><span class="cx"> class LayerTreeHostGtk final : public LayerTreeHost, WebCore::GraphicsLayerClient {
</span><span class="cx"> public:
</span><span class="cx">     static Ref&lt;LayerTreeHostGtk&gt; create(WebPage&amp;);
</span><span class="lines">@@ -65,7 +67,9 @@
</span><span class="cx">     void scrollNonCompositedContents(const WebCore::IntRect&amp; scrollRect) override;
</span><span class="cx">     void setViewOverlayRootLayer(WebCore::GraphicsLayer*) override;
</span><span class="cx"> 
</span><ins>+#if !USE(REDIRECTED_XCOMPOSITE_WINDOW)
</ins><span class="cx">     void setNativeSurfaceHandleForCompositing(uint64_t) override;
</span><ins>+#endif
</ins><span class="cx"> 
</span><span class="cx">     class RenderFrameScheduler {
</span><span class="cx">     public:
</span><span class="lines">@@ -98,6 +102,7 @@
</span><span class="cx">     void flushAndRenderLayers();
</span><span class="cx">     bool renderFrame();
</span><span class="cx">     bool makeContextCurrent();
</span><ins>+    void createTextureMapper();
</ins><span class="cx"> 
</span><span class="cx">     std::unique_ptr&lt;WebCore::GraphicsLayer&gt; m_rootLayer;
</span><span class="cx">     std::unique_ptr&lt;WebCore::GraphicsLayer&gt; m_nonCompositedContentLayer;
</span><span class="lines">@@ -104,6 +109,9 @@
</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><ins>+#if USE(REDIRECTED_XCOMPOSITE_WINDOW)
+    std::unique_ptr&lt;RedirectedXCompositeWindow&gt; m_redirectedWindow;
+#endif
</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="addfile"><h4>Added: trunk/Source/WebKit2/WebProcess/WebPage/gtk/RedirectedXCompositeWindow.cpp (0 => 204013)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/WebPage/gtk/RedirectedXCompositeWindow.cpp                                (rev 0)
+++ trunk/Source/WebKit2/WebProcess/WebPage/gtk/RedirectedXCompositeWindow.cpp        2016-08-02 06:42:18 UTC (rev 204013)
</span><span class="lines">@@ -0,0 +1,143 @@
</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;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),
+        WidthOfScreen(screen) + 1, 0, 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)
</ins></span></pre></div>
<a id="trunkSourceWebKit2WebProcessWebPagegtkRedirectedXCompositeWindowhfromrev204011trunkSourceWebKit2UIProcessgtkRedirectedXCompositeWindowh"></a>
<div class="copfile"><h4>Copied: trunk/Source/WebKit2/WebProcess/WebPage/gtk/RedirectedXCompositeWindow.h (from rev 204011, trunk/Source/WebKit2/UIProcess/gtk/RedirectedXCompositeWindow.h) (0 => 204013)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/WebPage/gtk/RedirectedXCompositeWindow.h                                (rev 0)
+++ trunk/Source/WebKit2/WebProcess/WebPage/gtk/RedirectedXCompositeWindow.h        2016-08-02 06:42:18 UTC (rev 204013)
</span><span class="lines">@@ -0,0 +1,65 @@
</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 &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)
</ins></span></pre>
</div>
</div>

</body>
</html>