зеркало из https://github.com/mozilla/gecko-dev.git
Make finer-grained decisions about whether to update hit testing trees. (bug 1352918
, r=kats)
Updating hit testing trees is very expensive for many layers, and often layer properties that change don't necessitate hit testing tree updates. While layer tree structure changes do, we can be smarter about individual layer attributes.
This commit is contained in:
Родитель
16e78d9ec4
Коммит
bc9324f621
|
@ -170,6 +170,27 @@ public:
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// This returns true if scrolling info is equivalent for the purposes of
|
||||||
|
// APZ hit testing.
|
||||||
|
bool HitTestingInfoIsEqual(const SimpleLayerAttributes& aOther) const {
|
||||||
|
if (mIsScrollbarContainer != aOther.mIsScrollbarContainer) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (mScrollbarTargetContainerId != aOther.mScrollbarTargetContainerId) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (mScrollbarDirection != aOther.mScrollbarDirection) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (FixedPositionScrollContainerId() != aOther.FixedPositionScrollContainerId()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (mTransform != aOther.mTransform) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Getters.
|
// Getters.
|
||||||
//
|
//
|
||||||
|
|
|
@ -480,6 +480,9 @@ APZCTreeManager::PrepareNodeForLayer(const LayerMetricsWrapper& aLayer,
|
||||||
|
|
||||||
RefPtr<HitTestingTreeNode> node = nullptr;
|
RefPtr<HitTestingTreeNode> node = nullptr;
|
||||||
if (!needsApzc) {
|
if (!needsApzc) {
|
||||||
|
// Note: if layer properties must be propagated to nodes, RecvUpdate in
|
||||||
|
// LayerTransactionParent.cpp must ensure that APZ will be notified
|
||||||
|
// when those properties change.
|
||||||
node = RecycleOrCreateNode(aState, nullptr, aLayersId);
|
node = RecycleOrCreateNode(aState, nullptr, aLayersId);
|
||||||
AttachNodeToTree(node, aParent, aNextSibling);
|
AttachNodeToTree(node, aParent, aNextSibling);
|
||||||
node->SetHitTestData(
|
node->SetHitTestData(
|
||||||
|
@ -674,6 +677,9 @@ APZCTreeManager::PrepareNodeForLayer(const LayerMetricsWrapper& aLayer,
|
||||||
GetEventRegionsOverride(aParent, aLayer));
|
GetEventRegionsOverride(aParent, aLayer));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Note: if layer properties must be propagated to nodes, RecvUpdate in
|
||||||
|
// LayerTransactionParent.cpp must ensure that APZ will be notified
|
||||||
|
// when those properties change.
|
||||||
node->SetScrollbarData(aLayer.GetScrollbarTargetContainerId(),
|
node->SetScrollbarData(aLayer.GetScrollbarTargetContainerId(),
|
||||||
aLayer.GetScrollbarDirection(),
|
aLayer.GetScrollbarDirection(),
|
||||||
aLayer.GetScrollThumbLength(),
|
aLayer.GetScrollThumbLength(),
|
||||||
|
|
|
@ -172,8 +172,8 @@ LayerTransactionParent::RecvUpdate(const TransactionInfo& aInfo)
|
||||||
layer_manager()->BeginTransaction();
|
layer_manager()->BeginTransaction();
|
||||||
}
|
}
|
||||||
|
|
||||||
// not all edits require an update to the hit testing tree
|
// Not all edits require an update to the hit testing tree.
|
||||||
bool updateHitTestingTree = false;
|
mUpdateHitTestingTree = false;
|
||||||
|
|
||||||
for (EditArray::index_type i = 0; i < aInfo.cset().Length(); ++i) {
|
for (EditArray::index_type i = 0; i < aInfo.cset().Length(); ++i) {
|
||||||
const Edit& edit = const_cast<Edit&>(aInfo.cset()[i]);
|
const Edit& edit = const_cast<Edit&>(aInfo.cset()[i]);
|
||||||
|
@ -188,7 +188,7 @@ LayerTransactionParent::RecvUpdate(const TransactionInfo& aInfo)
|
||||||
return IPC_FAIL_NO_REASON(this);
|
return IPC_FAIL_NO_REASON(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
updateHitTestingTree = true;
|
UpdateHitTestingTree(layer, "CreatePaintedLayer");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case Edit::TOpCreateContainerLayer: {
|
case Edit::TOpCreateContainerLayer: {
|
||||||
|
@ -199,7 +199,7 @@ LayerTransactionParent::RecvUpdate(const TransactionInfo& aInfo)
|
||||||
return IPC_FAIL_NO_REASON(this);
|
return IPC_FAIL_NO_REASON(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
updateHitTestingTree = true;
|
UpdateHitTestingTree(layer, "CreateContainerLayer");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case Edit::TOpCreateImageLayer: {
|
case Edit::TOpCreateImageLayer: {
|
||||||
|
@ -210,7 +210,7 @@ LayerTransactionParent::RecvUpdate(const TransactionInfo& aInfo)
|
||||||
return IPC_FAIL_NO_REASON(this);
|
return IPC_FAIL_NO_REASON(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
updateHitTestingTree = true;
|
UpdateHitTestingTree(layer, "CreateImageLayer");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case Edit::TOpCreateColorLayer: {
|
case Edit::TOpCreateColorLayer: {
|
||||||
|
@ -221,7 +221,7 @@ LayerTransactionParent::RecvUpdate(const TransactionInfo& aInfo)
|
||||||
return IPC_FAIL_NO_REASON(this);
|
return IPC_FAIL_NO_REASON(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
updateHitTestingTree = true;
|
UpdateHitTestingTree(layer, "CreateColorLayer");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case Edit::TOpCreateTextLayer: {
|
case Edit::TOpCreateTextLayer: {
|
||||||
|
@ -232,18 +232,18 @@ LayerTransactionParent::RecvUpdate(const TransactionInfo& aInfo)
|
||||||
return IPC_FAIL_NO_REASON(this);
|
return IPC_FAIL_NO_REASON(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
updateHitTestingTree = true;
|
UpdateHitTestingTree(layer, "CreateTextLayer");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case Edit::TOpCreateBorderLayer: {
|
case Edit::TOpCreateBorderLayer: {
|
||||||
MOZ_LAYERS_LOG(("[ParentSide] CreateTextLayer"));
|
MOZ_LAYERS_LOG(("[ParentSide] CreateBorderLayer"));
|
||||||
|
|
||||||
RefPtr<BorderLayer> layer = layer_manager()->CreateBorderLayer();
|
RefPtr<BorderLayer> layer = layer_manager()->CreateBorderLayer();
|
||||||
if (!BindLayer(layer, edit.get_OpCreateBorderLayer())) {
|
if (!BindLayer(layer, edit.get_OpCreateBorderLayer())) {
|
||||||
return IPC_FAIL_NO_REASON(this);
|
return IPC_FAIL_NO_REASON(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
updateHitTestingTree = true;
|
UpdateHitTestingTree(layer, "CreateBorderLayer");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case Edit::TOpCreateCanvasLayer: {
|
case Edit::TOpCreateCanvasLayer: {
|
||||||
|
@ -254,7 +254,7 @@ LayerTransactionParent::RecvUpdate(const TransactionInfo& aInfo)
|
||||||
return IPC_FAIL_NO_REASON(this);
|
return IPC_FAIL_NO_REASON(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
updateHitTestingTree = true;
|
UpdateHitTestingTree(layer, "CreateCanvasLayer");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case Edit::TOpCreateRefLayer: {
|
case Edit::TOpCreateRefLayer: {
|
||||||
|
@ -265,7 +265,7 @@ LayerTransactionParent::RecvUpdate(const TransactionInfo& aInfo)
|
||||||
return IPC_FAIL_NO_REASON(this);
|
return IPC_FAIL_NO_REASON(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
updateHitTestingTree = true;
|
UpdateHitTestingTree(layer, "CreateRefLayer");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case Edit::TOpSetDiagnosticTypes: {
|
case Edit::TOpSetDiagnosticTypes: {
|
||||||
|
@ -291,7 +291,7 @@ LayerTransactionParent::RecvUpdate(const TransactionInfo& aInfo)
|
||||||
}
|
}
|
||||||
mRoot = newRoot;
|
mRoot = newRoot;
|
||||||
|
|
||||||
updateHitTestingTree = true;
|
UpdateHitTestingTree(mRoot, "SetRoot");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case Edit::TOpInsertAfter: {
|
case Edit::TOpInsertAfter: {
|
||||||
|
@ -309,7 +309,7 @@ LayerTransactionParent::RecvUpdate(const TransactionInfo& aInfo)
|
||||||
return IPC_FAIL_NO_REASON(this);
|
return IPC_FAIL_NO_REASON(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
updateHitTestingTree = true;
|
UpdateHitTestingTree(layer, "InsertAfter");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case Edit::TOpPrependChild: {
|
case Edit::TOpPrependChild: {
|
||||||
|
@ -326,7 +326,7 @@ LayerTransactionParent::RecvUpdate(const TransactionInfo& aInfo)
|
||||||
return IPC_FAIL_NO_REASON(this);
|
return IPC_FAIL_NO_REASON(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
updateHitTestingTree = true;
|
UpdateHitTestingTree(layer, "PrependChild");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case Edit::TOpRemoveChild: {
|
case Edit::TOpRemoveChild: {
|
||||||
|
@ -343,7 +343,7 @@ LayerTransactionParent::RecvUpdate(const TransactionInfo& aInfo)
|
||||||
return IPC_FAIL_NO_REASON(this);
|
return IPC_FAIL_NO_REASON(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
updateHitTestingTree = true;
|
UpdateHitTestingTree(layer, "RemoveChild");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case Edit::TOpRepositionChild: {
|
case Edit::TOpRepositionChild: {
|
||||||
|
@ -361,7 +361,7 @@ LayerTransactionParent::RecvUpdate(const TransactionInfo& aInfo)
|
||||||
return IPC_FAIL_NO_REASON(this);
|
return IPC_FAIL_NO_REASON(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
updateHitTestingTree = true;
|
UpdateHitTestingTree(layer, "RepositionChild");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case Edit::TOpRaiseToTopChild: {
|
case Edit::TOpRaiseToTopChild: {
|
||||||
|
@ -381,7 +381,7 @@ LayerTransactionParent::RecvUpdate(const TransactionInfo& aInfo)
|
||||||
return IPC_FAIL_NO_REASON(this);
|
return IPC_FAIL_NO_REASON(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
updateHitTestingTree = true;
|
UpdateHitTestingTree(layer, "RaiseToTopChild");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case Edit::TCompositableOperation: {
|
case Edit::TCompositableOperation: {
|
||||||
|
@ -446,8 +446,12 @@ LayerTransactionParent::RecvUpdate(const TransactionInfo& aInfo)
|
||||||
if (!layer) {
|
if (!layer) {
|
||||||
return IPC_FAIL_NO_REASON(this);
|
return IPC_FAIL_NO_REASON(this);
|
||||||
}
|
}
|
||||||
|
const SimpleLayerAttributes& attrs = op.attrs();
|
||||||
|
const SimpleLayerAttributes& orig = layer->GetSimpleAttributes();
|
||||||
|
if (!attrs.HitTestingInfoIsEqual(orig)) {
|
||||||
|
UpdateHitTestingTree(layer, "scrolling info changed");
|
||||||
|
}
|
||||||
layer->SetSimpleAttributes(op.attrs());
|
layer->SetSimpleAttributes(op.attrs());
|
||||||
updateHitTestingTree = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Process attribute updates.
|
// Process attribute updates.
|
||||||
|
@ -456,7 +460,6 @@ LayerTransactionParent::RecvUpdate(const TransactionInfo& aInfo)
|
||||||
if (!SetLayerAttributes(op)) {
|
if (!SetLayerAttributes(op)) {
|
||||||
return IPC_FAIL_NO_REASON(this);
|
return IPC_FAIL_NO_REASON(this);
|
||||||
}
|
}
|
||||||
updateHitTestingTree = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Process paints separately, after all normal edits.
|
// Process paints separately, after all normal edits.
|
||||||
|
@ -466,7 +469,7 @@ LayerTransactionParent::RecvUpdate(const TransactionInfo& aInfo)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
mCompositorBridge->ShadowLayersUpdated(this, aInfo, updateHitTestingTree);
|
mCompositorBridge->ShadowLayersUpdated(this, aInfo, mUpdateHitTestingTree);
|
||||||
|
|
||||||
{
|
{
|
||||||
AutoResolveRefLayers resolve(mCompositorBridge->GetCompositionManager(this));
|
AutoResolveRefLayers resolve(mCompositorBridge->GetCompositionManager(this));
|
||||||
|
@ -521,16 +524,29 @@ LayerTransactionParent::SetLayerAttributes(const OpSetLayerAttributes& aOp)
|
||||||
|
|
||||||
const LayerAttributes& attrs = aOp.attrs();
|
const LayerAttributes& attrs = aOp.attrs();
|
||||||
const CommonLayerAttributes& common = attrs.common();
|
const CommonLayerAttributes& common = attrs.common();
|
||||||
layer->SetVisibleRegion(common.visibleRegion());
|
if (common.visibleRegion() != layer->GetVisibleRegion()) {
|
||||||
layer->SetEventRegions(common.eventRegions());
|
UpdateHitTestingTree(layer, "visible region changed");
|
||||||
layer->SetClipRect(common.useClipRect() ? Some(common.clipRect()) : Nothing());
|
layer->SetVisibleRegion(common.visibleRegion());
|
||||||
|
}
|
||||||
|
if (common.eventRegions() != layer->GetEventRegions()) {
|
||||||
|
UpdateHitTestingTree(layer, "event regions changed");
|
||||||
|
layer->SetEventRegions(common.eventRegions());
|
||||||
|
}
|
||||||
|
Maybe<ParentLayerIntRect> clipRect = common.useClipRect() ? Some(common.clipRect()) : Nothing();
|
||||||
|
if (clipRect != layer->GetClipRect()) {
|
||||||
|
UpdateHitTestingTree(layer, "clip rect changed");
|
||||||
|
layer->SetClipRect(clipRect);
|
||||||
|
}
|
||||||
if (LayerHandle maskLayer = common.maskLayer()) {
|
if (LayerHandle maskLayer = common.maskLayer()) {
|
||||||
layer->SetMaskLayer(AsLayer(maskLayer));
|
layer->SetMaskLayer(AsLayer(maskLayer));
|
||||||
} else {
|
} else {
|
||||||
layer->SetMaskLayer(nullptr);
|
layer->SetMaskLayer(nullptr);
|
||||||
}
|
}
|
||||||
layer->SetCompositorAnimations(common.compositorAnimations());
|
layer->SetCompositorAnimations(common.compositorAnimations());
|
||||||
layer->SetScrollMetadata(common.scrollMetadata());
|
if (common.scrollMetadata() != layer->GetAllScrollMetadata()) {
|
||||||
|
UpdateHitTestingTree(layer, "scroll metadata changed");
|
||||||
|
layer->SetScrollMetadata(common.scrollMetadata());
|
||||||
|
}
|
||||||
layer->SetDisplayListLog(common.displayListLog().get());
|
layer->SetDisplayListLog(common.displayListLog().get());
|
||||||
|
|
||||||
// The updated invalid region is added to the existing one, since we can
|
// The updated invalid region is added to the existing one, since we can
|
||||||
|
@ -579,8 +595,10 @@ LayerTransactionParent::SetLayerAttributes(const OpSetLayerAttributes& aOp)
|
||||||
containerLayer->SetInheritedScale(attrs.inheritedXScale(), attrs.inheritedYScale());
|
containerLayer->SetInheritedScale(attrs.inheritedXScale(), attrs.inheritedYScale());
|
||||||
containerLayer->SetScaleToResolution(attrs.scaleToResolution(),
|
containerLayer->SetScaleToResolution(attrs.scaleToResolution(),
|
||||||
attrs.presShellResolution());
|
attrs.presShellResolution());
|
||||||
containerLayer->SetEventRegionsOverride(attrs.eventRegionsOverride());
|
if (attrs.eventRegionsOverride() != containerLayer->GetEventRegionsOverride()) {
|
||||||
|
UpdateHitTestingTree(layer, "event regions override changed");
|
||||||
|
containerLayer->SetEventRegionsOverride(attrs.eventRegionsOverride());
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case Specific::TColorLayerAttributes: {
|
case Specific::TColorLayerAttributes: {
|
||||||
|
@ -640,6 +658,7 @@ LayerTransactionParent::SetLayerAttributes(const OpSetLayerAttributes& aOp)
|
||||||
}
|
}
|
||||||
refLayer->SetReferentId(specific.get_RefLayerAttributes().id());
|
refLayer->SetReferentId(specific.get_RefLayerAttributes().id());
|
||||||
refLayer->SetEventRegionsOverride(specific.get_RefLayerAttributes().eventRegionsOverride());
|
refLayer->SetEventRegionsOverride(specific.get_RefLayerAttributes().eventRegionsOverride());
|
||||||
|
UpdateHitTestingTree(layer, "event regions override changed");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case Specific::TImageLayerAttributes: {
|
case Specific::TImageLayerAttributes: {
|
||||||
|
|
|
@ -171,6 +171,13 @@ protected:
|
||||||
friend class CrossProcessCompositorBridgeParent;
|
friend class CrossProcessCompositorBridgeParent;
|
||||||
friend class layout::RenderFrameParent;
|
friend class layout::RenderFrameParent;
|
||||||
|
|
||||||
|
private:
|
||||||
|
// This is a function so we can log or breakpoint on why hit
|
||||||
|
// testing tree changes are made.
|
||||||
|
void UpdateHitTestingTree(Layer* aLayer, const char* aWhy) {
|
||||||
|
mUpdateHitTestingTree = true;
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
RefPtr<HostLayerManager> mLayerManager;
|
RefPtr<HostLayerManager> mLayerManager;
|
||||||
CompositorBridgeParentBase* mCompositorBridge;
|
CompositorBridgeParentBase* mCompositorBridge;
|
||||||
|
@ -216,8 +223,11 @@ private:
|
||||||
// transactions posted by the child.
|
// transactions posted by the child.
|
||||||
|
|
||||||
bool mDestroyed;
|
bool mDestroyed;
|
||||||
|
|
||||||
bool mIPCOpen;
|
bool mIPCOpen;
|
||||||
|
|
||||||
|
// This is set during RecvUpdate to track whether we'll need to update
|
||||||
|
// APZ's hit test regions.
|
||||||
|
bool mUpdateHitTestingTree;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace layers
|
} // namespace layers
|
||||||
|
|
Загрузка…
Ссылка в новой задаче