WebKit Bugzilla
Attachment 370664 Details for
Bug 198266
: Move GraphicsLayerCA::adjustTiledLayerVisibleRect() to TileController
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch
bug-198266-20190526204431.patch (text/plain), 20.38 KB, created by
Simon Fraser (smfr)
on 2019-05-26 20:44:32 PDT
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Simon Fraser (smfr)
Created:
2019-05-26 20:44:32 PDT
Size:
20.38 KB
patch
obsolete
>Subversion Revision: 245777 >diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index 19a2aa5ac2d776d8e122ee1076bc243de5157a7e..05d5c15b4935fc38e21d05e9bcf5856d040f8c65 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,31 @@ >+2019-05-26 Simon Fraser <simon.fraser@apple.com> >+ >+ Move GraphicsLayerCA::adjustTiledLayerVisibleRect() to TileController >+ https://bugs.webkit.org/show_bug.cgi?id=198266 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ 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-26 Simon Fraser <simon.fraser@apple.com> > > Move VelocityData to WebCore >diff --git a/Source/WebCore/platform/graphics/TiledBacking.h b/Source/WebCore/platform/graphics/TiledBacking.h >index 525c4f3a67589a0bcf60a38a0af76f1441cdef45..f22a6fcc506b50b63a6f1f32e8c76df98ec373bb 100644 >--- a/Source/WebCore/platform/graphics/TiledBacking.h >+++ b/Source/WebCore/platform/graphics/TiledBacking.h >@@ -95,7 +95,8 @@ public: > 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; >diff --git a/Source/WebCore/platform/graphics/ca/GraphicsLayerCA.cpp b/Source/WebCore/platform/graphics/ca/GraphicsLayerCA.cpp >index fbe4c357924a0a616db2e3da2048fcc5f4234dec..18ed2e7e59f7eb0017bb818caf86b9ed79e4a7d9 100644 >--- a/Source/WebCore/platform/graphics/ca/GraphicsLayerCA.cpp >+++ b/Source/WebCore/platform/graphics/ca/GraphicsLayerCA.cpp >@@ -1443,16 +1443,14 @@ bool GraphicsLayerCA::adjustCoverageRect(VisibleAndCoverageRects& rects, const F > { > 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 @@ void GraphicsLayerCA::updateDebugIndicators() > } > } > >-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()) >diff --git a/Source/WebCore/platform/graphics/ca/GraphicsLayerCA.h b/Source/WebCore/platform/graphics/ca/GraphicsLayerCA.h >index ebbfb52b5cee1e4d19855a4c35b275f2a8c8ec98..c921d5ffee69eb93d4d66969a8253ee10e6763f9 100644 >--- a/Source/WebCore/platform/graphics/ca/GraphicsLayerCA.h >+++ b/Source/WebCore/platform/graphics/ca/GraphicsLayerCA.h >@@ -323,8 +323,6 @@ private: > > 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; } >diff --git a/Source/WebCore/platform/graphics/ca/TileController.cpp b/Source/WebCore/platform/graphics/ca/TileController.cpp >index 2546ac7c9c312163bcc2cd8ac3ac08dc676e5375..8293e419935ec2bfe24f7bffbbbf9a2ac73fd70a 100644 >--- a/Source/WebCore/platform/graphics/ca/TileController.cpp >+++ b/Source/WebCore/platform/graphics/ca/TileController.cpp >@@ -386,22 +386,81 @@ static FloatRect expandRectWithinRect(const FloatRect& rect, const FloatSize& ne > } > #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 @@ void TileController::adjustTileCoverageRect(FloatRect& coverageRect, const Float > > 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 @@ void TileController::adjustTileCoverageRect(FloatRect& coverageRect, const Float > > 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 @@ void TileController::adjustTileCoverageRect(FloatRect& coverageRect, const Float > > 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 > } > >diff --git a/Source/WebCore/platform/graphics/ca/TileController.h b/Source/WebCore/platform/graphics/ca/TileController.h >index dbb049abe54317bd11bf08b6379df2acf68a17c3..8dfc432ac67f9f8174439a5d1100ebcf6a63c3c8 100644 >--- a/Source/WebCore/platform/graphics/ca/TileController.h >+++ b/Source/WebCore/platform/graphics/ca/TileController.h >@@ -87,8 +87,8 @@ public: > 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,22 +107,25 @@ public: > float tileDebugBorderWidth() const { return m_tileDebugBorderWidth; } > ScrollingModeIndication indicatorMode() const { return m_indicatorMode; } > >- void willStartLiveResize() override; >- void didEndLiveResize() override; >- >- 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; } >+ void willStartLiveResize() final; >+ void didEndLiveResize() final; >+ >+ 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(); > >@@ -151,32 +154,32 @@ private: > 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();
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Flags:
zalan
:
review+
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 198266
: 370664 |
370667