Title: [106870] trunk/Source
Revision
106870
Author
[email protected]
Date
2012-02-06 16:25:16 -0800 (Mon, 06 Feb 2012)

Log Message

[chromium] Drop tiles completely outside of layer bounds when resizing to a smaller size
https://bugs.webkit.org/show_bug.cgi?id=77910

Reviewed by Kenneth Russell.

Source/WebCore:

When resizing a tiled layer to a smaller size, drop all tiles that lie completely outside the new layer bounds.
This avoids attempting to access out-of-bounds tiles when iterating over all tiles in the tiler, which triggers
ASSERT()s, as well as saves some memory.

New unit test added to TiledLayerChromiumTest.

* platform/graphics/chromium/TiledLayerChromium.cpp:
(WebCore::TiledLayerChromium::invalidateRect):
* platform/graphics/chromium/cc/CCLayerTilingData.cpp:
(WebCore::CCLayerTilingData::setBounds):

Source/WebKit/chromium:

Adds test for resizing a layer to cover fewer tiles. Test hits ASSERT()s without any code changes.

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

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (106869 => 106870)


--- trunk/Source/WebCore/ChangeLog	2012-02-07 00:14:40 UTC (rev 106869)
+++ trunk/Source/WebCore/ChangeLog	2012-02-07 00:25:16 UTC (rev 106870)
@@ -1,3 +1,21 @@
+2012-02-06  James Robinson  <[email protected]>
+
+        [chromium] Drop tiles completely outside of layer bounds when resizing to a smaller size
+        https://bugs.webkit.org/show_bug.cgi?id=77910
+
+        Reviewed by Kenneth Russell.
+
+        When resizing a tiled layer to a smaller size, drop all tiles that lie completely outside the new layer bounds.
+        This avoids attempting to access out-of-bounds tiles when iterating over all tiles in the tiler, which triggers
+        ASSERT()s, as well as saves some memory.
+
+        New unit test added to TiledLayerChromiumTest.
+
+        * platform/graphics/chromium/TiledLayerChromium.cpp:
+        (WebCore::TiledLayerChromium::invalidateRect):
+        * platform/graphics/chromium/cc/CCLayerTilingData.cpp:
+        (WebCore::CCLayerTilingData::setBounds):
+
 2012-02-06  Chris Rogers  <[email protected]>
 
         zvmul incorrectly multiplies complex arrays on Windows.

Modified: trunk/Source/WebCore/platform/graphics/chromium/TiledLayerChromium.cpp (106869 => 106870)


--- trunk/Source/WebCore/platform/graphics/chromium/TiledLayerChromium.cpp	2012-02-07 00:14:40 UTC (rev 106869)
+++ trunk/Source/WebCore/platform/graphics/chromium/TiledLayerChromium.cpp	2012-02-07 00:25:16 UTC (rev 106870)
@@ -312,6 +312,7 @@
 
 void TiledLayerChromium::invalidateRect(const IntRect& layerRect)
 {
+    updateBounds();
     if (m_tiler->isEmpty() || layerRect.isEmpty() || m_skipsDraw)
         return;
 

Modified: trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerTilingData.cpp (106869 => 106870)


--- trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerTilingData.cpp	2012-02-07 00:14:40 UTC (rev 106869)
+++ trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerTilingData.cpp	2012-02-07 00:25:16 UTC (rev 106870)
@@ -117,6 +117,17 @@
 void CCLayerTilingData::setBounds(const IntSize& size)
 {
     m_tilingData.setTotalSize(size.width(), size.height());
+
+    // Any tiles completely outside our new bounds are invalid and should be dropped.
+    int left, top, right, bottom;
+    layerRectToTileIndices(IntRect(IntPoint(), size), left, top, right, bottom);
+    Vector<TileMapKey> invalidTileKeys;
+    for (TileMap::const_iterator it = m_tiles.begin(); it != m_tiles.end(); ++it) {
+        if (it->first.first > right || it->first.second > bottom)
+            invalidTileKeys.append(it->first);
+    }
+    for (size_t i = 0; i < invalidTileKeys.size(); ++i)
+        m_tiles.remove(invalidTileKeys[i]);
 }
 
 IntSize CCLayerTilingData::bounds() const

Modified: trunk/Source/WebKit/chromium/ChangeLog (106869 => 106870)


--- trunk/Source/WebKit/chromium/ChangeLog	2012-02-07 00:14:40 UTC (rev 106869)
+++ trunk/Source/WebKit/chromium/ChangeLog	2012-02-07 00:25:16 UTC (rev 106870)
@@ -1,3 +1,15 @@
+2012-02-06  James Robinson  <[email protected]>
+
+        [chromium] Drop tiles completely outside of layer bounds when resizing to a smaller size
+        https://bugs.webkit.org/show_bug.cgi?id=77910
+
+        Reviewed by Kenneth Russell.
+
+        Adds test for resizing a layer to cover fewer tiles. Test hits ASSERT()s without any code changes.
+
+        * tests/TiledLayerChromiumTest.cpp:
+        (::TEST):
+
 2012-02-06  Ryosuke Niwa  <[email protected]>
 
         Revert r106859. It was completely bogus.

Modified: trunk/Source/WebKit/chromium/tests/TiledLayerChromiumTest.cpp (106869 => 106870)


--- trunk/Source/WebKit/chromium/tests/TiledLayerChromiumTest.cpp	2012-02-07 00:14:40 UTC (rev 106869)
+++ trunk/Source/WebKit/chromium/tests/TiledLayerChromiumTest.cpp	2012-02-07 00:25:16 UTC (rev 106870)
@@ -565,4 +565,17 @@
     EXPECT_EQ(0u, occluded.rects().size());
 }
 
+TEST(TiledLayerChromiumTest, resizeToSmaller)
+{
+    OwnPtr<TextureManager> textureManager = TextureManager::create(60*1024*1024, 60*1024*1024, 1024);
+    RefPtr<FakeTiledLayerChromium> layer = adoptRef(new FakeTiledLayerChromium(textureManager.get()));
+
+    layer->setBounds(IntSize(700, 700));
+    layer->invalidateRect(IntRect(0, 0, 700, 700));
+    layer->prepareToUpdate(IntRect(0, 0, 700, 700));
+
+    layer->setBounds(IntSize(200, 200));
+    layer->invalidateRect(IntRect(0, 0, 200, 200));
+}
+
 } // namespace
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to