Title: [291080] trunk
Revision
291080
Author
[email protected]
Date
2022-03-09 15:06:19 -0800 (Wed, 09 Mar 2022)

Log Message

Empty float rects should remain empty after integrally enclosing them.
https://bugs.webkit.org/show_bug.cgi?id=237507

Reviewed by Alan Bujtas.

Source/WebCore:

Test: compositing/tile-coverage-subpixel-empty-rect.html

* platform/graphics/FloatRect.cpp:
(WebCore::enclosingIntRectPreservingEmptyRects):
* platform/graphics/FloatRect.h:
* platform/graphics/ca/TileGrid.cpp:
(WebCore::TileGrid::setNeedsDisplayInRect):
(WebCore::TileGrid::dropTilesInRect):
(WebCore::TileGrid::tilesWouldChangeForCoverageRect const):
(WebCore::TileGrid::prepopulateRect):
(WebCore::TileGrid::revalidateTiles):
(WebCore::TileGrid::ensureTilesForRect):

Add a new variant of enclosingIntRect(const Float&) that ensures that empty input rects
always return an empty output rect, even if the x/y position is fractional.
Significant portions of the layout code (including, but not limited to linesBoundingBox()) depend
on the old behavior, so the new behaviour is opt-in and only used by TileGrid.

Fixes the case where TileGrid received an empty coverage rect at a fractional position, and rounded
it out to a 1x1 rect and allocated unnecessary tiles.

LayoutTests:

* compositing/tile-coverage-subpixel-empty-rect-expected.txt: Added.
* compositing/tile-coverage-subpixel-empty-rect.html: Added.
* platform/gtk/compositing/tile-coverage-subpixel-empty-rect-expected.txt: Added.
* platform/ios/compositing/tile-coverage-subpixel-empty-rect-expected.txt: Added.

Adds a new test that uses multiple overflow:hidden clips and absolute positioning to create
an empty coverage rect with a subpixel x/y position that is within the bounds of an offscreen
layer. Confirms that we don't accidentally allocate a tile for this layer.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (291079 => 291080)


--- trunk/LayoutTests/ChangeLog	2022-03-09 22:45:42 UTC (rev 291079)
+++ trunk/LayoutTests/ChangeLog	2022-03-09 23:06:19 UTC (rev 291080)
@@ -1,3 +1,19 @@
+2022-03-09  Matt Woodrow  <[email protected]>
+
+        Empty float rects should remain empty after integrally enclosing them.
+        https://bugs.webkit.org/show_bug.cgi?id=237507
+
+        Reviewed by Alan Bujtas.
+
+        * compositing/tile-coverage-subpixel-empty-rect-expected.txt: Added.
+        * compositing/tile-coverage-subpixel-empty-rect.html: Added.
+        * platform/gtk/compositing/tile-coverage-subpixel-empty-rect-expected.txt: Added.
+        * platform/ios/compositing/tile-coverage-subpixel-empty-rect-expected.txt: Added.
+
+        Adds a new test that uses multiple overflow:hidden clips and absolute positioning to create
+        an empty coverage rect with a subpixel x/y position that is within the bounds of an offscreen
+        layer. Confirms that we don't accidentally allocate a tile for this layer.
+
 2022-03-09  Matteo Flores  <[email protected]>
 
         Unreviewed, reverting r290750.

Added: trunk/LayoutTests/compositing/tile-coverage-subpixel-empty-rect-expected.txt (0 => 291080)


