Title: [245794] trunk/Source/WebCore
Revision
245794
Author
[email protected]
Date
2019-05-27 09:06:06 -0700 (Mon, 27 May 2019)

Log Message

Move GraphicsLayerCA::adjustTiledLayerVisibleRect() to TileController
https://bugs.webkit.org/show_bug.cgi?id=198266

Reviewed by Zalan Bujtas.

GraphicsLayerCA::adjustTiledLayerVisibleRect() was computing tile coverage for a
TiledBacking, just like TileController::adjustTileCoverageRect(), so move the code
into TileController as a first step to unifying more of this code. It's currently
used for tiled compositing layers, including overflow:scroll, and tiled layers
whose coverage may be affected by animations, so it's general-purpose.

TileController::adjustTileCoverageRect() is used for scrollable things, so rename
it to adjustTileCoverageRectForScrolling().

No behavior change.

* platform/graphics/TiledBacking.h:
* platform/graphics/ca/GraphicsLayerCA.cpp:
(WebCore::GraphicsLayerCA::adjustCoverageRect const):
(WebCore::GraphicsLayerCA::adjustTiledLayerVisibleRect): Deleted.
* platform/graphics/ca/GraphicsLayerCA.h:
* platform/graphics/ca/TileController.cpp:
(WebCore::TileController::adjustTileCoverageRect const):
(WebCore::TileController::adjustTileCoverageRectForScrolling const):
* platform/graphics/ca/TileController.h:

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (245793 => 245794)


--- trunk/Source/WebCore/ChangeLog	2019-05-27 16:00:42 UTC (rev 245793)
+++ trunk/Source/WebCore/ChangeLog	2019-05-27 16:06:06 UTC (rev 245794)
@@ -1,3 +1,31 @@
+2019-05-26  Simon Fraser  <[email protected]>
+
+        Move GraphicsLayerCA::adjustTiledLayerVisibleRect() to TileController
+        https://bugs.webkit.org/show_bug.cgi?id=198266
+
+        Reviewed by Zalan Bujtas.
+
+        GraphicsLayerCA::adjustTiledLayerVisibleRect() was computing tile coverage for a
+        TiledBacking, just like TileController::adjustTileCoverageRect(), so move the code
+        into TileController as a first step to unifying more of this code. It's currently
+        used for tiled compositing layers, including overflow:scroll, and tiled layers
+        whose coverage may be affected by animations, so it's general-purpose.
+
+        TileController::adjustTileCoverageRect() is used for scrollable things, so rename
+        it to adjustTileCoverageRectForScrolling().
+
+        No behavior change.
+
+        * platform/graphics/TiledBacking.h:
+        * platform/graphics/ca/GraphicsLayerCA.cpp:
+        (WebCore::GraphicsLayerCA::adjustCoverageRect const):
+        (WebCore::GraphicsLayerCA::adjustTiledLayerVisibleRect): Deleted.
+        * platform/graphics/ca/GraphicsLayerCA.h:
+        * platform/graphics/ca/TileController.cpp:
+        (WebCore::TileController::adjustTileCoverageRect const):
+        (WebCore::TileController::adjustTileCoverageRectForScrolling const):
+        * platform/graphics/ca/TileController.h:
+
 2019-05-27  Simon Fraser  <[email protected]>
 
         Fix Apple Internal builds after r245788.

Modified: trunk/Source/WebCore/platform/graphics/TiledBacking.h (245793 => 245794)


--- trunk/Source/WebCore/platform/graphics/TiledBacking.h	2019-05-27 16:00:42 UTC (rev 245793)
+++ trunk/Source/WebCore/platform/graphics/TiledBacking.h	2019-05-27 16:06:06 UTC (rev 245794)
@@ -95,7 +95,8 @@
     virtual void setTileCoverage(TileCoverage) = 0;
     virtual TileCoverage tileCoverage() const = 0;
 
