<!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>[169370] 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/169370">169370</a></dd>
<dt>Author</dt> <dd>timothy_horton@apple.com</dd>
<dt>Date</dt> <dd>2014-05-26 23:14:15 -0700 (Mon, 26 May 2014)</dd>
</dl>

<h3>Log Message</h3>
<pre>[wk2] RemoteLayerBackingStore front buffers should be purgeable when unparented
https://bugs.webkit.org/show_bug.cgi?id=133020
&lt;rdar://problem/16521736&gt;

Reviewed by Simon Fraser.

* Shared/mac/RemoteLayerBackingStore.mm:
(WebKit::RemoteLayerBackingStore::display):
Let the context know whenever a RemoteLayerBackingStore is displayed, so that
RemoteLayerBackingStoreCollection can (if needed) note that the backing store
is active once again (because we only display parented backing store).

(WebKit::RemoteLayerBackingStore::setBufferVolatility):
Ensure that we never have live contexts attached to any buffers when
marking them volatile, because checking isInUse() with live contexts is futile.

* Shared/mac/RemoteLayerBackingStoreCollection.h:
* Shared/mac/RemoteLayerBackingStoreCollection.mm:
(WebKit::RemoteLayerBackingStoreCollection::RemoteLayerBackingStoreCollection):
(WebKit::RemoteLayerBackingStoreCollection::willFlushLayers):
(WebKit::RemoteLayerBackingStoreCollection::willCommitLayerTree):
(WebKit::RemoteLayerBackingStoreCollection::didFlushLayers):
(WebKit::RemoteLayerBackingStoreCollection::backingStoreWillBeDestroyed):
(WebKit::RemoteLayerBackingStoreCollection::backingStoreWillBeDisplayed):
(WebKit::RemoteLayerBackingStoreCollection::markBackingStoreVolatileImmediately):
(WebKit::RemoteLayerBackingStoreCollection::markBackingStoreVolatile):
(WebKit::RemoteLayerBackingStoreCollection::backingStoreBecameUnreachable):
(WebKit::RemoteLayerBackingStoreCollection::volatilityTimerFired):
(WebKit::RemoteLayerBackingStoreCollection::scheduleVolatilityTimer):
(WebKit::RemoteLayerBackingStoreCollection::purgeabilityTimerFired): Deleted.
(WebKit::RemoteLayerBackingStoreCollection::schedulePurgeabilityTimer): Deleted.
Rename purgeable-&gt;volatile for accuracy.
Keep track of two sets of backing store: those which are active/parented, and
those which are not. Backing store is moved to the inactive set after building
the transaction in which its owning layer is unparented.
When backing store is unparented, try to mark it volatile immediately. Also,
mark the backing store property as dirty on the owning layer so that when
said layer is reparented, we encode the backing store in the commit that reparents it,
as the UI process will throw away its reference to the backing store when
the layer is unparented. Mark the front buffers of unparented layers as volatile,
in addition to the others.

* Shared/mac/RemoteLayerTreeTransaction.h:
(WebKit::RemoteLayerTreeTransaction::layerIDsWithNewlyUnreachableBackingStore):
* Shared/mac/RemoteLayerTreeTransaction.mm:
(WebKit::RemoteLayerTreeTransaction::encode):
(WebKit::RemoteLayerTreeTransaction::decode):
(WebKit::RemoteLayerTreeTransaction::setLayerIDsWithNewlyUnreachableBackingStore):
Include the list of layers (by ID) with backing store which just became unreachable in the transaction.

* UIProcess/mac/RemoteLayerTreeHost.mm:
(WebKit::RemoteLayerTreeHost::updateLayerTree):
Clear the contents of layers which now have unreachable backing store.
Otherwise, the UI process would hold a 'use' on the IOSurface, and prevent
the Web process from marking it volatile.

* WebProcess/WebPage/mac/RemoteLayerTreeContext.h:
* WebProcess/WebPage/mac/RemoteLayerTreeContext.mm:
(WebKit::RemoteLayerTreeContext::backingStoreWillBeDisplayed):
* WebProcess/WebPage/mac/RemoteLayerTreeDrawingArea.mm:
(WebKit::RemoteLayerTreeDrawingArea::flushLayers):
Give RemoteLayerBackingStoreCollection a shot at the RemoteLayerTreeTransaction,
so that it can fill in layerIDsWithNewlyUnreachableBackingStore.
Also, let it know when the flush begins and ends, so that it can keep track
of which layers were reached in the flush.

