[chromium] Invalidate/update evicted tiles during commit
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 19 Mar 2012 21:37:00 +0000 (21:37 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 19 Mar 2012 21:37:00 +0000 (21:37 +0000)
https://bugs.webkit.org/show_bug.cgi?id=81529

Patch by Dana Jansens <danakj@chromium.org> on 2012-03-19
Reviewed by Adrienne Walker.

Source/WebCore:

A previous change caused a regression where evicted (invalid) tiles
were no longer marked as dirty and updated. The regress was caused
in https://bugs.webkit.org/show_bug.cgi?id=81175 and is fixed here.

Unit test: TiledLayerChromiumTest.pushDeletedTiles

* platform/graphics/chromium/TiledLayerChromium.cpp:
(WebCore::UpdatableTile::copyAndClearDirty):
(WebCore::TiledLayerChromium::prepareToUpdateTiles):

Source/WebKit/chromium:

* tests/TiledLayerChromiumTest.cpp:
(WTF::TEST):
(WTF):

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

Source/WebCore/ChangeLog
Source/WebCore/platform/graphics/chromium/TiledLayerChromium.cpp
Source/WebKit/chromium/ChangeLog
Source/WebKit/chromium/tests/TiledLayerChromiumTest.cpp

index 1a0d11d..c65e2bf 100644 (file)
@@ -1,3 +1,20 @@
+2012-03-19  Dana Jansens  <danakj@chromium.org>
+
+        [chromium] Invalidate/update evicted tiles during commit
+        https://bugs.webkit.org/show_bug.cgi?id=81529
+
+        Reviewed by Adrienne Walker.
+
+        A previous change caused a regression where evicted (invalid) tiles
+        were no longer marked as dirty and updated. The regress was caused
+        in https://bugs.webkit.org/show_bug.cgi?id=81175 and is fixed here.
+
+        Unit test: TiledLayerChromiumTest.pushDeletedTiles
+
+        * platform/graphics/chromium/TiledLayerChromium.cpp:
+        (WebCore::UpdatableTile::copyAndClearDirty):
+        (WebCore::TiledLayerChromium::prepareToUpdateTiles):
+
 2012-03-19  Adam Barth  <abarth@webkit.org>
 
         Remove PLATFORM(TORCHMOBILE) ifdef from MainResourceLoader.cpp
index f7a4008..7b86444 100644 (file)
@@ -63,6 +63,11 @@ public:
     ManagedTexture* managedTexture() { return m_texture->texture(); }
 
     bool isDirty() const { return !m_dirtyRect.isEmpty(); }
+    void copyAndClearDirty()
+    {
+        m_updateRect = m_dirtyRect;
+        m_dirtyRect = IntRect();
+    }
     // Returns whether the layer was dirty and not updated in the current frame. For tiles that were not culled, the
     // updateRect holds the area of the tile that was updated. Otherwise, the area that would have been updated.
     bool isDirtyForCurrentFrame() { return !m_dirtyRect.isEmpty() && (m_updateRect.isEmpty() || m_updateCulled); }
@@ -414,8 +419,10 @@ void TiledLayerChromium::prepareToUpdateTiles(bool idle, int left, int top, int
             if (!tile)
                 tile = createTile(i, j);
 
-            // Save the dirty rect since WebKit can change the tile's dirty rect during painting.
-            tile->m_updateRect = tile->m_dirtyRect;
+            if (!tile->managedTexture()->isValid(m_tiler->tileSize(), m_textureFormat)) {
+                // Sets the dirty rect to a full-sized tile with border texels.
+                tile->m_dirtyRect = m_tiler->tileRect(tile);
+            }
 
             // When not idle painting, if the visible region of the tile is occluded, don't reserve a texture or update the tile.
             // If any part of the tile is visible, then we need to update it so the tile is pushed to the impl thread.
@@ -423,6 +430,8 @@ void TiledLayerChromium::prepareToUpdateTiles(bool idle, int left, int top, int
                 IntRect visibleTileRect = intersection(m_tiler->tileBounds(i, j), visibleLayerRect());
                 if (occlusion->occluded(this, visibleTileRect)) {
                     tile->m_updateCulled = true;
+                    // Save the area we culled for recording metrics.
+                    tile->m_updateRect = tile->m_dirtyRect;
                     continue;
                 }
             }
@@ -431,10 +440,8 @@ void TiledLayerChromium::prepareToUpdateTiles(bool idle, int left, int top, int
             // of update. https://bugs.webkit.org/show_bug.cgi?id=77376
             if (tileOnlyNeedsPartialUpdate(tile) && layerTreeHost() && layerTreeHost()->requestPartialTextureUpdate())
                 tile->m_partialUpdate = true;
-            else if (tileNeedsBufferedUpdate(tile) && layerTreeHost())
+            else if (tileNeedsBufferedUpdate(tile) && layerTreeHost()) {
                 layerTreeHost()->deleteTextureAfterCommit(tile->managedTexture()->steal());
-
-            if (!tile->managedTexture()->isValid(m_tiler->tileSize(), m_textureFormat)) {
                 // Sets the dirty rect to a full-sized tile with border texels.
                 tile->m_dirtyRect = m_tiler->tileRect(tile);
             }
@@ -454,8 +461,7 @@ void TiledLayerChromium::prepareToUpdateTiles(bool idle, int left, int top, int
             }
 
             dirtyLayerRect.unite(tile->m_dirtyRect);
-            // Clear the dirty rect.
-            tile->m_dirtyRect = IntRect();
+            tile->copyAndClearDirty();
         }
     }
 
index 7f43239..5c3b164 100644 (file)
@@ -1,3 +1,14 @@
+2012-03-19  Dana Jansens  <danakj@chromium.org>
+
+        [chromium] Invalidate/update evicted tiles during commit
+        https://bugs.webkit.org/show_bug.cgi?id=81529
+
+        Reviewed by Adrienne Walker.
+
+        * tests/TiledLayerChromiumTest.cpp:
+        (WTF::TEST):
+        (WTF):
+
 2012-03-19  Sheriff Bot  <webkit.review.bot@gmail.com>
 
         Unreviewed, rolling out r111207.
index 7eebb97..8363c31 100644 (file)
@@ -335,6 +335,48 @@ TEST(TiledLayerChromiumTest, pushOccludedDirtyTiles)
     EXPECT_TRUE(layerImpl->hasTileAt(0, 1));
 }
 
+TEST(TiledLayerChromiumTest, pushDeletedTiles)
+{
+    OwnPtr<TextureManager> textureManager = TextureManager::create(4*1024*1024, 2*1024*1024, 1024);
+    RefPtr<FakeTiledLayerChromium> layer = adoptRef(new FakeTiledLayerChromium(textureManager.get()));
+    DebugScopedSetImplThread implThread;
+    OwnPtr<FakeCCTiledLayerImpl> layerImpl(adoptPtr(new FakeCCTiledLayerImpl(0)));
+
+    FakeTextureAllocator textureAllocator;
+    CCTextureUpdater updater(&textureAllocator);
+
+    // The tile size is 100x100, so this invalidates and then paints two tiles.
+    layer->setBounds(IntSize(100, 200));
+    layer->invalidateRect(IntRect(0, 0, 100, 200));
+    layer->prepareToUpdate(IntRect(0, 0, 100, 200), 0);
+    layer->updateCompositorResources(0, updater);
+    layer->pushPropertiesTo(layerImpl.get());
+
+    // We should have both tiles on the impl side.
+    EXPECT_TRUE(layerImpl->hasTileAt(0, 0));
+    EXPECT_TRUE(layerImpl->hasTileAt(0, 1));
+
+    textureManager->evictAndDeleteAllTextures(&textureAllocator);
+    textureManager->setMaxMemoryLimitBytes(4*1024*1024);
+    textureManager->setPreferredMemoryLimitBytes(4*1024*1024);
+
+    // This should drop the tiles on the impl thread.
+    layer->pushPropertiesTo(layerImpl.get());
+
+    // We should now have no textures on the impl thread.
+    EXPECT_FALSE(layerImpl->hasTileAt(0, 0));
+    EXPECT_FALSE(layerImpl->hasTileAt(0, 1));
+
+    // This should recreate and update the deleted textures.
+    layer->prepareToUpdate(IntRect(0, 0, 100, 100), 0);
+    layer->updateCompositorResources(0, updater);
+    layer->pushPropertiesTo(layerImpl.get());
+
+    // We should only have the first tile since the other tile was invalidated but not painted.
+    EXPECT_TRUE(layerImpl->hasTileAt(0, 0));
+    EXPECT_FALSE(layerImpl->hasTileAt(0, 1));
+}
+
 TEST(TiledLayerChromiumTest, pushIdlePaintTiles)
 {
     OwnPtr<TextureManager> textureManager = TextureManager::create(4*1024*1024, 2*1024*1024, 1024);