-    virtual void adjustTileCoverageRect(FloatRect& coverageRect, const FloatSize& newSize, const FloatRect& previousVisibleRect, const FloatRect& currentVisibleRect, float contentsScale) const = 0;
+    virtual FloatRect adjustTileCoverageRect(const FloatRect& coverageRect, const FloatRect& previousVisibleRect, const FloatRect& currentVisibleRect, bool sizeChanged) const = 0;
+    virtual FloatRect adjustTileCoverageRectForScrolling(const FloatRect& coverageRect, const FloatSize& newSize, const FloatRect& previousVisibleRect, const FloatRect& currentVisibleRect, float contentsScale) const = 0;
 
     virtual void willStartLiveResize() = 0;
     virtual void didEndLiveResize() = 0;

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


--- trunk/Source/WebCore/platform/graphics/ca/GraphicsLayerCA.cpp	2019-05-27 16:00:42 UTC (rev 245793)
+++ trunk/Source/WebCore/platform/graphics/ca/GraphicsLayerCA.cpp	2019-05-27 16:06:06 UTC (rev 245794)
@@ -1443,16 +1443,14 @@
 {
     FloatRect coverageRect = rects.coverageRect;
 
-    // FIXME: TileController's computeTileCoverageRect() code should move here, and we should unify these different
-    // ways of computing coverage.
     switch (type()) {
     case Type::PageTiledBacking:
-        tiledBacking()->adjustTileCoverageRect(coverageRect, size(), oldVisibleRect, rects.visibleRect, pageScaleFactor() * deviceScaleFactor());
+        coverageRect = tiledBacking()->adjustTileCoverageRectForScrolling(coverageRect, size(), oldVisibleRect, rects.visibleRect, pageScaleFactor() * deviceScaleFactor());
         break;
     case Type::Normal:
     case Type::ScrolledContents:
         if (m_layer->layerType() == PlatformCALayer::LayerTypeTiledBackingLayer)
-            coverageRect.unite(adjustTiledLayerVisibleRect(tiledBacking(), oldVisibleRect, rects.visibleRect, m_sizeAtLastCoverageRectUpdate, m_size));
+            coverageRect = tiledBacking()->adjustTileCoverageRect(coverageRect, oldVisibleRect, rects.visibleRect, size() != m_sizeAtLastCoverageRectUpdate);
         break;
     default:
         break;
@@ -2499,70 +2497,6 @@
     }
 }
 
