- Revision
- 183173
- Author
- [email protected]
- Date
- 2015-04-22 23:03:22 -0700 (Wed, 22 Apr 2015)
Log Message
[iOS] Move computeCoverageRect code from FrameView into TileController
https://bugs.webkit.org/show_bug.cgi?id=144087
Reviewed by Benjamin Poulain.
There is code in four different places that adjusts tiling coverage rect:
1. LegacyTileCache. This will remain unchanged.
2. FrameView::computeTileCoverageRect(). This was added to do velocity-based
page tiled coverage expansion for iOS WK2.
3. TileController::computeTileCoverageRect(): this is used for the page tiles
on Mac.
4. GraphicsLayerCA::adjustTiledLayerVisibleRect(). This is used by non-page
tiled layers on both iOS and Mac.
This patch reduced this list to 3, coalescing FrameView::computeTileCoverageRect()
and TileController::computeTileCoverageRect(). It removes the rect inflation that
affects the visibleRect passed into rootLayer->flushCompositingState() for iOS,
but the page tiles now do an identical coverage inflation. The visible rect
change does affect visible rect computations for non-page tiled backings, but
a future patch will restore that.
* page/FrameView.cpp:
(WebCore::FrameView::setScrollVelocity):
(WebCore::FrameView::computeCoverageRect): Deleted.
* page/FrameView.h:
* platform/graphics/TiledBacking.h:
(WebCore::VelocityData::VelocityData):
* platform/graphics/ca/TileController.cpp:
(WebCore::TileController::setVelocity):
(WebCore::TileController::computeTileCoverageRect):
* platform/graphics/ca/TileController.h:
* rendering/RenderLayerCompositor.cpp:
(WebCore::RenderLayerCompositor::flushPendingLayerChanges):
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (183172 => 183173)
--- trunk/Source/WebCore/ChangeLog 2015-04-23 06:02:14 UTC (rev 183172)
+++ trunk/Source/WebCore/ChangeLog 2015-04-23 06:03:22 UTC (rev 183173)
@@ -1,3 +1,39 @@
+2015-04-22 Simon Fraser <[email protected]>
+
+ [iOS] Move computeCoverageRect code from FrameView into TileController
+ https://bugs.webkit.org/show_bug.cgi?id=144087
+
+ Reviewed by Benjamin Poulain.
+
+ There is code in four different places that adjusts tiling coverage rect:
+ 1. LegacyTileCache. This will remain unchanged.
+ 2. FrameView::computeTileCoverageRect(). This was added to do velocity-based
+ page tiled coverage expansion for iOS WK2.
+ 3. TileController::computeTileCoverageRect(): this is used for the page tiles
+ on Mac.
+ 4. GraphicsLayerCA::adjustTiledLayerVisibleRect(). This is used by non-page
+ tiled layers on both iOS and Mac.
+
+ This patch reduced this list to 3, coalescing FrameView::computeTileCoverageRect()
+ and TileController::computeTileCoverageRect(). It removes the rect inflation that
+ affects the visibleRect passed into rootLayer->flushCompositingState() for iOS,
+ but the page tiles now do an identical coverage inflation. The visible rect
+ change does affect visible rect computations for non-page tiled backings, but
+ a future patch will restore that.
+
+ * page/FrameView.cpp:
+ (WebCore::FrameView::setScrollVelocity):
+ (WebCore::FrameView::computeCoverageRect): Deleted.
+ * page/FrameView.h:
+ * platform/graphics/TiledBacking.h:
+ (WebCore::VelocityData::VelocityData):
+ * platform/graphics/ca/TileController.cpp:
+ (WebCore::TileController::setVelocity):
+ (WebCore::TileController::computeTileCoverageRect):
+ * platform/graphics/ca/TileController.h:
+ * rendering/RenderLayerCompositor.cpp:
+ (WebCore::RenderLayerCompositor::flushPendingLayerChanges):
+
2015-04-22 Darin Adler <[email protected]>
Remove OwnPtr and PassOwnPtr use from WebKit/cf, WebKit/mac, and WebKit2
Modified: trunk/Source/WebCore/page/FrameView.cpp (183172 => 183173)
--- trunk/Source/WebCore/page/FrameView.cpp 2015-04-23 06:02:14 UTC (rev 183172)
+++ trunk/Source/WebCore/page/FrameView.cpp 2015-04-23 06:03:22 UTC (rev 183173)
@@ -107,9 +107,6 @@
#if PLATFORM(IOS)
#include "DocumentLoader.h"
#include "LegacyTileCache.h"
-#include "MemoryCache.h"
-#include "MemoryPressureHandler.h"
-#include "SystemMemory.h"
#endif
namespace WebCore {
@@ -4545,55 +4542,9 @@
void FrameView::setScrollVelocity(double horizontalVelocity, double verticalVelocity, double scaleChangeRate, double timestamp)
{
- m_horizontalVelocity = horizontalVelocity;
- m_verticalVelocity = verticalVelocity;
- m_scaleChangeRate = scaleChangeRate;
- m_lastVelocityUpdateTime = timestamp;
+ if (TiledBacking* tiledBacking = this->tiledBacking())
+ tiledBacking->setVelocity(VelocityData(horizontalVelocity, verticalVelocity, scaleChangeRate, timestamp));
}
-
-FloatRect FrameView::computeCoverageRect(double horizontalMargin, double verticalMargin) const
-{
- FloatRect exposedContentRect = this->exposedContentRect();
- if (!m_speculativeTilingEnabled || MemoryPressureHandler::singleton().isUnderMemoryPressure())
- return exposedContentRect;
-
- double currentTime = monotonicallyIncreasingTime();
- double timeDelta = currentTime - m_lastVelocityUpdateTime;
-
- FloatRect futureRect = exposedContentRect;
- futureRect.setLocation(FloatPoint(futureRect.location().x() + timeDelta * m_horizontalVelocity, futureRect.location().y() + timeDelta * m_verticalVelocity));
-
- if (m_horizontalVelocity) {
- futureRect.setWidth(futureRect.width() + horizontalMargin);
- if (m_horizontalVelocity < 0)
- futureRect.setX(futureRect.x() - horizontalMargin);
- }
-
- if (m_verticalVelocity) {
- futureRect.setHeight(futureRect.height() + verticalMargin);
- if (m_verticalVelocity < 0)
- futureRect.setY(futureRect.y() - verticalMargin);
- }
-
- if (m_scaleChangeRate <= 0 && !m_horizontalVelocity && !m_verticalVelocity) {
- futureRect.setWidth(futureRect.width() + horizontalMargin);
- futureRect.setHeight(futureRect.height() + verticalMargin);
- futureRect.setX(futureRect.x() - horizontalMargin / 2);
- futureRect.setY(futureRect.y() - verticalMargin / 2);
- }
-
- IntSize contentSize = contentsSize();
- if (futureRect.maxX() > contentSize.width())
- futureRect.setX(contentSize.width() - futureRect.width());
- if (futureRect.maxY() > contentSize.height())
- futureRect.setY(contentSize.height() - futureRect.height());
- if (futureRect.x() < 0)
- futureRect.setX(0);
- if (futureRect.y() < 0)
- futureRect.setY(0);
-
- return futureRect;
-}
#endif // PLATFORM(IOS)
void FrameView::setScrollingPerformanceLoggingEnabled(bool flag)
Modified: trunk/Source/WebCore/page/FrameView.h (183172 => 183173)
--- trunk/Source/WebCore/page/FrameView.h 2015-04-23 06:02:14 UTC (rev 183172)
+++ trunk/Source/WebCore/page/FrameView.h 2015-04-23 06:03:22 UTC (rev 183173)
@@ -139,7 +139,6 @@
WEBCORE_EXPORT void setCustomSizeForResizeEvent(IntSize);
WEBCORE_EXPORT void setScrollVelocity(double horizontalVelocity, double verticalVelocity, double scaleChangeRate, double timestamp);
- FloatRect computeCoverageRect(double horizontalMargin, double verticalMargin) const;
#else
bool useCustomFixedPositionLayoutRect() const { return false; }
#endif
Modified: trunk/Source/WebCore/platform/graphics/TiledBacking.h (183172 => 183173)
--- trunk/Source/WebCore/platform/graphics/TiledBacking.h 2015-04-23 06:02:14 UTC (rev 183172)
+++ trunk/Source/WebCore/platform/graphics/TiledBacking.h 2015-04-23 06:03:22 UTC (rev 183173)
@@ -40,6 +40,21 @@
AsyncScrollingIndication
};
+struct VelocityData {
+ double horizontalVelocity;
+ double verticalVelocity;
+ double scaleChangeRate;
+ double lastUpdateTime;
+
+ VelocityData(double horizontal = 0, double vertical = 0, double scaleChange = 0, double updateTime = 0)
+ : horizontalVelocity(horizontal)
+ , verticalVelocity(vertical)
+ , scaleChangeRate(scaleChange)
+ , lastUpdateTime(updateTime)
+ {
+ }
+};
+
class TiledBacking {
public:
virtual ~TiledBacking() { }
@@ -51,6 +66,8 @@
virtual void setTiledScrollingIndicatorPosition(const FloatPoint&) = 0;
virtual void setTopContentInset(float) = 0;
+ virtual void setVelocity(const VelocityData&) = 0;
+
virtual void prepopulateRect(const FloatRect&) = 0;
virtual void setIsInWindow(bool) = 0;
Modified: trunk/Source/WebCore/platform/graphics/ca/TileController.cpp (183172 => 183173)
--- trunk/Source/WebCore/platform/graphics/ca/TileController.cpp 2015-04-23 06:02:14 UTC (rev 183172)
+++ trunk/Source/WebCore/platform/graphics/ca/TileController.cpp 2015-04-23 06:03:22 UTC (rev 183173)
@@ -35,6 +35,7 @@
#include <wtf/MainThread.h>
#if PLATFORM(IOS)
+#include "MemoryPressureHandler.h"
#include "TileControllerMemoryHandlerIOS.h"
#endif
@@ -198,6 +199,11 @@
return tileGrid().tilesWouldChangeForVisibleRect(newVisibleRect, m_visibleRect);
}
+void TileController::setVelocity(const VelocityData& velocity)
+{
+ m_velocity = velocity;
+}
+
void TileController::setTopContentInset(float topContentInset)
{
m_topContentInset = topContentInset;
@@ -299,14 +305,59 @@
if (!m_isInWindow)
return visibleRect;
+#if PLATFORM(IOS)
+ // FIXME: unify the iOS and Mac code.
+ UNUSED_PARAM(previousVisibleRect);
+
+ if (m_tileCoverage == CoverageForVisibleArea || MemoryPressureHandler::singleton().isUnderMemoryPressure())
+ return visibleRect;
+
+ double horizontalMargin = defaultTileWidth / tileGrid().scale();
+ double verticalMargin = defaultTileHeight / tileGrid().scale();
+
+ double currentTime = monotonicallyIncreasingTime();
+ double timeDelta = currentTime - m_velocity.lastUpdateTime;
+
+ FloatRect futureRect = visibleRect;
+ futureRect.setLocation(FloatPoint(
+ futureRect.location().x() + timeDelta * m_velocity.horizontalVelocity,
+ futureRect.location().y() + timeDelta * m_velocity.verticalVelocity));
+
+ if (m_velocity.horizontalVelocity) {
+ futureRect.setWidth(futureRect.width() + horizontalMargin);
+ if (m_velocity.horizontalVelocity < 0)
+ futureRect.setX(futureRect.x() - horizontalMargin);
+ }
+
+ if (m_velocity.verticalVelocity) {
+ futureRect.setHeight(futureRect.height() + verticalMargin);
+ if (m_velocity.verticalVelocity < 0)
+ futureRect.setY(futureRect.y() - verticalMargin);
+ }
+
+ if (m_velocity.scaleChangeRate <= 0 && !m_velocity.horizontalVelocity && !m_velocity.verticalVelocity) {
+ futureRect.setWidth(futureRect.width() + horizontalMargin);
+ futureRect.setHeight(futureRect.height() + verticalMargin);
+ futureRect.setX(futureRect.x() - horizontalMargin / 2);
+ futureRect.setY(futureRect.y() - verticalMargin / 2);
+ }
+
+ IntSize contentSize = bounds().size();
+ if (futureRect.maxX() > contentSize.width())
+ futureRect.setX(contentSize.width() - futureRect.width());
+ if (futureRect.maxY() > contentSize.height())
+ futureRect.setY(contentSize.height() - futureRect.height());
+ if (futureRect.x() < 0)
+ futureRect.setX(0);
+ if (futureRect.y() < 0)
+ futureRect.setY(0);
+
+ return futureRect;
+#else
// FIXME: look at how far the document can scroll in each dimension.
float coverageHorizontalSize = visibleRect.width();
float coverageVerticalSize = visibleRect.height();
-#if PLATFORM(IOS)
- UNUSED_PARAM(previousVisibleRect);
- return visibleRect;
-#else
bool largeVisibleRectChange = !previousVisibleRect.isEmpty() && !visibleRect.intersects(previousVisibleRect);
// Inflate the coverage rect so that it covers 2x of the visible width and 3x of the visible height.
@@ -318,7 +369,7 @@
if (m_tileCoverage & CoverageForVerticalScrolling && !largeVisibleRectChange)
coverageVerticalSize *= 3;
-#endif
+
coverageVerticalSize += topMarginHeight() + bottomMarginHeight();
coverageHorizontalSize += leftMarginWidth() + rightMarginWidth();
@@ -332,6 +383,7 @@
coverageTop = std::max(coverageTop, coverageBounds.y());
return FloatRect(coverageLeft, coverageTop, coverageHorizontalSize, coverageVerticalSize);
+#endif
}
void TileController::scheduleTileRevalidation(double interval)
Modified: trunk/Source/WebCore/platform/graphics/ca/TileController.h (183172 => 183173)
--- trunk/Source/WebCore/platform/graphics/ca/TileController.h 2015-04-23 06:02:14 UTC (rev 183172)
+++ trunk/Source/WebCore/platform/graphics/ca/TileController.h 2015-04-23 06:03:22 UTC (rev 183173)
@@ -139,6 +139,7 @@
virtual bool tilesWouldChangeForVisibleRect(const FloatRect&) const override;
virtual void setTiledScrollingIndicatorPosition(const FloatPoint&) override;
virtual void setTopContentInset(float) override;
+ virtual void setVelocity(const VelocityData&) override;
virtual void prepopulateRect(const FloatRect&) override;
virtual void setIsInWindow(bool) override;
virtual void setTileCoverage(TileCoverage) override;
@@ -182,6 +183,8 @@
float m_deviceScaleFactor;
TileCoverage m_tileCoverage;
+
+ VelocityData m_velocity;
// m_marginTop and m_marginBottom are the height in pixels of the top and bottom margin tiles. The width
// of those tiles will be equivalent to the width of the other tiles in the grid. m_marginRight and
Modified: trunk/Source/WebCore/rendering/RenderLayerCompositor.cpp (183172 => 183173)
--- trunk/Source/WebCore/rendering/RenderLayerCompositor.cpp 2015-04-23 06:02:14 UTC (rev 183172)
+++ trunk/Source/WebCore/rendering/RenderLayerCompositor.cpp 2015-04-23 06:03:22 UTC (rev 183173)
@@ -458,10 +458,7 @@
if (GraphicsLayer* rootLayer = rootGraphicsLayer()) {
#if PLATFORM(IOS)
- double horizontalMargin = defaultTileWidth / pageScaleFactor();
- double verticalMargin = defaultTileHeight / pageScaleFactor();
- FloatRect visibleRect = frameView.computeCoverageRect(horizontalMargin, verticalMargin);
- rootLayer->flushCompositingState(visibleRect);
+ rootLayer->flushCompositingState(frameView.exposedContentRect());
#else
// Having a m_clipLayer indicates that we're doing scrolling via GraphicsLayers.
IntRect visibleRect = m_clipLayer ? IntRect(IntPoint(), frameView.unscaledVisibleContentSizeIncludingObscuredArea()) : frameView.visibleContentRect();