--- trunk/LayoutTests/compositing/tile-coverage-subpixel-empty-rect-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/compositing/tile-coverage-subpixel-empty-rect-expected.txt	2022-03-09 23:06:19 UTC (rev 291080)
@@ -0,0 +1,44 @@
+(GraphicsLayer
+  (anchor 0.00 0.00)
+  (bounds 3001.00 5100.00)
+  (children 1
+    (GraphicsLayer
+      (bounds 3001.00 5100.00)
+      (contentsOpaque 1)
+      (tile cache coverage 0, 0 1024 x 1024)
+      (tile size 512 x 512)
+      (top left tile 0, 0 tiles grid 2 x 2)
+      (in window 1)
+      (children 1
+        (GraphicsLayer
+          (position 1.00 2000.00)
+          (bounds 3000.00 3100.00)
+          (children 1
+            (GraphicsLayer
+              (position -1.00 0.00)
+              (anchor 0.50 0.50)
+              (bounds 3001.00 3101.00)
+              (usingTiledLayer 1)
+              (drawsContent 1)
+              (transform [1.00 0.00 0.00 0.00] [0.00 1.00 0.00 0.00] [0.00 0.00 1.00 0.00] [-1.00 0.00 0.00 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)
+              (in window 1)
+              (children 1
+                (GraphicsLayer
+                  (position 0.00 3000.00)
+                  (anchor 0.50 0.50)
+                  (bounds 101.00 101.00)
+                  (transform [1.00 0.00 0.00 0.00] [0.00 1.00 0.00 0.00] [0.00 0.00 1.00 0.00] [0.00 0.00 1.00 1.00])
+                )
+              )
+            )
+          )
+        )
+      )
+    )
+  )
+)
+Offscreen, but large, content
+

Added: trunk/LayoutTests/compositing/tile-coverage-subpixel-empty-rect.html (0 => 291080)


--- trunk/LayoutTests/compositing/tile-coverage-subpixel-empty-rect.html	                        (rev 0)
+++ trunk/LayoutTests/compositing/tile-coverage-subpixel-empty-rect.html	2022-03-09 23:06:19 UTC (rev 291080)
@@ -0,0 +1,28 @@
+<!DOCTYPE html>
+<html>
+<head>
+    <script>
+        if (window.testRunner)
+            testRunner.dumpAsText();
+
+        function dumpLayers()
+        {
+            var layersResult = document.getElementById('layers');
+            if (window.testRunner)
+                layersResult.innerText = window.internals.layerTreeAsText(document, internals.LAYER_TREE_INCLUDES_TILE_CACHES);
+        }
+
+        window.addEventListener('load', dumpLayers, false)
+    </script>
+</head>
+<body style="overflow:hidden">
+<pre id="layers">Layer tree goes here in DRT</pre>
+<div style="position:absolute; left:0.75px; top: 2000.25px; overflow:hidden">
+  <div style="transform: translate(-1px);">
+    <div style="width:3000px; height: 3000px; background-color:blue">Offscreen, but large, content</div>
+    <div style="transform: translateZ(1px); width: 100px; height: 100px"></div>
+  </div>
+</div>
+
+</body>
+</html>

Added: trunk/LayoutTests/platform/gtk/compositing/tile-coverage-subpixel-empty-rect-expected.txt (0 => 291080)


--- trunk/LayoutTests/platform/gtk/compositing/tile-coverage-subpixel-empty-rect-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/platform/gtk/compositing/tile-coverage-subpixel-empty-rect-expected.txt	2022-03-09 23:06:19 UTC (rev 291080)
@@ -0,0 +1,35 @@
+(GraphicsLayer
+  (anchor 0.00 0.00)
+  (bounds 3001.00 5100.00)
+  (children 1
+    (GraphicsLayer
+      (bounds 3001.00 5100.00)
+      (contentsOpaque 1)
+      (children 1
+        (GraphicsLayer
+          (position 1.00 2000.00)
+          (bounds 3000.00 3100.00)
+          (children 1
+            (GraphicsLayer
+              (position -1.00 0.00)
+              (anchor 0.50 0.50)
+              (bounds 3001.00 3101.00)
+              (drawsContent 1)
+              (transform [1.00 0.00 0.00 0.00] [0.00 1.00 0.00 0.00] [0.00 0.00 1.00 0.00] [-1.00 0.00 0.00 1.00])
+              (children 1
+                (GraphicsLayer
+                  (position 0.00 3000.00)
+                  (anchor 0.50 0.50)
+                  (bounds 101.00 101.00)
+                  (transform [1.00 0.00 0.00 0.00] [0.00 1.00 0.00 0.00] [0.00 0.00 1.00 0.00] [0.00 0.00 1.00 1.00])
+                )
+              )
+            )
+          )
+        )
+      )
+    )
+  )
+)
+Offscreen, but large, content
+

Added: trunk/LayoutTests/platform/ios/compositing/tile-coverage-subpixel-empty-rect-expected.txt (0 => 291080)


--- trunk/LayoutTests/platform/ios/compositing/tile-coverage-subpixel-empty-rect-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/platform/ios/compositing/tile-coverage-subpixel-empty-rect-expected.txt	2022-03-09 23:06:19 UTC (rev 291080)
@@ -0,0 +1,44 @@
+(GraphicsLayer
+  (anchor 0.00 0.00)
+  (bounds 3001.00 5100.00)
+  (children 1
+    (GraphicsLayer
+      (bounds 3001.00 5100.00)
+      (contentsOpaque 1)
+      (tile cache coverage 0, 0 1024 x 1024)
+      (tile size 512 x 512)
+      (top left tile 0, 0 tiles grid 2 x 2)
+      (in window 1)
+      (children 1
+        (GraphicsLayer
+          (position 1.00 2000.50)
+          (bounds 3000.00 3100.00)
+          (children 1
+            (GraphicsLayer
+              (position -0.50 -0.50)
+              (anchor 0.50 0.50)
+              (bounds 3000.50 3100.50)
+              (usingTiledLayer 1)
+              (drawsContent 1)
+              (transform [1.00 0.00 0.00 0.00] [0.00 1.00 0.00 0.00] [0.00 0.00 1.00 0.00] [-1.00 0.00 0.00 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)
+              (in window 1)
+              (children 1
+                (GraphicsLayer
+                  (position 0.00 3000.00)
+                  (anchor 0.50 0.50)
+                  (bounds 100.50 100.50)
+                  (transform [1.00 0.00 0.00 0.00] [0.00 1.00 0.00 0.00] [0.00 0.00 1.00 0.00] [0.00 0.00 1.00 1.00])
+                )
+              )
+            )
+          )
+        )
+      )
+    )
+  )
+)
+Offscreen, but large, content
+

Added: trunk/LayoutTests/platform/mac-wk1/compositing/tile-coverage-subpixel-empty-rect-expected.txt (0 => 291080)


--- trunk/LayoutTests/platform/mac-wk1/compositing/tile-coverage-subpixel-empty-rect-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/platform/mac-wk1/compositing/tile-coverage-subpixel-empty-rect-expected.txt	2022-03-09 23:06:19 UTC (rev 291080)
@@ -0,0 +1,40 @@
+(GraphicsLayer
+  (anchor 0.00 0.00)
+  (bounds 3001.00 5100.00)
+  (children 1
+    (GraphicsLayer
+      (bounds 3001.00 5100.00)
+      (contentsOpaque 1)
+      (children 1
+        (GraphicsLayer
+          (position 1.00 2000.00)
+          (bounds 3000.00 3100.00)
+          (children 1
+            (GraphicsLayer
+              (position -1.00 0.00)
+              (anchor 0.50 0.50)
+              (bounds 3001.00 3101.00)
+              (usingTiledLayer 1)
+              (drawsContent 1)
+              (transform [1.00 0.00 0.00 0.00] [0.00 1.00 0.00 0.00] [0.00 0.00 1.00 0.00] [-1.00 0.00 0.00 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)
+              (in window 1)
+              (children 1
+                (GraphicsLayer
+                  (position 0.00 3000.00)
+                  (anchor 0.50 0.50)
+                  (bounds 101.00 101.00)
+                  (transform [1.00 0.00 0.00 0.00] [0.00 1.00 0.00 0.00] [0.00 0.00 1.00 0.00] [0.00 0.00 1.00 1.00])
+                )
+              )
+            )
+          )
+        )
+      )
+    )
+  )
+)
+Offscreen, but large, content
+

Modified: trunk/Source/WebCore/ChangeLog (291079 => 291080)


--- trunk/Source/WebCore/ChangeLog	2022-03-09 22:45:42 UTC (rev 291079)
+++ trunk/Source/WebCore/ChangeLog	2022-03-09 23:06:19 UTC (rev 291080)
@@ -1,3 +1,31 @@
+2022-03-09  Matt Woodrow  <[email protected]>
+
+        Empty float rects should remain empty after integrally enclosing them.
+        https://bugs.webkit.org/show_bug.cgi?id=237507
+
+        Reviewed by Alan Bujtas.
+
+        Test: compositing/tile-coverage-subpixel-empty-rect.html
+
+        * platform/graphics/FloatRect.cpp:
+        (WebCore::enclosingIntRectPreservingEmptyRects):
+        * platform/graphics/FloatRect.h:
+        * platform/graphics/ca/TileGrid.cpp:
+        (WebCore::TileGrid::setNeedsDisplayInRect):
+        (WebCore::TileGrid::dropTilesInRect):
+        (WebCore::TileGrid::tilesWouldChangeForCoverageRect const):
+        (WebCore::TileGrid::prepopulateRect):
+        (WebCore::TileGrid::revalidateTiles):
+        (WebCore::TileGrid::ensureTilesForRect):
+
+        Add a new variant of enclosingIntRect(const Float&) that ensures that empty input rects
+        always return an empty output rect, even if the x/y position is fractional.
+        Significant portions of the layout code (including, but not limited to linesBoundingBox()) depend
+        on the old behavior, so the new behaviour is opt-in and only used by TileGrid.
+
+        Fixes the case where TileGrid received an empty coverage rect at a fractional position, and rounded
+        it out to a 1x1 rect and allocated unnecessary tiles.
+
 2022-03-09  Alex Christensen  <[email protected]>
 
         Fix AppleWin build

Modified: trunk/Source/WebCore/platform/graphics/FloatRect.cpp (291079 => 291080)


--- trunk/Source/WebCore/platform/graphics/FloatRect.cpp	2022-03-09 22:45:42 UTC (rev 291079)
+++ trunk/Source/WebCore/platform/graphics/FloatRect.cpp	2022-03-09 23:06:19 UTC (rev 291080)
@@ -253,6 +253,18 @@
     return IntRect(IntPoint(location), IntSize(maxPoint - location));
 }
 
+IntRect enclosingIntRectPreservingEmptyRects(const FloatRect& rect)
+{
+    // Empty rects with fractional x, y values turn into non-empty rects when converting to enclosing.
+    // We want to ensure that empty rects stay empty after the conversion, since some callers
+    // prefer this behavior.
+    FloatPoint location = flooredIntPoint(rect.minXMinYCorner());
+    if (rect.isEmpty())
+        return IntRect(IntPoint(location), { });
+    FloatPoint maxPoint = ceiledIntPoint(rect.maxXMaxYCorner());
+    return IntRect(IntPoint(location), IntSize(maxPoint - location));
+}
+
 IntRect roundedIntRect(const FloatRect& rect)
 {
     return IntRect(roundedIntPoint(rect.location()), roundedIntSize(rect.size()));

Modified: trunk/Source/WebCore/platform/graphics/FloatRect.h (291079 => 291080)


--- trunk/Source/WebCore/platform/graphics/FloatRect.h	2022-03-09 22:45:42 UTC (rev 291079)
+++ trunk/Source/WebCore/platform/graphics/FloatRect.h	2022-03-09 23:06:19 UTC (rev 291080)
@@ -307,6 +307,7 @@
 FloatRect normalizeRect(const FloatRect&);
 WEBCORE_EXPORT FloatRect encloseRectToDevicePixels(const FloatRect&, float deviceScaleFactor);
 WEBCORE_EXPORT IntRect enclosingIntRect(const FloatRect&);
+WEBCORE_EXPORT IntRect enclosingIntRectPreservingEmptyRects(const FloatRect&);
 WEBCORE_EXPORT IntRect roundedIntRect(const FloatRect&);
 
 WEBCORE_EXPORT WTF::TextStream& operator<<(WTF::TextStream&, const FloatRect&);

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


--- trunk/Source/WebCore/platform/graphics/ca/TileGrid.cpp	2022-03-09 22:45:42 UTC (rev 291079)
+++ trunk/Source/WebCore/platform/graphics/ca/TileGrid.cpp	2022-03-09 23:06:19 UTC (rev 291080)
@@ -119,7 +119,7 @@
 
     FloatRect scaledRect(rect);
     scaledRect.scale(m_scale);
-    IntRect repaintRectInTileCoords(enclosingIntRect(scaledRect));
+    IntRect repaintRectInTileCoords(enclosingIntRectPreservingEmptyRects(scaledRect));
 
     IntSize tileSize = m_tileSize;
 
@@ -151,7 +151,7 @@
 
     FloatRect scaledRect(rect);
     scaledRect.scale(m_scale);
-    IntRect dropRectInTileCoords(enclosingIntRect(scaledRect));
+    IntRect dropRectInTileCoords(enclosingIntRectPreservingEmptyRects(scaledRect));
 
     Vector<TileIndex> tilesToRemove;
 
@@ -213,7 +213,7 @@
 
     FloatRect scaledRect(coverageRect);
     scaledRect.scale(m_scale);
-    IntRect currentCoverageRectInTileCoords(enclosingIntRect(scaledRect));
+    IntRect currentCoverageRectInTileCoords(enclosingIntRectPreservingEmptyRects(scaledRect));
 
     IntRect tileCoverageRect;
     TileIndex topLeft;
@@ -230,7 +230,7 @@
 {
     LOG_WITH_STREAM(Tiling, stream << "TileGrid " << this << " prepopulateRect: " << rect);
 
-    IntRect enclosingCoverageRect = enclosingIntRect(rect);
+    IntRect enclosingCoverageRect = enclosingIntRectPreservingEmptyRects(rect);
     if (m_primaryTileCoverageRect.contains(enclosingCoverageRect))
         return false;
 
@@ -343,7 +343,7 @@
 
     FloatRect scaledRect(coverageRect);
     scaledRect.scale(m_scale);
-    IntRect coverageRectInTileCoords(enclosingIntRect(scaledRect));
+    IntRect coverageRectInTileCoords(enclosingIntRectPreservingEmptyRects(scaledRect));
 
     TileCohort currCohort = nextTileCohort();
     unsigned tilesInCohort = 0;
@@ -447,7 +447,7 @@
 
         FloatRect scaledBounds(bounds);
         scaledBounds.scale(m_scale);
-        IntRect boundsInTileCoords(enclosingIntRect(scaledBounds));
+        IntRect boundsInTileCoords(enclosingIntRectPreservingEmptyRects(scaledBounds));
 
         TileIndex topLeftForBounds;
         TileIndex bottomRightForBounds;
@@ -542,7 +542,7 @@
 
     FloatRect scaledRect(rect);
     scaledRect.scale(m_scale);
-    IntRect rectInTileCoords(enclosingIntRect(scaledRect));
+    IntRect rectInTileCoords(enclosingIntRectPreservingEmptyRects(scaledRect));
 
     TileIndex topLeft;
     TileIndex bottomRight;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to