Title: [203261] trunk
Revision
203261
Author
[email protected]
Date
2016-07-14 18:46:25 -0700 (Thu, 14 Jul 2016)

Log Message

[iOS WK2] When scrolling apple.com/music on iPad Pro in landscape, left-hand tiles appear first
https://bugs.webkit.org/show_bug.cgi?id=159798
rdar://problem/27362717

Reviewed by Tim Horton.
Source/WebCore:

In out-of-visible tiled layers, we always allocated the top-left tile, wasting
memory and causing ugliness when scrolling that layer into view. This happened
because getTileIndexRangeForRect() had no way to express the fact that no tiles
should be created.

Fix getTileIndexRangeForRect() to return a bool, and fix callers to respect the
return value.

Test: compositing/tiling/offscreen-tiled-layer.html

* platform/graphics/ca/GraphicsLayerCA.cpp:
(WebCore::GraphicsLayerCA::dumpAdditionalProperties):
* platform/graphics/ca/TileGrid.cpp:
(WebCore::TileGrid::setNeedsDisplayInRect):
(WebCore::TileGrid::tilesWouldChangeForCoverageRect):
(WebCore::TileGrid::getTileIndexRangeForRect):
(WebCore::TileGrid::revalidateTiles):
(WebCore::TileGrid::ensureTilesForRect):
(WebCore::TileGrid::extent):
* platform/graphics/ca/TileGrid.h:

LayoutTests:

Test with an offscreen tiled layer.

* compositing/tiling/offscreen-tiled-layer-expected.txt: Added.
* compositing/tiling/offscreen-tiled-layer.html: Added.
* platform/ios-simulator-wk1/compositing/tiling/offscreen-tiled-layer-expected.txt: Added.
* platform/ios-simulator-wk2/compositing/tiling/offscreen-tiled-layer-expected.txt: Added.
* platform/mac-wk1/compositing/tiling/offscreen-tiled-layer-expected.txt: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (203260 => 203261)


--- trunk/LayoutTests/ChangeLog	2016-07-15 00:52:15 UTC (rev 203260)
+++ trunk/LayoutTests/ChangeLog	2016-07-15 01:46:25 UTC (rev 203261)
@@ -1,3 +1,19 @@
+2016-07-14  Simon Fraser  <[email protected]>
+
+        [iOS WK2] When scrolling apple.com/music on iPad Pro in landscape, left-hand tiles appear first
+        https://bugs.webkit.org/show_bug.cgi?id=159798
+        rdar://problem/27362717
+
+        Reviewed by Tim Horton.
+        
+        Test with an offscreen tiled layer.
+
+        * compositing/tiling/offscreen-tiled-layer-expected.txt: Added.
+        * compositing/tiling/offscreen-tiled-layer.html: Added.
+        * platform/ios-simulator-wk1/compositing/tiling/offscreen-tiled-layer-expected.txt: Added.
+        * platform/ios-simulator-wk2/compositing/tiling/offscreen-tiled-layer-expected.txt: Added.
+        * platform/mac-wk1/compositing/tiling/offscreen-tiled-layer-expected.txt: Added.
+
 2016-07-14  Ryan Haddad  <[email protected]>
 
         Skipping editing/spelling/copy-paste-crash.html on ios-simulator.

Added: trunk/LayoutTests/compositing/tiling/offscreen-tiled-layer-expected.txt (0 => 203261)


--- trunk/LayoutTests/compositing/tiling/offscreen-tiled-layer-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/compositing/tiling/offscreen-tiled-layer-expected.txt	2016-07-15 01:46:25 UTC (rev 203261)
@@ -0,0 +1,38 @@
+(GraphicsLayer
+  (anchor 0.00 0.00)
+  (bounds 2208.00 2808.00)
+  (visible rect 0.00, 0.00 785.00 x 585.00)
+  (coverage rect 0.00, 0.00 785.00 x 585.00)
+  (intersects coverage rect 1)
+  (contentsScale 1.00)
+  (children 1
+    (GraphicsLayer
+      (bounds 2208.00 2808.00)
+      (contentsOpaque 1)
+      (visible rect 0.00, 0.00 785.00 x 585.00)
+      (coverage rect 0.00, 0.00 785.00 x 585.00)
+      (intersects coverage rect 1)
+      (contentsScale 1.00)
+      (tile cache coverage 0, 0 1024 x 1024)
+      (tile size 512 x 512)
+      (top left tile 0, 0 tiles grid 2 x 2)
+      (children 1
+        (GraphicsLayer
+          (position 8.00 1800.00)
+          (bounds 2200.00 1000.00)
+          (usingTiledLayer 1)
+          (contentsOpaque 1)
+          (drawsContent 1)
+          (visible rect 0.00, 0.00 0.00 x 0.00)
+          (coverage rect -8.00, -1800.00 785.00 x 585.00)
+          (intersects coverage rect 0)
+          (contentsScale 1.00)
+          (tile cache coverage 0, 0 0 x 0)
+          (tile size 512 x 512)
+          (top left tile 0, 0 tiles grid 0 x 0)
+        )
+      )
+    )
+  )
+)
+Some text here.

