Title: [185036] trunk/Source/WebCore
Revision
185036
Author
akl...@apple.com
Date
2015-05-30 19:25:56 -0700 (Sat, 30 May 2015)

Log Message

[iOS] Tiling coverage sometimes inflated by outdated scale factor.
<https://webkit.org/b/145494>
<rdar://problem/20989389>

Reviewed by Benjamin Poulain.

Have GraphicsLayerCA plumb the current contents scale through to TileController::adjustCoverageRect()
instead of TileController getting it from TileGrid.

This avoids a situation where adjustCoverageRect() could cause temporarily oversized tiling coverage
if called while TileGrid's content scale is outdated, and we're neither zooming or pinching, following
a pinch zoom that increased the scale factor.

Specifically, if all the velocity data is zero, we pad the coverage rect by a horizontal and vertical
margin computed like so:

    margin = defaultTileSize / tileGrid.scale

If the actual scale is 5, but the TileGrid's outdated scale is e.g 0.8, you'll get a much larger
margin than you really wanted. Then the whole thing gets scaled up by 5x later on, and we explode
in a fiery feast of IOSurface allocations.

* platform/graphics/TiledBacking.h:
* platform/graphics/ca/GraphicsLayerCA.cpp:
(WebCore::GraphicsLayerCA::adjustCoverageRect):
* platform/graphics/ca/TileController.cpp:
(WebCore::TileController::computeTileCoverageRect):
* platform/graphics/ca/TileController.h:

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (185035 => 185036)


--- trunk/Source/WebCore/ChangeLog	2015-05-31 01:08:42 UTC (rev 185035)
+++ trunk/Source/WebCore/ChangeLog	2015-05-31 02:25:56 UTC (rev 185036)
@@ -1,3 +1,34 @@
+2015-05-30  Andreas Kling  <akl...@apple.com>
+
+        [iOS] Tiling coverage sometimes inflated by outdated scale factor.
+        <https://webkit.org/b/145494>
+        <rdar://problem/20989389>
+
+        Reviewed by Benjamin Poulain.
+
+        Have GraphicsLayerCA plumb the current contents scale through to TileController::adjustCoverageRect()
+        instead of TileController getting it from TileGrid.
+
+        This avoids a situation where adjustCoverageRect() could cause temporarily oversized tiling coverage
+        if called while TileGrid's content scale is outdated, and we're neither zooming or pinching, following
+        a pinch zoom that increased the scale factor.
+
+        Specifically, if all the velocity data is zero, we pad the coverage rect by a horizontal and vertical
+        margin computed like so:
+
+            margin = defaultTileSize / tileGrid.scale
+
+        If the actual scale is 5, but the TileGrid's outdated scale is e.g 0.8, you'll get a much larger
+        margin than you really wanted. Then the whole thing gets scaled up by 5x later on, and we explode
+        in a fiery feast of IOSurface allocations.
+
+        * platform/graphics/TiledBacking.h:
+        * platform/graphics/ca/GraphicsLayerCA.cpp:
+        (WebCore::GraphicsLayerCA::adjustCoverageRect):
+        * platform/graphics/ca/TileController.cpp:
+        (WebCore::TileController::computeTileCoverageRect):
+        * platform/graphics/ca/TileController.h:
+
 2015-05-30  Brady Eidson  <beid...@apple.com>
 
         Fix Windows tests broken by r185007.

Modified: trunk/Source/WebCore/platform/graphics/TiledBacking.h (185035 => 185036)


--- trunk/Source/WebCore/platform/graphics/TiledBacking.h	2015-05-31 01:08:42 UTC (rev 185035)
+++ trunk/Source/WebCore/platform/graphics/TiledBacking.h	2015-05-31 02:25:56 UTC (rev 185036)
@@ -91,7 +91,7 @@
     virtual void setTileCoverage(TileCoverage) = 0;
     virtual TileCoverage tileCoverage() const = 0;
 
-    virtual FloatRect computeTileCoverageRect(const FloatSize& newSize, const FloatRect& previousVisibleRect, const FloatRect& currentVisibleRect) const = 0;
+    virtual FloatRect computeTileCoverageRect(const FloatSize& newSize, const FloatRect& previousVisibleRect, const FloatRect& currentVisibleRect, float contentsScale) const = 0;
 
     virtual IntSize tileSize() const = 0;
 