-FloatRect GraphicsLayerCA::adjustTiledLayerVisibleRect(TiledBacking* tiledBacking, const FloatRect& oldVisibleRect, const FloatRect& newVisibleRect, const FloatSize& oldSize, const FloatSize& newSize)
-{
-    // If the old visible rect is empty, we have no information about how the visible area is changing
-    // (maybe the layer was just created), so don't attempt to expand. Also don't attempt to expand
-    // if the size changed or the rects don't overlap.
-    if (oldVisibleRect.isEmpty() || newSize != oldSize || !newVisibleRect.intersects(oldVisibleRect))
-        return newVisibleRect;
-
-    if (MemoryPressureHandler::singleton().isUnderMemoryPressure())
-        return newVisibleRect;
-
-    const float paddingMultiplier = 2;
-
-    float leftEdgeDelta = paddingMultiplier * (newVisibleRect.x() - oldVisibleRect.x());
-    float rightEdgeDelta = paddingMultiplier * (newVisibleRect.maxX() - oldVisibleRect.maxX());
-
-    float topEdgeDelta = paddingMultiplier * (newVisibleRect.y() - oldVisibleRect.y());
-    float bottomEdgeDelta = paddingMultiplier * (newVisibleRect.maxY() - oldVisibleRect.maxY());
-    
-    FloatRect existingTileBackingRect = tiledBacking->visibleRect();
-    FloatRect expandedRect = newVisibleRect;
-
-    // More exposed on left side.
-    if (leftEdgeDelta < 0) {
-        float newLeft = expandedRect.x() + leftEdgeDelta;
-        // Pad to the left, but don't reduce padding that's already in the backing store (since we're still exposing to the left).
-        if (newLeft < existingTileBackingRect.x())
-            expandedRect.shiftXEdgeTo(newLeft);
-        else
-            expandedRect.shiftXEdgeTo(existingTileBackingRect.x());
-    }
-
-    // More exposed on right.
-    if (rightEdgeDelta > 0) {
-        float newRight = expandedRect.maxX() + rightEdgeDelta;
-        // Pad to the right, but don't reduce padding that's already in the backing store (since we're still exposing to the right).
-        if (newRight > existingTileBackingRect.maxX())
-            expandedRect.setWidth(newRight - expandedRect.x());
-        else
-            expandedRect.setWidth(existingTileBackingRect.maxX() - expandedRect.x());
-    }
-
-    // More exposed at top.
-    if (topEdgeDelta < 0) {
-        float newTop = expandedRect.y() + topEdgeDelta;
-        if (newTop < existingTileBackingRect.y())
-            expandedRect.shiftYEdgeTo(newTop);
-        else
-            expandedRect.shiftYEdgeTo(existingTileBackingRect.y());
-    }
-
-    // More exposed on bottom.
-    if (bottomEdgeDelta > 0) {
-        float newBottom = expandedRect.maxY() + bottomEdgeDelta;
-        if (newBottom > existingTileBackingRect.maxY())
-            expandedRect.setHeight(newBottom - expandedRect.y());
-        else
-            expandedRect.setHeight(existingTileBackingRect.maxY() - expandedRect.y());
-    }
-    
-    expandedRect.intersect(tiledBacking->boundsWithoutMargin());
-    return expandedRect;
-}
-
 void GraphicsLayerCA::updateTiles()
 {
     if (!m_layer->usesTiledBackingLayer())

Modified: trunk/Source/WebCore/platform/graphics/ca/GraphicsLayerCA.h (245793 => 245794)


--- trunk/Source/WebCore/platform/graphics/ca/GraphicsLayerCA.h	2019-05-27 16:00:42 UTC (rev 245793)
+++ trunk/Source/WebCore/platform/graphics/ca/GraphicsLayerCA.h	2019-05-27 16:06:06 UTC (rev 245794)
@@ -323,8 +323,6 @@
 
     void setVisibleAndCoverageRects(const VisibleAndCoverageRects&, bool isViewportConstrained);
     
-    static FloatRect adjustTiledLayerVisibleRect(TiledBacking*, const FloatRect& oldVisibleRect, const FloatRect& newVisibleRect, const FloatSize& oldSize, const FloatSize& newSize);
-
     bool recursiveVisibleRectChangeRequiresFlush(const CommitState&, const TransformState&) const;
     
     bool isPageTiledBackingLayer() const { return type() == Type::PageTiledBacking; }

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


--- trunk/Source/WebCore/platform/graphics/ca/TileController.cpp	2019-05-27 16:00:42 UTC (rev 245793)
+++ trunk/Source/WebCore/platform/graphics/ca/TileController.cpp	2019-05-27 16:06:06 UTC (rev 245794)
@@ -37,6 +37,7 @@
 #include "VelocityData.h"
 #include <utility>
 #include <wtf/MainThread.h>
+#include <wtf/MemoryPressureHandler.h>
 #include <wtf/text/TextStream.h>
 
 #if HAVE(IOSURFACE)
@@ -45,7 +46,6 @@
 
 #if PLATFORM(IOS_FAMILY)
 #include "TileControllerMemoryHandlerIOS.h"
-#include <wtf/MemoryPressureHandler.h>
 #endif
 
 namespace WebCore {
@@ -386,22 +386,81 @@
 }
 #endif
 
-void TileController::adjustTileCoverageRect(FloatRect& coverageRect, const FloatSize& newSize, const FloatRect& previousVisibleRect, const FloatRect& visibleRect, float contentsScale) const
+FloatRect TileController::adjustTileCoverageRect(const FloatRect& coverageRect, const FloatRect& previousVisibleRect, const FloatRect& currentVisibleRect, bool sizeChanged) 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) {
-        coverageRect = visibleRect;
-        return;
+    // If the old visible rect is empty, we have no information about how the visible area is changing
+    // (maybe the layer was just created), so don't attempt to expand. Also don't attempt to expand
+    // if the size changed or the rects don't overlap.
+    if (previousVisibleRect.isEmpty() || sizeChanged  || !currentVisibleRect.intersects(previousVisibleRect))
+        return unionRect(coverageRect, currentVisibleRect);
+
+    if (MemoryPressureHandler::singleton().isUnderMemoryPressure())
+        return unionRect(coverageRect, currentVisibleRect);
+
+    const float paddingMultiplier = 2;
+
+    float leftEdgeDelta = paddingMultiplier * (currentVisibleRect.x() - previousVisibleRect.x());
+    float rightEdgeDelta = paddingMultiplier * (currentVisibleRect.maxX() - previousVisibleRect.maxX());
+
+    float topEdgeDelta = paddingMultiplier * (currentVisibleRect.y() - previousVisibleRect.y());
+    float bottomEdgeDelta = paddingMultiplier * (currentVisibleRect.maxY() - previousVisibleRect.maxY());
+    
+    FloatRect expandedRect = currentVisibleRect;
+
+    // More exposed on left side.
+    if (leftEdgeDelta < 0) {
+        float newLeft = expandedRect.x() + leftEdgeDelta;
+        // Pad to the left, but don't reduce padding that's already in the backing store (since we're still exposing to the left).
+        if (newLeft < previousVisibleRect.x())
+            expandedRect.shiftXEdgeTo(newLeft);
+        else
+            expandedRect.shiftXEdgeTo(previousVisibleRect.x());
     }
 
+    // More exposed on right.
+    if (rightEdgeDelta > 0) {
+        float newRight = expandedRect.maxX() + rightEdgeDelta;
+        // Pad to the right, but don't reduce padding that's already in the backing store (since we're still exposing to the right).
+        if (newRight > previousVisibleRect.maxX())
+            expandedRect.setWidth(newRight - expandedRect.x());
+        else
+            expandedRect.setWidth(previousVisibleRect.maxX() - expandedRect.x());
+    }
+
+    // More exposed at top.
+    if (topEdgeDelta < 0) {
+        float newTop = expandedRect.y() + topEdgeDelta;
+        if (newTop < previousVisibleRect.y())
+            expandedRect.shiftYEdgeTo(newTop);
+        else
+            expandedRect.shiftYEdgeTo(previousVisibleRect.y());
+    }
+
+    // More exposed on bottom.
+    if (bottomEdgeDelta > 0) {
+        float newBottom = expandedRect.maxY() + bottomEdgeDelta;
+        if (newBottom > previousVisibleRect.maxY())
+            expandedRect.setHeight(newBottom - expandedRect.y());
+        else
+            expandedRect.setHeight(previousVisibleRect.maxY() - expandedRect.y());
+    }
+    
+    expandedRect.intersect(boundsWithoutMargin());
+    return unionRect(coverageRect, expandedRect);
+}
+
+FloatRect TileController::adjustTileCoverageRectForScrolling(const FloatRect& coverageRect, 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)
+        return visibleRect;
+
 #if PLATFORM(IOS_FAMILY)
     // FIXME: unify the iOS and Mac code.
     UNUSED_PARAM(previousVisibleRect);
     