Added: trunk/LayoutTests/compositing/tiling/offscreen-tiled-layer.html (0 => 203261)


--- trunk/LayoutTests/compositing/tiling/offscreen-tiled-layer.html	                        (rev 0)
+++ trunk/LayoutTests/compositing/tiling/offscreen-tiled-layer.html	2016-07-15 01:46:25 UTC (rev 203261)
@@ -0,0 +1,38 @@
+<!DOCTYPE html>
+
+<html>
+<head>
+    <style>
+        .box {
+            margin-top: 1800px;
+            height: 1000px;
+            width: 2200px;
+            background-color: blue;
+        }
+        
+        .composited {
+            -webkit-transform: translateZ(0);
+        }
+    </style>
+    <script>
+        if (window.testRunner)
+            testRunner.dumpAsText();
+
+        function doTest()
+        {
+            if (window.internals) {
+                document.getElementById('layers').innerText = internals.layerTreeAsText(document,
+                    internals.LAYER_TREE_INCLUDES_VISIBLE_RECTS | internals.LAYER_TREE_INCLUDES_TILE_CACHES);
+            }
+        }
+        
+        window.addEventListener('load', doTest, false);
+    </script>
+</head>
+<body>
+<pre id="layers"></pre>
+    <div class="composited box">
+        Some text here.
+    </div>
+</body>
+</html>

Added: trunk/LayoutTests/platform/ios-simulator-wk1/compositing/tiling/offscreen-tiled-layer-expected.txt (0 => 203261)


--- trunk/LayoutTests/platform/ios-simulator-wk1/compositing/tiling/offscreen-tiled-layer-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/platform/ios-simulator-wk1/compositing/tiling/offscreen-tiled-layer-expected.txt	2016-07-15 01:46:25 UTC (rev 203261)
@@ -0,0 +1,35 @@
+(GraphicsLayer
+  (anchor 0.00 0.00)
+  (bounds 2208.00 2808.00)
+  (visible rect 0.00, 0.00 800.00 x 600.00)
+  (coverage rect 0.00, 0.00 800.00 x 600.00)
+  (intersects coverage rect 1)
+  (contentsScale 2.00)
+  (children 1
+    (GraphicsLayer
+      (bounds 2208.00 2808.00)
+      (contentsOpaque 1)
+      (visible rect 0.00, 0.00 800.00 x 600.00)
+      (coverage rect 0.00, 0.00 800.00 x 600.00)
+      (intersects coverage rect 1)
+      (contentsScale 2.00)
+      (children 1
+        (GraphicsLayer
+          (position 8.00 1800.00)
+          (bounds 2200.00 1000.00)
+          (usingTiledLayer 1)
+          (contentsOpaque 1)
+          (drawsContent 1)
+          (visible rect 0.00, 0.00 0.00 x 0.00)
+          (coverage rect -8.00, -1800.00 800.00 x 600.00)
+          (intersects coverage rect 0)
+          (contentsScale 2.00)
+          (tile cache coverage 0, 0 0 x 0)
+          (tile size 512 x 512)
+          (top left tile 0, 0 tiles grid 0 x 0)
+        )
+      )
+    )
+  )
+)
+Some text here.

Added: trunk/LayoutTests/platform/ios-simulator-wk2/compositing/tiling/offscreen-tiled-layer-expected.txt (0 => 203261)


