Add a way to update GraphicsLayerCA visibleRects without having to do a flush
[WebKit-https.git] / Source / WebCore / platform / graphics / ca / mac / TileController.mm
index 8643c9e..0ad1239 100644 (file)
@@ -306,6 +306,35 @@ void TileController::setVisibleRect(const FloatRect& visibleRect)
     revalidateTiles();
 }
 
     revalidateTiles();
 }
 
+bool TileController::tilesWouldChangeForVisibleRect(const FloatRect& newVisibleRect) const
+{
+    FloatRect visibleRect = newVisibleRect;
+
+    if (m_clipsToExposedRect)
+        visibleRect.intersect(m_exposedRect);
+
+    if (visibleRect.isEmpty() || bounds().isEmpty())
+        return false;
+        
+    FloatRect currentTileCoverageRect = computeTileCoverageRect(m_visibleRect, newVisibleRect);
+    FloatRect scaledRect(currentTileCoverageRect);
+    scaledRect.scale(m_scale);
+    IntRect currentCoverageRectInTileCoords(enclosingIntRect(scaledRect));
+
+    IntSize newTileSize = tileSizeForCoverageRect(currentTileCoverageRect);
+    bool tileSizeChanged = newTileSize != m_tileSize;
+    if (tileSizeChanged)
+        return true;
+
+    TileIndex topLeft;
+    TileIndex bottomRight;
+    getTileIndexRangeForRect(currentCoverageRectInTileCoords, topLeft, bottomRight);
+
+    IntRect coverageRect = rectForTileIndex(topLeft);
+    coverageRect.unite(rectForTileIndex(bottomRight));
+    return coverageRect != m_primaryTileCoverageRect;
+}
+
 void TileController::setExposedRect(const FloatRect& exposedRect)
 {
     if (m_exposedRect == exposedRect)
 void TileController::setExposedRect(const FloatRect& exposedRect)
 {
     if (m_exposedRect == exposedRect)
@@ -417,9 +446,9 @@ void TileController::getTileIndexRangeForRect(const IntRect& rect, TileIndex& to
     bottomRight.setY(max(bottomYRatio - 1, 0));
 }
 
     bottomRight.setY(max(bottomYRatio - 1, 0));
 }
 
-FloatRect TileController::computeTileCoverageRect(const FloatRect& previousVisibleRect) const
+FloatRect TileController::computeTileCoverageRect(const FloatRect& previousVisibleRect, const FloatRect& currentVisibleRect) const
 {
 {
-    FloatRect visibleRect = m_visibleRect;
+    FloatRect visibleRect = currentVisibleRect;
 
     if (m_clipsToExposedRect)
         visibleRect.intersect(m_exposedRect);
 
     if (m_clipsToExposedRect)
         visibleRect.intersect(m_exposedRect);
@@ -591,7 +620,7 @@ void TileController::revalidateTiles(TileValidationPolicyFlags foregroundValidat
     
     TileValidationPolicyFlags validationPolicy = m_isInWindow ? foregroundValidationPolicy : backgroundValidationPolicy;
     
     
     TileValidationPolicyFlags validationPolicy = m_isInWindow ? foregroundValidationPolicy : backgroundValidationPolicy;
     
-    FloatRect tileCoverageRect = computeTileCoverageRect(m_visibleRectAtLastRevalidate);
+    FloatRect tileCoverageRect = computeTileCoverageRect(m_visibleRectAtLastRevalidate, m_visibleRect);
     FloatRect scaledRect(tileCoverageRect);
     scaledRect.scale(m_scale);
     IntRect coverageRectInTileCoords(enclosingIntRect(scaledRect));
     FloatRect scaledRect(tileCoverageRect);
     scaledRect.scale(m_scale);
     IntRect coverageRectInTileCoords(enclosingIntRect(scaledRect));