-    if (m_tileCoverage == CoverageForVisibleArea || MemoryPressureHandler::singleton().isUnderMemoryPressure()) {
-        coverageRect = visibleRect;
-        return;
-    }
+    if (m_tileCoverage == CoverageForVisibleArea || MemoryPressureHandler::singleton().isUnderMemoryPressure())
+        return visibleRect;
 
     double horizontalMargin = kDefaultTileSize / contentsScale;
     double verticalMargin = kDefaultTileSize / contentsScale;
@@ -428,9 +487,8 @@
 
     if (!m_velocity.horizontalVelocity && !m_velocity.verticalVelocity) {
         if (m_velocity.scaleChangeRate > 0) {
-            coverageRect = visibleRect;
             LOG_WITH_STREAM(Tiling, stream << "TileController " << this << " computeTileCoverageRect - zooming, coverage is visible rect " << coverageRect);
-            return;
+            return visibleRect;
         }
         futureRect.setWidth(futureRect.width() + horizontalMargin);
         futureRect.setHeight(futureRect.height() + verticalMargin);
@@ -452,7 +510,7 @@
 
     LOG_WITH_STREAM(Tiling, stream << "TileController " << this << " computeTileCoverageRect - coverage " << coverageRect << " expanded to " << unionRect(coverageRect, futureRect) << " velocity " << m_velocity);
 
-    coverageRect.unite(futureRect);
+    return unionRect(coverageRect, futureRect);
 #else
     UNUSED_PARAM(contentsScale);
 
@@ -479,7 +537,7 @@
     
     FloatRect coverage = expandRectWithinRect(visibleRect, coverageSize, coverageBounds);
     LOG_WITH_STREAM(Tiling, stream << "TileController::computeTileCoverageRect newSize=" << newSize << " mode " << m_tileCoverage << " expanded to " << coverageSize << " bounds with margin " << coverageBounds << " coverage " << coverage);
-    coverageRect.unite(coverage);
+    return unionRect(coverageRect, coverage);
 #endif
 }
 

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


