The tile cache should keep track of the tile coverage rect
authorandersca@apple.com <andersca@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 21 Feb 2012 22:21:51 +0000 (22:21 +0000)
committerandersca@apple.com <andersca@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 21 Feb 2012 22:21:51 +0000 (22:21 +0000)
https://bugs.webkit.org/show_bug.cgi?id=79149
<rdar://problem/10877338>

Reviewed by Andreas Kling.

Keep track of the tile coverage rect and use it to avoid trying to iterate over non-existent tiles on large pages.

* platform/graphics/ca/mac/TileCache.h:
(TileCache):
* platform/graphics/ca/mac/TileCache.mm:
(WebCore::TileCache::setNeedsDisplayInRect):
(WebCore::TileCache::revalidateTiles):

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

Source/WebCore/ChangeLog
Source/WebCore/platform/graphics/ca/mac/TileCache.h
Source/WebCore/platform/graphics/ca/mac/TileCache.mm

index b5a0ec8..3e66152 100644 (file)
@@ -1,3 +1,19 @@
+2012-02-21  Anders Carlsson  <andersca@apple.com>
+
+        The tile cache should keep track of the tile coverage rect
+        https://bugs.webkit.org/show_bug.cgi?id=79149
+        <rdar://problem/10877338>
+
+        Reviewed by Andreas Kling.
+
+        Keep track of the tile coverage rect and use it to avoid trying to iterate over non-existent tiles on large pages.
+
+        * platform/graphics/ca/mac/TileCache.h:
+        (TileCache):
+        * platform/graphics/ca/mac/TileCache.mm:
+        (WebCore::TileCache::setNeedsDisplayInRect):
+        (WebCore::TileCache::revalidateTiles):
+
 2012-02-21  Andreas Kling  <awesomekling@apple.com>
 
         Make WebKitCSSShaderValue inherit directly from CSSValue.
index 768b2aa..675b85a 100644 (file)
@@ -27,7 +27,7 @@
 #define TileCache_h
 
 #include "IntPointHash.h"
-#include "IntSize.h"
+#include "IntRect.h"
 #include "Timer.h"
 #include <wtf/HashMap.h>
 #include <wtf/Noncopyable.h>
@@ -97,6 +97,7 @@ private:
     typedef HashMap<TileIndex, RetainPtr<WebTileLayer> > TileMap;
     TileMap m_tiles;
     Timer<TileCache> m_tileRevalidationTimer;
+    IntRect m_tileCoverageRect;
 
     bool m_acceleratesDrawing;
 
index 0dcfc4f..a74ff72 100644 (file)
@@ -93,7 +93,7 @@ void TileCache::setNeedsDisplayInRect(const IntRect& rect)
     // Find the tiles that need to be invalidated.
     TileIndex topLeft;
     TileIndex bottomRight;
-    getTileIndexRangeForRect(rect, topLeft, bottomRight);
+    getTileIndexRangeForRect(intersection(rect, m_tileCoverageRect), topLeft, bottomRight);
 
     for (int y = topLeft.y(); y <= bottomRight.y(); ++y) {
         for (int x = topLeft.x(); x <= bottomRight.x(); ++x) {
@@ -333,6 +333,13 @@ void TileCache::revalidateTiles()
         }
     }
 
+    m_tileCoverageRect = IntRect();
+    for (TileMap::iterator it = m_tiles.begin(), end = m_tiles.end(); it != end; ++it) {
+        const TileIndex& tileIndex = it->first;
+
+        m_tileCoverageRect.unite(rectForTileIndex(tileIndex));
+    }
+
     if (!didCreateNewTiles)
         return;