<!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>[167041] trunk/Source/WebCore</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/167041">167041</a></dd>
<dt>Author</dt> <dd>antti@apple.com</dd>
<dt>Date</dt> <dd>2014-04-09 15:29:15 -0700 (Wed, 09 Apr 2014)</dd>
</dl>

<h3>Log Message</h3>
<pre>TileGrid should be PlatformCALayerClient instead of TileController
https://bugs.webkit.org/show_bug.cgi?id=131456

Reviewed by Tim Horton.

The client interface is for the tiles in the grid.

* platform/graphics/ca/mac/TileController.h:
* platform/graphics/ca/mac/TileController.mm:
(WebCore::TileController::setContentsScale):
(WebCore::TileController::createTileLayer):
(WebCore::TileController::platformCALayerPaintContents): Deleted.
(WebCore::TileController::platformCALayerDeviceScaleFactor): Deleted.
(WebCore::TileController::platformCALayerShowDebugBorders): Deleted.
(WebCore::TileController::platformCALayerShowRepaintCounter): Deleted.
(WebCore::TileController::platformCALayerIncrementRepaintCount): Deleted.
* platform/graphics/ca/mac/TileGrid.h:
        
    Move repaint counter to TileGrid too.

* platform/graphics/ca/mac/TileGrid.mm:
(WebCore::TileGrid::removeTiles):
(WebCore::TileGrid::removeAllSecondaryTiles):
(WebCore::TileGrid::removeTilesInCohort):
        
   Cleaned up tile removal.