--- trunk/Source/WebCore/platform/graphics/ca/TileController.h	2019-05-27 16:00:42 UTC (rev 245793)
+++ trunk/Source/WebCore/platform/graphics/ca/TileController.h	2019-05-27 16:06:06 UTC (rev 245794)
@@ -87,8 +87,8 @@
     WEBCORE_EXPORT void setTileDebugBorderWidth(float);
     WEBCORE_EXPORT void setTileDebugBorderColor(Color);
 
-    FloatRect visibleRect() const override { return m_visibleRect; }
-    FloatRect coverageRect() const override { return m_coverageRect; }
+    FloatRect visibleRect() const final { return m_visibleRect; }
+    FloatRect coverageRect() const final { return m_coverageRect; }
     Optional<FloatRect> layoutViewportRect() const { return m_layoutViewportRect; }
 
     void setTileSizeUpdateDelayDisabledForTesting(bool) final;
@@ -107,23 +107,26 @@
     float tileDebugBorderWidth() const { return m_tileDebugBorderWidth; }
     ScrollingModeIndication indicatorMode() const { return m_indicatorMode; }
 
-    void willStartLiveResize() override;
-    void didEndLiveResize() override;
+    void willStartLiveResize() final;
+    void didEndLiveResize() final;
 
-    IntSize tileSize() const override;
-    IntRect bounds() const override;
-    IntRect boundsWithoutMargin() const override;
-    bool hasMargins() const override;
-    bool hasHorizontalMargins() const override;
-    bool hasVerticalMargins() const override;
-    int topMarginHeight() const override;
-    int bottomMarginHeight() const override;
-    int leftMarginWidth() const override;
-    int rightMarginWidth() const override;
-    TileCoverage tileCoverage() const override { return m_tileCoverage; }
-    void adjustTileCoverageRect(FloatRect& coverageRect, const FloatSize& newSize, const FloatRect& previousVisibleRect, const FloatRect& currentVisibleRect, float contentsScale) const override;
-    bool scrollingPerformanceLoggingEnabled() const override { return m_scrollingPerformanceLoggingEnabled; }
+    IntSize tileSize() const final;
+    IntRect bounds() const final;
+    IntRect boundsWithoutMargin() const final;
+    bool hasMargins() const final;
+    bool hasHorizontalMargins() const final;
+    bool hasVerticalMargins() const final;
+    int topMarginHeight() const final;
+    int bottomMarginHeight() const final;
+    int leftMarginWidth() const final;
+    int rightMarginWidth() const final;
+    TileCoverage tileCoverage() const final { return m_tileCoverage; }
 
