TileGrid creates new tiles when there are recyclable tiles about to be removed
authortimothy_horton@apple.com <timothy_horton@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 22 Dec 2016 03:06:05 +0000 (03:06 +0000)
committertimothy_horton@apple.com <timothy_horton@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 22 Dec 2016 03:06:05 +0000 (03:06 +0000)
https://bugs.webkit.org/show_bug.cgi?id=166408

Reviewed by Simon Fraser.

No new tests; existing tests cover this code, this is just a perf win,
specifically reducing the amount of layer churn during zooming.

* platform/graphics/ca/TileGrid.cpp:
(WebCore::TileGrid::revalidateTiles):
Remove all the tiles that will be removed first, then add new tiles.
Strictly ordering it this way means that tiles will be removed, go into
the LayerPool, then be pulled back out of the LayerPool to sit in the
newly-covered areas. Previously, we would sometimes make new layers
for newly-covered areas, and then remove unneeded but otherwise recyclable
tiles, which would then just go sit in the LayerPool (and often get
pruned, wastefully).

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

Source/WebCore/ChangeLog
Source/WebCore/platform/graphics/ca/TileGrid.cpp

index 92afddf..5535dc1 100644 (file)
@@ -1,3 +1,23 @@
+2016-12-21  Tim Horton  <timothy_horton@apple.com>
+
+        TileGrid creates new tiles when there are recyclable tiles about to be removed
+        https://bugs.webkit.org/show_bug.cgi?id=166408
+
+        Reviewed by Simon Fraser.
+
+        No new tests; existing tests cover this code, this is just a perf win,
+        specifically reducing the amount of layer churn during zooming.
+
+        * platform/graphics/ca/TileGrid.cpp:
+        (WebCore::TileGrid::revalidateTiles):
+        Remove all the tiles that will be removed first, then add new tiles.
+        Strictly ordering it this way means that tiles will be removed, go into
+        the LayerPool, then be pulled back out of the LayerPool to sit in the
+        newly-covered areas. Previously, we would sometimes make new layers
+        for newly-covered areas, and then remove unneeded but otherwise recyclable
+        tiles, which would then just go sit in the LayerPool (and often get
+        pruned, wastefully).
+
 2016-12-21  Eric Carlson  <eric.carlson@apple.com>
 
         [MediaStream] Update media-stream-event-constructor test
index 28f29cb..6acd905 100644 (file)
@@ -406,19 +406,9 @@ void TileGrid::revalidateTiles(TileValidationPolicy validationPolicy)
             removeTilesInCohort(currCohort);
     }
 
-    // Ensure primary tile coverage tiles.
-    m_primaryTileCoverageRect = ensureTilesForRect(coverageRect, CoverageType::PrimaryTiles);
-
     if (validationPolicy & PruneSecondaryTiles) {
         removeAllSecondaryTiles();
         m_cohortList.clear();
-    } else {
-        for (auto& secondaryCoverageRect : m_secondaryTileCoverageRects) {
-            FloatRect secondaryRectInLayerCoordinates(secondaryCoverageRect);
-            secondaryRectInLayerCoordinates.scale(1 / m_scale);
-            ensureTilesForRect(secondaryRectInLayerCoordinates, CoverageType::SecondaryTiles);
-        }
-        m_secondaryTileCoverageRects.clear();
     }
 
     if (m_controller.unparentsOffscreenTiles() && (validationPolicy & UnparentAllTiles)) {
@@ -465,6 +455,19 @@ void TileGrid::revalidateTiles(TileValidationPolicy validationPolicy)
         }
     }
 
+    // Ensure primary tile coverage tiles.
+    m_primaryTileCoverageRect = ensureTilesForRect(coverageRect, CoverageType::PrimaryTiles);
+
+    // Ensure secondary tiles (requested via prepopulateRect).
+    if (!(validationPolicy & PruneSecondaryTiles)) {
+        for (auto& secondaryCoverageRect : m_secondaryTileCoverageRects) {
+            FloatRect secondaryRectInLayerCoordinates(secondaryCoverageRect);
+            secondaryRectInLayerCoordinates.scale(1 / m_scale);
+            ensureTilesForRect(secondaryRectInLayerCoordinates, CoverageType::SecondaryTiles);
+        }
+        m_secondaryTileCoverageRects.clear();
+    }
+
     m_controller.didRevalidateTiles();
 }