Title: [97809] trunk/Source/WebCore
Revision
97809
Author
[email protected]
Date
2011-10-18 16:19:15 -0700 (Tue, 18 Oct 2011)

Log Message

[chromium] Preserve offscreen tiles instead of immediately recycling them
https://bugs.webkit.org/show_bug.cgi?id=70352

Reviewed by James Robinson.

Tested by existing layout tests.

Prior to having a TextureManager class, tiled layers recycled their
textures internally to avoid reallocation. Unfortunately, it recycled
these tiles as soon as they went offscreen, even if they were still
valid. Instead, keep tiles around forever, letting the TextureManager
decide (via LRU) when to reclaim the underlying textures. This will
improve scrolling performance due to not needing to repaint tiles.

This change does lead to more texture reallocation for any textures
that get reclaimed, but the command buffer implementation already
pools and reuses texture ids, so it should not introduce additional
flush syncs. If there's any performance penalty, it'll be at the
driver level, but I'd prefer to measure that there's a problem before
prematurely optimizing and adding complexity to the TextureManager.

* platform/graphics/chromium/TiledLayerChromium.cpp:
(WebCore::TiledLayerChromium::cleanupResources):
(WebCore::TiledLayerChromium::createTile):
(WebCore::TiledLayerChromium::prepareToUpdate):
* platform/graphics/chromium/TiledLayerChromium.h:

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (97808 => 97809)


--- trunk/Source/WebCore/ChangeLog	2011-10-18 23:17:26 UTC (rev 97808)
+++ trunk/Source/WebCore/ChangeLog	2011-10-18 23:19:15 UTC (rev 97809)
@@ -1,3 +1,32 @@
+2011-10-18  Adrienne Walker  <[email protected]>
+
+        [chromium] Preserve offscreen tiles instead of immediately recycling them
+        https://bugs.webkit.org/show_bug.cgi?id=70352
+
+        Reviewed by James Robinson.
+
+        Tested by existing layout tests.
+
+        Prior to having a TextureManager class, tiled layers recycled their
+        textures internally to avoid reallocation. Unfortunately, it recycled
+        these tiles as soon as they went offscreen, even if they were still
+        valid. Instead, keep tiles around forever, letting the TextureManager
+        decide (via LRU) when to reclaim the underlying textures. This will
+        improve scrolling performance due to not needing to repaint tiles.
+
+        This change does lead to more texture reallocation for any textures
+        that get reclaimed, but the command buffer implementation already
+        pools and reuses texture ids, so it should not introduce additional
+        flush syncs. If there's any performance penalty, it'll be at the
+        driver level, but I'd prefer to measure that there's a problem before
+        prematurely optimizing and adding complexity to the TextureManager.
+
+        * platform/graphics/chromium/TiledLayerChromium.cpp:
+        (WebCore::TiledLayerChromium::cleanupResources):
+        (WebCore::TiledLayerChromium::createTile):
+        (WebCore::TiledLayerChromium::prepareToUpdate):
+        * platform/graphics/chromium/TiledLayerChromium.h:
+
 2011-10-18  Adam Klein  <[email protected]>
 
         [MutationObservers] Implement WebKitMutationObserver.observe for characterData changes

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


--- trunk/Source/WebCore/platform/graphics/chromium/TiledLayerChromium.cpp	2011-10-18 23:17:26 UTC (rev 97808)
+++ trunk/Source/WebCore/platform/graphics/chromium/TiledLayerChromium.cpp	2011-10-18 23:19:15 UTC (rev 97809)
@@ -87,7 +87,6 @@
     LayerChromium::cleanupResources();
 
     m_tiler.clear();
-    m_unusedTiles.clear();
     m_paintRect = IntRect();
     m_requestedUpdateRect = IntRect();
 }
@@ -262,39 +261,13 @@
 
 UpdatableTile* TiledLayerChromium::createTile(int i, int j)
 {
-    RefPtr<UpdatableTile> tile;
-    if (m_unusedTiles.size() > 0) {
-        tile = m_unusedTiles.last().release();
-        m_unusedTiles.removeLast();
-        ASSERT(tile->refCount() == 1);
-    } else {
-        TextureManager* manager = textureManager();
-        tile = adoptRef(new UpdatableTile(ManagedTexture::create(manager)));
-    }
+    RefPtr<UpdatableTile> tile = adoptRef(new UpdatableTile(ManagedTexture::create(textureManager())));
     m_tiler->addTile(tile, i, j);
     tile->m_dirtyLayerRect = m_tiler->tileLayerRect(tile.get());
 
     return tile.get();
 }
 
-void TiledLayerChromium::invalidateTiles(const IntRect& contentRect)
-{
-    if (!m_tiler->numTiles())
-        return;
-
-    Vector<CCLayerTilingData::TileMapKey> removeKeys;
-    for (CCLayerTilingData::TileMap::const_iterator iter = m_tiler->tiles().begin(); iter != m_tiler->tiles().end(); ++iter) {
-        CCLayerTilingData::Tile* tile = iter->second.get();
-        IntRect tileRect = m_tiler->tileContentRect(tile);
-        if (tileRect.intersects(contentRect))
-            continue;
-        removeKeys.append(iter->first);
-    }
-
-    for (size_t i = 0; i < removeKeys.size(); ++i)
-        m_unusedTiles.append(static_pointer_cast<UpdatableTile>(m_tiler->takeTile(removeKeys[i].first, removeKeys[i].second)));
-}
-
 void TiledLayerChromium::invalidateRect(const IntRect& contentRect)
 {
     if (!m_tiler || contentRect.isEmpty() || m_skipsDraw)
@@ -355,9 +328,6 @@
         return;
     }
 
-    // Invalidate old tiles that were previously used but aren't in use this
-    // frame so that they can get reused for new tiles.
-    invalidateTiles(contentRect);
     m_tiler->growLayerToContain(contentRect);
 
     if (!m_tiler->numTiles()) {

Modified: trunk/Source/WebCore/platform/graphics/chromium/TiledLayerChromium.h (97808 => 97809)


--- trunk/Source/WebCore/platform/graphics/chromium/TiledLayerChromium.h	2011-10-18 23:17:26 UTC (rev 97808)
+++ trunk/Source/WebCore/platform/graphics/chromium/TiledLayerChromium.h	2011-10-18 23:19:15 UTC (rev 97809)
@@ -80,7 +80,6 @@
 
     UpdatableTile* tileAt(int, int) const;
     UpdatableTile* createTile(int, int);
-    void invalidateTiles(const IntRect& contentRect);
 
     TextureManager* textureManager() const;
 
@@ -90,9 +89,6 @@
     // of the layer that is actually re-painted by WebKit.
     IntRect m_paintRect;
 
-    // Tightly packed set of unused tiles.
-    Vector<RefPtr<UpdatableTile> > m_unusedTiles;
-
     TilingOption m_tilingOption;
     GC3Denum m_textureFormat;
     bool m_skipsDraw;
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to