--- trunk/LayoutTests/platform/ios-simulator-wk2/compositing/tiling/offscreen-tiled-layer-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/platform/ios-simulator-wk2/compositing/tiling/offscreen-tiled-layer-expected.txt	2016-07-15 01:46:25 UTC (rev 203261)
@@ -0,0 +1,38 @@
+(GraphicsLayer
+  (anchor 0.00 0.00)
+  (bounds 2208.00 2808.00)
+  (visible rect 0.00, 0.00 800.00 x 600.00)
+  (coverage rect 0.00, 0.00 800.00 x 600.00)
+  (intersects coverage rect 1)
+  (contentsScale 2.00)
+  (children 1
+    (GraphicsLayer
+      (bounds 2208.00 2808.00)
+      (contentsOpaque 1)
+      (visible rect 0.00, 0.00 800.00 x 600.00)
+      (coverage rect 0.00, 0.00 800.00 x 600.00)
+      (intersects coverage rect 1)
+      (contentsScale 2.00)
+      (tile cache coverage 0, 0 1024 x 1024)
+      (tile size 512 x 512)
+      (top left tile 0, 0 tiles grid 2 x 2)
+      (children 1
+        (GraphicsLayer
+          (position 8.00 1800.00)
+          (bounds 2200.00 1000.00)
+          (usingTiledLayer 1)
+          (contentsOpaque 1)
+          (drawsContent 1)
+          (visible rect 0.00, 0.00 0.00 x 0.00)
+          (coverage rect -8.00, -1800.00 800.00 x 600.00)
+          (intersects coverage rect 0)
+          (contentsScale 2.00)
+          (tile cache coverage 0, 0 0 x 0)
+          (tile size 512 x 512)
+          (top left tile 0, 0 tiles grid 0 x 0)
+        )
+      )
+    )
+  )
+)
+Some text here.

Added: trunk/LayoutTests/platform/mac-wk1/compositing/tiling/offscreen-tiled-layer-expected.txt (0 => 203261)


--- trunk/LayoutTests/platform/mac-wk1/compositing/tiling/offscreen-tiled-layer-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/platform/mac-wk1/compositing/tiling/offscreen-tiled-layer-expected.txt	2016-07-15 01:46:25 UTC (rev 203261)
@@ -0,0 +1,35 @@
+(GraphicsLayer
+  (anchor 0.00 0.00)
+  (bounds 2208.00 2808.00)
+  (visible rect 0.00, 0.00 785.00 x 585.00)
+  (coverage rect 0.00, 0.00 785.00 x 585.00)
+  (intersects coverage rect 1)
+  (contentsScale 1.00)
+  (children 1
+    (GraphicsLayer
+      (bounds 2208.00 2808.00)
+      (contentsOpaque 1)
+      (visible rect 0.00, 0.00 785.00 x 585.00)
+      (coverage rect 0.00, 0.00 785.00 x 585.00)
+      (intersects coverage rect 1)
+      (contentsScale 1.00)
+      (children 1
+        (GraphicsLayer
+          (position 8.00 1800.00)
+          (bounds 2200.00 1000.00)
+          (usingTiledLayer 1)
+          (contentsOpaque 1)
+          (drawsContent 1)
+          (visible rect 0.00, 0.00 0.00 x 0.00)
+          (coverage rect -8.00, -1800.00 785.00 x 585.00)
+          (intersects coverage rect 0)
+          (contentsScale 1.00)
+          (tile cache coverage 0, 0 0 x 0)
+          (tile size 512 x 512)
+          (top left tile 0, 0 tiles grid 0 x 0)
+        )
+      )
+    )
+  )
+)
+Some text here.

Modified: trunk/Source/WebCore/ChangeLog (203260 => 203261)


--- trunk/Source/WebCore/ChangeLog	2016-07-15 00:52:15 UTC (rev 203260)
+++ trunk/Source/WebCore/ChangeLog	2016-07-15 01:46:25 UTC (rev 203261)
@@ -1,3 +1,32 @@
+2016-07-14  Simon Fraser  <[email protected]>
+
+        [iOS WK2] When scrolling apple.com/music on iPad Pro in landscape, left-hand tiles appear first
+        https://bugs.webkit.org/show_bug.cgi?id=159798
+        rdar://problem/27362717
+
+        Reviewed by Tim Horton.
+
+        In out-of-visible tiled layers, we always allocated the top-left tile, wasting
+        memory and causing ugliness when scrolling that layer into view. This happened
+        because getTileIndexRangeForRect() had no way to express the fact that no tiles
+        should be created.
+
+        Fix getTileIndexRangeForRect() to return a bool, and fix callers to respect the
+        return value.
+
+        Test: compositing/tiling/offscreen-tiled-layer.html
+
+        * platform/graphics/ca/GraphicsLayerCA.cpp:
+        (WebCore::GraphicsLayerCA::dumpAdditionalProperties):
+        * platform/graphics/ca/TileGrid.cpp:
+        (WebCore::TileGrid::setNeedsDisplayInRect):
+        (WebCore::TileGrid::tilesWouldChangeForCoverageRect):
+        (WebCore::TileGrid::getTileIndexRangeForRect):
+        (WebCore::TileGrid::revalidateTiles):
+        (WebCore::TileGrid::ensureTilesForRect):
+        (WebCore::TileGrid::extent):
+        * platform/graphics/ca/TileGrid.h:
+
 2016-07-14  John Wilander  <[email protected]>
 
         Remove credentials in URL when accessed through location.href

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


