<!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>[166545] trunk/Source/WebKit2</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/166545">166545</a></dd>
<dt>Author</dt> <dd>timothy_horton@apple.com</dd>
<dt>Date</dt> <dd>2014-03-31 16:30:43 -0700 (Mon, 31 Mar 2014)</dd>
</dl>

<h3>Log Message</h3>
<pre>[iOS WebKit2] Flush all surfaces after painting into all of them, instead of after painting into each one
https://bugs.webkit.org/show_bug.cgi?id=130768
&lt;rdar://problem/16421471&gt;

Reviewed by Benjamin Poulain.

* Shared/mac/RemoteLayerBackingStore.h:
Make RemoteLayerBackingStore noncopyable.
Add flush(), which synchronously flushes painting operations on the underlying backing store.
Add storage for the CGContext that needs to be flushed, and ensure that it is flushed before we paint again.

* Shared/mac/RemoteLayerBackingStore.mm:
(RemoteLayerBackingStore::display):

(RemoteLayerBackingStore::drawInContext):
Don't flush the context immediately after painting.

(RemoteLayerBackingStore::flush):
Flush the current front surface/buffer's context.
Clear the new pending-flush members.

* WebProcess/WebPage/mac/RemoteLayerTreeDrawingArea.mm:
(WebKit::flushBackingStoreChangesInTransaction):
(WebKit::RemoteLayerTreeDrawingArea::flushLayers):
Crawl through all of the valid changed backing stores in the transaction and flush them.
Reset changed properties after encoding the commit.

* Shared/mac/RemoteLayerTreeTransaction.h:
(WebKit::RemoteLayerTreeTransaction::LayerProperties::resetChangedProperties):
(WebKit::RemoteLayerTreeTransaction::changedLayers):
(WebKit::RemoteLayerTreeTransaction::changedLayerProperties):
* Shared/mac/RemoteLayerTreeTransaction.mm:
(WebKit::RemoteLayerTreeTransaction::LayerProperties::LayerProperties):
(WebKit::RemoteLayerTreeTransaction::LayerProperties::decode):
(WebKit::RemoteLayerTreeTransaction::encode):
(WebKit::RemoteLayerTreeTransaction::decode):
(WebKit::RemoteLayerTreeTransaction::layerPropertiesChanged):
(WebKit::dumpChangedLayers):
Instead of storing a copy of the LayerProperties struct for each changed layer
while building the transaction in the Web process, store a list of changed layers,
and directly encode the commit from those layers' LayerProperties. This provides a few benefits:
        - We avoid copying LayerProperties for every changed layer, every commit
        - We can make RemoteLayerBackingStore noncopyable
        - We can walk the changed layers after building the transaction
        in order to flush backing store, and actually affect the layers'
        own RemoteLayerBackingStore instead of a copy.
The UI process will still generate a LayerPropertiesMap at decode time.

* UIProcess/mac/RemoteLayerTreeHost.mm:
(WebKit::RemoteLayerTreeHost::updateLayerTree):
Don't copy the LayerProperties struct for the debug overlay. Instead,
adjust the properties which the debug overlay whacks directly on the layer,
after applying the normal LayerProperties.

* WebProcess/WebPage/mac/PlatformCALayerRemote.cpp:
(PlatformCALayerRemote::recursiveBuildTransaction):
Don't reset changed layer properties in the middle of building a transaction. Instead,
RemoteLayerTreeDrawingArea::flushLayers() will reset all the flags on all changed layers
after the commit is encoded.