(WebCore::TileGrid::revalidateTiles):
(WebCore::TileGrid::ensureTilesForRect):
(WebCore::TileGrid::platformCALayerPaintContents):
(WebCore::TileGrid::platformCALayerDeviceScaleFactor):
(WebCore::TileGrid::platformCALayerShowDebugBorders):
(WebCore::TileGrid::platformCALayerShowRepaintCounter):
(WebCore::TileGrid::platformCALayerContentsOpaque):
(WebCore::TileGrid::platformCALayerIncrementRepaintCount):
(WebCore::queueTileForRemoval): Deleted.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicscamacTileControllerh">trunk/Source/WebCore/platform/graphics/ca/mac/TileController.h</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicscamacTileControllermm">trunk/Source/WebCore/platform/graphics/ca/mac/TileController.mm</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicscamacTileGridh">trunk/Source/WebCore/platform/graphics/ca/mac/TileGrid.h</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicscamacTileGridmm">trunk/Source/WebCore/platform/graphics/ca/mac/TileGrid.mm</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (167040 => 167041)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2014-04-09 22:24:42 UTC (rev 167040)
+++ trunk/Source/WebCore/ChangeLog        2014-04-09 22:29:15 UTC (rev 167041)
</span><span class="lines">@@ -1,3 +1,42 @@
</span><ins>+2014-04-09  Antti Koivisto  &lt;antti@apple.com&gt;
+
+        TileGrid should be PlatformCALayerClient instead of TileController
+        https://bugs.webkit.org/show_bug.cgi?id=131456
+
+        Reviewed by Tim Horton.
+
+        The client interface is for the tiles in the grid.
+
+        * platform/graphics/ca/mac/TileController.h:
+        * platform/graphics/ca/mac/TileController.mm:
+        (WebCore::TileController::setContentsScale):
+        (WebCore::TileController::createTileLayer):
+        (WebCore::TileController::platformCALayerPaintContents): Deleted.
+        (WebCore::TileController::platformCALayerDeviceScaleFactor): Deleted.
+        (WebCore::TileController::platformCALayerShowDebugBorders): Deleted.
+        (WebCore::TileController::platformCALayerShowRepaintCounter): Deleted.
+        (WebCore::TileController::platformCALayerIncrementRepaintCount): Deleted.
+        * platform/graphics/ca/mac/TileGrid.h:
+        
+            Move repaint counter to TileGrid too.
+
+        * platform/graphics/ca/mac/TileGrid.mm:
+        (WebCore::TileGrid::removeTiles):
+        (WebCore::TileGrid::removeAllSecondaryTiles):
+        (WebCore::TileGrid::removeTilesInCohort):
+        
+           Cleaned up tile removal.
+
+        (WebCore::TileGrid::revalidateTiles):
+        (WebCore::TileGrid::ensureTilesForRect):
+        (WebCore::TileGrid::platformCALayerPaintContents):
+        (WebCore::TileGrid::platformCALayerDeviceScaleFactor):
+        (WebCore::TileGrid::platformCALayerShowDebugBorders):
+        (WebCore::TileGrid::platformCALayerShowRepaintCounter):
+        (WebCore::TileGrid::platformCALayerContentsOpaque):
+        (WebCore::TileGrid::platformCALayerIncrementRepaintCount):
+        (WebCore::queueTileForRemoval): Deleted.
+
</ins><span class="cx"> 2014-04-09  Alexey Proskuryakov  &lt;ap@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Rename some dragging functions
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicscamacTileControllerh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/ca/mac/TileController.h (167040 => 167041)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/ca/mac/TileController.h        2014-04-09 22:24:42 UTC (rev 167040)
+++ trunk/Source/WebCore/platform/graphics/ca/mac/TileController.h        2014-04-09 22:29:15 UTC (rev 167041)
</span><span class="lines">@@ -48,9 +48,8 @@
</span><span class="cx"> 
</span><span class="cx"> typedef Vector&lt;RetainPtr&lt;PlatformLayer&gt;&gt; PlatformLayerList;
</span><span class="cx"> 
</span><del>-class TileController final : public TiledBacking, public PlatformCALayerClient {
-    WTF_MAKE_NONCOPYABLE(TileController);
-
</del><ins>+class TileController final : public TiledBacking {
+    WTF_MAKE_NONCOPYABLE(TileController); WTF_MAKE_FAST_ALLOCATED;
</ins><span class="cx"> public:
</span><span class="cx">     static PassOwnPtr&lt;TileController&gt; create(PlatformCALayer*);
</span><span class="cx">     ~TileController();
</span><span class="lines">@@ -104,6 +103,7 @@
</span><span class="cx">     virtual int rightMarginWidth() const override;
</span><span class="cx">     virtual TileCoverage tileCoverage() const override { return m_tileCoverage; }
</span><span class="cx">     virtual bool unparentsOffscreenTiles() const override { return m_unparentsOffscreenTiles; }
</span><ins>+    virtual bool scrollingPerformanceLoggingEnabled() const override { return m_scrollingPerformanceLoggingEnabled; }
</ins><span class="cx"> 
</span><span class="cx">     IntRect boundsWithoutMargin() const;
</span><span class="cx"> 
</span><span class="lines">@@ -117,12 +117,9 @@
</span><span class="cx">     bool shouldAggressivelyRetainTiles() const;
</span><span class="cx">     bool shouldTemporarilyRetainTileCohorts() const;
</span><span class="cx"> 
</span><del>-    typedef HashMap&lt;PlatformCALayer*, int&gt; RepaintCountMap;
-    RepaintCountMap&amp; repaintCountMap() { return m_tileRepaintCounts; }
-
</del><span class="cx">     void updateTileCoverageMap();
</span><span class="cx"> 
</span><del>-    RefPtr&lt;PlatformCALayer&gt; createTileLayer(const IntRect&amp;);
</del><ins>+    RefPtr&lt;PlatformCALayer&gt; createTileLayer(const IntRect&amp;, TileGrid&amp;);
</ins><span class="cx"> 
</span><span class="cx">     const TileGrid&amp; tileGrid() const { return *m_tileGrid; }
</span><span class="cx"> 
</span><span class="lines">@@ -144,7 +141,6 @@
</span><span class="cx">     virtual void forceRepaint() override;
</span><span class="cx">     virtual IntRect tileGridExtent() const override;
</span><span class="cx">     virtual void setScrollingPerformanceLoggingEnabled(bool flag) override { m_scrollingPerformanceLoggingEnabled = flag; }
</span><del>-    virtual bool scrollingPerformanceLoggingEnabled() const override { return m_scrollingPerformanceLoggingEnabled; }
</del><span class="cx">     virtual void setUnparentsOffscreenTiles(bool flag) override { m_unparentsOffscreenTiles = flag; }
</span><span class="cx">     virtual double retainedTileBackingStoreMemory() const override;
</span><span class="cx">     virtual IntRect tileCoverageRect() const override;
</span><span class="lines">@@ -152,15 +148,6 @@
</span><span class="cx">     virtual void setScrollingModeIndication(ScrollingModeIndication) override;
</span><span class="cx">     virtual void setTileMargins(int marginTop, int marginBottom, int marginLeft, int marginRight) override;
</span><span class="cx"> 
</span><del>-    // PlatformCALayerClient
-    virtual void platformCALayerPaintContents(PlatformCALayer*, GraphicsContext&amp;, const FloatRect&amp;) override;
-    virtual bool platformCALayerShowDebugBorders() const override;
-    virtual bool platformCALayerShowRepaintCounter(PlatformCALayer*) const override;
-    virtual int platformCALayerIncrementRepaintCount(PlatformCALayer*) override;
-    virtual bool platformCALayerContentsOpaque() const override { return m_tilesAreOpaque; }
-    virtual bool platformCALayerDrawsContent() const override { return true; }
-    virtual float platformCALayerDeviceScaleFactor() const override;
-
</del><span class="cx">     void scheduleTileRevalidation(double interval);
</span><span class="cx">     void tileRevalidationTimerFired(Timer&lt;TileController&gt;*);
</span><span class="cx"> 
</span><span class="lines">@@ -181,8 +168,6 @@
</span><span class="cx"> 
</span><span class="cx">     Timer&lt;TileController&gt; m_tileRevalidationTimer;
</span><span class="cx"> 
</span><del>-    RepaintCountMap m_tileRepaintCounts;
-
</del><span class="cx">     float m_contentsScale;
</span><span class="cx">     float m_deviceScaleFactor;
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicscamacTileControllermm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/ca/mac/TileController.mm (167040 => 167041)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/ca/mac/TileController.mm        2014-04-09 22:24:42 UTC (rev 167040)
+++ trunk/Source/WebCore/platform/graphics/ca/mac/TileController.mm        2014-04-09 22:29:15 UTC (rev 167041)
</span><span class="lines">@@ -26,7 +26,6 @@
</span><span class="cx"> #import &quot;config.h&quot;
</span><span class="cx"> #import &quot;TileController.h&quot;
</span><span class="cx"> 
</span><del>-#import &quot;GraphicsContext.h&quot;
</del><span class="cx"> #import &quot;IntRect.h&quot;
</span><span class="cx"> #import &quot;PlatformCALayer.h&quot;
</span><span class="cx"> #import &quot;Region.h&quot;
</span><span class="lines">@@ -35,7 +34,6 @@
</span><span class="cx"> #if !PLATFORM(IOS)
</span><span class="cx"> #import &quot;LayerPool.h&quot;
</span><span class="cx"> #endif
</span><del>-#import &quot;WebLayer.h&quot;
</del><span class="cx"> #import &lt;wtf/MainThread.h&gt;
</span><span class="cx"> #import &lt;utility&gt;
</span><span class="cx"> 
</span><span class="lines">@@ -103,59 +101,13 @@
</span><span class="cx">     tileGrid().setNeedsDisplayInRect(rect);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void TileController::platformCALayerPaintContents(PlatformCALayer* platformCALayer, GraphicsContext&amp; context, const FloatRect&amp;)
-{
-#if PLATFORM(IOS)
-    if (pthread_main_np())
-        WebThreadLock();
-#endif
-
-    {
-        GraphicsContextStateSaver stateSaver(context);
-
-        FloatPoint3D layerOrigin = platformCALayer-&gt;position();
-        context.translate(-layerOrigin.x(), -layerOrigin.y());
-        context.scale(FloatSize(tileGrid().scale(), tileGrid().scale()));
-
-        RepaintRectList dirtyRects = collectRectsToPaint(context.platformContext(), platformCALayer);
-        drawLayerContents(context.platformContext(), m_tileCacheLayer, dirtyRects);
-    }
-
-    int repaintCount = platformCALayerIncrementRepaintCount(platformCALayer);
-    if (owningGraphicsLayer()-&gt;platformCALayerShowRepaintCounter(0))
-        drawRepaintIndicator(context.platformContext(), platformCALayer, repaintCount, cachedCGColor(m_tileDebugBorderColor, ColorSpaceDeviceRGB));
-
-    if (scrollingPerformanceLoggingEnabled()) {
-        FloatRect visiblePart(platformCALayer-&gt;position().x(), platformCALayer-&gt;position().y(), platformCALayer-&gt;bounds().size().width(), platformCALayer-&gt;bounds().size().height());
-        visiblePart.intersect(visibleRect());
-
-        if (repaintCount == 1 &amp;&amp; !visiblePart.isEmpty())
-            WTFLogAlways(&quot;SCROLLING: Filled visible fresh tile. Time: %f Unfilled Pixels: %u\n&quot;, WTF::monotonicallyIncreasingTime(), blankPixelCount());
-    }
-}
-
-float TileController::platformCALayerDeviceScaleFactor() const
-{
-    return owningGraphicsLayer()-&gt;platformCALayerDeviceScaleFactor();
-}
-
-bool TileController::platformCALayerShowDebugBorders() const
-{
-    return owningGraphicsLayer()-&gt;platformCALayerShowDebugBorders();
-}
-
-bool TileController::platformCALayerShowRepaintCounter(PlatformCALayer*) const
-{
-    return owningGraphicsLayer()-&gt;platformCALayerShowRepaintCounter(0);
-}
-
</del><span class="cx"> void TileController::setContentsScale(float scale)
</span><span class="cx"> {
</span><span class="cx">     m_contentsScale = scale;
</span><span class="cx">     
</span><span class="cx">     ASSERT(owningGraphicsLayer()-&gt;isCommittingChanges());
</span><span class="cx"> 
</span><del>-    float deviceScaleFactor = platformCALayerDeviceScaleFactor();
</del><ins>+    float deviceScaleFactor = owningGraphicsLayer()-&gt;platformCALayerDeviceScaleFactor();
</ins><span class="cx"> 
</span><span class="cx">     // The scale we get is the product of the page scale factor and device scale factor.
</span><span class="cx">     // Divide by the device scale factor so we'll get the page scale factor.
</span><span class="lines">@@ -478,7 +430,7 @@
</span><span class="cx">     return m_marginRight;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-RefPtr&lt;PlatformCALayer&gt; TileController::createTileLayer(const IntRect&amp; tileRect)
</del><ins>+RefPtr&lt;PlatformCALayer&gt; TileController::createTileLayer(const IntRect&amp; tileRect, TileGrid&amp; grid)
</ins><span class="cx"> {
</span><span class="cx"> #if PLATFORM(IOS)
</span><span class="cx">     RefPtr&lt;PlatformCALayer&gt; layer;
</span><span class="lines">@@ -486,11 +438,10 @@
</span><span class="cx">     RefPtr&lt;PlatformCALayer&gt; layer = LayerPool::sharedPool()-&gt;takeLayerWithSize(tileRect.size());
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><del>-    if (layer) {
-        m_tileRepaintCounts.remove(layer.get());
-        layer-&gt;setOwner(this);
-    } else
-        layer = m_tileCacheLayer-&gt;createCompatibleLayer(PlatformCALayer::LayerTypeTiledBackingTileLayer, this);
</del><ins>+    if (layer)
+        layer-&gt;setOwner(&amp;grid);
+    else
+        layer = m_tileCacheLayer-&gt;createCompatibleLayer(PlatformCALayer::LayerTypeTiledBackingTileLayer, &amp;grid);
</ins><span class="cx"> 
</span><span class="cx">     layer-&gt;setAnchorPoint(FloatPoint3D());
</span><span class="cx">     layer-&gt;setBounds(FloatRect(FloatPoint(), tileRect.size()));
</span><span class="lines">@@ -514,18 +465,6 @@
</span><span class="cx">     return layer;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-int TileController::platformCALayerIncrementRepaintCount(PlatformCALayer* platformCALayer)
-{
-    int repaintCount = 0;
-
-    if (m_tileRepaintCounts.contains(platformCALayer))
-        repaintCount = m_tileRepaintCounts.get(platformCALayer);
-
-    m_tileRepaintCounts.set(platformCALayer, ++repaintCount);
-
-    return repaintCount;
-}
-
</del><span class="cx"> Vector&lt;RefPtr&lt;PlatformCALayer&gt;&gt; TileController::containerLayers()
</span><span class="cx"> {
</span><span class="cx">     Vector&lt;RefPtr&lt;PlatformCALayer&gt;&gt; layerList(1);
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicscamacTileGridh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/ca/mac/TileGrid.h (167040 => 167041)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/ca/mac/TileGrid.h        2014-04-09 22:24:42 UTC (rev 167040)
+++ trunk/Source/WebCore/platform/graphics/ca/mac/TileGrid.h        2014-04-09 22:29:15 UTC (rev 167041)
</span><span class="lines">@@ -28,6 +28,7 @@
</span><span class="cx"> 
</span><span class="cx"> #include &quot;IntPointHash.h&quot;
</span><span class="cx"> #include &quot;IntRect.h&quot;
</span><ins>+#include &quot;PlatformCALayerClient.h&quot;
</ins><span class="cx"> #include &quot;Timer.h&quot;
</span><span class="cx"> #include &lt;wtf/Deque.h&gt;
</span><span class="cx"> #include &lt;wtf/HashMap.h&gt;
</span><span class="lines">@@ -36,11 +37,12 @@
</span><span class="cx"> 
</span><span class="cx"> namespace WebCore {
</span><span class="cx"> 
</span><ins>+class GraphicsContext;
</ins><span class="cx"> class PlatformCALayer;
</span><span class="cx"> class TileController;
</span><span class="cx"> 
</span><del>-class TileGrid {
-    WTF_MAKE_NONCOPYABLE(TileGrid);
</del><ins>+class TileGrid : public PlatformCALayerClient {
+    WTF_MAKE_NONCOPYABLE(TileGrid); WTF_MAKE_FAST_ALLOCATED;
</ins><span class="cx"> public:
</span><span class="cx">     TileGrid(TileController&amp;);
</span><span class="cx">     ~TileGrid();
</span><span class="lines">@@ -109,6 +111,17 @@
</span><span class="cx">     TileCohort newestTileCohort() const;
</span><span class="cx">     TileCohort oldestTileCohort() const;
</span><span class="cx"> 
</span><ins>+    void removeTiles(Vector&lt;TileGrid::TileIndex&gt;&amp; toRemove);
+
+    // PlatformCALayerClient
+    virtual void platformCALayerPaintContents(PlatformCALayer*, GraphicsContext&amp;, const FloatRect&amp;) override;
+    virtual bool platformCALayerShowDebugBorders() const override;
+    virtual bool platformCALayerShowRepaintCounter(PlatformCALayer*) const override;
+    virtual int platformCALayerIncrementRepaintCount(PlatformCALayer*) override;
+    virtual bool platformCALayerContentsOpaque() const override;
+    virtual bool platformCALayerDrawsContent() const override { return true; }
+    virtual float platformCALayerDeviceScaleFactor() const override;
+
</ins><span class="cx">     TileController&amp; m_controller;
</span><span class="cx">     Ref&lt;PlatformCALayer&gt; m_containerLayer;
</span><span class="cx"> 
</span><span class="lines">@@ -132,6 +145,9 @@
</span><span class="cx">     TileCohortList m_cohortList;
</span><span class="cx"> 
</span><span class="cx">     Timer&lt;TileGrid&gt; m_cohortRemovalTimer;
</span><ins>+
+    typedef HashMap&lt;PlatformCALayer*, int&gt; RepaintCountMap;
+    RepaintCountMap m_tileRepaintCounts;
</ins><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicscamacTileGridmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/ca/mac/TileGrid.mm (167040 => 167041)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/ca/mac/TileGrid.mm        2014-04-09 22:24:42 UTC (rev 167040)
+++ trunk/Source/WebCore/platform/graphics/ca/mac/TileGrid.mm        2014-04-09 22:29:15 UTC (rev 167041)
</span><span class="lines">@@ -26,9 +26,11 @@
</span><span class="cx"> #import &quot;config.h&quot;
</span><span class="cx"> #import &quot;TileGrid.h&quot;
</span><span class="cx"> 
</span><ins>+#import &quot;GraphicsContext.h&quot;
</ins><span class="cx"> #import &quot;LayerPool.h&quot;
</span><span class="cx"> #import &quot;PlatformCALayer.h&quot;
</span><span class="cx"> #import &quot;TileController.h&quot;
</span><ins>+#import &quot;WebLayer.h&quot;
</ins><span class="cx"> #import &lt;wtf/MainThread.h&gt;
</span><span class="cx"> 
</span><span class="cx"> #if PLATFORM(IOS)
</span><span class="lines">@@ -280,31 +282,30 @@
</span><span class="cx">     return TileController::blankPixelCountForTiles(tiles, m_controller.visibleRect(), IntPoint(0,0));
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-static inline void queueTileForRemoval(const TileGrid::TileIndex&amp; tileIndex, const TileGrid::TileInfo&amp; tileInfo, Vector&lt;TileGrid::TileIndex&gt;&amp; tilesToRemove, TileController::RepaintCountMap&amp; repaintCounts)
</del><ins>+void TileGrid::removeTiles(Vector&lt;TileGrid::TileIndex&gt;&amp; toRemove)
</ins><span class="cx"> {
</span><del>-    tileInfo.layer-&gt;removeFromSuperlayer();
-    repaintCounts.remove(tileInfo.layer.get());
-    tilesToRemove.append(tileIndex);
</del><ins>+    for (size_t i = 0; i &lt; toRemove.size(); ++i) {
+        TileInfo tileInfo = m_tiles.take(toRemove[i]);
+        tileInfo.layer-&gt;removeFromSuperlayer();
+        m_tileRepaintCounts.remove(tileInfo.layer.get());
+#if !PLATFORM(IOS)
+        LayerPool::sharedPool()-&gt;addLayer(tileInfo.layer);
+#endif
+    }
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void TileGrid::removeAllSecondaryTiles()
</span><span class="cx"> {
</span><span class="cx">     Vector&lt;TileIndex&gt; tilesToRemove;
</span><span class="cx"> 
</span><del>-    for (TileMap::iterator it = m_tiles.begin(), end = m_tiles.end(); it != end; ++it) {
-        const TileInfo&amp; tileInfo = it-&gt;value;
</del><ins>+    for (auto&amp; entry : m_tiles) {
+        const TileInfo&amp; tileInfo = entry.value;
</ins><span class="cx">         if (tileInfo.cohort == VisibleTileCohort)
</span><span class="cx">             continue;
</span><del>-
-        queueTileForRemoval(it-&gt;key, it-&gt;value, tilesToRemove, m_controller.repaintCountMap());
</del><ins>+        tilesToRemove.append(entry.key);
</ins><span class="cx">     }
</span><span class="cx"> 
</span><del>-    for (size_t i = 0; i &lt; tilesToRemove.size(); ++i) {
-        TileInfo tileInfo = m_tiles.take(tilesToRemove[i]);
-#if !PLATFORM(IOS)
-        LayerPool::sharedPool()-&gt;addLayer(tileInfo.layer);
-#endif
-    }
</del><ins>+    removeTiles(tilesToRemove);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void TileGrid::removeTilesInCohort(TileCohort cohort)
</span><span class="lines">@@ -312,20 +313,14 @@
</span><span class="cx">     ASSERT(cohort != VisibleTileCohort);
</span><span class="cx">     Vector&lt;TileIndex&gt; tilesToRemove;
</span><span class="cx"> 
</span><del>-    for (TileMap::iterator it = m_tiles.begin(), end = m_tiles.end(); it != end; ++it) {
-        const TileInfo&amp; tileInfo = it-&gt;value;
</del><ins>+    for (auto&amp; entry : m_tiles) {
+        const TileInfo&amp; tileInfo = entry.value;
</ins><span class="cx">         if (tileInfo.cohort != cohort)
</span><span class="cx">             continue;
</span><del>-
-        queueTileForRemoval(it-&gt;key, it-&gt;value, tilesToRemove, m_controller.repaintCountMap());
</del><ins>+        tilesToRemove.append(entry.key);
</ins><span class="cx">     }
</span><span class="cx"> 
</span><del>-    for (size_t i = 0; i &lt; tilesToRemove.size(); ++i) {
-        TileInfo tileInfo = m_tiles.take(tilesToRemove[i]);
-#if !PLATFORM(IOS)
-        LayerPool::sharedPool()-&gt;addLayer(tileInfo.layer);
-#endif
-    }
</del><ins>+    removeTiles(tilesToRemove);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void TileGrid::revalidateTiles(TileValidationPolicyFlags validationPolicy)
</span><span class="lines">@@ -429,13 +424,9 @@
</span><span class="cx">         getTileIndexRangeForRect(boundsInTileCoords, topLeftForBounds, bottomRightForBounds);
</span><span class="cx"> 
</span><span class="cx">         Vector&lt;TileIndex&gt; tilesToRemove;
</span><del>-        for (TileMap::iterator it = m_tiles.begin(), end = m_tiles.end(); it != end; ++it) {
-            const TileIndex&amp; index = it-&gt;key;
-            if (index.y() &lt; topLeftForBounds.y()
-                || index.y() &gt; bottomRightForBounds.y()
-                || index.x() &lt; topLeftForBounds.x()
-                || index.x() &gt; bottomRightForBounds.x())
-                queueTileForRemoval(index, it-&gt;value, tilesToRemove, m_controller.repaintCountMap());
</del><ins>+        for (auto&amp; index : m_tiles.keys()) {
+            if (index.y() &lt; topLeftForBounds.y() || index.y() &gt; bottomRightForBounds.y() || index.x() &lt; topLeftForBounds.x() || index.x() &gt; bottomRightForBounds.x())
+                tilesToRemove.append(index);
</ins><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx">         for (size_t i = 0, size = tilesToRemove.size(); i &lt; size; ++i) {
</span><span class="lines">@@ -532,9 +523,10 @@
</span><span class="cx"> 
</span><span class="cx">             bool shouldChangeTileLayerFrame = false;
</span><span class="cx"> 
</span><del>-            if (!tileInfo.layer)
-                tileInfo.layer = m_controller.createTileLayer(tileRect);
-            else {
</del><ins>+            if (!tileInfo.layer) {
+                tileInfo.layer = m_controller.createTileLayer(tileRect, *this);
+                ASSERT(!m_tileRepaintCounts.contains(tileInfo.layer.get()));
+            } else {
</ins><span class="cx">                 // We already have a layer for this tile. Ensure that its size is correct.
</span><span class="cx">                 FloatSize tileLayerSize(tileInfo.layer-&gt;bounds().size());
</span><span class="cx">                 shouldChangeTileLayerFrame = tileLayerSize != FloatSize(tileRect.size());
</span><span class="lines">@@ -644,7 +636,70 @@
</span><span class="cx">     }
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void TileGrid::platformCALayerPaintContents(PlatformCALayer* platformCALayer, GraphicsContext&amp; context, const FloatRect&amp;)
+{
</ins><span class="cx"> #if PLATFORM(IOS)
</span><ins>+    if (pthread_main_np())
+        WebThreadLock();
+#endif
+
+    {
+        GraphicsContextStateSaver stateSaver(context);
+
+        FloatPoint3D layerOrigin = platformCALayer-&gt;position();
+        context.translate(-layerOrigin.x(), -layerOrigin.y());
+        context.scale(FloatSize(m_scale, m_scale));
+
+        RepaintRectList dirtyRects = collectRectsToPaint(context.platformContext(), platformCALayer);
+        drawLayerContents(context.platformContext(), &amp;m_controller.rootLayer(), dirtyRects);
+    }
+
+    int repaintCount = platformCALayerIncrementRepaintCount(platformCALayer);
+    if (m_controller.rootLayer().owner()-&gt;platformCALayerShowRepaintCounter(0))
+        drawRepaintIndicator(context.platformContext(), platformCALayer, repaintCount, cachedCGColor(m_controller.tileDebugBorderColor(), ColorSpaceDeviceRGB));
+
+    if (m_controller.scrollingPerformanceLoggingEnabled()) {
+        FloatRect visiblePart(platformCALayer-&gt;position().x(), platformCALayer-&gt;position().y(), platformCALayer-&gt;bounds().size().width(), platformCALayer-&gt;bounds().size().height());
+        visiblePart.intersect(m_controller.visibleRect());
+
+        if (repaintCount == 1 &amp;&amp; !visiblePart.isEmpty())
+            WTFLogAlways(&quot;SCROLLING: Filled visible fresh tile. Time: %f Unfilled Pixels: %u\n&quot;, WTF::monotonicallyIncreasingTime(), blankPixelCount());
+    }
+}
+
+float TileGrid::platformCALayerDeviceScaleFactor() const
+{
+    return m_controller.rootLayer().owner()-&gt;platformCALayerDeviceScaleFactor();
+}
+
+bool TileGrid::platformCALayerShowDebugBorders() const
+{
+    return m_controller.rootLayer().owner()-&gt;platformCALayerShowDebugBorders();
+}
+
+bool TileGrid::platformCALayerShowRepaintCounter(PlatformCALayer*) const
+{
+    return m_controller.rootLayer().owner()-&gt;platformCALayerShowRepaintCounter(0);
+}
+
+bool TileGrid::platformCALayerContentsOpaque() const
+{
+    return m_controller.tilesAreOpaque();
+}
+
+int TileGrid::platformCALayerIncrementRepaintCount(PlatformCALayer* platformCALayer)
+{
+    int repaintCount = 0;
+
+    if (m_tileRepaintCounts.contains(platformCALayer))
+        repaintCount = m_tileRepaintCounts.get(platformCALayer);
+
+    m_tileRepaintCounts.set(platformCALayer, ++repaintCount);
+
+    return repaintCount;
+}
+
+#if PLATFORM(IOS)
</ins><span class="cx"> void TileGrid::removeUnparentedTilesNow()
</span><span class="cx"> {
</span><span class="cx">     while (!m_cohortList.isEmpty()) {
</span></span></pre>
</div>
</div>

</body>
</html>