- Revision
- 161315
- Author
- [email protected]
- Date
- 2014-01-04 13:48:03 -0800 (Sat, 04 Jan 2014)
Log Message
Prepare the ScrollingTree for remote use
https://bugs.webkit.org/show_bug.cgi?id=126493
Reviewed by Sam Weinig.
When committing the scrolling tree, we clone the ScrollingStateTree
to hand off to another thread, or (in future) to encode to send to the
UI process. During this cloning process, two types of layer transformations
take place: for threaded scrolling, we replace GraphicsLayer with PlatformLayers.
For remote scrolling, we'll replace GraphicsLayers with PlatformLayerIDs.
Allow the ScrollingCoordinator to specify which type of transformation occurs
by giving ScrollingStateTree a LayerRepresentation::Type member,
which is consulted during ScrollingStateNode cloning.
Also only copy layers that have changed to avoid setting dirty bits.
Expose some other stuff on ScrollingStateTree which will be needed for
remote scrolling.
* page/scrolling/ScrollingStateFixedNode.cpp:
(WebCore::ScrollingStateFixedNode::syncLayerPositionForViewportRect):
* page/scrolling/ScrollingStateNode.cpp:
(WebCore::ScrollingStateNode::ScrollingStateNode):
* page/scrolling/ScrollingStateNode.h:
(WebCore::LayerRepresentation::operator GraphicsLayer::PlatformLayerID):
(WebCore::LayerRepresentation::toRepresentation):
(WebCore::ScrollingStateNode::changedProperties):
(WebCore::ScrollingStateNode::setChangedProperties):
(WebCore::ScrollingStateNode::parentNodeID):
* page/scrolling/ScrollingStateScrollingNode.cpp:
(WebCore::ScrollingStateScrollingNode::ScrollingStateScrollingNode):
* page/scrolling/ScrollingStateStickyNode.cpp:
(WebCore::ScrollingStateStickyNode::syncLayerPositionForViewportRect):
* page/scrolling/ScrollingStateTree.cpp:
(WebCore::ScrollingStateTree::ScrollingStateTree):
(WebCore::ScrollingStateTree::commit):
(WebCore::ScrollingStateTree::setRemovedNodes):
(WebCore::ScrollingStateTree::stateNodeForID):
* page/scrolling/ScrollingStateTree.h:
(WebCore::ScrollingStateTree::nodeCount):
(WebCore::ScrollingStateTree::nodeMap):
(WebCore::ScrollingStateTree::preferredLayerRepresentation):
(WebCore::ScrollingStateTree::setPreferredLayerRepresentation):
* page/scrolling/mac/ScrollingCoordinatorMac.mm:
(WebCore::ScrollingCoordinatorMac::commitTreeState):
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (161314 => 161315)
--- trunk/Source/WebCore/ChangeLog 2014-01-04 20:53:51 UTC (rev 161314)
+++ trunk/Source/WebCore/ChangeLog 2014-01-04 21:48:03 UTC (rev 161315)
@@ -1,3 +1,51 @@
+2014-01-04 Simon Fraser <[email protected]>
+
+ Prepare the ScrollingTree for remote use
+ https://bugs.webkit.org/show_bug.cgi?id=126493
+
+ Reviewed by Sam Weinig.
+
+ When committing the scrolling tree, we clone the ScrollingStateTree
+ to hand off to another thread, or (in future) to encode to send to the
+ UI process. During this cloning process, two types of layer transformations
+ take place: for threaded scrolling, we replace GraphicsLayer with PlatformLayers.
+ For remote scrolling, we'll replace GraphicsLayers with PlatformLayerIDs.
+ Allow the ScrollingCoordinator to specify which type of transformation occurs
+ by giving ScrollingStateTree a LayerRepresentation::Type member,
+ which is consulted during ScrollingStateNode cloning.
+
+ Also only copy layers that have changed to avoid setting dirty bits.
+
+ Expose some other stuff on ScrollingStateTree which will be needed for
+ remote scrolling.
+
+ * page/scrolling/ScrollingStateFixedNode.cpp:
+ (WebCore::ScrollingStateFixedNode::syncLayerPositionForViewportRect):
+ * page/scrolling/ScrollingStateNode.cpp:
+ (WebCore::ScrollingStateNode::ScrollingStateNode):
+ * page/scrolling/ScrollingStateNode.h:
+ (WebCore::LayerRepresentation::operator GraphicsLayer::PlatformLayerID):
+ (WebCore::LayerRepresentation::toRepresentation):
+ (WebCore::ScrollingStateNode::changedProperties):
+ (WebCore::ScrollingStateNode::setChangedProperties):
+ (WebCore::ScrollingStateNode::parentNodeID):
+ * page/scrolling/ScrollingStateScrollingNode.cpp:
+ (WebCore::ScrollingStateScrollingNode::ScrollingStateScrollingNode):
+ * page/scrolling/ScrollingStateStickyNode.cpp:
+ (WebCore::ScrollingStateStickyNode::syncLayerPositionForViewportRect):
+ * page/scrolling/ScrollingStateTree.cpp:
+ (WebCore::ScrollingStateTree::ScrollingStateTree):
+ (WebCore::ScrollingStateTree::commit):
+ (WebCore::ScrollingStateTree::setRemovedNodes):
+ (WebCore::ScrollingStateTree::stateNodeForID):
+ * page/scrolling/ScrollingStateTree.h:
+ (WebCore::ScrollingStateTree::nodeCount):
+ (WebCore::ScrollingStateTree::nodeMap):
+ (WebCore::ScrollingStateTree::preferredLayerRepresentation):
+ (WebCore::ScrollingStateTree::setPreferredLayerRepresentation):
+ * page/scrolling/mac/ScrollingCoordinatorMac.mm:
+ (WebCore::ScrollingCoordinatorMac::commitTreeState):
+
2014-01-04 Sam Weinig <[email protected]>
Move LineBreaker functions to LineBreaker.cpp
Modified: trunk/Source/WebCore/page/scrolling/ScrollingStateFixedNode.cpp (161314 => 161315)
--- trunk/Source/WebCore/page/scrolling/ScrollingStateFixedNode.cpp 2014-01-04 20:53:51 UTC (rev 161314)
+++ trunk/Source/WebCore/page/scrolling/ScrollingStateFixedNode.cpp 2014-01-04 21:48:03 UTC (rev 161315)
@@ -72,7 +72,8 @@
void ScrollingStateFixedNode::syncLayerPositionForViewportRect(const LayoutRect& viewportRect)
{
FloatPoint position = m_constraints.layerPositionForViewportRect(viewportRect);
- static_cast<GraphicsLayer*>(layer())->syncPosition(position);
+ if (layer().representsGraphicsLayer())
+ static_cast<GraphicsLayer*>(layer())->syncPosition(position);
}
void ScrollingStateFixedNode::dumpProperties(TextStream& ts, int indent) const
Modified: trunk/Source/WebCore/page/scrolling/ScrollingStateNode.cpp (161314 => 161315)
--- trunk/Source/WebCore/page/scrolling/ScrollingStateNode.cpp 2014-01-04 20:53:51 UTC (rev 161314)
+++ trunk/Source/WebCore/page/scrolling/ScrollingStateNode.cpp 2014-01-04 21:48:03 UTC (rev 161315)
@@ -54,9 +54,8 @@
, m_scrollingStateTree(adoptiveTree)
, m_parent(0)
{
- // The cloned tree references PlatformLayers, which are safe to send to the scrolling thread.
- // FIXME: this Mac threaded-scrolling assumption doesn't belong here.
- setLayer(stateNode.layer().toPlatformLayer());
+ if (hasChangedProperty(ScrollLayer))
+ setLayer(stateNode.layer().toRepresentation(adoptiveTree.preferredLayerRepresentation()));
scrollingStateTree().addNode(this);
}
Modified: trunk/Source/WebCore/page/scrolling/ScrollingStateNode.h (161314 => 161315)
--- trunk/Source/WebCore/page/scrolling/ScrollingStateNode.h 2014-01-04 20:53:51 UTC (rev 161314)
+++ trunk/Source/WebCore/page/scrolling/ScrollingStateNode.h 2014-01-04 21:48:03 UTC (rev 161315)
@@ -52,7 +52,7 @@
// c) Remote scrolling UI process, where LayerRepresentation wraps just a PlatformLayerID.
class LayerRepresentation {
public:
- enum LayerRepresentationType {
+ enum Type {
EmptyRepresentation,
GraphicsLayerRepresentation,
PlatformLayerRepresentation,
@@ -97,7 +97,7 @@
operator GraphicsLayer::PlatformLayerID() const
{
- ASSERT(m_representation == PlatformLayerIDRepresentation || m_representation == GraphicsLayerRepresentation);
+ ASSERT(m_representation != PlatformLayerRepresentation);
return m_layerID;
}
@@ -120,16 +120,25 @@
return true;
}
- LayerRepresentation toPlatformLayer() const
+ LayerRepresentation toRepresentation(Type representation) const
{
- ASSERT(m_representation == GraphicsLayerRepresentation);
- return m_graphicsLayer ? m_graphicsLayer->platformLayer() : nullptr;
+ switch (representation) {
+ case EmptyRepresentation:
+ return LayerRepresentation();
+ case GraphicsLayerRepresentation:
+ ASSERT(m_representation == GraphicsLayerRepresentation);
+ return *this;
+ case PlatformLayerRepresentation:
+ return m_graphicsLayer ? m_graphicsLayer->platformLayer() : nullptr;
+ case PlatformLayerIDRepresentation:
+ return LayerRepresentation(m_layerID);
+ }
+ return LayerRepresentation();
}
-
+
bool representsGraphicsLayer() const { return m_representation == GraphicsLayerRepresentation; }
- bool representsPlatformLayer() const { return m_representation == PlatformLayerRepresentation; }
bool representsPlatformLayerID() const { return m_representation == PlatformLayerIDRepresentation; }
-
+
private:
union {
GraphicsLayer* m_graphicsLayer;
@@ -137,7 +146,7 @@
};
GraphicsLayer::PlatformLayerID m_layerID;
- LayerRepresentationType m_representation;
+ Type m_representation;
};
class ScrollingStateNode {
@@ -162,6 +171,9 @@
void resetChangedProperties() { m_changedProperties = 0; }
void setPropertyChanged(unsigned propertyBit);
+ ChangedProperties changedProperties() const { return m_changedProperties; }
+ void setChangedProperties(ChangedProperties changedProperties) { m_changedProperties = changedProperties; }
+
virtual void syncLayerPositionForViewportRect(const LayoutRect& /*viewportRect*/) { }
const LayerRepresentation& layer() const { return m_layer; }
@@ -173,6 +185,7 @@
ScrollingStateNode* parent() const { return m_parent; }
void setParent(ScrollingStateNode* parent) { m_parent = parent; }
+ ScrollingNodeID parentNodeID() const { return m_parent ? m_parent->scrollingNodeID() : 0; }
Vector<OwnPtr<ScrollingStateNode>>* children() const { return m_children.get(); }
@@ -188,7 +201,6 @@
void dump(TextStream&, int indent) const;
virtual void dumpProperties(TextStream&, int indent) const = 0;
- ChangedProperties changedProperties() const { return m_changedProperties; }
void willBeRemovedFromStateTree();
const ScrollingNodeType m_nodeType;
Modified: trunk/Source/WebCore/page/scrolling/ScrollingStateScrollingNode.cpp (161314 => 161315)
--- trunk/Source/WebCore/page/scrolling/ScrollingStateScrollingNode.cpp 2014-01-04 20:53:51 UTC (rev 161314)
+++ trunk/Source/WebCore/page/scrolling/ScrollingStateScrollingNode.cpp 2014-01-04 21:48:03 UTC (rev 161315)
@@ -75,11 +75,14 @@
, m_requestedScrollPosition(stateNode.requestedScrollPosition())
, m_requestedScrollPositionRepresentsProgrammaticScroll(stateNode.requestedScrollPositionRepresentsProgrammaticScroll())
{
- // The cloned tree references PlatformLayers, which are safe to send to the scrolling thread.
- // FIXME: this Mac threaded-scrolling assumption doesn't belong here.
- setCounterScrollingLayer(stateNode.counterScrollingLayer().toPlatformLayer());
- setHeaderLayer(stateNode.headerLayer().toPlatformLayer());
- setFooterLayer(stateNode.footerLayer().toPlatformLayer());
+ if (hasChangedProperty(CounterScrollingLayer))
+ setCounterScrollingLayer(stateNode.counterScrollingLayer().toRepresentation(adoptiveTree.preferredLayerRepresentation()));
+
+ if (hasChangedProperty(HeaderLayer))
+ setHeaderLayer(stateNode.headerLayer().toRepresentation(adoptiveTree.preferredLayerRepresentation()));
+
+ if (hasChangedProperty(FooterLayer))
+ setFooterLayer(stateNode.footerLayer().toRepresentation(adoptiveTree.preferredLayerRepresentation()));
}
ScrollingStateScrollingNode::~ScrollingStateScrollingNode()
Modified: trunk/Source/WebCore/page/scrolling/ScrollingStateStickyNode.cpp (161314 => 161315)
--- trunk/Source/WebCore/page/scrolling/ScrollingStateStickyNode.cpp 2014-01-04 20:53:51 UTC (rev 161314)
+++ trunk/Source/WebCore/page/scrolling/ScrollingStateStickyNode.cpp 2014-01-04 21:48:03 UTC (rev 161315)
@@ -72,7 +72,8 @@
void ScrollingStateStickyNode::syncLayerPositionForViewportRect(const LayoutRect& viewportRect)
{
FloatPoint position = m_constraints.layerPositionForConstrainingRect(viewportRect);
- static_cast<GraphicsLayer*>(layer())->syncPosition(position);
+ if (layer().representsGraphicsLayer())
+ static_cast<GraphicsLayer*>(layer())->syncPosition(position);
}
void ScrollingStateStickyNode::dumpProperties(TextStream& ts, int indent) const
Modified: trunk/Source/WebCore/page/scrolling/ScrollingStateTree.cpp (161314 => 161315)
--- trunk/Source/WebCore/page/scrolling/ScrollingStateTree.cpp 2014-01-04 20:53:51 UTC (rev 161314)
+++ trunk/Source/WebCore/page/scrolling/ScrollingStateTree.cpp 2014-01-04 21:48:03 UTC (rev 161315)
@@ -44,6 +44,7 @@
: m_scrollingCoordinator(scrollingCoordinator)
, m_hasChangedProperties(false)
, m_hasNewRootStateNode(false)
+ , m_preferredLayerRepresentation(LayerRepresentation::GraphicsLayerRepresentation)
{
}
@@ -140,10 +141,12 @@
m_stateNodeMap.clear();
}
-PassOwnPtr<ScrollingStateTree> ScrollingStateTree::commit()
+PassOwnPtr<ScrollingStateTree> ScrollingStateTree::commit(LayerRepresentation::Type preferredLayerRepresentation)
{
// This function clones and resets the current state tree, but leaves the tree structure intact.
OwnPtr<ScrollingStateTree> treeStateClone = ScrollingStateTree::create();
+ treeStateClone->setPreferredLayerRepresentation(preferredLayerRepresentation);
+
if (m_rootStateNode)
treeStateClone->setRootStateNode(static_pointer_cast<ScrollingStateScrollingNode>(m_rootStateNode->cloneAndReset(*treeStateClone)));
@@ -192,12 +195,17 @@
setHasChangedProperties();
}
+void ScrollingStateTree::setRemovedNodes(Vector<ScrollingNodeID> nodes)
+{
+ m_nodesRemovedSinceLastCommit = std::move(nodes);
+}
+
ScrollingStateNode* ScrollingStateTree::stateNodeForID(ScrollingNodeID scrollLayerID)
{
if (!scrollLayerID)
return 0;
- HashMap<ScrollingNodeID, ScrollingStateNode*>::const_iterator it = m_stateNodeMap.find(scrollLayerID);
+ auto it = m_stateNodeMap.find(scrollLayerID);
if (it == m_stateNodeMap.end())
return 0;
Modified: trunk/Source/WebCore/page/scrolling/ScrollingStateTree.h (161314 => 161315)
--- trunk/Source/WebCore/page/scrolling/ScrollingStateTree.h 2014-01-04 20:53:51 UTC (rev 161314)
+++ trunk/Source/WebCore/page/scrolling/ScrollingStateTree.h 2014-01-04 21:48:03 UTC (rev 161315)
@@ -57,15 +57,24 @@
void clear();
const Vector<ScrollingNodeID>& removedNodes() const { return m_nodesRemovedSinceLastCommit; }
+ void setRemovedNodes(Vector<ScrollingNodeID>);
// Copies the current tree state and clears the changed properties mask in the original.
- PassOwnPtr<ScrollingStateTree> commit();
+ PassOwnPtr<ScrollingStateTree> commit(LayerRepresentation::Type preferredLayerRepresentation);
void setHasChangedProperties(bool = true);
bool hasChangedProperties() const { return m_hasChangedProperties; }
bool hasNewRootStateNode() const { return m_hasNewRootStateNode; }
+
+ int nodeCount() const { return m_stateNodeMap.size(); }
+ typedef HashMap<ScrollingNodeID, ScrollingStateNode*> StateNodeMap;
+ const StateNodeMap& nodeMap() const { return m_stateNodeMap; }
+
+ LayerRepresentation::Type preferredLayerRepresentation() const { return m_preferredLayerRepresentation; }
+ void setPreferredLayerRepresentation(LayerRepresentation::Type representation) { m_preferredLayerRepresentation = representation; }
+
private:
ScrollingStateTree(AsyncScrollingCoordinator*);
@@ -75,11 +84,12 @@
void didRemoveNode(ScrollingNodeID);
AsyncScrollingCoordinator* m_scrollingCoordinator;
- HashMap<ScrollingNodeID, ScrollingStateNode*> m_stateNodeMap;
+ StateNodeMap m_stateNodeMap;
OwnPtr<ScrollingStateScrollingNode> m_rootStateNode;
Vector<ScrollingNodeID> m_nodesRemovedSinceLastCommit;
bool m_hasChangedProperties;
bool m_hasNewRootStateNode;
+ LayerRepresentation::Type m_preferredLayerRepresentation;
};
} // namespace WebCore
Modified: trunk/Source/WebCore/page/scrolling/mac/ScrollingCoordinatorMac.mm (161314 => 161315)
--- trunk/Source/WebCore/page/scrolling/mac/ScrollingCoordinatorMac.mm 2014-01-04 20:53:51 UTC (rev 161314)
+++ trunk/Source/WebCore/page/scrolling/mac/ScrollingCoordinatorMac.mm 2014-01-04 21:48:03 UTC (rev 161315)
@@ -110,7 +110,7 @@
{
ASSERT(scrollingStateTree()->hasChangedProperties());
- OwnPtr<ScrollingStateTree> treeState = scrollingStateTree()->commit();
+ OwnPtr<ScrollingStateTree> treeState = scrollingStateTree()->commit(LayerRepresentation::PlatformLayerRepresentation);
ScrollingThread::dispatch(bind(&ThreadedScrollingTree::commitNewTreeState, toThreadedScrollingTree(scrollingTree()), treeState.release()));
updateTiledScrollingIndicator();