--- trunk/Source/WebCore/platform/graphics/ca/GraphicsLayerCA.cpp	2016-07-15 00:52:15 UTC (rev 203260)
+++ trunk/Source/WebCore/platform/graphics/ca/GraphicsLayerCA.cpp	2016-07-15 01:46:25 UTC (rev 203261)
@@ -3496,7 +3496,7 @@
 
     if (behavior & LayerTreeAsTextDebug) {
         writeIndent(textStream, indent + 1);
-        textStream << "(acceleratetes drawing " << m_acceleratesDrawing << ")\n";
+        textStream << "(accelerates drawing " << m_acceleratesDrawing << ")\n";
         writeIndent(textStream, indent + 1);
         textStream << "(uses display-list drawing " << m_usesDisplayListDrawing << ")\n";
     }

Modified: trunk/Source/WebCore/platform/graphics/ca/TileGrid.cpp (203260 => 203261)


--- trunk/Source/WebCore/platform/graphics/ca/TileGrid.cpp	2016-07-15 00:52:15 UTC (rev 203260)
+++ trunk/Source/WebCore/platform/graphics/ca/TileGrid.cpp	2016-07-15 01:46:25 UTC (rev 203261)
@@ -112,15 +112,15 @@
     if (repaintRectInTileCoords.height() < 2 * tileSize.height() && repaintRectInTileCoords.width() < 2 * tileSize.width()) {
         TileIndex topLeft;
         TileIndex bottomRight;
-        getTileIndexRangeForRect(repaintRectInTileCoords, topLeft, bottomRight);
-
-        for (int y = topLeft.y(); y <= bottomRight.y(); ++y) {
-            for (int x = topLeft.x(); x <= bottomRight.x(); ++x) {
-                TileIndex tileIndex(x, y);
-                
-                TileMap::iterator it = m_tiles.find(tileIndex);
-                if (it != m_tiles.end())
-                    setTileNeedsDisplayInRect(tileIndex, it->value, repaintRectInTileCoords, m_primaryTileCoverageRect);
+        if (getTileIndexRangeForRect(repaintRectInTileCoords, topLeft, bottomRight)) {
+            for (int y = topLeft.y(); y <= bottomRight.y(); ++y) {
+                for (int x = topLeft.x(); x <= bottomRight.x(); ++x) {
+                    TileIndex tileIndex(x, y);
+                    
+                    TileMap::iterator it = m_tiles.find(tileIndex);
+                    if (it != m_tiles.end())
+                        setTileNeedsDisplayInRect(tileIndex, it->value, repaintRectInTileCoords, m_primaryTileCoverageRect);
+                }
             }
         }
         return;
@@ -199,12 +199,14 @@
     scaledRect.scale(m_scale);
     IntRect currentCoverageRectInTileCoords(enclosingIntRect(scaledRect));
 
+    IntRect tileCoverageRect;
     TileIndex topLeft;
     TileIndex bottomRight;
-    getTileIndexRangeForRect(currentCoverageRectInTileCoords, topLeft, bottomRight);
+    if (getTileIndexRangeForRect(currentCoverageRectInTileCoords, topLeft, bottomRight)) {
+        tileCoverageRect = rectForTileIndex(topLeft);
+        tileCoverageRect.unite(rectForTileIndex(bottomRight));
+    }
 
-    IntRect tileCoverageRect = rectForTileIndex(topLeft);
-    tileCoverageRect.unite(rectForTileIndex(bottomRight));
     return tileCoverageRect != m_primaryTileCoverageRect;
 }
 
@@ -231,11 +233,14 @@
     return rect;
 }
 
-void TileGrid::getTileIndexRangeForRect(const IntRect& rect, TileIndex& topLeft, TileIndex& bottomRight) const
+bool TileGrid::getTileIndexRangeForRect(const IntRect& rect, TileIndex& topLeft, TileIndex& bottomRight) const
 {
     IntRect clampedRect = m_controller.bounds();
     clampedRect.scale(m_scale);
     clampedRect.intersect(rect);
+    
+    if (clampedRect.isEmpty())
+        return false;
 
     auto tileSize = m_tileSize;
     if (clampedRect.x() >= 0)
@@ -253,6 +258,8 @@
 
     int bottomYRatio = ceil((float)clampedRect.maxY() / tileSize.height());
     bottomRight.setY(std::max(bottomYRatio - 1, 0));
+    
+    return true;
 }
 
 unsigned TileGrid::blankPixelCount() const
@@ -348,6 +355,7 @@
 
         PlatformCALayer* tileLayer = tileInfo.layer.get();
         IntRect tileRect = rectForTileIndex(tileIndex);
+
         if (tileRect.intersects(coverageRectInTileCoords)) {
             tileInfo.cohort = VisibleTileCohort;
             if (tileInfo.hasStaleContent) {
@@ -444,14 +452,14 @@
 
         TileIndex topLeftForBounds;
         TileIndex bottomRightForBounds;
-        getTileIndexRangeForRect(boundsInTileCoords, topLeftForBounds, bottomRightForBounds);
-
-        Vector<TileIndex> tilesToRemove;
-        for (auto& index : m_tiles.keys()) {
-            if (index.y() < topLeftForBounds.y() || index.y() > bottomRightForBounds.y() || index.x() < topLeftForBounds.x() || index.x() > bottomRightForBounds.x())
-                tilesToRemove.append(index);
+        if (getTileIndexRangeForRect(boundsInTileCoords, topLeftForBounds, bottomRightForBounds)) {
+            Vector<TileIndex> tilesToRemove;
+            for (auto& index : m_tiles.keys()) {
+                if (index.y() < topLeftForBounds.y() || index.y() > bottomRightForBounds.y() || index.x() < topLeftForBounds.x() || index.x() > bottomRightForBounds.x())
+                    tilesToRemove.append(index);
+            }
+            removeTiles(tilesToRemove);
         }
-        removeTiles(tilesToRemove);
     }
 
     m_controller.didRevalidateTiles();
@@ -526,7 +534,8 @@
 
     TileIndex topLeft;
     TileIndex bottomRight;
-    getTileIndexRangeForRect(rectInTileCoords, topLeft, bottomRight);
+    if (!getTileIndexRangeForRect(rectInTileCoords, topLeft, bottomRight))
+        return IntRect();
 
     TileCohort currCohort = nextTileCohort();
     unsigned tilesInCohort = 0;
@@ -581,10 +590,12 @@
 {
     TileIndex topLeft;
     TileIndex bottomRight;
-    getTileIndexRangeForRect(m_primaryTileCoverageRect, topLeft, bottomRight);
+    if (getTileIndexRangeForRect(m_primaryTileCoverageRect, topLeft, bottomRight)) {
+        // Return index of top, left tile and the number of tiles across and down.
+        return IntRect(topLeft.x(), topLeft.y(), bottomRight.x() - topLeft.x() + 1, bottomRight.y() - topLeft.y() + 1);
+    }
 
-    // Return index of top, left tile and the number of tiles across and down.
-    return IntRect(topLeft.x(), topLeft.y(), bottomRight.x() - topLeft.x() + 1, bottomRight.y() - topLeft.y() + 1);
+    return IntRect();
 }
 
 double TileGrid::retainedTileBackingStoreMemory() const

Modified: trunk/Source/WebCore/platform/graphics/ca/TileGrid.h (203260 => 203261)


--- trunk/Source/WebCore/platform/graphics/ca/TileGrid.h	2016-07-15 00:52:15 UTC (rev 203260)
+++ trunk/Source/WebCore/platform/graphics/ca/TileGrid.h	2016-07-15 01:46:25 UTC (rev 203261)
@@ -110,7 +110,7 @@
     void setTileNeedsDisplayInRect(const TileIndex&, TileInfo&, const IntRect& repaintRectInTileCoords, const IntRect& coverageRectInTileCoords);
 
     IntRect rectForTileIndex(const TileIndex&) const;
-    void getTileIndexRangeForRect(const IntRect&, TileIndex& topLeft, TileIndex& bottomRight) const;
+    bool getTileIndexRangeForRect(const IntRect&, TileIndex& topLeft, TileIndex& bottomRight) const;
 
     enum class CoverageType { PrimaryTiles, SecondaryTiles };
     IntRect ensureTilesForRect(const FloatRect&, CoverageType);
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to