* WebCore.exp.in:
* platform/graphics/cg/IOSurfacePool.cpp:
(WebCore::IOSurfacePool::willAddSurface):
* platform/graphics/cocoa/IOSurface.h:
* platform/graphics/cocoa/IOSurface.mm:
(IOSurface::releaseGraphicsContext):
Rename clearGraphicsContext to releaseGraphicsContext for clarity.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreWebCoreexpin">trunk/Source/WebCore/WebCore.exp.in</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicscgIOSurfacePoolcpp">trunk/Source/WebCore/platform/graphics/cg/IOSurfacePool.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicscocoaIOSurfaceh">trunk/Source/WebCore/platform/graphics/cocoa/IOSurface.h</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicscocoaIOSurfacemm">trunk/Source/WebCore/platform/graphics/cocoa/IOSurface.mm</a></li>
<li><a href="#trunkSourceWebKit2ChangeLog">trunk/Source/WebKit2/ChangeLog</a></li>
<li><a href="#trunkSourceWebKit2SharedmacRemoteLayerBackingStoremm">trunk/Source/WebKit2/Shared/mac/RemoteLayerBackingStore.mm</a></li>
<li><a href="#trunkSourceWebKit2SharedmacRemoteLayerBackingStoreCollectionh">trunk/Source/WebKit2/Shared/mac/RemoteLayerBackingStoreCollection.h</a></li>
<li><a href="#trunkSourceWebKit2SharedmacRemoteLayerBackingStoreCollectionmm">trunk/Source/WebKit2/Shared/mac/RemoteLayerBackingStoreCollection.mm</a></li>
<li><a href="#trunkSourceWebKit2SharedmacRemoteLayerTreeTransactionh">trunk/Source/WebKit2/Shared/mac/RemoteLayerTreeTransaction.h</a></li>
<li><a href="#trunkSourceWebKit2SharedmacRemoteLayerTreeTransactionmm">trunk/Source/WebKit2/Shared/mac/RemoteLayerTreeTransaction.mm</a></li>
<li><a href="#trunkSourceWebKit2UIProcessmacRemoteLayerTreeHostmm">trunk/Source/WebKit2/UIProcess/mac/RemoteLayerTreeHost.mm</a></li>
<li><a href="#trunkSourceWebKit2WebProcessWebPagemacRemoteLayerTreeContexth">trunk/Source/WebKit2/WebProcess/WebPage/mac/RemoteLayerTreeContext.h</a></li>
<li><a href="#trunkSourceWebKit2WebProcessWebPagemacRemoteLayerTreeContextmm">trunk/Source/WebKit2/WebProcess/WebPage/mac/RemoteLayerTreeContext.mm</a></li>
<li><a href="#trunkSourceWebKit2WebProcessWebPagemacRemoteLayerTreeDrawingAreamm">trunk/Source/WebKit2/WebProcess/WebPage/mac/RemoteLayerTreeDrawingArea.mm</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (169369 => 169370)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2014-05-27 05:38:27 UTC (rev 169369)
+++ trunk/Source/WebCore/ChangeLog        2014-05-27 06:14:15 UTC (rev 169370)
</span><span class="lines">@@ -1,3 +1,19 @@
</span><ins>+2014-05-26  Tim Horton  &lt;timothy_horton@apple.com&gt;
+
+        [wk2] RemoteLayerBackingStore front buffers should be purgeable when unparented
+        https://bugs.webkit.org/show_bug.cgi?id=133020
+        &lt;rdar://problem/16521736&gt;
+
+        Reviewed by Simon Fraser.
+
+        * WebCore.exp.in:
+        * platform/graphics/cg/IOSurfacePool.cpp:
+        (WebCore::IOSurfacePool::willAddSurface):
+        * platform/graphics/cocoa/IOSurface.h:
+        * platform/graphics/cocoa/IOSurface.mm:
+        (IOSurface::releaseGraphicsContext):
+        Rename clearGraphicsContext to releaseGraphicsContext for clarity.
+
</ins><span class="cx"> 2014-05-26  Philip Rogers  &lt;pdr@google.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Remove special case for transparent SVG root layers
</span></span></pre></div>
<a id="trunkSourceWebCoreWebCoreexpin"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/WebCore.exp.in (169369 => 169370)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/WebCore.exp.in        2014-05-27 05:38:27 UTC (rev 169369)
+++ trunk/Source/WebCore/WebCore.exp.in        2014-05-27 06:14:15 UTC (rev 169370)
</span><span class="lines">@@ -3143,9 +3143,9 @@
</span><span class="cx"> __ZN7WebCore9IOSurface11createImageEv
</span><span class="cx"> __ZN7WebCore9IOSurface13setIsVolatileEb
</span><span class="cx"> __ZN7WebCore9IOSurface18createFromMachPortEjNS_10ColorSpaceE
</span><del>-__ZN7WebCore9IOSurface20clearGraphicsContextEv
</del><span class="cx"> __ZN7WebCore9IOSurface21ensureGraphicsContextEv
</span><span class="cx"> __ZN7WebCore9IOSurface21ensurePlatformContextEv
</span><ins>+__ZN7WebCore9IOSurface22releaseGraphicsContextEv
</ins><span class="cx"> __ZN7WebCore9IOSurface6createENS_7IntSizeENS_10ColorSpaceE
</span><span class="cx"> __ZNK7WebCore9IOSurface14createMachPortEv
</span><span class="cx"> __ZNK7WebCore9IOSurface7isInUseEv
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicscgIOSurfacePoolcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/cg/IOSurfacePool.cpp (169369 => 169370)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/cg/IOSurfacePool.cpp        2014-05-27 05:38:27 UTC (rev 169369)
+++ trunk/Source/WebCore/platform/graphics/cg/IOSurfacePool.cpp        2014-05-27 06:14:15 UTC (rev 169370)
</span><span class="lines">@@ -80,7 +80,7 @@
</span><span class="cx">     CachedSurfaceDetails&amp; details = m_surfaceDetails.add(surface, CachedSurfaceDetails()).iterator-&gt;value;
</span><span class="cx">     details.resetLastUseTime();
</span><span class="cx"> 
</span><del>-    surface-&gt;clearGraphicsContext();
</del><ins>+    surface-&gt;releaseGraphicsContext();
</ins><span class="cx"> 
</span><span class="cx">     size_t surfaceBytes = surface-&gt;totalBytes();
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicscocoaIOSurfaceh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/cocoa/IOSurface.h (169369 => 169370)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/cocoa/IOSurface.h        2014-05-27 05:38:27 UTC (rev 169369)
+++ trunk/Source/WebCore/platform/graphics/cocoa/IOSurface.h        2014-05-27 06:14:15 UTC (rev 169370)
</span><span class="lines">@@ -75,7 +75,7 @@
</span><span class="cx"> 
</span><span class="cx">     // The graphics context cached on the surface counts as a &quot;user&quot;, so to get
</span><span class="cx">     // an accurate result from isInUse(), it needs to be released.
</span><del>-    void clearGraphicsContext();
</del><ins>+    void releaseGraphicsContext();
</ins><span class="cx"> 
</span><span class="cx"> private:
</span><span class="cx">     IOSurface(IntSize, ColorSpace);
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicscocoaIOSurfacemm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/cocoa/IOSurface.mm (169369 => 169370)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/cocoa/IOSurface.mm        2014-05-27 05:38:27 UTC (rev 169369)
+++ trunk/Source/WebCore/platform/graphics/cocoa/IOSurface.mm        2014-05-27 06:14:15 UTC (rev 169370)
</span><span class="lines">@@ -191,7 +191,7 @@
</span><span class="cx">     return IOSurfaceIsInUse(m_surface.get());
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void IOSurface::clearGraphicsContext()
</del><ins>+void IOSurface::releaseGraphicsContext()
</ins><span class="cx"> {
</span><span class="cx">     m_graphicsContext = nullptr;
</span><span class="cx">     m_cgContext = nullptr;
</span></span></pre></div>
<a id="trunkSourceWebKit2ChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/ChangeLog (169369 => 169370)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/ChangeLog        2014-05-27 05:38:27 UTC (rev 169369)
+++ trunk/Source/WebKit2/ChangeLog        2014-05-27 06:14:15 UTC (rev 169370)
</span><span class="lines">@@ -1,3 +1,71 @@
</span><ins>+2014-05-26  Tim Horton  &lt;timothy_horton@apple.com&gt;
+
+        [wk2] RemoteLayerBackingStore front buffers should be purgeable when unparented
+        https://bugs.webkit.org/show_bug.cgi?id=133020
+        &lt;rdar://problem/16521736&gt;
+
+        Reviewed by Simon Fraser.
+
+        * Shared/mac/RemoteLayerBackingStore.mm:
+        (WebKit::RemoteLayerBackingStore::display):
+        Let the context know whenever a RemoteLayerBackingStore is displayed, so that
+        RemoteLayerBackingStoreCollection can (if needed) note that the backing store
+        is active once again (because we only display parented backing store).
+
+        (WebKit::RemoteLayerBackingStore::setBufferVolatility):
+        Ensure that we never have live contexts attached to any buffers when
+        marking them volatile, because checking isInUse() with live contexts is futile.
+
+        * Shared/mac/RemoteLayerBackingStoreCollection.h:
+        * Shared/mac/RemoteLayerBackingStoreCollection.mm:
+        (WebKit::RemoteLayerBackingStoreCollection::RemoteLayerBackingStoreCollection):
+        (WebKit::RemoteLayerBackingStoreCollection::willFlushLayers):
+        (WebKit::RemoteLayerBackingStoreCollection::willCommitLayerTree):
+        (WebKit::RemoteLayerBackingStoreCollection::didFlushLayers):
+        (WebKit::RemoteLayerBackingStoreCollection::backingStoreWillBeDestroyed):
+        (WebKit::RemoteLayerBackingStoreCollection::backingStoreWillBeDisplayed):
+        (WebKit::RemoteLayerBackingStoreCollection::markBackingStoreVolatileImmediately):
+        (WebKit::RemoteLayerBackingStoreCollection::markBackingStoreVolatile):
+        (WebKit::RemoteLayerBackingStoreCollection::backingStoreBecameUnreachable):
+        (WebKit::RemoteLayerBackingStoreCollection::volatilityTimerFired):
+        (WebKit::RemoteLayerBackingStoreCollection::scheduleVolatilityTimer):
+        (WebKit::RemoteLayerBackingStoreCollection::purgeabilityTimerFired): Deleted.
+        (WebKit::RemoteLayerBackingStoreCollection::schedulePurgeabilityTimer): Deleted.
+        Rename purgeable-&gt;volatile for accuracy.
+        Keep track of two sets of backing store: those which are active/parented, and
+        those which are not. Backing store is moved to the inactive set after building
+        the transaction in which its owning layer is unparented.
+        When backing store is unparented, try to mark it volatile immediately. Also,
+        mark the backing store property as dirty on the owning layer so that when
+        said layer is reparented, we encode the backing store in the commit that reparents it,
+        as the UI process will throw away its reference to the backing store when
+        the layer is unparented. Mark the front buffers of unparented layers as volatile,
+        in addition to the others.
+
+        * Shared/mac/RemoteLayerTreeTransaction.h:
+        (WebKit::RemoteLayerTreeTransaction::layerIDsWithNewlyUnreachableBackingStore):
+        * Shared/mac/RemoteLayerTreeTransaction.mm:
+        (WebKit::RemoteLayerTreeTransaction::encode):
+        (WebKit::RemoteLayerTreeTransaction::decode):
+        (WebKit::RemoteLayerTreeTransaction::setLayerIDsWithNewlyUnreachableBackingStore):
+        Include the list of layers (by ID) with backing store which just became unreachable in the transaction.
+
+        * UIProcess/mac/RemoteLayerTreeHost.mm:
+        (WebKit::RemoteLayerTreeHost::updateLayerTree):
+        Clear the contents of layers which now have unreachable backing store.
+        Otherwise, the UI process would hold a 'use' on the IOSurface, and prevent
+        the Web process from marking it volatile.
+
+        * WebProcess/WebPage/mac/RemoteLayerTreeContext.h:
+        * WebProcess/WebPage/mac/RemoteLayerTreeContext.mm:
+        (WebKit::RemoteLayerTreeContext::backingStoreWillBeDisplayed):
+        * WebProcess/WebPage/mac/RemoteLayerTreeDrawingArea.mm:
+        (WebKit::RemoteLayerTreeDrawingArea::flushLayers):
+        Give RemoteLayerBackingStoreCollection a shot at the RemoteLayerTreeTransaction,
+        so that it can fill in layerIDsWithNewlyUnreachableBackingStore.
+        Also, let it know when the flush begins and ends, so that it can keep track
+        of which layers were reached in the flush.
+
</ins><span class="cx"> 2014-05-26  Shivakumar JM  &lt;shiva.jm@samsung.com&gt;
</span><span class="cx"> 
</span><span class="cx">         [EFL][WK2] Fix EWK2BackForwardListTest test fails.
</span></span></pre></div>
<a id="trunkSourceWebKit2SharedmacRemoteLayerBackingStoremm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/Shared/mac/RemoteLayerBackingStore.mm (169369 => 169370)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/Shared/mac/RemoteLayerBackingStore.mm        2014-05-27 05:38:27 UTC (rev 169369)
+++ trunk/Source/WebKit2/Shared/mac/RemoteLayerBackingStore.mm        2014-05-27 06:14:15 UTC (rev 169370)
</span><span class="lines">@@ -201,6 +201,9 @@
</span><span class="cx"> 
</span><span class="cx">     m_lastDisplayTime = std::chrono::steady_clock::now();
</span><span class="cx"> 
</span><ins>+    if (m_context)
+        m_context-&gt;backingStoreWillBeDisplayed(this);
+
</ins><span class="cx">     // Make the previous front buffer non-volatile early, so that we can dirty the whole layer if it comes back empty.
</span><span class="cx">     setBufferVolatility(BufferType::Front, false);
</span><span class="cx"> 
</span><span class="lines">@@ -236,7 +239,7 @@
</span><span class="cx">         context.translate(0, -expandedScaledSize.height());
</span><span class="cx">         drawInContext(context, backImage.get());
</span><span class="cx"> 
</span><del>-        m_frontBuffer.surface-&gt;clearGraphicsContext();
</del><ins>+        m_frontBuffer.surface-&gt;releaseGraphicsContext();
</ins><span class="cx"> 
</span><span class="cx">         return true;
</span><span class="cx">     }
</span><span class="lines">@@ -382,6 +385,8 @@
</span><span class="cx">     switch(type) {
</span><span class="cx">     case BufferType::Front:
</span><span class="cx">         if (m_frontBuffer.surface &amp;&amp; m_frontBuffer.isVolatile != isVolatile) {
</span><ins>+            if (isVolatile)
+                m_frontBuffer.surface-&gt;releaseGraphicsContext();
</ins><span class="cx">             if (!isVolatile || !m_frontBuffer.surface-&gt;isInUse()) {
</span><span class="cx">                 IOSurface::SurfaceState previousState = m_frontBuffer.surface-&gt;setIsVolatile(isVolatile);
</span><span class="cx">                 m_frontBuffer.isVolatile = isVolatile;
</span><span class="lines">@@ -395,6 +400,8 @@
</span><span class="cx">         break;
</span><span class="cx">     case BufferType::Back:
</span><span class="cx">         if (m_backBuffer.surface &amp;&amp; m_backBuffer.isVolatile != isVolatile) {
</span><ins>+            if (isVolatile)
+                m_backBuffer.surface-&gt;releaseGraphicsContext();
</ins><span class="cx">             if (!isVolatile || !m_backBuffer.surface-&gt;isInUse()) {
</span><span class="cx">                 m_backBuffer.surface-&gt;setIsVolatile(isVolatile);
</span><span class="cx">                 m_backBuffer.isVolatile = isVolatile;
</span><span class="lines">@@ -404,6 +411,8 @@
</span><span class="cx">         break;
</span><span class="cx">     case BufferType::SecondaryBack:
</span><span class="cx">         if (m_secondaryBackBuffer.surface &amp;&amp; m_secondaryBackBuffer.isVolatile != isVolatile) {
</span><ins>+            if (isVolatile)
+                m_secondaryBackBuffer.surface-&gt;releaseGraphicsContext();
</ins><span class="cx">             if (!isVolatile || !m_secondaryBackBuffer.surface-&gt;isInUse()) {
</span><span class="cx">                 m_secondaryBackBuffer.surface-&gt;setIsVolatile(isVolatile);
</span><span class="cx">                 m_secondaryBackBuffer.isVolatile = isVolatile;
</span></span></pre></div>
<a id="trunkSourceWebKit2SharedmacRemoteLayerBackingStoreCollectionh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/Shared/mac/RemoteLayerBackingStoreCollection.h (169369 => 169370)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/Shared/mac/RemoteLayerBackingStoreCollection.h        2014-05-27 05:38:27 UTC (rev 169369)
+++ trunk/Source/WebKit2/Shared/mac/RemoteLayerBackingStoreCollection.h        2014-05-27 06:14:15 UTC (rev 169370)
</span><span class="lines">@@ -34,6 +34,7 @@
</span><span class="cx"> 
</span><span class="cx"> class RemoteLayerBackingStore;
</span><span class="cx"> class RemoteLayerTreeContext;
</span><ins>+class RemoteLayerTreeTransaction;
</ins><span class="cx"> 
</span><span class="cx"> class RemoteLayerBackingStoreCollection {
</span><span class="cx">     WTF_MAKE_NONCOPYABLE(RemoteLayerBackingStoreCollection);
</span><span class="lines">@@ -45,17 +46,29 @@
</span><span class="cx">     void backingStoreWasCreated(RemoteLayerBackingStore*);
</span><span class="cx">     void backingStoreWillBeDestroyed(RemoteLayerBackingStore*);
</span><span class="cx"> 
</span><del>-    void purgeabilityTimerFired(WebCore::Timer&lt;RemoteLayerBackingStoreCollection&gt;&amp;);
</del><ins>+    void backingStoreWillBeDisplayed(RemoteLayerBackingStore*);
+    void backingStoreBecameUnreachable(RemoteLayerBackingStore*);
</ins><span class="cx"> 
</span><del>-    void schedulePurgeabilityTimer();
</del><ins>+    void willFlushLayers();
+    void willCommitLayerTree(RemoteLayerTreeTransaction&amp;);
+    void didFlushLayers();
</ins><span class="cx"> 
</span><ins>+    void volatilityTimerFired(WebCore::Timer&lt;RemoteLayerBackingStoreCollection&gt;&amp;);
+
+    void scheduleVolatilityTimer();
+
</ins><span class="cx"> private:
</span><ins>+    bool markBackingStoreVolatileImmediately(RemoteLayerBackingStore&amp;);
+    bool markBackingStoreVolatile(RemoteLayerBackingStore&amp;, std::chrono::steady_clock::time_point now);
+
</ins><span class="cx">     HashSet&lt;RemoteLayerBackingStore*&gt; m_liveBackingStore;
</span><ins>+    HashSet&lt;RemoteLayerBackingStore*&gt; m_unparentedBackingStore;
+    HashSet&lt;RemoteLayerBackingStore*&gt; m_reachableBackingStoreInLatestFlush;
</ins><span class="cx"> 
</span><del>-    void markInactiveBackingStorePurgeable();
</del><ins>+    RemoteLayerTreeContext* m_context;
+    WebCore::Timer&lt;RemoteLayerBackingStoreCollection&gt; m_volatilityTimer;
</ins><span class="cx"> 
</span><del>-    RemoteLayerTreeContext* m_context;
-    WebCore::Timer&lt;RemoteLayerBackingStoreCollection&gt; m_purgeabilityTimer;
</del><ins>+    bool m_inLayerFlush;
</ins><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> } // namespace WebKit
</span></span></pre></div>
<a id="trunkSourceWebKit2SharedmacRemoteLayerBackingStoreCollectionmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/Shared/mac/RemoteLayerBackingStoreCollection.mm (169369 => 169370)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/Shared/mac/RemoteLayerBackingStoreCollection.mm        2014-05-27 05:38:27 UTC (rev 169369)
+++ trunk/Source/WebKit2/Shared/mac/RemoteLayerBackingStoreCollection.mm        2014-05-27 06:14:15 UTC (rev 169370)
</span><span class="lines">@@ -30,18 +30,54 @@
</span><span class="cx"> #import &quot;RemoteLayerBackingStore.h&quot;
</span><span class="cx"> #import &quot;RemoteLayerTreeContext.h&quot;
</span><span class="cx"> 
</span><del>-const std::chrono::seconds purgeableBackingStoreAgeThreshold = 1_s;
-const std::chrono::milliseconds purgeableSecondaryBackingStoreAgeThreshold = 200_ms;
-const std::chrono::milliseconds purgeabilityTimerInterval = 200_ms;
</del><ins>+const std::chrono::seconds volatileBackingStoreAgeThreshold = 1_s;
+const std::chrono::milliseconds volatileSecondaryBackingStoreAgeThreshold = 200_ms;
+const std::chrono::milliseconds volatilityTimerInterval = 200_ms;
</ins><span class="cx"> 
</span><span class="cx"> namespace WebKit {
</span><span class="cx"> 
</span><span class="cx"> RemoteLayerBackingStoreCollection::RemoteLayerBackingStoreCollection(RemoteLayerTreeContext* context)
</span><span class="cx">     : m_context(context)
</span><del>-    , m_purgeabilityTimer(this, &amp;RemoteLayerBackingStoreCollection::purgeabilityTimerFired)
</del><ins>+    , m_volatilityTimer(this, &amp;RemoteLayerBackingStoreCollection::volatilityTimerFired)
+    , m_inLayerFlush(false)
</ins><span class="cx"> {
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void RemoteLayerBackingStoreCollection::willFlushLayers()
+{
+    m_inLayerFlush = true;
+    m_reachableBackingStoreInLatestFlush.clear();
+}
+
+void RemoteLayerBackingStoreCollection::willCommitLayerTree(RemoteLayerTreeTransaction&amp; transaction)
+{
+    ASSERT(m_inLayerFlush);
+    Vector&lt;WebCore::GraphicsLayer::PlatformLayerID&gt; newlyUnreachableLayerIDs;
+    for (auto&amp; backingStore : m_liveBackingStore) {
+        if (!m_reachableBackingStoreInLatestFlush.contains(backingStore))
+            newlyUnreachableLayerIDs.append(backingStore-&gt;layer()-&gt;layerID());
+    }
+
+    transaction.setLayerIDsWithNewlyUnreachableBackingStore(newlyUnreachableLayerIDs);
+}
+
+void RemoteLayerBackingStoreCollection::didFlushLayers()
+{
+    m_inLayerFlush = false;
+
+    Vector&lt;RemoteLayerBackingStore*&gt; newlyUnreachableBackingStore;
+    for (auto&amp; backingStore : m_liveBackingStore) {
+        if (!m_reachableBackingStoreInLatestFlush.contains(backingStore))
+            newlyUnreachableBackingStore.append(backingStore);
+    }
+
+    for (auto&amp; backingStore : newlyUnreachableBackingStore)
+        backingStoreBecameUnreachable(backingStore);
+
+    if (!newlyUnreachableBackingStore.isEmpty())
+        scheduleVolatilityTimer();
+}
+
</ins><span class="cx"> void RemoteLayerBackingStoreCollection::backingStoreWasCreated(RemoteLayerBackingStore* backingStore)
</span><span class="cx"> {
</span><span class="cx">     m_liveBackingStore.add(backingStore);
</span><span class="lines">@@ -50,41 +86,92 @@
</span><span class="cx"> void RemoteLayerBackingStoreCollection::backingStoreWillBeDestroyed(RemoteLayerBackingStore* backingStore)
</span><span class="cx"> {
</span><span class="cx">     m_liveBackingStore.remove(backingStore);
</span><ins>+    m_unparentedBackingStore.remove(backingStore);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-void RemoteLayerBackingStoreCollection::purgeabilityTimerFired(WebCore::Timer&lt;RemoteLayerBackingStoreCollection&gt;&amp;)
</del><ins>+void RemoteLayerBackingStoreCollection::backingStoreWillBeDisplayed(RemoteLayerBackingStore* backingStore)
</ins><span class="cx"> {
</span><del>-    auto now = std::chrono::steady_clock::now();
-    bool hadRecentlyPaintedBackingStore = false;
-    bool successfullyMadeBackingStorePurgeable = true;
</del><ins>+    ASSERT(m_inLayerFlush);
+    m_reachableBackingStoreInLatestFlush.add(backingStore);
</ins><span class="cx"> 
</span><del>-    for (const auto&amp; backingStore : m_liveBackingStore) {
-        if (now - backingStore-&gt;lastDisplayTime() &lt; purgeableBackingStoreAgeThreshold) {
-            hadRecentlyPaintedBackingStore = true;
</del><ins>+    auto backingStoreIter = m_unparentedBackingStore.find(backingStore);
+    if (backingStoreIter == m_unparentedBackingStore.end())
+        return;
+    m_liveBackingStore.add(backingStore);
+    m_unparentedBackingStore.remove(backingStoreIter);
+}
</ins><span class="cx"> 
</span><del>-            if (now - backingStore-&gt;lastDisplayTime() &gt;= purgeableSecondaryBackingStoreAgeThreshold)
-                backingStore-&gt;setBufferVolatility(RemoteLayerBackingStore::BufferType::SecondaryBack, true);
</del><ins>+bool RemoteLayerBackingStoreCollection::markBackingStoreVolatileImmediately(RemoteLayerBackingStore&amp; backingStore)
+{
+    ASSERT(!m_inLayerFlush);
+    bool successfullyMadeBackingStoreVolatile = true;
</ins><span class="cx"> 
</span><del>-            continue;
-        }
</del><ins>+    if (!backingStore.setBufferVolatility(RemoteLayerBackingStore::BufferType::SecondaryBack, true))
+        successfullyMadeBackingStoreVolatile = false;
</ins><span class="cx"> 
</span><del>-        // FIXME: If the layer is unparented, we should make all buffers volatile.
-        if (!backingStore-&gt;setBufferVolatility(RemoteLayerBackingStore::BufferType::SecondaryBack, true))
-            successfullyMadeBackingStorePurgeable = false;
-        if (!backingStore-&gt;setBufferVolatility(RemoteLayerBackingStore::BufferType::Back, true))
-            successfullyMadeBackingStorePurgeable = false;
</del><ins>+    if (!backingStore.setBufferVolatility(RemoteLayerBackingStore::BufferType::Back, true))
+        successfullyMadeBackingStoreVolatile = false;
+
+    if (!m_reachableBackingStoreInLatestFlush.contains(&amp;backingStore)) {
+        if (!backingStore.setBufferVolatility(RemoteLayerBackingStore::BufferType::Front, true))
+            successfullyMadeBackingStoreVolatile = false;
</ins><span class="cx">     }
</span><span class="cx"> 
</span><del>-    if (!hadRecentlyPaintedBackingStore &amp;&amp; successfullyMadeBackingStorePurgeable)
-        m_purgeabilityTimer.stop();
</del><ins>+    return successfullyMadeBackingStoreVolatile;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-void RemoteLayerBackingStoreCollection::schedulePurgeabilityTimer()
</del><ins>+bool RemoteLayerBackingStoreCollection::markBackingStoreVolatile(RemoteLayerBackingStore&amp; backingStore, std::chrono::steady_clock::time_point now)
</ins><span class="cx"> {
</span><del>-    if (m_purgeabilityTimer.isActive())
</del><ins>+    if (now - backingStore.lastDisplayTime() &lt; volatileBackingStoreAgeThreshold) {
+        if (now - backingStore.lastDisplayTime() &gt;= volatileSecondaryBackingStoreAgeThreshold)
+            backingStore.setBufferVolatility(RemoteLayerBackingStore::BufferType::SecondaryBack, true);
+
+        return false;
+    }
+    
+    return markBackingStoreVolatileImmediately(backingStore);
+}
+
+void RemoteLayerBackingStoreCollection::backingStoreBecameUnreachable(RemoteLayerBackingStore* backingStore)
+{
+    ASSERT(backingStore-&gt;layer());
+
+    auto backingStoreIter = m_liveBackingStore.find(backingStore);
+    if (backingStoreIter == m_liveBackingStore.end())
</ins><span class="cx">         return;
</span><ins>+    m_unparentedBackingStore.add(backingStore);
+    m_liveBackingStore.remove(backingStoreIter);
</ins><span class="cx"> 
</span><del>-    m_purgeabilityTimer.startRepeating(purgeabilityTimerInterval);
</del><ins>+    // If a layer with backing store is removed from the tree, mark it as having changed backing store, so that
+    // on the commit which returns it to the tree, we serialize the backing store (despite possibly not painting).
+    backingStore-&gt;layer()-&gt;properties().notePropertiesChanged(RemoteLayerTreeTransaction::BackingStoreChanged);
+
+    // This will not succeed in marking all buffers as volatile, because the commit unparenting the layer hasn't
+    // made it to the UI process yet. The volatility timer will finish marking the remaining buffers later.
+    markBackingStoreVolatileImmediately(*backingStore);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void RemoteLayerBackingStoreCollection::volatilityTimerFired(WebCore::Timer&lt;RemoteLayerBackingStoreCollection&gt;&amp;)
+{
+    bool successfullyMadeBackingStoreVolatile = true;
+
+    auto now = std::chrono::steady_clock::now();
+    for (const auto&amp; backingStore : m_liveBackingStore)
+        successfullyMadeBackingStoreVolatile &amp;= markBackingStoreVolatile(*backingStore, now);
+
+    for (const auto&amp; backingStore : m_unparentedBackingStore)
+        successfullyMadeBackingStoreVolatile &amp;= markBackingStoreVolatileImmediately(*backingStore);
+
+    if (successfullyMadeBackingStoreVolatile)
+        m_volatilityTimer.stop();
+}
+
+void RemoteLayerBackingStoreCollection::scheduleVolatilityTimer()
+{
+    if (m_volatilityTimer.isActive())
+        return;
+
+    m_volatilityTimer.startRepeating(volatilityTimerInterval);
+}
+
</ins><span class="cx"> } // namespace WebKit
</span></span></pre></div>
<a id="trunkSourceWebKit2SharedmacRemoteLayerTreeTransactionh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/Shared/mac/RemoteLayerTreeTransaction.h (169369 => 169370)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/Shared/mac/RemoteLayerTreeTransaction.h        2014-05-27 05:38:27 UTC (rev 169369)
+++ trunk/Source/WebKit2/Shared/mac/RemoteLayerTreeTransaction.h        2014-05-27 06:14:15 UTC (rev 169370)
</span><span class="lines">@@ -163,6 +163,7 @@
</span><span class="cx">     void layerPropertiesChanged(PlatformCALayerRemote*, LayerProperties&amp;);
</span><span class="cx">     void setCreatedLayers(Vector&lt;LayerCreationProperties&gt;);
</span><span class="cx">     void setDestroyedLayerIDs(Vector&lt;WebCore::GraphicsLayer::PlatformLayerID&gt;);
</span><ins>+    void setLayerIDsWithNewlyUnreachableBackingStore(Vector&lt;WebCore::GraphicsLayer::PlatformLayerID&gt;);
</ins><span class="cx"> 
</span><span class="cx"> #if !defined(NDEBUG) || !LOG_DISABLED
</span><span class="cx">     WTF::CString description() const;
</span><span class="lines">@@ -173,6 +174,7 @@
</span><span class="cx"> 
</span><span class="cx">     Vector&lt;LayerCreationProperties&gt; createdLayers() const { return m_createdLayers; }
</span><span class="cx">     Vector&lt;WebCore::GraphicsLayer::PlatformLayerID&gt; destroyedLayers() const { return m_destroyedLayerIDs; }
</span><ins>+    Vector&lt;WebCore::GraphicsLayer::PlatformLayerID&gt; layerIDsWithNewlyUnreachableBackingStore() const { return m_layerIDsWithNewlyUnreachableBackingStore; }
</ins><span class="cx"> 
</span><span class="cx">     Vector&lt;RefPtr&lt;PlatformCALayerRemote&gt;&gt;&amp; changedLayers() { return m_changedLayers; }
</span><span class="cx"> 
</span><span class="lines">@@ -214,6 +216,7 @@
</span><span class="cx">     Vector&lt;LayerCreationProperties&gt; m_createdLayers;
</span><span class="cx">     Vector&lt;WebCore::GraphicsLayer::PlatformLayerID&gt; m_destroyedLayerIDs;
</span><span class="cx">     Vector&lt;WebCore::GraphicsLayer::PlatformLayerID&gt; m_videoLayerIDsPendingFullscreen;
</span><ins>+    Vector&lt;WebCore::GraphicsLayer::PlatformLayerID&gt; m_layerIDsWithNewlyUnreachableBackingStore;
</ins><span class="cx"> 
</span><span class="cx">     WebCore::IntSize m_contentsSize;
</span><span class="cx">     WebCore::Color m_pageExtendedBackgroundColor;
</span></span></pre></div>
<a id="trunkSourceWebKit2SharedmacRemoteLayerTreeTransactionmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/Shared/mac/RemoteLayerTreeTransaction.mm (169369 => 169370)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/Shared/mac/RemoteLayerTreeTransaction.mm        2014-05-27 05:38:27 UTC (rev 169369)
+++ trunk/Source/WebKit2/Shared/mac/RemoteLayerTreeTransaction.mm        2014-05-27 06:14:15 UTC (rev 169370)
</span><span class="lines">@@ -452,6 +452,7 @@
</span><span class="cx">     
</span><span class="cx">     encoder &lt;&lt; m_destroyedLayerIDs;
</span><span class="cx">     encoder &lt;&lt; m_videoLayerIDsPendingFullscreen;
</span><ins>+    encoder &lt;&lt; m_layerIDsWithNewlyUnreachableBackingStore;
</ins><span class="cx"> 
</span><span class="cx">     encoder &lt;&lt; m_contentsSize;
</span><span class="cx">     encoder &lt;&lt; m_pageExtendedBackgroundColor;
</span><span class="lines">@@ -503,6 +504,14 @@
</span><span class="cx">     if (!decoder.decode(result.m_videoLayerIDsPendingFullscreen))
</span><span class="cx">         return false;
</span><span class="cx"> 
</span><ins>+    if (!decoder.decode(result.m_layerIDsWithNewlyUnreachableBackingStore))
+        return false;
+
+    for (auto&amp; layerID : result.m_layerIDsWithNewlyUnreachableBackingStore) {
+        if (!layerID)
+            return false;
+    }
+
</ins><span class="cx">     if (!decoder.decode(result.m_contentsSize))
</span><span class="cx">         return false;
</span><span class="cx">     
</span><span class="lines">@@ -555,6 +564,11 @@
</span><span class="cx">     m_destroyedLayerIDs = std::move(destroyedLayerIDs);
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void RemoteLayerTreeTransaction::setLayerIDsWithNewlyUnreachableBackingStore(Vector&lt;GraphicsLayer::PlatformLayerID&gt; layerIDsWithNewlyUnreachableBackingStore)
+{
+    m_layerIDsWithNewlyUnreachableBackingStore = std::move(layerIDsWithNewlyUnreachableBackingStore);
+}
+
</ins><span class="cx"> #if !defined(NDEBUG) || !LOG_DISABLED
</span><span class="cx"> 
</span><span class="cx"> class RemoteLayerTreeTextStream : public TextStream
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessmacRemoteLayerTreeHostmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/mac/RemoteLayerTreeHost.mm (169369 => 169370)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/mac/RemoteLayerTreeHost.mm        2014-05-27 05:38:27 UTC (rev 169369)
+++ trunk/Source/WebKit2/UIProcess/mac/RemoteLayerTreeHost.mm        2014-05-27 06:14:15 UTC (rev 169370)
</span><span class="lines">@@ -96,6 +96,11 @@
</span><span class="cx">     for (auto&amp; destroyedLayer : transaction.destroyedLayers())
</span><span class="cx">         layerWillBeRemoved(destroyedLayer);
</span><span class="cx"> 
</span><ins>+    // Drop the contents of any layers which were unparented; the Web process will re-send
+    // the backing store in the commit that reparents them.
+    for (auto&amp; newlyUnreachableLayerID : transaction.layerIDsWithNewlyUnreachableBackingStore())
+        asLayer(getLayer(newlyUnreachableLayerID)).contents = nullptr;
+
</ins><span class="cx">     return rootLayerChanged;
</span><span class="cx"> }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcessWebPagemacRemoteLayerTreeContexth"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/WebPage/mac/RemoteLayerTreeContext.h (169369 => 169370)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/WebPage/mac/RemoteLayerTreeContext.h        2014-05-27 05:38:27 UTC (rev 169369)
+++ trunk/Source/WebKit2/WebProcess/WebPage/mac/RemoteLayerTreeContext.h        2014-05-27 06:14:15 UTC (rev 169370)
</span><span class="lines">@@ -50,6 +50,7 @@
</span><span class="cx"> 
</span><span class="cx">     void backingStoreWasCreated(RemoteLayerBackingStore*);
</span><span class="cx">     void backingStoreWillBeDestroyed(RemoteLayerBackingStore*);
</span><ins>+    void backingStoreWillBeDisplayed(RemoteLayerBackingStore*);
</ins><span class="cx"> 
</span><span class="cx">     LayerHostingMode layerHostingMode() const { return m_webPage-&gt;layerHostingMode(); }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcessWebPagemacRemoteLayerTreeContextmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/WebPage/mac/RemoteLayerTreeContext.mm (169369 => 169370)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/WebPage/mac/RemoteLayerTreeContext.mm        2014-05-27 05:38:27 UTC (rev 169369)
+++ trunk/Source/WebKit2/WebProcess/WebPage/mac/RemoteLayerTreeContext.mm        2014-05-27 06:14:15 UTC (rev 169370)
</span><span class="lines">@@ -86,6 +86,11 @@
</span><span class="cx">     m_backingStoreCollection.backingStoreWillBeDestroyed(backingStore);
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void RemoteLayerTreeContext::backingStoreWillBeDisplayed(RemoteLayerBackingStore* backingStore)
+{
+    m_backingStoreCollection.backingStoreWillBeDisplayed(backingStore);
+}
+
</ins><span class="cx"> std::unique_ptr&lt;GraphicsLayer&gt; RemoteLayerTreeContext::createGraphicsLayer(GraphicsLayerClient&amp; client)
</span><span class="cx"> {
</span><span class="cx">     return std::make_unique&lt;GraphicsLayerCARemote&gt;(client, this);
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcessWebPagemacRemoteLayerTreeDrawingAreamm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/WebPage/mac/RemoteLayerTreeDrawingArea.mm (169369 => 169370)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/WebPage/mac/RemoteLayerTreeDrawingArea.mm        2014-05-27 05:38:27 UTC (rev 169369)
+++ trunk/Source/WebKit2/WebProcess/WebPage/mac/RemoteLayerTreeDrawingArea.mm        2014-05-27 06:14:15 UTC (rev 169370)
</span><span class="lines">@@ -257,6 +257,9 @@
</span><span class="cx"> 
</span><span class="cx">     RELEASE_ASSERT(!m_pendingBackingStoreFlusher || m_pendingBackingStoreFlusher-&gt;hasFlushed());
</span><span class="cx"> 
</span><ins>+    RemoteLayerBackingStoreCollection&amp; backingStoreCollection = m_remoteLayerTreeContext-&gt;backingStoreCollection();
+    backingStoreCollection.willFlushLayers();
+
</ins><span class="cx">     m_webPage-&gt;layoutIfNeeded();
</span><span class="cx"> 
</span><span class="cx">     FloatRect visibleRect(FloatPoint(), m_viewSize);
</span><span class="lines">@@ -265,9 +268,10 @@
</span><span class="cx">     m_webPage-&gt;corePage()-&gt;mainFrame().view()-&gt;flushCompositingStateIncludingSubframes();
</span><span class="cx">     m_rootLayer-&gt;flushCompositingStateForThisLayerOnly();
</span><span class="cx"> 
</span><del>-    // FIXME: minize these transactions if nothing changed.
</del><ins>+    // FIXME: Minimize these transactions if nothing changed.
</ins><span class="cx">     RemoteLayerTreeTransaction layerTransaction;
</span><span class="cx">     m_remoteLayerTreeContext-&gt;buildTransaction(layerTransaction, *toGraphicsLayerCARemote(m_rootLayer.get())-&gt;platformCALayer());
</span><ins>+    backingStoreCollection.willCommitLayerTree(layerTransaction);
</ins><span class="cx">     m_webPage-&gt;willCommitLayerTree(layerTransaction);
</span><span class="cx"> 
</span><span class="cx">     RemoteScrollingCoordinatorTransaction scrollingTransaction;
</span><span class="lines">@@ -282,6 +286,7 @@
</span><span class="cx">     auto commitEncoder = std::make_unique&lt;IPC::MessageEncoder&gt;(Messages::RemoteLayerTreeDrawingAreaProxy::CommitLayerTree::receiverName(), Messages::RemoteLayerTreeDrawingAreaProxy::CommitLayerTree::name(), m_webPage-&gt;pageID());
</span><span class="cx">     commitEncoder-&gt;encode(message.arguments());
</span><span class="cx"> 
</span><ins>+    // FIXME: Move all backing store flushing management to RemoteLayerBackingStoreCollection.
</ins><span class="cx">     bool hadAnyChangedBackingStore = false;
</span><span class="cx">     Vector&lt;RetainPtr&lt;CGContextRef&gt;&gt; contextsToFlush;
</span><span class="cx">     for (auto&amp; layer : layerTransaction.changedLayers()) {
</span><span class="lines">@@ -296,8 +301,10 @@
</span><span class="cx">         layer-&gt;didCommit();
</span><span class="cx">     }
</span><span class="cx"> 
</span><ins>+    backingStoreCollection.didFlushLayers();
+
</ins><span class="cx">     if (hadAnyChangedBackingStore)
</span><del>-        m_remoteLayerTreeContext-&gt;backingStoreCollection().schedulePurgeabilityTimer();
</del><ins>+        backingStoreCollection.scheduleVolatilityTimer();
</ins><span class="cx"> 
</span><span class="cx">     RefPtr&lt;BackingStoreFlusher&gt; backingStoreFlusher = BackingStoreFlusher::create(WebProcess::shared().parentProcessConnection(), std::move(commitEncoder), std::move(contextsToFlush));
</span><span class="cx">     m_pendingBackingStoreFlusher = backingStoreFlusher;
</span></span></pre>
</div>
</div>

</body>
</html>