[chromium] Merge updates and idle updates into one pass
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 10 Jul 2012 02:29:15 +0000 (02:29 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 10 Jul 2012 02:29:15 +0000 (02:29 +0000)
https://bugs.webkit.org/show_bug.cgi?id=90324

Patch by Eric Penner <epenner@google.com> on 2012-07-09
Reviewed by Adrienne Walker.

Source/WebCore:

We no longer need to do painting is passes in order
to allocate memory in the right order. So this merges
updates and idle updates into one pass.

Covered by existing unit tests (some of which are
updated with this patch).

* platform/graphics/chromium/ContentLayerChromium.cpp:
(WebCore::ContentLayerChromium::needMoreUpdates):
* platform/graphics/chromium/ContentLayerChromium.h:
(ContentLayerChromium):
* platform/graphics/chromium/LayerChromium.h:
(WebCore::LayerChromium::needMoreUpdates):
* platform/graphics/chromium/TiledLayerChromium.cpp:
(WebCore::TiledLayerChromium::updateTiles):
(WebCore::TiledLayerChromium::updateLayerRect):
* platform/graphics/chromium/TiledLayerChromium.h:
(TiledLayerChromium):
* platform/graphics/chromium/cc/CCLayerTreeHost.cpp:
(WebCore::CCLayerTreeHost::CCLayerTreeHost):
(WebCore::CCLayerTreeHost::compositeAndReadback):
(WebCore::CCLayerTreeHost::updateLayers):
(WebCore::CCLayerTreeHost::paintMasksForRenderSurface):
(WebCore::CCLayerTreeHost::paintLayerContents):
* platform/graphics/chromium/cc/CCLayerTreeHost.h:
(CCLayerTreeHost):

Source/WebKit/chromium:

* tests/CCLayerTreeHostTest.cpp:
(WTF::ContentLayerChromiumWithUpdateTracking::resetPaintContentsCount):
(WTF::ContentLayerChromiumWithUpdateTracking::ContentLayerChromiumWithUpdateTracking):
(ContentLayerChromiumWithUpdateTracking):
(WTF::CCLayerTreeHostTestOpacityChange::afterTest):
* tests/CCTiledLayerTestCommon.h:
(FakeTiledLayerChromium):
* tests/TiledLayerChromiumTest.cpp:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@122185 268f45cc-cd09-0410-ab3c-d52691b4dbfc

12 files changed:
Source/WebCore/ChangeLog
Source/WebCore/platform/graphics/chromium/ContentLayerChromium.cpp
Source/WebCore/platform/graphics/chromium/ContentLayerChromium.h
Source/WebCore/platform/graphics/chromium/LayerChromium.h
Source/WebCore/platform/graphics/chromium/TiledLayerChromium.cpp
Source/WebCore/platform/graphics/chromium/TiledLayerChromium.h
Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHost.cpp
Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHost.h
Source/WebKit/chromium/ChangeLog
Source/WebKit/chromium/tests/CCLayerTreeHostTest.cpp
Source/WebKit/chromium/tests/CCTiledLayerTestCommon.h
Source/WebKit/chromium/tests/TiledLayerChromiumTest.cpp

index 4c27c8b..0fc90fa 100644 (file)
@@ -1,3 +1,37 @@
+2012-07-09  Eric Penner  <epenner@google.com>
+
+        [chromium] Merge updates and idle updates into one pass
+        https://bugs.webkit.org/show_bug.cgi?id=90324
+
+        Reviewed by Adrienne Walker.
+
+        We no longer need to do painting is passes in order
+        to allocate memory in the right order. So this merges
+        updates and idle updates into one pass.
+
+        Covered by existing unit tests (some of which are
+        updated with this patch).
+
+        * platform/graphics/chromium/ContentLayerChromium.cpp:
+        (WebCore::ContentLayerChromium::needMoreUpdates):
+        * platform/graphics/chromium/ContentLayerChromium.h:
+        (ContentLayerChromium):
+        * platform/graphics/chromium/LayerChromium.h:
+        (WebCore::LayerChromium::needMoreUpdates):
+        * platform/graphics/chromium/TiledLayerChromium.cpp:
+        (WebCore::TiledLayerChromium::updateTiles):
+        (WebCore::TiledLayerChromium::updateLayerRect):
+        * platform/graphics/chromium/TiledLayerChromium.h:
+        (TiledLayerChromium):
+        * platform/graphics/chromium/cc/CCLayerTreeHost.cpp:
+        (WebCore::CCLayerTreeHost::CCLayerTreeHost):
+        (WebCore::CCLayerTreeHost::compositeAndReadback):
+        (WebCore::CCLayerTreeHost::updateLayers):
+        (WebCore::CCLayerTreeHost::paintMasksForRenderSurface):
+        (WebCore::CCLayerTreeHost::paintLayerContents):
+        * platform/graphics/chromium/cc/CCLayerTreeHost.h:
+        (CCLayerTreeHost):
+
 2012-07-09  Yoshifumi Inoue  <yosin@chromium.org>
 
         [Platform] Introduce LocaleMac class
index e1f1577..078d377 100644 (file)
@@ -108,15 +108,11 @@ void ContentLayerChromium::update(CCTextureUpdater& updater, const CCOcclusionTr
     m_needsDisplay = false;
 }
 
-void ContentLayerChromium::idleUpdate(CCTextureUpdater& updater, const CCOcclusionTracker* occlusion)
+bool ContentLayerChromium::needMoreUpdates()
 {
     if (!drawsContent())
-        return;
-
-    const IntRect layerRect = visibleLayerRect();
-    idleUpdateLayerRect(updater, layerRect, occlusion);
-    if (needsIdlePaint(layerRect))
-        setNeedsCommit();
+        return false;
+    return needsIdlePaint(visibleLayerRect());
 }
 
 void ContentLayerChromium::createTextureUpdaterIfNeeded()
index 313c387..d8ea485 100644 (file)
@@ -78,7 +78,7 @@ public:
     virtual bool drawsContent() const OVERRIDE;
     virtual void setTexturePriorities(const CCPriorityCalculator&) OVERRIDE;
     virtual void update(CCTextureUpdater&, const CCOcclusionTracker*) OVERRIDE;
-    virtual void idleUpdate(CCTextureUpdater&, const CCOcclusionTracker*) OVERRIDE;
+    virtual bool needMoreUpdates() OVERRIDE;
 
     virtual void setOpaque(bool) OVERRIDE;
 
index 894b2fd..e3ceb94 100644 (file)
@@ -211,7 +211,7 @@ public:
     // These methods typically need to be overwritten by derived classes.
     virtual bool drawsContent() const { return m_isDrawable; }
     virtual void update(CCTextureUpdater&, const CCOcclusionTracker*) { }
-    virtual void idleUpdate(CCTextureUpdater&, const CCOcclusionTracker*) { }
+    virtual bool needMoreUpdates() { return false; }
     virtual void setIsMask(bool) { }
     virtual void bindContentsTexture() { }
     virtual bool needsContentsScale() const { return false; }
index 65ceac8..e653a2d 100644 (file)
@@ -350,6 +350,9 @@ void TiledLayerChromium::updateTiles(bool idle, int left, int top, int right, in
 {
     createTextureUpdaterIfNeeded();
 
+    // We shouldn't track any occlusion metrics during idle painting.
+    ASSERT(!idle || !occlusion);
+
     // Create tiles as needed, expanding a dirty rect to contain all
     // the dirty regions currently being drawn. All dirty tiles that are to be painted
     // get their updateRect set to dirtyRect and dirtyRect cleared. This way if
@@ -608,7 +611,7 @@ void TiledLayerChromium::resetUpdateState()
     }
 }
 
-void TiledLayerChromium::updateLayerRect(CCTextureUpdater& updater, const IntRect& layerRect, const CCOcclusionTracker* occlusion)
+void TiledLayerChromium::updateLayerRect(CCTextureUpdater& updater, const IntRect& contentRect, const CCOcclusionTracker* occlusion)
 {
     m_skipsDraw = false;
     m_skipsIdlePaint = false;
@@ -616,37 +619,30 @@ void TiledLayerChromium::updateLayerRect(CCTextureUpdater& updater, const IntRec
 
     updateBounds();
 
-    if (layerRect.isEmpty() || m_tiler->hasEmptyBounds())
+    if (m_tiler->hasEmptyBounds())
         return;
 
-    int left, top, right, bottom;
-    m_tiler->layerRectToTileIndices(layerRect, left, top, right, bottom);
-
-    updateTiles(false, left, top, right, bottom, updater, occlusion);
-}
+    // Visible painting. Only paint visible tiles if the visible rect isn't empty.
+    if (!contentRect.isEmpty()) {
+        int left, top, right, bottom;
+        m_tiler->layerRectToTileIndices(contentRect, left, top, right, bottom);
+        updateTiles(false, left, top, right, bottom, updater, occlusion);
+    }
 
-void TiledLayerChromium::idleUpdateLayerRect(CCTextureUpdater& updater, const IntRect& layerRect, const CCOcclusionTracker* occlusion)
-{
     // Abort if we have already painted or run out of memory.
     if (m_skipsIdlePaint || m_didPaint)
         return;
 
-    ASSERT(m_tiler);
-
-    updateBounds();
-
-    if (m_tiler->hasEmptyBounds())
-        return;
-
-    IntRect idlePaintLayerRect = idlePaintRect(layerRect);
-    if (idlePaintLayerRect.isEmpty())
+    // If we have already painting everything visible. Do some pre-painting while idle.
+    IntRect idlePaintContentRect = idlePaintRect(contentRect);
+    if (idlePaintContentRect.isEmpty())
         return;
 
     int prepaintLeft, prepaintTop, prepaintRight, prepaintBottom;
-    m_tiler->layerRectToTileIndices(idlePaintLayerRect, prepaintLeft, prepaintTop, prepaintRight, prepaintBottom);
+    m_tiler->layerRectToTileIndices(idlePaintContentRect, prepaintLeft, prepaintTop, prepaintRight, prepaintBottom);
 
     // If the layer is not visible, we have nothing to expand from, so instead we prepaint the outer-most set of tiles.
-    if (layerRect.isEmpty()) {
+    if (contentRect.isEmpty()) {
         updateTiles(true, prepaintLeft, prepaintTop, prepaintRight, prepaintTop, updater, 0);
         if (m_didPaint || m_skipsIdlePaint)
             return;
@@ -661,7 +657,7 @@ void TiledLayerChromium::idleUpdateLayerRect(CCTextureUpdater& updater, const In
     }
 
     int left, top, right, bottom;
-    m_tiler->layerRectToTileIndices(layerRect, left, top, right, bottom);
+    m_tiler->layerRectToTileIndices(contentRect, left, top, right, bottom);
 
     // Otherwise, prepaint anything that was occluded but inside the layer's visible region.
     updateTiles(true, left, top, right, bottom, updater, 0);
@@ -697,7 +693,7 @@ void TiledLayerChromium::idleUpdateLayerRect(CCTextureUpdater& updater, const In
     }
 }
 
-bool TiledLayerChromium::needsIdlePaint(const IntRect& layerRect)
+bool TiledLayerChromium::needsIdlePaint(const IntRect& contentRect)
 {
     if (m_skipsIdlePaint)
         return false;
@@ -705,17 +701,17 @@ bool TiledLayerChromium::needsIdlePaint(const IntRect& layerRect)
     if (m_tiler->hasEmptyBounds())
         return false;
 
-    IntRect idlePaintLayerRect = idlePaintRect(layerRect);
-    if (idlePaintLayerRect.isEmpty())
+    IntRect idlePaintContentRect = idlePaintRect(contentRect);
+    if (idlePaintContentRect.isEmpty())
         return false;
 
     int left, top, right, bottom;
-    m_tiler->layerRectToTileIndices(idlePaintLayerRect, left, top, right, bottom);
+    m_tiler->layerRectToTileIndices(idlePaintContentRect, left, top, right, bottom);
 
     for (int j = top; j <= bottom; ++j) {
         for (int i = left; i <= right; ++i) {
             // If the layerRect is empty, then we are painting the outer-most set of tiles only.
-            if (layerRect.isEmpty() && i != left && i != right && j != top && j != bottom)
+            if (contentRect.isEmpty() && i != left && i != right && j != top && j != bottom)
                 continue;
             UpdatableTile* tile = tileAt(i, j);
             ASSERT(tile); // Did setTexturePriorities get skipped?
@@ -732,14 +728,14 @@ bool TiledLayerChromium::needsIdlePaint(const IntRect& layerRect)
     return false;
 }
 
-IntRect TiledLayerChromium::idlePaintRect(const IntRect& visibleLayerRect)
+IntRect TiledLayerChromium::idlePaintRect(const IntRect& visibleRect)
 {
     IntRect contentRect(IntPoint::zero(), contentBounds());
 
     // For layers that are animating transforms but not visible at all, we don't know what part
     // of them is going to become visible. For small layers we return the entire layer, for larger
     // ones we avoid prepainting the layer at all.
-    if (visibleLayerRect.isEmpty()) {
+    if (visibleRect.isEmpty()) {
         bool isSmallLayer = m_tiler->numTilesX() <= 9 && m_tiler->numTilesY() <= 9 && m_tiler->numTilesX() * m_tiler->numTilesY() <= 9;
         if ((drawTransformIsAnimating() || screenSpaceTransformIsAnimating()) && isSmallLayer)
             return contentRect;
@@ -748,7 +744,7 @@ IntRect TiledLayerChromium::idlePaintRect(const IntRect& visibleLayerRect)
 
     // FIXME: This can be made a lot larger now! We should increase
     //        this slowly while insuring it doesn't cause any perf issues.
-    IntRect prepaintRect = visibleLayerRect;
+    IntRect prepaintRect = visibleRect;
     prepaintRect.inflateX(m_tiler->tileSize().width());
     prepaintRect.inflateY(m_tiler->tileSize().height() * 2);
     prepaintRect.intersect(contentRect);
index cde552c..d2ed45c 100644 (file)
@@ -85,10 +85,7 @@ protected:
     // Prepare data needed to update textures that intersect with layerRect.
     void updateLayerRect(CCTextureUpdater&, const IntRect& layerRect, const CCOcclusionTracker*);
 
-    // Same as above, but this will try to paint additional surrounding content if idle.
-    void idleUpdateLayerRect(CCTextureUpdater&, const IntRect& layerRect, const CCOcclusionTracker*);
-
-    // After preparing an update, returns true if more pre-painting is needed.
+    // After preparing an update, returns true if more painting is needed.
     bool needsIdlePaint(const IntRect& layerRect);
 
     IntRect idlePaintRect(const IntRect& visibleLayerRect);
index 4365722..414b205 100644 (file)
@@ -85,7 +85,7 @@ CCLayerTreeHost::CCLayerTreeHost(CCLayerTreeHostClient* client, const CCLayerTre
     , m_pageScaleFactor(1)
     , m_minPageScaleFactor(1)
     , m_maxPageScaleFactor(1)
-    , m_triggerIdlePaints(true)
+    , m_triggerIdleUpdates(true)
     , m_backgroundColor(SK_ColorWHITE)
     , m_hasTransparentBackground(false)
     , m_partialTextureUpdateRequests(0)
@@ -288,9 +288,9 @@ void CCLayerTreeHost::didLoseContext()
 
 bool CCLayerTreeHost::compositeAndReadback(void *pixels, const IntRect& rect)
 {
-    m_triggerIdlePaints = false;
+    m_triggerIdleUpdates = false;
     bool ret = m_proxy->compositeAndReadback(pixels, rect);
-    m_triggerIdlePaints = true;
+    m_triggerIdleUpdates = true;
     return ret;
 }
 
@@ -492,14 +492,9 @@ void CCLayerTreeHost::updateLayers(LayerChromium* rootLayer, CCTextureUpdater& u
 
     prioritizeTextures(updateList);
 
-    paintLayerContents(updateList, PaintVisible, updater);
-
-    if (m_triggerIdlePaints) {
-        // The second (idle) paint will be a no-op in layers where painting already occured above.
-        // FIXME: This pass can be merged with the visible pass now that textures
-        //        are prioritized above.
-        paintLayerContents(updateList, PaintIdle, updater);
-    }
+    bool needMoreUpdates = paintLayerContents(updateList, updater);
+    if (m_triggerIdleUpdates && needMoreUpdates)
+        setNeedsCommit();
 
     for (size_t i = 0; i < updateList.size(); ++i)
         updateList[i]->clearRenderSurface();
@@ -550,37 +545,33 @@ void CCLayerTreeHost::prioritizeTextures(const LayerList& updateList)
     m_contentsTextureManager->prioritizeTextures(renderSurfacesBytes);
 }
 
-// static
-void CCLayerTreeHost::update(LayerChromium* layer, PaintType paintType, CCTextureUpdater& updater, const CCOcclusionTracker* occlusion)
-{
-    ASSERT(layer);
-    ASSERT(PaintVisible == paintType || PaintIdle == paintType);
-    if (PaintVisible == paintType)
-        layer->update(updater, occlusion);
-    else
-        layer->idleUpdate(updater, occlusion);
-}
-
-void CCLayerTreeHost::paintMasksForRenderSurface(LayerChromium* renderSurfaceLayer, PaintType paintType, CCTextureUpdater& updater)
+bool CCLayerTreeHost::paintMasksForRenderSurface(LayerChromium* renderSurfaceLayer, CCTextureUpdater& updater)
 {
     // Note: Masks and replicas only exist for layers that own render surfaces. If we reach this point
     // in code, we already know that at least something will be drawn into this render surface, so the
     // mask and replica should be painted.
 
+    bool needMoreUpdates = false;
     LayerChromium* maskLayer = renderSurfaceLayer->maskLayer();
-    if (maskLayer)
-        update(maskLayer, paintType, updater, 0);
+    if (maskLayer) {
+        maskLayer->update(updater, 0);
+        needMoreUpdates |= maskLayer->needMoreUpdates();
+    }
 
     LayerChromium* replicaMaskLayer = renderSurfaceLayer->replicaLayer() ? renderSurfaceLayer->replicaLayer()->maskLayer() : 0;
-    if (replicaMaskLayer)
-        update(replicaMaskLayer, paintType, updater, 0);
+    if (replicaMaskLayer) {
+        replicaMaskLayer->update(updater, 0);
+        needMoreUpdates |= replicaMaskLayer->needMoreUpdates();
+    }
+    return needMoreUpdates;
 }
 
-void CCLayerTreeHost::paintLayerContents(const LayerList& renderSurfaceLayerList, PaintType paintType, CCTextureUpdater& updater)
+bool CCLayerTreeHost::paintLayerContents(const LayerList& renderSurfaceLayerList, CCTextureUpdater& updater)
 {
     // Use FrontToBack to allow for testing occlusion and performing culling during the tree walk.
     typedef CCLayerIterator<LayerChromium, Vector<RefPtr<LayerChromium> >, RenderSurfaceChromium, CCLayerIteratorActions::FrontToBack> CCLayerIteratorType;
 
+    bool needMoreUpdates = false;
     bool recordMetricsForFrame = true; // FIXME: In the future, disable this when about:tracing is off.
     CCOcclusionTracker occlusionTracker(IntRect(IntPoint(), deviceViewportSize()), recordMetricsForFrame);
     occlusionTracker.setMinimumTrackingSize(CCOcclusionTracker::preferredMinimumTrackingSize());
@@ -591,10 +582,11 @@ void CCLayerTreeHost::paintLayerContents(const LayerList& renderSurfaceLayerList
 
         if (it.representsTargetRenderSurface()) {
             ASSERT(it->renderSurface()->drawOpacity() || it->renderSurface()->drawOpacityIsAnimating());
-            paintMasksForRenderSurface(*it, paintType, updater);
+            needMoreUpdates |= paintMasksForRenderSurface(*it, updater);
         } else if (it.representsItself()) {
             ASSERT(!it->bounds().isEmpty());
-            update(*it, paintType, updater, &occlusionTracker);
+            it->update(updater, &occlusionTracker);
+            needMoreUpdates |= it->needMoreUpdates();
         }
 
         occlusionTracker.leaveLayer(it);
@@ -603,6 +595,8 @@ void CCLayerTreeHost::paintLayerContents(const LayerList& renderSurfaceLayerList
     occlusionTracker.overdrawMetrics().didUseContentsTextureMemoryBytes(m_contentsTextureManager->memoryAboveCutoffBytes());
     occlusionTracker.overdrawMetrics().didUseRenderSurfaceTextureMemoryBytes(m_contentsTextureManager->memoryForRenderSurfacesBytes());
     occlusionTracker.overdrawMetrics().recordMetrics(this);
+
+    return needMoreUpdates;
 }
 
 static LayerChromium* findFirstScrollableLayer(LayerChromium* layer)
index 974f4ce..c2143ea 100644 (file)
@@ -278,10 +278,9 @@ private:
 
     void initializeLayerRenderer();
 
-    enum PaintType { PaintVisible, PaintIdle };
-    static void update(LayerChromium*, PaintType, CCTextureUpdater&, const CCOcclusionTracker*);
-    void paintLayerContents(const LayerList&, PaintType, CCTextureUpdater&);
-    void paintMasksForRenderSurface(LayerChromium*, PaintType, CCTextureUpdater&);
+    static void update(LayerChromium*, CCTextureUpdater&, const CCOcclusionTracker*);
+    bool paintLayerContents(const LayerList&, CCTextureUpdater&);
+    bool paintMasksForRenderSurface(LayerChromium*, CCTextureUpdater&);
 
     void updateLayers(LayerChromium*, CCTextureUpdater&);
 
@@ -323,7 +322,8 @@ private:
 
     float m_pageScaleFactor;
     float m_minPageScaleFactor, m_maxPageScaleFactor;
-    bool m_triggerIdlePaints;
+    bool m_triggerIdleUpdates;
+
     SkColor m_backgroundColor;
     bool m_hasTransparentBackground;
 
index eabe725..86e7085 100644 (file)
@@ -1,3 +1,19 @@
+2012-07-09  Eric Penner  <epenner@google.com>
+
+        [chromium] Merge updates and idle updates into one pass
+        https://bugs.webkit.org/show_bug.cgi?id=90324
+
+        Reviewed by Adrienne Walker.
+
+        * tests/CCLayerTreeHostTest.cpp:
+        (WTF::ContentLayerChromiumWithUpdateTracking::resetPaintContentsCount):
+        (WTF::ContentLayerChromiumWithUpdateTracking::ContentLayerChromiumWithUpdateTracking):
+        (ContentLayerChromiumWithUpdateTracking):
+        (WTF::CCLayerTreeHostTestOpacityChange::afterTest):
+        * tests/CCTiledLayerTestCommon.h:
+        (FakeTiledLayerChromium):
+        * tests/TiledLayerChromiumTest.cpp:
+
 2012-07-09  Yoshifumi Inoue  <yosin@chromium.org>
 
         [Platform] Introduce LocaleMac class
index 4460c99..39d0d79 100644 (file)
@@ -1158,8 +1158,7 @@ public:
     static PassRefPtr<ContentLayerChromiumWithUpdateTracking> create(ContentLayerDelegate *delegate) { return adoptRef(new ContentLayerChromiumWithUpdateTracking(delegate)); }
 
     int paintContentsCount() { return m_paintContentsCount; }
-    int idlePaintContentsCount() { return m_idlePaintContentsCount; }
-    void resetPaintContentsCount() { m_paintContentsCount = 0; m_idlePaintContentsCount = 0;}
+    void resetPaintContentsCount() { m_paintContentsCount = 0; }
 
     virtual void update(CCTextureUpdater& updater, const CCOcclusionTracker* occlusion) OVERRIDE
     {
@@ -1167,24 +1166,16 @@ public:
         m_paintContentsCount++;
     }
 
-    virtual void idleUpdate(CCTextureUpdater& updater, const CCOcclusionTracker* occlusion) OVERRIDE
-    {
-        ContentLayerChromium::idleUpdate(updater, occlusion);
-        m_idlePaintContentsCount++;
-    }
-
 private:
     explicit ContentLayerChromiumWithUpdateTracking(ContentLayerDelegate* delegate)
         : ContentLayerChromium(delegate)
         , m_paintContentsCount(0)
-        , m_idlePaintContentsCount(0)
     {
         setBounds(IntSize(10, 10));
         setIsDrawable(true);
     }
 
     int m_paintContentsCount;
-    int m_idlePaintContentsCount;
 };
 
 // Layer opacity change during paint should not prevent compositor resources from being updated during commit.
@@ -1214,9 +1205,6 @@ public:
         // update() should have been called once.
         EXPECT_EQ(1, m_updateCheckLayer->paintContentsCount());
 
-        // idleUpdate() should have been called once
-        EXPECT_EQ(1, m_updateCheckLayer->idlePaintContentsCount());
-
         // clear m_updateCheckLayer so CCLayerTreeHost dies.
         m_updateCheckLayer.clear();
     }
index 369bac9..53e58b3 100644 (file)
@@ -112,7 +112,6 @@ public:
 
     using WebCore::TiledLayerChromium::invalidateRect;
     using WebCore::TiledLayerChromium::updateLayerRect;
-    using WebCore::TiledLayerChromium::idleUpdateLayerRect;
     using WebCore::TiledLayerChromium::needsIdlePaint;
     using WebCore::TiledLayerChromium::skipsDraw;
     using WebCore::TiledLayerChromium::numPaintedTiles;
index 5b31042..c277e00 100644 (file)
@@ -259,7 +259,6 @@ TEST_F(TiledLayerChromiumTest, pushIdlePaintTiles)
 
         layer->updateLayerRect(updater, visibleRect, 0);
         EXPECT_TRUE(layer->needsIdlePaint(visibleRect));
-        layer->idleUpdateLayerRect(updater, visibleRect, 0);
         updateTextures();
         layer->pushPropertiesTo(layerImpl.get());
     }
@@ -328,7 +327,6 @@ TEST_F(TiledLayerChromiumTest, pushTilesAfterIdlePaintFailed)
     layer1->setTexturePriorities(priorityCalculator);
     textureManager->prioritizeTextures(0);
     layer2->updateLayerRect(updater, IntRect(0, 0, 100, 100), 0);
-    layer2->idleUpdateLayerRect(updater, layer2Rect, 0);
 
     // Oh well, commit the frame and push.
     updateTextures();
@@ -382,7 +380,6 @@ TEST_F(TiledLayerChromiumTest, pushIdlePaintedOccludedTiles)
     layer->setTexturePriorities(priorityCalculator);
     textureManager->prioritizeTextures(0);
     layer->updateLayerRect(updater, IntRect(0, 0, 100, 100), &occluded);
-    layer->idleUpdateLayerRect(updater, IntRect(0, 0, 100, 100), &occluded);
     updateTextures();
     layer->pushPropertiesTo(layerImpl.get());
 
@@ -526,7 +523,6 @@ TEST_F(TiledLayerChromiumTest, idlePaintOutOfMemory)
     layer->setTexturePriorities(priorityCalculator);
     textureManager->prioritizeTextures(0);
     layer->updateLayerRect(updater, visibleRect, 0);
-    layer->idleUpdateLayerRect(updater, visibleRect, 0);
 
     // We shouldn't signal we need another idle paint.
     EXPECT_FALSE(layer->needsIdlePaint(visibleRect));
@@ -539,82 +535,35 @@ TEST_F(TiledLayerChromiumTest, idlePaintZeroSizedLayer)
     DebugScopedSetImplThread implThread;
     OwnPtr<FakeCCTiledLayerImpl> layerImpl(adoptPtr(new FakeCCTiledLayerImpl(1)));
 
-    // The layer's bounds are empty.
-    IntRect contentRect;
+    bool animating[2] = {false, true};
+    for (int i = 0; i < 2; i++) {
+        // Pretend the layer is animating.
+        layer->setDrawTransformIsAnimating(animating[i]);
 
-    layer->setBounds(contentRect.size());
-    layer->setVisibleLayerRect(contentRect);
-    layer->invalidateRect(contentRect);
-
-    layer->setTexturePriorities(priorityCalculator);
-    textureManager->prioritizeTextures(0);
-    layer->updateLayerRect(updater, contentRect, 0);
-
-    // Empty layers don't have tiles.
-    EXPECT_EQ(0u, layer->numPaintedTiles());
-
-    // Empty layers don't need prepaint.
-    EXPECT_FALSE(layer->needsIdlePaint(contentRect));
-
-    layer->pushPropertiesTo(layerImpl.get());
-
-    // Empty layers don't have tiles.
-    EXPECT_FALSE(layerImpl->hasTileAt(0, 0));
-
-    // Non-visible layers don't idle paint.
-    layer->idleUpdateLayerRect(updater, contentRect, 0);
-
-    // Empty layers don't have tiles.
-    EXPECT_EQ(0u, layer->numPaintedTiles());
-
-    layer->pushPropertiesTo(layerImpl.get());
-
-    // Empty layers don't have tiles.
-    EXPECT_FALSE(layerImpl->hasTileAt(0, 0));
-}
-
-TEST_F(TiledLayerChromiumTest, idlePaintZeroSizedAnimatingLayer)
-{
-    OwnPtr<CCPrioritizedTextureManager> textureManager = CCPrioritizedTextureManager::create(20000, 1024);
-    RefPtr<FakeTiledLayerChromium> layer = adoptRef(new FakeTiledLayerChromium(textureManager.get()));
-    DebugScopedSetImplThread implThread;
-    OwnPtr<FakeCCTiledLayerImpl> layerImpl(adoptPtr(new FakeCCTiledLayerImpl(1)));
-
-    // Pretend the layer is animating.
-    layer->setDrawTransformIsAnimating(true);
-
-    // The layer's bounds are empty.
-    IntRect contentRect;
+        // The layer's bounds are empty.
+        IntRect contentRect;
 
-    layer->setBounds(contentRect.size());
-    layer->setVisibleLayerRect(contentRect);
-    layer->invalidateRect(contentRect);
+        layer->setBounds(contentRect.size());
+        layer->setVisibleLayerRect(contentRect);
+        layer->invalidateRect(contentRect);
 
-    layer->setTexturePriorities(priorityCalculator);
-    textureManager->prioritizeTextures(0);
-    layer->updateLayerRect(updater, contentRect, 0);
-
-    // Empty layers don't have tiles.
-    EXPECT_EQ(0u, layer->numPaintedTiles());
-
-    // Empty layers don't need prepaint.
-    EXPECT_FALSE(layer->needsIdlePaint(contentRect));
-
-    layer->pushPropertiesTo(layerImpl.get());
+        layer->setTexturePriorities(priorityCalculator);
+        textureManager->prioritizeTextures(0);
 
-    // Empty layers don't have tiles.
-    EXPECT_FALSE(layerImpl->hasTileAt(0, 0));
+        // Empty layers don't paint or idle-paint.
+        layer->updateLayerRect(updater, contentRect, 0);
 
-    // Non-visible layers don't idle paint.
-    layer->idleUpdateLayerRect(updater, contentRect, 0);
+        // Empty layers don't have tiles.
+        EXPECT_EQ(0u, layer->numPaintedTiles());
 
-    // Empty layers don't have tiles.
-    EXPECT_EQ(0u, layer->numPaintedTiles());
+        // Empty layers don't need prepaint.
+        EXPECT_FALSE(layer->needsIdlePaint(contentRect));
 
-    layer->pushPropertiesTo(layerImpl.get());
+        layer->pushPropertiesTo(layerImpl.get());
 
-    // Empty layers don't have tiles.
-    EXPECT_FALSE(layerImpl->hasTileAt(0, 0));
+        // Empty layers don't have tiles.
+        EXPECT_FALSE(layerImpl->hasTileAt(0, 0));
+    }
 }
 
 TEST_F(TiledLayerChromiumTest, idlePaintNonVisibleLayers)
@@ -634,25 +583,20 @@ TEST_F(TiledLayerChromiumTest, idlePaintNonVisibleLayers)
     layer->setVisibleLayerRect(visibleRect);
     layer->invalidateRect(contentRect);
 
-    layer->setTexturePriorities(priorityCalculator);
-    textureManager->prioritizeTextures(0);
-    layer->updateLayerRect(updater, visibleRect, 0);
-
-    // Non-visible layers don't need idle paint.
-    EXPECT_FALSE(layer->needsIdlePaint(visibleRect));
-
-    layer->pushPropertiesTo(layerImpl.get());
-
-    // We should not have any tiles pushed since the layer is not visible.
-    EXPECT_FALSE(layerImpl->hasTileAt(0, 0));
+    for (int i = 0; i < 2; i++) {
+        // Paint / idle-paint.
+        layer->setTexturePriorities(priorityCalculator);
+        textureManager->prioritizeTextures(0);
+        layer->updateLayerRect(updater, visibleRect, 0);
 
-    // Non-visible layers don't idle paint.
-    layer->idleUpdateLayerRect(updater, visibleRect, 0);
+        // Non-visible layers don't need idle paint.
+        EXPECT_FALSE(layer->needsIdlePaint(visibleRect));
 
-    layer->pushPropertiesTo(layerImpl.get());
+        layer->pushPropertiesTo(layerImpl.get());
 
-    // We should not have any tiles pushed since the layer is not visible.
-    EXPECT_FALSE(layerImpl->hasTileAt(0, 0));
+        // We should not have any tiles pushed since the layer is not visible.
+        EXPECT_FALSE(layerImpl->hasTileAt(0, 0));
+    }
 }
 
 static void testHaveOuterTiles(FakeCCTiledLayerImpl* layerImpl, int width, int height, int have)
@@ -698,19 +642,6 @@ TEST_F(TiledLayerChromiumTest, idlePaintNonVisibleAnimatingLayers)
             // we shoud paint nothing.
             bool shouldPrepaint = !layer->idlePaintRect(visibleRect).isEmpty();
 
-            // This paints the layer but there's nothing visible so it's a no-op.
-            layer->updateLayerRect(updater, visibleRect, 0);
-            // This drops all the tile objects since they were not painted.
-            updateTextures();
-            layer->pushPropertiesTo(layerImpl.get());
-
-            // We should not have any tiles pushed yet since the layer is not visible and we've not prepainted.
-            testHaveOuterTiles(layerImpl.get(), width[i], height[j], 0);
-
-            // Set priorities and recreate tiles.
-            layer->setTexturePriorities(priorityCalculator);
-            textureManager->prioritizeTextures(0);
-
             // Normally we don't allow non-visible layers to pre-paint, but if they are animating then we should.
             EXPECT_EQ(shouldPrepaint, layer->needsIdlePaint(visibleRect));
 
@@ -720,10 +651,10 @@ TEST_F(TiledLayerChromiumTest, idlePaintNonVisibleAnimatingLayers)
                 textureManager->prioritizeTextures(0);
 
                 layer->updateLayerRect(updater, visibleRect, 0);
-                layer->idleUpdateLayerRect(updater, visibleRect, 0);
                 updateTextures();
                 layer->pushPropertiesTo(layerImpl.get());
             }
+
             testHaveOuterTiles(layerImpl.get(), width[i], height[j], shouldPrepaint ? 1 : 0);
 
             // We don't currently idle paint past the outermost tiles.
@@ -733,10 +664,10 @@ TEST_F(TiledLayerChromiumTest, idlePaintNonVisibleAnimatingLayers)
                 textureManager->prioritizeTextures(0);
 
                 layer->updateLayerRect(updater, visibleRect, 0);
-                layer->idleUpdateLayerRect(updater, visibleRect, 0);
                 updateTextures();
                 layer->pushPropertiesTo(layerImpl.get());
             }
+
             testHaveOuterTiles(layerImpl.get(), width[i], height[j], shouldPrepaint ? 1 : 0);
         }
     }
@@ -1243,9 +1174,9 @@ TEST_F(TiledLayerChromiumTest, tilesNotPaintedWithoutInvalidation)
 
     layer->fakeLayerTextureUpdater()->clearPrepareRectCount();
 
-    // Repaint without marking it dirty. The culled tiles remained dirty.
+    // Repaint without marking it dirty. The 3 culled tiles will be pre-painted now.
     layer->updateLayerRect(updater, IntRect(0, 0, 600, 600), &occluded);
-    EXPECT_EQ(0, layer->fakeLayerTextureUpdater()->prepareRectCount());
+    EXPECT_EQ(3, layer->fakeLayerTextureUpdater()->prepareRectCount());
 
     EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedOpaque(), 0, 1);
     EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedTranslucent(), 330000, 1);
@@ -1440,14 +1371,6 @@ TEST_F(TiledLayerChromiumTest, visibleContentOpaqueRegion)
     EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedOpaque(), 17100, 1);
     EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedTranslucent(), 20000 + 20000 - 17100 + 1 + 1, 1);
     EXPECT_EQ(0, occluded.overdrawMetrics().tilesCulledForUpload());
-
-    // No metrics are recorded in prepaint, so the values should not change from above.
-    layer->idleUpdateLayerRect(updater, contentBounds, &occluded);
-    updateTextures();
-    EXPECT_NEAR(occluded.overdrawMetrics().pixelsPainted(), 20000 * 2 + 1  + 1, 1);
-    EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedOpaque(), 17100, 1);
-    EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedTranslucent(), 20000 + 20000 - 17100 + 1 + 1, 1);
-    EXPECT_EQ(0, occluded.overdrawMetrics().tilesCulledForUpload());
 }
 
 TEST_F(TiledLayerChromiumTest, pixelsPaintedMetrics)