зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1357754 - Extract a template function from UpdateHitTestingTree. r=botond
Currently the public UpdateHitTestingTree function takes a Layer* which assumes there is a layer tree to traverse. However, with WebRender, that is not the case. This patch has two conceptual changes. The first change is to extract the innards of UpdateHitTestingTree to take a LayerMetricsWrapper instead of a Layer* and traverse the layer tree using that. This was already mostly happening but this makes the Layer*/LayerMetricsWrapper boundary a little more explicit. The second change is to make the extracted helper function templated, so it accepts anything that is template-compatible with LayerMetricsWrapper. I chose to use a template rather inheritance to avoid the performance hit of virtual functions, since this code runs relatively often. This paves the way for adding a different kind of tree-traversal object instead of the LayerMetricsWrapper while reusing the same logic to build the hit-testing tree and APZC nodes. MozReview-Commit-ID: 6SmnX6Bn2QV
This commit is contained in:
Родитель
070cc4b9a7
Коммит
e1121dae1a
|
@ -213,12 +213,12 @@ APZCTreeManager::SetAllowedTouchBehavior(uint64_t aInputBlockId,
|
||||||
mInputQueue->SetAllowedTouchBehavior(aInputBlockId, aValues);
|
mInputQueue->SetAllowedTouchBehavior(aInputBlockId, aValues);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
template<class ScrollNode> void // ScrollNode is a LayerMetricsWrapper
|
||||||
APZCTreeManager::UpdateHitTestingTree(uint64_t aRootLayerTreeId,
|
APZCTreeManager::UpdateHitTestingTreeImpl(uint64_t aRootLayerTreeId,
|
||||||
Layer* aRoot,
|
const ScrollNode& aRoot,
|
||||||
bool aIsFirstPaint,
|
bool aIsFirstPaint,
|
||||||
uint64_t aOriginatingLayersId,
|
uint64_t aOriginatingLayersId,
|
||||||
uint32_t aPaintSequenceNumber)
|
uint32_t aPaintSequenceNumber)
|
||||||
{
|
{
|
||||||
APZThreadUtils::AssertOnCompositorThread();
|
APZThreadUtils::AssertOnCompositorThread();
|
||||||
|
|
||||||
|
@ -268,11 +268,10 @@ APZCTreeManager::UpdateHitTestingTree(uint64_t aRootLayerTreeId,
|
||||||
ancestorTransforms.push(Matrix4x4());
|
ancestorTransforms.push(Matrix4x4());
|
||||||
|
|
||||||
mApzcTreeLog << "[start]\n";
|
mApzcTreeLog << "[start]\n";
|
||||||
LayerMetricsWrapper root(aRoot);
|
|
||||||
mTreeLock.AssertCurrentThreadOwns();
|
mTreeLock.AssertCurrentThreadOwns();
|
||||||
|
|
||||||
ForEachNode<ReverseIterator>(root,
|
ForEachNode<ReverseIterator>(aRoot,
|
||||||
[&](LayerMetricsWrapper aLayerMetrics)
|
[&](ScrollNode aLayerMetrics)
|
||||||
{
|
{
|
||||||
mApzcTreeLog << aLayerMetrics.Name() << '\t';
|
mApzcTreeLog << aLayerMetrics.Name() << '\t';
|
||||||
|
|
||||||
|
@ -308,7 +307,7 @@ APZCTreeManager::UpdateHitTestingTree(uint64_t aRootLayerTreeId,
|
||||||
layersId = (aLayerMetrics.AsRefLayer() ? aLayerMetrics.AsRefLayer()->GetReferentId() : layersId);
|
layersId = (aLayerMetrics.AsRefLayer() ? aLayerMetrics.AsRefLayer()->GetReferentId() : layersId);
|
||||||
indents.push(gfx::TreeAutoIndent(mApzcTreeLog));
|
indents.push(gfx::TreeAutoIndent(mApzcTreeLog));
|
||||||
},
|
},
|
||||||
[&](LayerMetricsWrapper aLayerMetrics)
|
[&](ScrollNode aLayerMetrics)
|
||||||
{
|
{
|
||||||
next = parent;
|
next = parent;
|
||||||
parent = parent->GetParent();
|
parent = parent->GetParent();
|
||||||
|
@ -337,11 +336,23 @@ APZCTreeManager::UpdateHitTestingTree(uint64_t aRootLayerTreeId,
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
APZCTreeManager::UpdateHitTestingTree(uint64_t aRootLayerTreeId,
|
||||||
|
Layer* aRoot,
|
||||||
|
bool aIsFirstPaint,
|
||||||
|
uint64_t aOriginatingLayersId,
|
||||||
|
uint32_t aPaintSequenceNumber)
|
||||||
|
{
|
||||||
|
LayerMetricsWrapper root(aRoot);
|
||||||
|
UpdateHitTestingTreeImpl(aRootLayerTreeId, root, aIsFirstPaint,
|
||||||
|
aOriginatingLayersId, aPaintSequenceNumber);
|
||||||
|
}
|
||||||
|
|
||||||
// Compute the clip region to be used for a layer with an APZC. This function
|
// Compute the clip region to be used for a layer with an APZC. This function
|
||||||
// is only called for layers which actually have scrollable metrics and an APZC.
|
// is only called for layers which actually have scrollable metrics and an APZC.
|
||||||
static ParentLayerIntRegion
|
template<class ScrollNode> static ParentLayerIntRegion
|
||||||
ComputeClipRegion(GeckoContentController* aController,
|
ComputeClipRegion(GeckoContentController* aController,
|
||||||
const LayerMetricsWrapper& aLayer)
|
const ScrollNode& aLayer)
|
||||||
{
|
{
|
||||||
ParentLayerIntRegion clipRegion;
|
ParentLayerIntRegion clipRegion;
|
||||||
if (aLayer.GetClipRect()) {
|
if (aLayer.GetClipRect()) {
|
||||||
|
@ -357,8 +368,8 @@ ComputeClipRegion(GeckoContentController* aController,
|
||||||
return clipRegion;
|
return clipRegion;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
template<class ScrollNode> void
|
||||||
APZCTreeManager::PrintAPZCInfo(const LayerMetricsWrapper& aLayer,
|
APZCTreeManager::PrintAPZCInfo(const ScrollNode& aLayer,
|
||||||
const AsyncPanZoomController* apzc)
|
const AsyncPanZoomController* apzc)
|
||||||
{
|
{
|
||||||
const FrameMetrics& metrics = aLayer.Metrics();
|
const FrameMetrics& metrics = aLayer.Metrics();
|
||||||
|
@ -386,8 +397,8 @@ APZCTreeManager::AttachNodeToTree(HitTestingTreeNode* aNode,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static EventRegions
|
template<class ScrollNode> static EventRegions
|
||||||
GetEventRegions(const LayerMetricsWrapper& aLayer)
|
GetEventRegions(const ScrollNode& aLayer)
|
||||||
{
|
{
|
||||||
if (aLayer.IsScrollInfoLayer()) {
|
if (aLayer.IsScrollInfoLayer()) {
|
||||||
ParentLayerIntRect compositionBounds(RoundedToInt(aLayer.Metrics().GetCompositionBounds()));
|
ParentLayerIntRect compositionBounds(RoundedToInt(aLayer.Metrics().GetCompositionBounds()));
|
||||||
|
@ -419,9 +430,9 @@ APZCTreeManager::RecycleOrCreateNode(TreeBuildingState& aState,
|
||||||
return node.forget();
|
return node.forget();
|
||||||
}
|
}
|
||||||
|
|
||||||
static EventRegionsOverride
|
template<class ScrollNode> static EventRegionsOverride
|
||||||
GetEventRegionsOverride(HitTestingTreeNode* aParent,
|
GetEventRegionsOverride(HitTestingTreeNode* aParent,
|
||||||
const LayerMetricsWrapper& aLayer)
|
const ScrollNode& aLayer)
|
||||||
{
|
{
|
||||||
// Make it so that if the flag is set on the layer tree, it automatically
|
// Make it so that if the flag is set on the layer tree, it automatically
|
||||||
// propagates to all the nodes in the corresponding subtree rooted at that
|
// propagates to all the nodes in the corresponding subtree rooted at that
|
||||||
|
@ -457,8 +468,8 @@ APZCTreeManager::NotifyScrollbarDragRejected(const ScrollableLayerGuid& aGuid) c
|
||||||
state->mController->NotifyAsyncScrollbarDragRejected(aGuid.mScrollId);
|
state->mController->NotifyAsyncScrollbarDragRejected(aGuid.mScrollId);
|
||||||
}
|
}
|
||||||
|
|
||||||
HitTestingTreeNode*
|
template<class ScrollNode> HitTestingTreeNode*
|
||||||
APZCTreeManager::PrepareNodeForLayer(const LayerMetricsWrapper& aLayer,
|
APZCTreeManager::PrepareNodeForLayer(const ScrollNode& aLayer,
|
||||||
const FrameMetrics& aMetrics,
|
const FrameMetrics& aMetrics,
|
||||||
uint64_t aLayersId,
|
uint64_t aLayersId,
|
||||||
const gfx::Matrix4x4& aAncestorTransform,
|
const gfx::Matrix4x4& aAncestorTransform,
|
||||||
|
|
|
@ -436,6 +436,13 @@ private:
|
||||||
typedef bool (*GuidComparator)(const ScrollableLayerGuid&, const ScrollableLayerGuid&);
|
typedef bool (*GuidComparator)(const ScrollableLayerGuid&, const ScrollableLayerGuid&);
|
||||||
|
|
||||||
/* Helpers */
|
/* Helpers */
|
||||||
|
template<class ScrollNode>
|
||||||
|
void UpdateHitTestingTreeImpl(uint64_t aRootLayerTreeId,
|
||||||
|
const ScrollNode& aRoot,
|
||||||
|
bool aIsFirstPaint,
|
||||||
|
uint64_t aOriginatingLayersId,
|
||||||
|
uint32_t aPaintSequenceNumber);
|
||||||
|
|
||||||
void AttachNodeToTree(HitTestingTreeNode* aNode,
|
void AttachNodeToTree(HitTestingTreeNode* aNode,
|
||||||
HitTestingTreeNode* aParent,
|
HitTestingTreeNode* aParent,
|
||||||
HitTestingTreeNode* aNextSibling);
|
HitTestingTreeNode* aNextSibling);
|
||||||
|
@ -466,7 +473,8 @@ private:
|
||||||
already_AddRefed<HitTestingTreeNode> RecycleOrCreateNode(TreeBuildingState& aState,
|
already_AddRefed<HitTestingTreeNode> RecycleOrCreateNode(TreeBuildingState& aState,
|
||||||
AsyncPanZoomController* aApzc,
|
AsyncPanZoomController* aApzc,
|
||||||
uint64_t aLayersId);
|
uint64_t aLayersId);
|
||||||
HitTestingTreeNode* PrepareNodeForLayer(const LayerMetricsWrapper& aLayer,
|
template<class ScrollNode>
|
||||||
|
HitTestingTreeNode* PrepareNodeForLayer(const ScrollNode& aLayer,
|
||||||
const FrameMetrics& aMetrics,
|
const FrameMetrics& aMetrics,
|
||||||
uint64_t aLayersId,
|
uint64_t aLayersId,
|
||||||
const gfx::Matrix4x4& aAncestorTransform,
|
const gfx::Matrix4x4& aAncestorTransform,
|
||||||
|
@ -474,7 +482,8 @@ private:
|
||||||
HitTestingTreeNode* aNextSibling,
|
HitTestingTreeNode* aNextSibling,
|
||||||
TreeBuildingState& aState);
|
TreeBuildingState& aState);
|
||||||
|
|
||||||
void PrintAPZCInfo(const LayerMetricsWrapper& aLayer,
|
template<class ScrollNode>
|
||||||
|
void PrintAPZCInfo(const ScrollNode& aLayer,
|
||||||
const AsyncPanZoomController* apzc);
|
const AsyncPanZoomController* apzc);
|
||||||
|
|
||||||
void NotifyScrollbarDragRejected(const ScrollableLayerGuid& aGuid) const;
|
void NotifyScrollbarDragRejected(const ScrollableLayerGuid& aGuid) const;
|
||||||
|
|
Загрузка…
Ссылка в новой задаче