* WebProcess/WebPage/mac/PlatformCALayerRemote.h:
(WebKit::PlatformCALayerRemote::properties):</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebKit2ChangeLog">trunk/Source/WebKit2/ChangeLog</a></li>
<li><a href="#trunkSourceWebKit2SharedmacRemoteLayerBackingStoreh">trunk/Source/WebKit2/Shared/mac/RemoteLayerBackingStore.h</a></li>
<li><a href="#trunkSourceWebKit2SharedmacRemoteLayerBackingStoremm">trunk/Source/WebKit2/Shared/mac/RemoteLayerBackingStore.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="#trunkSourceWebKit2WebProcessWebPagemacPlatformCALayerRemotecpp">trunk/Source/WebKit2/WebProcess/WebPage/mac/PlatformCALayerRemote.cpp</a></li>
<li><a href="#trunkSourceWebKit2WebProcessWebPagemacPlatformCALayerRemoteh">trunk/Source/WebKit2/WebProcess/WebPage/mac/PlatformCALayerRemote.h</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="trunkSourceWebKit2ChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/ChangeLog (166544 => 166545)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/ChangeLog        2014-03-31 23:27:29 UTC (rev 166544)
+++ trunk/Source/WebKit2/ChangeLog        2014-03-31 23:30:43 UTC (rev 166545)
</span><span class="lines">@@ -1,3 +1,68 @@
</span><ins>+2014-03-31  Tim Horton  &lt;timothy_horton@apple.com&gt;
+
+        [iOS WebKit2] Flush all surfaces after painting into all of them, instead of after painting into each one
+        https://bugs.webkit.org/show_bug.cgi?id=130768
+        &lt;rdar://problem/16421471&gt;
+
+        Reviewed by Benjamin Poulain.
+
+        * Shared/mac/RemoteLayerBackingStore.h:
+        Make RemoteLayerBackingStore noncopyable.
+        Add flush(), which synchronously flushes painting operations on the underlying backing store.
+        Add storage for the CGContext that needs to be flushed, and ensure that it is flushed before we paint again.
+
+        * Shared/mac/RemoteLayerBackingStore.mm:
+        (RemoteLayerBackingStore::display):
+
+        (RemoteLayerBackingStore::drawInContext):
+        Don't flush the context immediately after painting.
+
+        (RemoteLayerBackingStore::flush):
+        Flush the current front surface/buffer's context.
+        Clear the new pending-flush members.
+
+        * WebProcess/WebPage/mac/RemoteLayerTreeDrawingArea.mm:
+        (WebKit::flushBackingStoreChangesInTransaction):
+        (WebKit::RemoteLayerTreeDrawingArea::flushLayers):
+        Crawl through all of the valid changed backing stores in the transaction and flush them.
+        Reset changed properties after encoding the commit.
+
+        * Shared/mac/RemoteLayerTreeTransaction.h:
+        (WebKit::RemoteLayerTreeTransaction::LayerProperties::resetChangedProperties):
+        (WebKit::RemoteLayerTreeTransaction::changedLayers):
+        (WebKit::RemoteLayerTreeTransaction::changedLayerProperties):
+        * Shared/mac/RemoteLayerTreeTransaction.mm:
+        (WebKit::RemoteLayerTreeTransaction::LayerProperties::LayerProperties):
+        (WebKit::RemoteLayerTreeTransaction::LayerProperties::decode):
+        (WebKit::RemoteLayerTreeTransaction::encode):
+        (WebKit::RemoteLayerTreeTransaction::decode):
+        (WebKit::RemoteLayerTreeTransaction::layerPropertiesChanged):
+        (WebKit::dumpChangedLayers):
+        Instead of storing a copy of the LayerProperties struct for each changed layer
+        while building the transaction in the Web process, store a list of changed layers,
+        and directly encode the commit from those layers' LayerProperties. This provides a few benefits:
+                - We avoid copying LayerProperties for every changed layer, every commit
+                - We can make RemoteLayerBackingStore noncopyable
+                - We can walk the changed layers after building the transaction
+                in order to flush backing store, and actually affect the layers'
+                own RemoteLayerBackingStore instead of a copy.
+        The UI process will still generate a LayerPropertiesMap at decode time.
+        
+        * UIProcess/mac/RemoteLayerTreeHost.mm:
+        (WebKit::RemoteLayerTreeHost::updateLayerTree):
+        Don't copy the LayerProperties struct for the debug overlay. Instead,
+        adjust the properties which the debug overlay whacks directly on the layer,
+        after applying the normal LayerProperties.
+
+        * WebProcess/WebPage/mac/PlatformCALayerRemote.cpp:
+        (PlatformCALayerRemote::recursiveBuildTransaction):
+        Don't reset changed layer properties in the middle of building a transaction. Instead,
+        RemoteLayerTreeDrawingArea::flushLayers() will reset all the flags on all changed layers
+        after the commit is encoded.
+
+        * WebProcess/WebPage/mac/PlatformCALayerRemote.h:
+        (WebKit::PlatformCALayerRemote::properties):
+
</ins><span class="cx"> 2014-03-31  Simon Fraser  &lt;simon.fraser@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         [UI-side compositing] Proxy animations to the UI process
</span></span></pre></div>
<a id="trunkSourceWebKit2SharedmacRemoteLayerBackingStoreh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/Shared/mac/RemoteLayerBackingStore.h (166544 => 166545)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/Shared/mac/RemoteLayerBackingStore.h        2014-03-31 23:27:29 UTC (rev 166544)
+++ trunk/Source/WebKit2/Shared/mac/RemoteLayerBackingStore.h        2014-03-31 23:30:43 UTC (rev 166545)
</span><span class="lines">@@ -43,6 +43,8 @@
</span><span class="cx"> class PlatformCALayerRemote;
</span><span class="cx"> 
</span><span class="cx"> class RemoteLayerBackingStore {
</span><ins>+    WTF_MAKE_NONCOPYABLE(RemoteLayerBackingStore);
+    WTF_MAKE_FAST_ALLOCATED;
</ins><span class="cx"> public:
</span><span class="cx">     RemoteLayerBackingStore();
</span><span class="cx"> 
</span><span class="lines">@@ -76,6 +78,8 @@
</span><span class="cx">         return !!m_frontBuffer;
</span><span class="cx">     }
</span><span class="cx"> 
</span><ins>+    void flush();
+
</ins><span class="cx"> private:
</span><span class="cx">     void drawInContext(WebCore::GraphicsContext&amp;, CGImageRef backImage);
</span><span class="cx">     void clearBackingStore();
</span><span class="lines">@@ -95,6 +99,8 @@
</span><span class="cx">     RefPtr&lt;WebCore::IOSurface&gt; m_backSurface;
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><ins>+    RetainPtr&lt;CGContextRef&gt; m_frontContextPendingFlush;
+
</ins><span class="cx">     bool m_acceleratesDrawing;
</span><span class="cx"> 
</span><span class="cx">     WebCore::RepaintRectList m_paintingRects;
</span></span></pre></div>
<a id="trunkSourceWebKit2SharedmacRemoteLayerBackingStoremm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/Shared/mac/RemoteLayerBackingStore.mm (166544 => 166545)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/Shared/mac/RemoteLayerBackingStore.mm        2014-03-31 23:27:29 UTC (rev 166544)
+++ trunk/Source/WebKit2/Shared/mac/RemoteLayerBackingStore.mm        2014-03-31 23:30:43 UTC (rev 166545)
</span><span class="lines">@@ -151,6 +151,8 @@
</span><span class="cx"> 
</span><span class="cx"> bool RemoteLayerBackingStore::display()
</span><span class="cx"> {
</span><ins>+    ASSERT(!m_frontContextPendingFlush);
+
</ins><span class="cx">     if (!m_layer)
</span><span class="cx">         return false;
</span><span class="cx"> 
</span><span class="lines">@@ -202,10 +204,10 @@
</span><span class="cx"> 
</span><span class="cx">         return true;
</span><span class="cx">     }
</span><del>-#else
-    ASSERT(!m_acceleratesDrawing);
</del><span class="cx"> #endif
</span><span class="cx"> 
</span><ins>+    ASSERT(!m_acceleratesDrawing);
+
</ins><span class="cx">     std::swap(m_frontBuffer, m_backBuffer);
</span><span class="cx">     if (!m_frontBuffer)
</span><span class="cx">         m_frontBuffer = ShareableBitmap::createShareable(expandedScaledSize, m_isOpaque ? ShareableBitmap::NoFlags : ShareableBitmap::SupportsAlpha);
</span><span class="lines">@@ -294,7 +296,7 @@
</span><span class="cx">     m_dirtyRegion = Region();
</span><span class="cx">     m_paintingRects.clear();
</span><span class="cx"> 
</span><del>-    CGContextFlush(context.platformContext());
</del><ins>+    m_frontContextPendingFlush = context.platformContext();
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void RemoteLayerBackingStore::enumerateRectsBeingDrawn(CGContextRef context, void (^block)(CGRect))
</span><span class="lines">@@ -327,4 +329,12 @@
</span><span class="cx">     layer.contents = (id)m_frontBuffer-&gt;makeCGImageCopy().get();
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void RemoteLayerBackingStore::flush()
+{
+    if (m_frontContextPendingFlush) {
+        CGContextFlush(m_frontContextPendingFlush.get());
+        m_frontContextPendingFlush = nullptr;
+    }
+}
+
</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 (166544 => 166545)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/Shared/mac/RemoteLayerTreeTransaction.h        2014-03-31 23:27:29 UTC (rev 166544)
+++ trunk/Source/WebKit2/Shared/mac/RemoteLayerTreeTransaction.h        2014-03-31 23:30:43 UTC (rev 166545)
</span><span class="lines">@@ -108,6 +108,11 @@
</span><span class="cx">             everChangedProperties |= changeFlags;
</span><span class="cx">         }
</span><span class="cx"> 
</span><ins>+        void resetChangedProperties()
+        {
+            changedProperties = RemoteLayerTreeTransaction::NoChange;
+        }
+
</ins><span class="cx">         LayerChange changedProperties;
</span><span class="cx">         LayerChange everChangedProperties;
</span><span class="cx"> 
</span><span class="lines">@@ -163,12 +168,15 @@
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="cx">     typedef HashMap&lt;WebCore::GraphicsLayer::PlatformLayerID, std::unique_ptr&lt;LayerProperties&gt;&gt; LayerPropertiesMap;
</span><del>-    
</del><ins>+
</ins><span class="cx">     Vector&lt;LayerCreationProperties&gt; createdLayers() const { return m_createdLayers; }
</span><del>-    const LayerPropertiesMap&amp; changedLayers() const { return m_changedLayerProperties; }
-    LayerPropertiesMap&amp; changedLayers() { return m_changedLayerProperties; }
</del><span class="cx">     Vector&lt;WebCore::GraphicsLayer::PlatformLayerID&gt; destroyedLayers() const { return m_destroyedLayerIDs; }
</span><span class="cx"> 
</span><ins>+    Vector&lt;RefPtr&lt;PlatformCALayerRemote&gt;&gt;&amp; changedLayers() { return m_changedLayers; }
+
+    const LayerPropertiesMap&amp; changedLayerProperties() const { return m_changedLayerProperties; }
+    LayerPropertiesMap&amp; changedLayerProperties() { return m_changedLayerProperties; }
+
</ins><span class="cx">     WebCore::IntSize contentsSize() const { return m_contentsSize; }
</span><span class="cx">     void setContentsSize(const WebCore::IntSize&amp; size) { m_contentsSize = size; };
</span><span class="cx">     
</span><span class="lines">@@ -198,7 +206,9 @@
</span><span class="cx">     
</span><span class="cx"> private:
</span><span class="cx">     WebCore::GraphicsLayer::PlatformLayerID m_rootLayerID;
</span><del>-    LayerPropertiesMap m_changedLayerProperties;
</del><ins>+    Vector&lt;RefPtr&lt;PlatformCALayerRemote&gt;&gt; m_changedLayers; // Only used in the Web process.
+    LayerPropertiesMap m_changedLayerProperties; // Only used in the UI process.
+
</ins><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></span></pre></div>
<a id="trunkSourceWebKit2SharedmacRemoteLayerTreeTransactionmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/Shared/mac/RemoteLayerTreeTransaction.mm (166544 => 166545)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/Shared/mac/RemoteLayerTreeTransaction.mm        2014-03-31 23:27:29 UTC (rev 166544)
+++ trunk/Source/WebKit2/Shared/mac/RemoteLayerTreeTransaction.mm        2014-03-31 23:30:43 UTC (rev 166545)
</span><span class="lines">@@ -128,14 +128,14 @@
</span><span class="cx">     , masksToBounds(other.masksToBounds)
</span><span class="cx">     , opaque(other.opaque)
</span><span class="cx"> {
</span><ins>+    // FIXME: LayerProperties should reference backing store by ID, so that two layers can have the same backing store (for clones).
+    // FIXME: LayerProperties shouldn't be copyable; PlatformCALayerRemote::clone should copy the relevant properties.
+
</ins><span class="cx">     if (other.transform)
</span><span class="cx">         transform = std::make_unique&lt;TransformationMatrix&gt;(*other.transform);
</span><span class="cx"> 
</span><span class="cx">     if (other.sublayerTransform)
</span><span class="cx">         sublayerTransform = std::make_unique&lt;TransformationMatrix&gt;(*other.sublayerTransform);
</span><del>-    
-    if (other.backingStore)
-        backingStore = std::make_unique&lt;RemoteLayerBackingStore&gt;(*other.backingStore);
</del><span class="cx"> 
</span><span class="cx">     if (other.filters)
</span><span class="cx">         filters = std::make_unique&lt;FilterOperations&gt;(*other.filters);
</span><span class="lines">@@ -382,11 +382,11 @@
</span><span class="cx">         if (!decoder.decode(hasFrontBuffer))
</span><span class="cx">             return false;
</span><span class="cx">         if (hasFrontBuffer) {
</span><del>-            RemoteLayerBackingStore backingStore;
-            if (!decoder.decode(backingStore))
</del><ins>+            std::unique_ptr&lt;RemoteLayerBackingStore&gt; backingStore = std::make_unique&lt;RemoteLayerBackingStore&gt;();
+            if (!decoder.decode(*backingStore))
</ins><span class="cx">                 return false;
</span><span class="cx">             
</span><del>-            result.backingStore = std::make_unique&lt;RemoteLayerBackingStore&gt;(backingStore);
</del><ins>+            result.backingStore = std::move(backingStore);
</ins><span class="cx">         }
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="lines">@@ -428,11 +428,11 @@
</span><span class="cx">     encoder &lt;&lt; m_rootLayerID;
</span><span class="cx">     encoder &lt;&lt; m_createdLayers;
</span><span class="cx"> 
</span><del>-    encoder &lt;&lt; m_changedLayerProperties.size();
</del><ins>+    encoder &lt;&lt; static_cast&lt;uint64_t&gt;(m_changedLayers.size());
</ins><span class="cx"> 
</span><del>-    for (const auto&amp; layerProperties : m_changedLayerProperties) {
-        encoder &lt;&lt; layerProperties.key;
-        encoder &lt;&lt; *layerProperties.value;
</del><ins>+    for (RefPtr&lt;PlatformCALayerRemote&gt; layer : m_changedLayers) {
+        encoder &lt;&lt; layer-&gt;layerID();
+        encoder &lt;&lt; layer-&gt;properties();
</ins><span class="cx">     }
</span><span class="cx">     
</span><span class="cx">     encoder &lt;&lt; m_destroyedLayerIDs;
</span><span class="lines">@@ -461,11 +461,11 @@
</span><span class="cx">     if (!decoder.decode(result.m_createdLayers))
</span><span class="cx">         return false;
</span><span class="cx"> 
</span><del>-    int numChangedLayerProperties;
</del><ins>+    uint64_t numChangedLayerProperties;
</ins><span class="cx">     if (!decoder.decode(numChangedLayerProperties))
</span><span class="cx">         return false;
</span><span class="cx"> 
</span><del>-    for (int i = 0; i &lt; numChangedLayerProperties; ++i) {
</del><ins>+    for (uint64_t i = 0; i &lt; numChangedLayerProperties; ++i) {
</ins><span class="cx">         GraphicsLayer::PlatformLayerID layerID;
</span><span class="cx">         if (!decoder.decode(layerID))
</span><span class="cx">             return false;
</span><span class="lines">@@ -474,7 +474,7 @@
</span><span class="cx">         if (!decoder.decode(*layerProperties))
</span><span class="cx">             return false;
</span><span class="cx"> 
</span><del>-        result.changedLayers().set(layerID, std::move(layerProperties));
</del><ins>+        result.changedLayerProperties().set(layerID, std::move(layerProperties));
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     if (!decoder.decode(result.m_destroyedLayerIDs))
</span><span class="lines">@@ -527,7 +527,7 @@
</span><span class="cx"> 
</span><span class="cx"> void RemoteLayerTreeTransaction::layerPropertiesChanged(PlatformCALayerRemote* remoteLayer, RemoteLayerTreeTransaction::LayerProperties&amp; properties)
</span><span class="cx"> {
</span><del>-    m_changedLayerProperties.set(remoteLayer-&gt;layerID(), std::make_unique&lt;RemoteLayerTreeTransaction::LayerProperties&gt;(properties));
</del><ins>+    m_changedLayers.append(remoteLayer);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void RemoteLayerTreeTransaction::setCreatedLayers(Vector&lt;LayerCreationProperties&gt; createdLayers)
</span><span class="lines">@@ -818,7 +818,7 @@
</span><span class="cx"> 
</span><span class="cx">         if (layerProperties.changedProperties &amp; RemoteLayerTreeTransaction::BackingStoreChanged) {
</span><span class="cx">             if (const RemoteLayerBackingStore* backingStore = layerProperties.backingStore.get())
</span><del>-                dumpProperty&lt;RemoteLayerBackingStore&gt;(ts, &quot;backingStore&quot;, *backingStore);
</del><ins>+                dumpProperty&lt;const RemoteLayerBackingStore&amp;&gt;(ts, &quot;backingStore&quot;, *backingStore);
</ins><span class="cx">             else
</span><span class="cx">                 dumpProperty&lt;String&gt;(ts, &quot;backingStore&quot;, &quot;removed&quot;);
</span><span class="cx">         }
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessmacRemoteLayerTreeHostmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/mac/RemoteLayerTreeHost.mm (166544 => 166545)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/mac/RemoteLayerTreeHost.mm        2014-03-31 23:27:29 UTC (rev 166544)
+++ trunk/Source/WebKit2/UIProcess/mac/RemoteLayerTreeHost.mm        2014-03-31 23:30:43 UTC (rev 166545)
</span><span class="lines">@@ -56,7 +56,7 @@
</span><span class="cx"> bool RemoteLayerTreeHost::updateLayerTree(const RemoteLayerTreeTransaction&amp; transaction, float indicatorScaleFactor)
</span><span class="cx"> {
</span><span class="cx">     for (const auto&amp; createdLayer : transaction.createdLayers()) {
</span><del>-        const RemoteLayerTreeTransaction::LayerProperties* properties = transaction.changedLayers().get(createdLayer.layerID);
</del><ins>+        const RemoteLayerTreeTransaction::LayerProperties* properties = transaction.changedLayerProperties().get(createdLayer.layerID);
</ins><span class="cx">         createLayer(createdLayer, properties);
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="lines">@@ -67,7 +67,7 @@
</span><span class="cx">         rootLayerChanged = true;
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    for (auto&amp; changedLayer : transaction.changedLayers()) {
</del><ins>+    for (auto&amp; changedLayer : transaction.changedLayerProperties()) {
</ins><span class="cx">         auto layerID = changedLayer.key;
</span><span class="cx">         const RemoteLayerTreeTransaction::LayerProperties&amp; properties = *changedLayer.value;
</span><span class="cx"> 
</span><span class="lines">@@ -84,13 +84,13 @@
</span><span class="cx">             relatedLayers.set(properties.maskLayerID, getLayer(properties.maskLayerID));
</span><span class="cx"> 
</span><span class="cx">         if (m_isDebugLayerTreeHost) {
</span><del>-            RemoteLayerTreeTransaction::LayerProperties propertiesCopy(properties);
-            propertiesCopy.masksToBounds = false;
-            if (propertiesCopy.changedProperties &amp; RemoteLayerTreeTransaction::BorderWidthChanged)
-                propertiesCopy.borderWidth *= 1 / indicatorScaleFactor;
-            
-            RemoteLayerTreePropertyApplier::applyProperties(layer, this, propertiesCopy, relatedLayers);
-        } else
</del><ins>+            RemoteLayerTreePropertyApplier::applyProperties(layer, properties, relatedLayers);
+
+            if (properties.changedProperties &amp; RemoteLayerTreeTransaction::BorderWidthChanged)
+                asLayer(layer).borderWidth = properties.borderWidth / indicatorScaleFactor;
+            asLayer(layer).masksToBounds = false;
+          } else
+        else
</ins><span class="cx">             RemoteLayerTreePropertyApplier::applyProperties(layer, this, properties, relatedLayers);
</span><span class="cx">     }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcessWebPagemacPlatformCALayerRemotecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/WebPage/mac/PlatformCALayerRemote.cpp (166544 => 166545)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/WebPage/mac/PlatformCALayerRemote.cpp        2014-03-31 23:27:29 UTC (rev 166544)
+++ trunk/Source/WebKit2/WebProcess/WebPage/mac/PlatformCALayerRemote.cpp        2014-03-31 23:30:43 UTC (rev 166545)
</span><span class="lines">@@ -72,7 +72,7 @@
</span><span class="cx"> {
</span><span class="cx">     RefPtr&lt;PlatformCALayerRemote&gt; layer = adoptRef(new PlatformCALayerRemote(other, owner, context));
</span><span class="cx"> 
</span><del>-    context-&gt;layerWasCreated(layer.get(), LayerTypeCustom);
</del><ins>+    context-&gt;layerWasCreated(layer.get(), other.layerType());
</ins><span class="cx"> 
</span><span class="cx">     return layer.release();
</span><span class="cx"> }
</span><span class="lines">@@ -126,12 +126,11 @@
</span><span class="cx"> 
</span><span class="cx">         if (m_layerType == LayerTypeCustom) {
</span><span class="cx">             RemoteLayerTreePropertyApplier::applyProperties(platformLayer(), nullptr, m_properties, RemoteLayerTreePropertyApplier::RelatedLayerMap());
</span><del>-            m_properties.changedProperties = RemoteLayerTreeTransaction::NoChange;
</del><ins>+            m_properties.resetChangedProperties();
</ins><span class="cx">             return;
</span><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx">         transaction.layerPropertiesChanged(this, m_properties);
</span><del>-        m_properties.changedProperties = RemoteLayerTreeTransaction::NoChange;
</del><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     for (size_t i = 0; i &lt; m_children.size(); ++i) {
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcessWebPagemacPlatformCALayerRemoteh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/WebPage/mac/PlatformCALayerRemote.h (166544 => 166545)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/WebPage/mac/PlatformCALayerRemote.h        2014-03-31 23:27:29 UTC (rev 166544)
+++ trunk/Source/WebKit2/WebProcess/WebPage/mac/PlatformCALayerRemote.h        2014-03-31 23:30:43 UTC (rev 166545)
</span><span class="lines">@@ -151,6 +151,8 @@
</span><span class="cx"> 
</span><span class="cx">     virtual uint32_t hostingContextID();
</span><span class="cx"> 
</span><ins>+    RemoteLayerTreeTransaction::LayerProperties&amp; properties() { return m_properties; }
+
</ins><span class="cx"> protected:
</span><span class="cx">     PlatformCALayerRemote(WebCore::PlatformCALayer::LayerType, WebCore::PlatformCALayerClient* owner, RemoteLayerTreeContext* context);
</span><span class="cx">     PlatformCALayerRemote(const PlatformCALayerRemote&amp;, WebCore::PlatformCALayerClient*, RemoteLayerTreeContext*);
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcessWebPagemacRemoteLayerTreeDrawingAreamm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/WebPage/mac/RemoteLayerTreeDrawingArea.mm (166544 => 166545)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/WebPage/mac/RemoteLayerTreeDrawingArea.mm        2014-03-31 23:27:29 UTC (rev 166544)
+++ trunk/Source/WebKit2/WebProcess/WebPage/mac/RemoteLayerTreeDrawingArea.mm        2014-03-31 23:30:43 UTC (rev 166545)
</span><span class="lines">@@ -28,6 +28,7 @@
</span><span class="cx"> 
</span><span class="cx"> #import &quot;DrawingAreaProxyMessages.h&quot;
</span><span class="cx"> #import &quot;GraphicsLayerCARemote.h&quot;
</span><ins>+#import &quot;PlatformCALayerRemote.h&quot;
</ins><span class="cx"> #import &quot;RemoteLayerTreeContext.h&quot;
</span><span class="cx"> #import &quot;RemoteLayerTreeDrawingAreaProxyMessages.h&quot;
</span><span class="cx"> #import &quot;RemoteScrollingCoordinator.h&quot;
</span><span class="lines">@@ -309,6 +310,17 @@
</span><span class="cx">     flushLayers();
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+static void flushBackingStoreChangesInTransaction(RemoteLayerTreeTransaction&amp; transaction)
+{
+    for (RefPtr&lt;PlatformCALayerRemote&gt; layer : transaction.changedLayers()) {
+        if (!layer-&gt;properties().changedProperties &amp; RemoteLayerTreeTransaction::BackingStoreChanged)
+            return;
+
+        if (RemoteLayerBackingStore* backingStore = layer-&gt;properties().backingStore.get())
+            backingStore-&gt;flush();
+    }
+}
+
</ins><span class="cx"> void RemoteLayerTreeDrawingArea::flushLayers()
</span><span class="cx"> {
</span><span class="cx">     if (!m_rootLayer)
</span><span class="lines">@@ -340,8 +352,14 @@
</span><span class="cx">         toRemoteScrollingCoordinator(m_webPage-&gt;scrollingCoordinator())-&gt;buildTransaction(scrollingTransaction);
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><ins>+    // FIXME: Move flushing backing store and sending CommitLayerTree onto a background thread.
+    flushBackingStoreChangesInTransaction(layerTransaction);
+
</ins><span class="cx">     m_waitingForBackingStoreSwap = true;
</span><span class="cx">     m_webPage-&gt;send(Messages::RemoteLayerTreeDrawingAreaProxy::CommitLayerTree(layerTransaction, scrollingTransaction));
</span><ins>+
+    for (auto&amp; layer : layerTransaction.changedLayers())
+        layer-&gt;properties().resetChangedProperties();
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void RemoteLayerTreeDrawingArea::didUpdate()
</span></span></pre>
</div>
</div>

</body>
</html>