Changeset 122185 in webkit


Ignore:
Timestamp:
Jul 9, 2012 7:29:15 PM (12 years ago)
Author:
commit-queue@webkit.org
Message:

[chromium] Merge updates and idle updates into one pass
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:
Location:
trunk/Source
Files:
12 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r122184 r122185  
     12012-07-09  Eric Penner  <epenner@google.com>
     2
     3        [chromium] Merge updates and idle updates into one pass
     4        https://bugs.webkit.org/show_bug.cgi?id=90324
     5
     6        Reviewed by Adrienne Walker.
     7
     8        We no longer need to do painting is passes in order
     9        to allocate memory in the right order. So this merges
     10        updates and idle updates into one pass.
     11
     12        Covered by existing unit tests (some of which are
     13        updated with this patch).
     14
     15        * platform/graphics/chromium/ContentLayerChromium.cpp:
     16        (WebCore::ContentLayerChromium::needMoreUpdates):
     17        * platform/graphics/chromium/ContentLayerChromium.h:
     18        (ContentLayerChromium):
     19        * platform/graphics/chromium/LayerChromium.h:
     20        (WebCore::LayerChromium::needMoreUpdates):
     21        * platform/graphics/chromium/TiledLayerChromium.cpp:
     22        (WebCore::TiledLayerChromium::updateTiles):
     23        (WebCore::TiledLayerChromium::updateLayerRect):
     24        * platform/graphics/chromium/TiledLayerChromium.h:
     25        (TiledLayerChromium):
     26        * platform/graphics/chromium/cc/CCLayerTreeHost.cpp:
     27        (WebCore::CCLayerTreeHost::CCLayerTreeHost):
     28        (WebCore::CCLayerTreeHost::compositeAndReadback):
     29        (WebCore::CCLayerTreeHost::updateLayers):
     30        (WebCore::CCLayerTreeHost::paintMasksForRenderSurface):
     31        (WebCore::CCLayerTreeHost::paintLayerContents):
     32        * platform/graphics/chromium/cc/CCLayerTreeHost.h:
     33        (CCLayerTreeHost):
     34
    1352012-07-09  Yoshifumi Inoue  <yosin@chromium.org>
    236
  • trunk/Source/WebCore/platform/graphics/chromium/ContentLayerChromium.cpp

    r121628 r122185  
    109109}
    110110
    111 void ContentLayerChromium::idleUpdate(CCTextureUpdater& updater, const CCOcclusionTracker* occlusion)
     111bool ContentLayerChromium::needMoreUpdates()
    112112{
    113113    if (!drawsContent())
    114         return;
    115 
    116     const IntRect layerRect = visibleLayerRect();
    117     idleUpdateLayerRect(updater, layerRect, occlusion);
    118     if (needsIdlePaint(layerRect))
    119         setNeedsCommit();
     114        return false;
     115    return needsIdlePaint(visibleLayerRect());
    120116}
    121117
  • trunk/Source/WebCore/platform/graphics/chromium/ContentLayerChromium.h

    r121628 r122185  
    7979    virtual void setTexturePriorities(const CCPriorityCalculator&) OVERRIDE;
    8080    virtual void update(CCTextureUpdater&, const CCOcclusionTracker*) OVERRIDE;
    81     virtual void idleUpdate(CCTextureUpdater&, const CCOcclusionTracker*) OVERRIDE;
     81    virtual bool needMoreUpdates() OVERRIDE;
    8282
    8383    virtual void setOpaque(bool) OVERRIDE;
  • trunk/Source/WebCore/platform/graphics/chromium/LayerChromium.h

    r121574 r122185  
    212212    virtual bool drawsContent() const { return m_isDrawable; }
    213213    virtual void update(CCTextureUpdater&, const CCOcclusionTracker*) { }
    214     virtual void idleUpdate(CCTextureUpdater&, const CCOcclusionTracker*) { }
     214    virtual bool needMoreUpdates() { return false; }
    215215    virtual void setIsMask(bool) { }
    216216    virtual void bindContentsTexture() { }
  • trunk/Source/WebCore/platform/graphics/chromium/TiledLayerChromium.cpp

    r121870 r122185  
    351351    createTextureUpdaterIfNeeded();
    352352
     353    // We shouldn't track any occlusion metrics during idle painting.
     354    ASSERT(!idle || !occlusion);
     355
    353356    // Create tiles as needed, expanding a dirty rect to contain all
    354357    // the dirty regions currently being drawn. All dirty tiles that are to be painted
     
    609612}
    610613
    611 void TiledLayerChromium::updateLayerRect(CCTextureUpdater& updater, const IntRect& layerRect, const CCOcclusionTracker* occlusion)
     614void TiledLayerChromium::updateLayerRect(CCTextureUpdater& updater, const IntRect& contentRect, const CCOcclusionTracker* occlusion)
    612615{
    613616    m_skipsDraw = false;
     
    617620    updateBounds();
    618621
    619     if (layerRect.isEmpty() || m_tiler->hasEmptyBounds())
     622    if (m_tiler->hasEmptyBounds())
    620623        return;
    621624
    622     int left, top, right, bottom;
    623     m_tiler->layerRectToTileIndices(layerRect, left, top, right, bottom);
    624 
    625     updateTiles(false, left, top, right, bottom, updater, occlusion);
    626 }
    627 
    628 void TiledLayerChromium::idleUpdateLayerRect(CCTextureUpdater& updater, const IntRect& layerRect, const CCOcclusionTracker* occlusion)
    629 {
     625    // Visible painting. Only paint visible tiles if the visible rect isn't empty.
     626    if (!contentRect.isEmpty()) {
     627        int left, top, right, bottom;
     628        m_tiler->layerRectToTileIndices(contentRect, left, top, right, bottom);
     629        updateTiles(false, left, top, right, bottom, updater, occlusion);
     630    }
     631
    630632    // Abort if we have already painted or run out of memory.
    631633    if (m_skipsIdlePaint || m_didPaint)
    632634        return;
    633635
    634     ASSERT(m_tiler);
    635 
    636     updateBounds();
    637 
    638     if (m_tiler->hasEmptyBounds())
     636    // If we have already painting everything visible. Do some pre-painting while idle.
     637    IntRect idlePaintContentRect = idlePaintRect(contentRect);
     638    if (idlePaintContentRect.isEmpty())
    639639        return;
    640640
    641     IntRect idlePaintLayerRect = idlePaintRect(layerRect);
    642     if (idlePaintLayerRect.isEmpty())
    643         return;
    644 
    645641    int prepaintLeft, prepaintTop, prepaintRight, prepaintBottom;
    646     m_tiler->layerRectToTileIndices(idlePaintLayerRect, prepaintLeft, prepaintTop, prepaintRight, prepaintBottom);
     642    m_tiler->layerRectToTileIndices(idlePaintContentRect, prepaintLeft, prepaintTop, prepaintRight, prepaintBottom);
    647643
    648644    // If the layer is not visible, we have nothing to expand from, so instead we prepaint the outer-most set of tiles.
    649     if (layerRect.isEmpty()) {
     645    if (contentRect.isEmpty()) {
    650646        updateTiles(true, prepaintLeft, prepaintTop, prepaintRight, prepaintTop, updater, 0);
    651647        if (m_didPaint || m_skipsIdlePaint)
     
    662658
    663659    int left, top, right, bottom;
    664     m_tiler->layerRectToTileIndices(layerRect, left, top, right, bottom);
     660    m_tiler->layerRectToTileIndices(contentRect, left, top, right, bottom);
    665661
    666662    // Otherwise, prepaint anything that was occluded but inside the layer's visible region.
     
    698694}
    699695
    700 bool TiledLayerChromium::needsIdlePaint(const IntRect& layerRect)
     696bool TiledLayerChromium::needsIdlePaint(const IntRect& contentRect)
    701697{
    702698    if (m_skipsIdlePaint)
     
    706702        return false;
    707703
    708     IntRect idlePaintLayerRect = idlePaintRect(layerRect);
    709     if (idlePaintLayerRect.isEmpty())
     704    IntRect idlePaintContentRect = idlePaintRect(contentRect);
     705    if (idlePaintContentRect.isEmpty())
    710706        return false;
    711707
    712708    int left, top, right, bottom;
    713     m_tiler->layerRectToTileIndices(idlePaintLayerRect, left, top, right, bottom);
     709    m_tiler->layerRectToTileIndices(idlePaintContentRect, left, top, right, bottom);
    714710
    715711    for (int j = top; j <= bottom; ++j) {
    716712        for (int i = left; i <= right; ++i) {
    717713            // If the layerRect is empty, then we are painting the outer-most set of tiles only.
    718             if (layerRect.isEmpty() && i != left && i != right && j != top && j != bottom)
     714            if (contentRect.isEmpty() && i != left && i != right && j != top && j != bottom)
    719715                continue;
    720716            UpdatableTile* tile = tileAt(i, j);
     
    733729}
    734730
    735 IntRect TiledLayerChromium::idlePaintRect(const IntRect& visibleLayerRect)
     731IntRect TiledLayerChromium::idlePaintRect(const IntRect& visibleRect)
    736732{
    737733    IntRect contentRect(IntPoint::zero(), contentBounds());
     
    740736    // of them is going to become visible. For small layers we return the entire layer, for larger
    741737    // ones we avoid prepainting the layer at all.
    742     if (visibleLayerRect.isEmpty()) {
     738    if (visibleRect.isEmpty()) {
    743739        bool isSmallLayer = m_tiler->numTilesX() <= 9 && m_tiler->numTilesY() <= 9 && m_tiler->numTilesX() * m_tiler->numTilesY() <= 9;
    744740        if ((drawTransformIsAnimating() || screenSpaceTransformIsAnimating()) && isSmallLayer)
     
    749745    // FIXME: This can be made a lot larger now! We should increase
    750746    //        this slowly while insuring it doesn't cause any perf issues.
    751     IntRect prepaintRect = visibleLayerRect;
     747    IntRect prepaintRect = visibleRect;
    752748    prepaintRect.inflateX(m_tiler->tileSize().width());
    753749    prepaintRect.inflateY(m_tiler->tileSize().height() * 2);
  • trunk/Source/WebCore/platform/graphics/chromium/TiledLayerChromium.h

    r121870 r122185  
    8686    void updateLayerRect(CCTextureUpdater&, const IntRect& layerRect, const CCOcclusionTracker*);
    8787
    88     // Same as above, but this will try to paint additional surrounding content if idle.
    89     void idleUpdateLayerRect(CCTextureUpdater&, const IntRect& layerRect, const CCOcclusionTracker*);
    90 
    91     // After preparing an update, returns true if more pre-painting is needed.
     88    // After preparing an update, returns true if more painting is needed.
    9289    bool needsIdlePaint(const IntRect& layerRect);
    9390
  • trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHost.cpp

    r121870 r122185  
    8686    , m_minPageScaleFactor(1)
    8787    , m_maxPageScaleFactor(1)
    88     , m_triggerIdlePaints(true)
     88    , m_triggerIdleUpdates(true)
    8989    , m_backgroundColor(SK_ColorWHITE)
    9090    , m_hasTransparentBackground(false)
     
    289289bool CCLayerTreeHost::compositeAndReadback(void *pixels, const IntRect& rect)
    290290{
    291     m_triggerIdlePaints = false;
     291    m_triggerIdleUpdates = false;
    292292    bool ret = m_proxy->compositeAndReadback(pixels, rect);
    293     m_triggerIdlePaints = true;
     293    m_triggerIdleUpdates = true;
    294294    return ret;
    295295}
     
    493493    prioritizeTextures(updateList);
    494494
    495     paintLayerContents(updateList, PaintVisible, updater);
    496 
    497     if (m_triggerIdlePaints) {
    498         // The second (idle) paint will be a no-op in layers where painting already occured above.
    499         // FIXME: This pass can be merged with the visible pass now that textures
    500         //        are prioritized above.
    501         paintLayerContents(updateList, PaintIdle, updater);
    502     }
     495    bool needMoreUpdates = paintLayerContents(updateList, updater);
     496    if (m_triggerIdleUpdates && needMoreUpdates)
     497        setNeedsCommit();
    503498
    504499    for (size_t i = 0; i < updateList.size(); ++i)
     
    551546}
    552547
    553 // static
    554 void CCLayerTreeHost::update(LayerChromium* layer, PaintType paintType, CCTextureUpdater& updater, const CCOcclusionTracker* occlusion)
    555 {
    556     ASSERT(layer);
    557     ASSERT(PaintVisible == paintType || PaintIdle == paintType);
    558     if (PaintVisible == paintType)
    559         layer->update(updater, occlusion);
    560     else
    561         layer->idleUpdate(updater, occlusion);
    562 }
    563 
    564 void CCLayerTreeHost::paintMasksForRenderSurface(LayerChromium* renderSurfaceLayer, PaintType paintType, CCTextureUpdater& updater)
     548bool CCLayerTreeHost::paintMasksForRenderSurface(LayerChromium* renderSurfaceLayer, CCTextureUpdater& updater)
    565549{
    566550    // Note: Masks and replicas only exist for layers that own render surfaces. If we reach this point
     
    568552    // mask and replica should be painted.
    569553
     554    bool needMoreUpdates = false;
    570555    LayerChromium* maskLayer = renderSurfaceLayer->maskLayer();
    571     if (maskLayer)
    572         update(maskLayer, paintType, updater, 0);
     556    if (maskLayer) {
     557        maskLayer->update(updater, 0);
     558        needMoreUpdates |= maskLayer->needMoreUpdates();
     559    }
    573560
    574561    LayerChromium* replicaMaskLayer = renderSurfaceLayer->replicaLayer() ? renderSurfaceLayer->replicaLayer()->maskLayer() : 0;
    575     if (replicaMaskLayer)
    576         update(replicaMaskLayer, paintType, updater, 0);
    577 }
    578 
    579 void CCLayerTreeHost::paintLayerContents(const LayerList& renderSurfaceLayerList, PaintType paintType, CCTextureUpdater& updater)
     562    if (replicaMaskLayer) {
     563        replicaMaskLayer->update(updater, 0);
     564        needMoreUpdates |= replicaMaskLayer->needMoreUpdates();
     565    }
     566    return needMoreUpdates;
     567}
     568
     569bool CCLayerTreeHost::paintLayerContents(const LayerList& renderSurfaceLayerList, CCTextureUpdater& updater)
    580570{
    581571    // Use FrontToBack to allow for testing occlusion and performing culling during the tree walk.
    582572    typedef CCLayerIterator<LayerChromium, Vector<RefPtr<LayerChromium> >, RenderSurfaceChromium, CCLayerIteratorActions::FrontToBack> CCLayerIteratorType;
    583573
     574    bool needMoreUpdates = false;
    584575    bool recordMetricsForFrame = true; // FIXME: In the future, disable this when about:tracing is off.
    585576    CCOcclusionTracker occlusionTracker(IntRect(IntPoint(), deviceViewportSize()), recordMetricsForFrame);
     
    592583        if (it.representsTargetRenderSurface()) {
    593584            ASSERT(it->renderSurface()->drawOpacity() || it->renderSurface()->drawOpacityIsAnimating());
    594             paintMasksForRenderSurface(*it, paintType, updater);
     585            needMoreUpdates |= paintMasksForRenderSurface(*it, updater);
    595586        } else if (it.representsItself()) {
    596587            ASSERT(!it->bounds().isEmpty());
    597             update(*it, paintType, updater, &occlusionTracker);
     588            it->update(updater, &occlusionTracker);
     589            needMoreUpdates |= it->needMoreUpdates();
    598590        }
    599591
     
    604596    occlusionTracker.overdrawMetrics().didUseRenderSurfaceTextureMemoryBytes(m_contentsTextureManager->memoryForRenderSurfacesBytes());
    605597    occlusionTracker.overdrawMetrics().recordMetrics(this);
     598
     599    return needMoreUpdates;
    606600}
    607601
  • trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHost.h

    r121574 r122185  
    279279    void initializeLayerRenderer();
    280280
    281     enum PaintType { PaintVisible, PaintIdle };
    282     static void update(LayerChromium*, PaintType, CCTextureUpdater&, const CCOcclusionTracker*);
    283     void paintLayerContents(const LayerList&, PaintType, CCTextureUpdater&);
    284     void paintMasksForRenderSurface(LayerChromium*, PaintType, CCTextureUpdater&);
     281    static void update(LayerChromium*, CCTextureUpdater&, const CCOcclusionTracker*);
     282    bool paintLayerContents(const LayerList&, CCTextureUpdater&);
     283    bool paintMasksForRenderSurface(LayerChromium*, CCTextureUpdater&);
    285284
    286285    void updateLayers(LayerChromium*, CCTextureUpdater&);
     
    324323    float m_pageScaleFactor;
    325324    float m_minPageScaleFactor, m_maxPageScaleFactor;
    326     bool m_triggerIdlePaints;
     325    bool m_triggerIdleUpdates;
     326
    327327    SkColor m_backgroundColor;
    328328    bool m_hasTransparentBackground;
  • trunk/Source/WebKit/chromium/ChangeLog

    r122184 r122185  
     12012-07-09  Eric Penner  <epenner@google.com>
     2
     3        [chromium] Merge updates and idle updates into one pass
     4        https://bugs.webkit.org/show_bug.cgi?id=90324
     5
     6        Reviewed by Adrienne Walker.
     7
     8        * tests/CCLayerTreeHostTest.cpp:
     9        (WTF::ContentLayerChromiumWithUpdateTracking::resetPaintContentsCount):
     10        (WTF::ContentLayerChromiumWithUpdateTracking::ContentLayerChromiumWithUpdateTracking):
     11        (ContentLayerChromiumWithUpdateTracking):
     12        (WTF::CCLayerTreeHostTestOpacityChange::afterTest):
     13        * tests/CCTiledLayerTestCommon.h:
     14        (FakeTiledLayerChromium):
     15        * tests/TiledLayerChromiumTest.cpp:
     16
    1172012-07-09  Yoshifumi Inoue  <yosin@chromium.org>
    218
  • trunk/Source/WebKit/chromium/tests/CCLayerTreeHostTest.cpp

    r121864 r122185  
    11591159
    11601160    int paintContentsCount() { return m_paintContentsCount; }
    1161     int idlePaintContentsCount() { return m_idlePaintContentsCount; }
    1162     void resetPaintContentsCount() { m_paintContentsCount = 0; m_idlePaintContentsCount = 0;}
     1161    void resetPaintContentsCount() { m_paintContentsCount = 0; }
    11631162
    11641163    virtual void update(CCTextureUpdater& updater, const CCOcclusionTracker* occlusion) OVERRIDE
     
    11661165        ContentLayerChromium::update(updater, occlusion);
    11671166        m_paintContentsCount++;
    1168     }
    1169 
    1170     virtual void idleUpdate(CCTextureUpdater& updater, const CCOcclusionTracker* occlusion) OVERRIDE
    1171     {
    1172         ContentLayerChromium::idleUpdate(updater, occlusion);
    1173         m_idlePaintContentsCount++;
    11741167    }
    11751168
     
    11781171        : ContentLayerChromium(delegate)
    11791172        , m_paintContentsCount(0)
    1180         , m_idlePaintContentsCount(0)
    11811173    {
    11821174        setBounds(IntSize(10, 10));
     
    11851177
    11861178    int m_paintContentsCount;
    1187     int m_idlePaintContentsCount;
    11881179};
    11891180
     
    12141205        // update() should have been called once.
    12151206        EXPECT_EQ(1, m_updateCheckLayer->paintContentsCount());
    1216 
    1217         // idleUpdate() should have been called once
    1218         EXPECT_EQ(1, m_updateCheckLayer->idlePaintContentsCount());
    12191207
    12201208        // clear m_updateCheckLayer so CCLayerTreeHost dies.
  • trunk/Source/WebKit/chromium/tests/CCTiledLayerTestCommon.h

    r121870 r122185  
    113113    using WebCore::TiledLayerChromium::invalidateRect;
    114114    using WebCore::TiledLayerChromium::updateLayerRect;
    115     using WebCore::TiledLayerChromium::idleUpdateLayerRect;
    116115    using WebCore::TiledLayerChromium::needsIdlePaint;
    117116    using WebCore::TiledLayerChromium::skipsDraw;
  • trunk/Source/WebKit/chromium/tests/TiledLayerChromiumTest.cpp

    r122160 r122185  
    260260        layer->updateLayerRect(updater, visibleRect, 0);
    261261        EXPECT_TRUE(layer->needsIdlePaint(visibleRect));
    262         layer->idleUpdateLayerRect(updater, visibleRect, 0);
    263262        updateTextures();
    264263        layer->pushPropertiesTo(layerImpl.get());
     
    329328    textureManager->prioritizeTextures(0);
    330329    layer2->updateLayerRect(updater, IntRect(0, 0, 100, 100), 0);
    331     layer2->idleUpdateLayerRect(updater, layer2Rect, 0);
    332330
    333331    // Oh well, commit the frame and push.
     
    383381    textureManager->prioritizeTextures(0);
    384382    layer->updateLayerRect(updater, IntRect(0, 0, 100, 100), &occluded);
    385     layer->idleUpdateLayerRect(updater, IntRect(0, 0, 100, 100), &occluded);
    386383    updateTextures();
    387384    layer->pushPropertiesTo(layerImpl.get());
     
    527524    textureManager->prioritizeTextures(0);
    528525    layer->updateLayerRect(updater, visibleRect, 0);
    529     layer->idleUpdateLayerRect(updater, visibleRect, 0);
    530526
    531527    // We shouldn't signal we need another idle paint.
     
    540536    OwnPtr<FakeCCTiledLayerImpl> layerImpl(adoptPtr(new FakeCCTiledLayerImpl(1)));
    541537
    542     // The layer's bounds are empty.
    543     IntRect contentRect;
    544 
    545     layer->setBounds(contentRect.size());
    546     layer->setVisibleLayerRect(contentRect);
    547     layer->invalidateRect(contentRect);
    548 
    549     layer->setTexturePriorities(priorityCalculator);
    550     textureManager->prioritizeTextures(0);
    551     layer->updateLayerRect(updater, contentRect, 0);
    552 
    553     // Empty layers don't have tiles.
    554     EXPECT_EQ(0u, layer->numPaintedTiles());
    555 
    556     // Empty layers don't need prepaint.
    557     EXPECT_FALSE(layer->needsIdlePaint(contentRect));
    558 
    559     layer->pushPropertiesTo(layerImpl.get());
    560 
    561     // Empty layers don't have tiles.
    562     EXPECT_FALSE(layerImpl->hasTileAt(0, 0));
    563 
    564     // Non-visible layers don't idle paint.
    565     layer->idleUpdateLayerRect(updater, contentRect, 0);
    566 
    567     // Empty layers don't have tiles.
    568     EXPECT_EQ(0u, layer->numPaintedTiles());
    569 
    570     layer->pushPropertiesTo(layerImpl.get());
    571 
    572     // Empty layers don't have tiles.
    573     EXPECT_FALSE(layerImpl->hasTileAt(0, 0));
    574 }
    575 
    576 TEST_F(TiledLayerChromiumTest, idlePaintZeroSizedAnimatingLayer)
    577 {
    578     OwnPtr<CCPrioritizedTextureManager> textureManager = CCPrioritizedTextureManager::create(20000, 1024);
    579     RefPtr<FakeTiledLayerChromium> layer = adoptRef(new FakeTiledLayerChromium(textureManager.get()));
    580     DebugScopedSetImplThread implThread;
    581     OwnPtr<FakeCCTiledLayerImpl> layerImpl(adoptPtr(new FakeCCTiledLayerImpl(1)));
    582 
    583     // Pretend the layer is animating.
    584     layer->setDrawTransformIsAnimating(true);
    585 
    586     // The layer's bounds are empty.
    587     IntRect contentRect;
    588 
    589     layer->setBounds(contentRect.size());
    590     layer->setVisibleLayerRect(contentRect);
    591     layer->invalidateRect(contentRect);
    592 
    593     layer->setTexturePriorities(priorityCalculator);
    594     textureManager->prioritizeTextures(0);
    595     layer->updateLayerRect(updater, contentRect, 0);
    596 
    597     // Empty layers don't have tiles.
    598     EXPECT_EQ(0u, layer->numPaintedTiles());
    599 
    600     // Empty layers don't need prepaint.
    601     EXPECT_FALSE(layer->needsIdlePaint(contentRect));
    602 
    603     layer->pushPropertiesTo(layerImpl.get());
    604 
    605     // Empty layers don't have tiles.
    606     EXPECT_FALSE(layerImpl->hasTileAt(0, 0));
    607 
    608     // Non-visible layers don't idle paint.
    609     layer->idleUpdateLayerRect(updater, contentRect, 0);
    610 
    611     // Empty layers don't have tiles.
    612     EXPECT_EQ(0u, layer->numPaintedTiles());
    613 
    614     layer->pushPropertiesTo(layerImpl.get());
    615 
    616     // Empty layers don't have tiles.
    617     EXPECT_FALSE(layerImpl->hasTileAt(0, 0));
     538    bool animating[2] = {false, true};
     539    for (int i = 0; i < 2; i++) {
     540        // Pretend the layer is animating.
     541        layer->setDrawTransformIsAnimating(animating[i]);
     542
     543        // The layer's bounds are empty.
     544        IntRect contentRect;
     545
     546        layer->setBounds(contentRect.size());
     547        layer->setVisibleLayerRect(contentRect);
     548        layer->invalidateRect(contentRect);
     549
     550        layer->setTexturePriorities(priorityCalculator);
     551        textureManager->prioritizeTextures(0);
     552
     553        // Empty layers don't paint or idle-paint.
     554        layer->updateLayerRect(updater, contentRect, 0);
     555
     556        // Empty layers don't have tiles.
     557        EXPECT_EQ(0u, layer->numPaintedTiles());
     558
     559        // Empty layers don't need prepaint.
     560        EXPECT_FALSE(layer->needsIdlePaint(contentRect));
     561
     562        layer->pushPropertiesTo(layerImpl.get());
     563
     564        // Empty layers don't have tiles.
     565        EXPECT_FALSE(layerImpl->hasTileAt(0, 0));
     566    }
    618567}
    619568
     
    635584    layer->invalidateRect(contentRect);
    636585
    637     layer->setTexturePriorities(priorityCalculator);
    638     textureManager->prioritizeTextures(0);
    639     layer->updateLayerRect(updater, visibleRect, 0);
    640 
    641     // Non-visible layers don't need idle paint.
    642     EXPECT_FALSE(layer->needsIdlePaint(visibleRect));
    643 
    644     layer->pushPropertiesTo(layerImpl.get());
    645 
    646     // We should not have any tiles pushed since the layer is not visible.
    647     EXPECT_FALSE(layerImpl->hasTileAt(0, 0));
    648 
    649     // Non-visible layers don't idle paint.
    650     layer->idleUpdateLayerRect(updater, visibleRect, 0);
    651 
    652     layer->pushPropertiesTo(layerImpl.get());
    653 
    654     // We should not have any tiles pushed since the layer is not visible.
    655     EXPECT_FALSE(layerImpl->hasTileAt(0, 0));
     586    for (int i = 0; i < 2; i++) {
     587        // Paint / idle-paint.
     588        layer->setTexturePriorities(priorityCalculator);
     589        textureManager->prioritizeTextures(0);
     590        layer->updateLayerRect(updater, visibleRect, 0);
     591
     592        // Non-visible layers don't need idle paint.
     593        EXPECT_FALSE(layer->needsIdlePaint(visibleRect));
     594
     595        layer->pushPropertiesTo(layerImpl.get());
     596
     597        // We should not have any tiles pushed since the layer is not visible.
     598        EXPECT_FALSE(layerImpl->hasTileAt(0, 0));
     599    }
    656600}
    657601
     
    699643            bool shouldPrepaint = !layer->idlePaintRect(visibleRect).isEmpty();
    700644
    701             // This paints the layer but there's nothing visible so it's a no-op.
    702             layer->updateLayerRect(updater, visibleRect, 0);
    703             // This drops all the tile objects since they were not painted.
    704             updateTextures();
    705             layer->pushPropertiesTo(layerImpl.get());
    706 
    707             // We should not have any tiles pushed yet since the layer is not visible and we've not prepainted.
    708             testHaveOuterTiles(layerImpl.get(), width[i], height[j], 0);
    709 
    710             // Set priorities and recreate tiles.
    711             layer->setTexturePriorities(priorityCalculator);
    712             textureManager->prioritizeTextures(0);
    713 
    714645            // Normally we don't allow non-visible layers to pre-paint, but if they are animating then we should.
    715646            EXPECT_EQ(shouldPrepaint, layer->needsIdlePaint(visibleRect));
     
    721652
    722653                layer->updateLayerRect(updater, visibleRect, 0);
    723                 layer->idleUpdateLayerRect(updater, visibleRect, 0);
    724654                updateTextures();
    725655                layer->pushPropertiesTo(layerImpl.get());
    726656            }
     657
    727658            testHaveOuterTiles(layerImpl.get(), width[i], height[j], shouldPrepaint ? 1 : 0);
    728659
     
    734665
    735666                layer->updateLayerRect(updater, visibleRect, 0);
    736                 layer->idleUpdateLayerRect(updater, visibleRect, 0);
    737667                updateTextures();
    738668                layer->pushPropertiesTo(layerImpl.get());
    739669            }
     670
    740671            testHaveOuterTiles(layerImpl.get(), width[i], height[j], shouldPrepaint ? 1 : 0);
    741672        }
     
    12441175    layer->fakeLayerTextureUpdater()->clearPrepareRectCount();
    12451176
    1246     // Repaint without marking it dirty. The culled tiles remained dirty.
     1177    // Repaint without marking it dirty. The 3 culled tiles will be pre-painted now.
    12471178    layer->updateLayerRect(updater, IntRect(0, 0, 600, 600), &occluded);
    1248     EXPECT_EQ(0, layer->fakeLayerTextureUpdater()->prepareRectCount());
     1179    EXPECT_EQ(3, layer->fakeLayerTextureUpdater()->prepareRectCount());
    12491180
    12501181    EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedOpaque(), 0, 1);
     
    14371368    EXPECT_EQ(1u, opaqueContents.rects().size());
    14381369
    1439     EXPECT_NEAR(occluded.overdrawMetrics().pixelsPainted(), 20000 * 2 + 1  + 1, 1);
    1440     EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedOpaque(), 17100, 1);
    1441     EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedTranslucent(), 20000 + 20000 - 17100 + 1 + 1, 1);
    1442     EXPECT_EQ(0, occluded.overdrawMetrics().tilesCulledForUpload());
    1443 
    1444     // No metrics are recorded in prepaint, so the values should not change from above.
    1445     layer->idleUpdateLayerRect(updater, contentBounds, &occluded);
    1446     updateTextures();
    14471370    EXPECT_NEAR(occluded.overdrawMetrics().pixelsPainted(), 20000 * 2 + 1  + 1, 1);
    14481371    EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedOpaque(), 17100, 1);
Note: See TracChangeset for help on using the changeset viewer.