Modified: trunk/Source/WebCore/platform/graphics/ca/GraphicsLayerCA.cpp (185035 => 185036)


--- trunk/Source/WebCore/platform/graphics/ca/GraphicsLayerCA.cpp	2015-05-31 01:08:42 UTC (rev 185035)
+++ trunk/Source/WebCore/platform/graphics/ca/GraphicsLayerCA.cpp	2015-05-31 02:25:56 UTC (rev 185036)
@@ -1246,7 +1246,7 @@
     // ways of computing coverage.
     switch (type()) {
     case Type::PageTiledBacking:
-        coverageRect = tiledBacking()->computeTileCoverageRect(size(), oldVisibleRect, rects.visibleRect);
+        coverageRect = tiledBacking()->computeTileCoverageRect(size(), oldVisibleRect, rects.visibleRect, pageScaleFactor() * deviceScaleFactor());
         break;
     case Type::Normal:
         if (m_layer->layerType() == PlatformCALayer::LayerTypeTiledBackingLayer)

Modified: trunk/Source/WebCore/platform/graphics/ca/TileController.cpp (185035 => 185036)


--- trunk/Source/WebCore/platform/graphics/ca/TileController.cpp	2015-05-31 01:08:42 UTC (rev 185035)
+++ trunk/Source/WebCore/platform/graphics/ca/TileController.cpp	2015-05-31 02:25:56 UTC (rev 185036)
@@ -313,7 +313,7 @@
     return boundsWithoutMargin;
 }
 
-FloatRect TileController::computeTileCoverageRect(const FloatSize& newSize, const FloatRect& previousVisibleRect, const FloatRect& visibleRect) const
+FloatRect TileController::computeTileCoverageRect(const FloatSize& newSize, const FloatRect& previousVisibleRect, const FloatRect& visibleRect, float contentsScale) const
 {
     // If the page is not in a window (for example if it's in a background tab), we limit the tile coverage rect to the visible rect.
     if (!m_isInWindow)
@@ -326,12 +326,12 @@
     if (m_tileCoverage == CoverageForVisibleArea || MemoryPressureHandler::singleton().isUnderMemoryPressure())
         return visibleRect;
 
-    double horizontalMargin = defaultTileWidth / tileGrid().scale();
-    double verticalMargin = defaultTileHeight / tileGrid().scale();
+    double horizontalMargin = defaultTileWidth / contentsScale;
+    double verticalMargin = defaultTileHeight / contentsScale;
 
     double currentTime = monotonicallyIncreasingTime();
     double timeDelta = currentTime - m_velocity.lastUpdateTime;
-    
+
     FloatRect futureRect = visibleRect;
     futureRect.setLocation(FloatPoint(
         futureRect.location().x() + timeDelta * m_velocity.horizontalVelocity,
@@ -372,6 +372,8 @@
 
     return futureRect;
 #else
+    UNUSED_PARAM(contentsScale);
+
     // FIXME: look at how far the document can scroll in each dimension.
     float coverageHorizontalSize = visibleRect.width();
     float coverageVerticalSize = visibleRect.height();

Modified: trunk/Source/WebCore/platform/graphics/ca/TileController.h (185035 => 185036)


--- trunk/Source/WebCore/platform/graphics/ca/TileController.h	2015-05-31 01:08:42 UTC (rev 185035)
+++ trunk/Source/WebCore/platform/graphics/ca/TileController.h	2015-05-31 02:25:56 UTC (rev 185036)
@@ -106,7 +106,7 @@
     virtual int leftMarginWidth() const override;
     virtual int rightMarginWidth() const override;
     virtual TileCoverage tileCoverage() const override { return m_tileCoverage; }
-    virtual FloatRect computeTileCoverageRect(const FloatSize& newSize, const FloatRect& previousVisibleRect, const FloatRect& currentVisibleRect) const override;
+    virtual FloatRect computeTileCoverageRect(const FloatSize& newSize, const FloatRect& previousVisibleRect, const FloatRect& currentVisibleRect, float contentsScale) const override;
     virtual bool unparentsOffscreenTiles() const override { return m_unparentsOffscreenTiles; }
     virtual bool scrollingPerformanceLoggingEnabled() const override { return m_scrollingPerformanceLoggingEnabled; }
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to