+    FloatRect adjustTileCoverageRect(const FloatRect& coverageRect, const FloatRect& previousVisibleRect, const FloatRect& currentVisibleRect, bool sizeChanged) const final;
+    FloatRect adjustTileCoverageRectForScrolling(const FloatRect& coverageRect, const FloatSize& newSize, const FloatRect& previousVisibleRect, const FloatRect& currentVisibleRect, float contentsScale) const final;
+
+    bool scrollingPerformanceLoggingEnabled() const final { return m_scrollingPerformanceLoggingEnabled; }
+
     IntSize computeTileSize();
 
     IntRect boundsAtLastRevalidate() const { return m_boundsAtLastRevalidate; }
@@ -151,32 +154,32 @@
     float topContentInset() const { return m_topContentInset; }
 
     // TiledBacking member functions.
-    void setVisibleRect(const FloatRect&) override;
-    void setLayoutViewportRect(Optional<FloatRect>) override;
-    void setCoverageRect(const FloatRect&) override;
-    bool tilesWouldChangeForCoverageRect(const FloatRect&) const override;
-    void setTiledScrollingIndicatorPosition(const FloatPoint&) override;
-    void setTopContentInset(float) override;
-    void setVelocity(const VelocityData&) override;
-    void setScrollability(Scrollability) override;
-    void prepopulateRect(const FloatRect&) override;
-    void setIsInWindow(bool) override;
-    bool isInWindow() const override { return m_isInWindow; }
-    void setTileCoverage(TileCoverage) override;
-    void revalidateTiles() override;
-    void forceRepaint() override;
-    IntRect tileGridExtent() const override;
-    void setScrollingPerformanceLoggingEnabled(bool flag) override { m_scrollingPerformanceLoggingEnabled = flag; }
-    double retainedTileBackingStoreMemory() const override;
-    IntRect tileCoverageRect() const override;
+    void setVisibleRect(const FloatRect&) final;
+    void setLayoutViewportRect(Optional<FloatRect>) final;
+    void setCoverageRect(const FloatRect&) final;
+    bool tilesWouldChangeForCoverageRect(const FloatRect&) const final;
+    void setTiledScrollingIndicatorPosition(const FloatPoint&) final;
+    void setTopContentInset(float) final;
+    void setVelocity(const VelocityData&) final;
+    void setScrollability(Scrollability) final;
+    void prepopulateRect(const FloatRect&) final;
+    void setIsInWindow(bool) final;
+    bool isInWindow() const final { return m_isInWindow; }
+    void setTileCoverage(TileCoverage) final;
+    void revalidateTiles() final;
+    void forceRepaint() final;
+    IntRect tileGridExtent() const final;
+    void setScrollingPerformanceLoggingEnabled(bool flag) final { m_scrollingPerformanceLoggingEnabled = flag; }
+    double retainedTileBackingStoreMemory() const final;
+    IntRect tileCoverageRect() const final;
 #if USE(CA)
-    PlatformCALayer* tiledScrollingIndicatorLayer() override;
+    PlatformCALayer* tiledScrollingIndicatorLayer() final;
 #endif
-    void setScrollingModeIndication(ScrollingModeIndication) override;
-    void setHasMargins(bool marginTop, bool marginBottom, bool marginLeft, bool marginRight) override;
-    void setMarginSize(int) override;
-    void setZoomedOutContentsScale(float) override;
-    float zoomedOutContentsScale() const override;
+    void setScrollingModeIndication(ScrollingModeIndication) final;
+    void setHasMargins(bool marginTop, bool marginBottom, bool marginLeft, bool marginRight) final;
+    void setMarginSize(int) final;
+    void setZoomedOutContentsScale(float) final;
+    float zoomedOutContentsScale() const final;
 
     void updateMargins();
     void clearZoomedOutTileGrid();
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to