diff --git a/gfx/layers/apz/public/APZSampler.h b/gfx/layers/apz/public/APZSampler.h index ae8695b46286..fcf2015ce647 100644 --- a/gfx/layers/apz/public/APZSampler.h +++ b/gfx/layers/apz/public/APZSampler.h @@ -63,6 +63,13 @@ public: bool GetAPZTestData(uint64_t aLayersId, APZTestData* aOutData); + void SetTestAsyncScrollOffset(uint64_t aLayersId, + const FrameMetrics::ViewID& aScrollId, + const CSSPoint& aOffset); + void SetTestAsyncZoom(uint64_t aLayersId, + const FrameMetrics::ViewID& aScrollId, + const LayerToParentLayerScale& aZoom); + protected: virtual ~APZSampler(); diff --git a/gfx/layers/apz/src/APZSampler.cpp b/gfx/layers/apz/src/APZSampler.cpp index 304441638855..3a542c3867a7 100644 --- a/gfx/layers/apz/src/APZSampler.cpp +++ b/gfx/layers/apz/src/APZSampler.cpp @@ -95,5 +95,33 @@ APZSampler::GetAPZTestData(uint64_t aLayersId, return mApz->GetAPZTestData(aLayersId, aOutData); } +void +APZSampler::SetTestAsyncScrollOffset(uint64_t aLayersId, + const FrameMetrics::ViewID& aScrollId, + const CSSPoint& aOffset) +{ + MOZ_ASSERT(CompositorThreadHolder::IsInCompositorThread()); + RefPtr apzc = mApz->GetTargetAPZC(aLayersId, aScrollId); + if (apzc) { + apzc->SetTestAsyncScrollOffset(aOffset); + } else { + NS_WARNING("Unable to find APZC in SetTestAsyncScrollOffset"); + } +} + +void +APZSampler::SetTestAsyncZoom(uint64_t aLayersId, + const FrameMetrics::ViewID& aScrollId, + const LayerToParentLayerScale& aZoom) +{ + MOZ_ASSERT(CompositorThreadHolder::IsInCompositorThread()); + RefPtr apzc = mApz->GetTargetAPZC(aLayersId, aScrollId); + if (apzc) { + apzc->SetTestAsyncZoom(aZoom); + } else { + NS_WARNING("Unable to find APZC in SetTestAsyncZoom"); + } +} + } // namespace layers } // namespace mozilla diff --git a/gfx/layers/ipc/CompositorBridgeParent.cpp b/gfx/layers/ipc/CompositorBridgeParent.cpp index d628ec9f1f21..61108cd2eb3d 100644 --- a/gfx/layers/ipc/CompositorBridgeParent.cpp +++ b/gfx/layers/ipc/CompositorBridgeParent.cpp @@ -1378,6 +1378,30 @@ CompositorBridgeParent::RecvGetFrameUniformity(FrameUniformityData* aOutData) return IPC_OK(); } +void +CompositorBridgeParent::SetTestAsyncScrollOffset( + const uint64_t& aLayersId, + const FrameMetrics::ViewID& aScrollId, + const CSSPoint& aPoint) +{ + if (mApzSampler) { + uint64_t layersId = (aLayersId == 0 ? mRootLayerTreeID : aLayersId); + mApzSampler->SetTestAsyncScrollOffset(layersId, aScrollId, aPoint); + } +} + +void +CompositorBridgeParent::SetTestAsyncZoom( + const uint64_t& aLayersId, + const FrameMetrics::ViewID& aScrollId, + const LayerToParentLayerScale& aZoom) +{ + if (mApzSampler) { + uint64_t layersId = (aLayersId == 0 ? mRootLayerTreeID : aLayersId); + mApzSampler->SetTestAsyncZoom(layersId, aScrollId, aZoom); + } +} + void CompositorBridgeParent::FlushApzRepaints(const uint64_t& aLayersId) { diff --git a/gfx/layers/ipc/CompositorBridgeParent.h b/gfx/layers/ipc/CompositorBridgeParent.h index d68107b91eed..a244d83d7e20 100644 --- a/gfx/layers/ipc/CompositorBridgeParent.h +++ b/gfx/layers/ipc/CompositorBridgeParent.h @@ -114,6 +114,12 @@ public: const TimeStamp& aTime) { return true; } virtual void LeaveTestMode(const uint64_t& aId) { } virtual void ApplyAsyncProperties(LayerTransactionParent* aLayerTree) = 0; + virtual void SetTestAsyncScrollOffset(const uint64_t& aLayersId, + const FrameMetrics::ViewID& aScrollId, + const CSSPoint& aPoint) = 0; + virtual void SetTestAsyncZoom(const uint64_t& aLayersId, + const FrameMetrics::ViewID& aScrollId, + const LayerToParentLayerScale& aZoom) = 0; virtual void FlushApzRepaints(const uint64_t& aLayersId) = 0; virtual void GetAPZTestData(const uint64_t& aLayersId, APZTestData* aOutData) { } @@ -248,6 +254,12 @@ public: void LeaveTestMode(const uint64_t& aId) override; void ApplyAsyncProperties(LayerTransactionParent* aLayerTree) override; CompositorAnimationStorage* GetAnimationStorage(); + void SetTestAsyncScrollOffset(const uint64_t& aLayersId, + const FrameMetrics::ViewID& aScrollId, + const CSSPoint& aPoint) override; + void SetTestAsyncZoom(const uint64_t& aLayersId, + const FrameMetrics::ViewID& aScrollId, + const LayerToParentLayerScale& aZoom) override; void FlushApzRepaints(const uint64_t& aLayersId) override; void GetAPZTestData(const uint64_t& aLayersId, APZTestData* aOutData) override; diff --git a/gfx/layers/ipc/CrossProcessCompositorBridgeParent.cpp b/gfx/layers/ipc/CrossProcessCompositorBridgeParent.cpp index 69d78c3df0f2..35eb0334e432 100644 --- a/gfx/layers/ipc/CrossProcessCompositorBridgeParent.cpp +++ b/gfx/layers/ipc/CrossProcessCompositorBridgeParent.cpp @@ -463,6 +463,40 @@ CrossProcessCompositorBridgeParent::ApplyAsyncProperties( state->mParent->ApplyAsyncProperties(aLayerTree); } +void +CrossProcessCompositorBridgeParent::SetTestAsyncScrollOffset( + const uint64_t& aLayersId, + const FrameMetrics::ViewID& aScrollId, + const CSSPoint& aPoint) +{ + MOZ_ASSERT(aLayersId != 0); + const CompositorBridgeParent::LayerTreeState* state = + CompositorBridgeParent::GetIndirectShadowTree(aLayersId); + if (!state) { + return; + } + + MOZ_ASSERT(state->mParent); + state->mParent->SetTestAsyncScrollOffset(aLayersId, aScrollId, aPoint); +} + +void +CrossProcessCompositorBridgeParent::SetTestAsyncZoom( + const uint64_t& aLayersId, + const FrameMetrics::ViewID& aScrollId, + const LayerToParentLayerScale& aZoom) +{ + MOZ_ASSERT(aLayersId != 0); + const CompositorBridgeParent::LayerTreeState* state = + CompositorBridgeParent::GetIndirectShadowTree(aLayersId); + if (!state) { + return; + } + + MOZ_ASSERT(state->mParent); + state->mParent->SetTestAsyncZoom(aLayersId, aScrollId, aZoom); +} + void CrossProcessCompositorBridgeParent::FlushApzRepaints(const uint64_t& aLayersId) { diff --git a/gfx/layers/ipc/CrossProcessCompositorBridgeParent.h b/gfx/layers/ipc/CrossProcessCompositorBridgeParent.h index 2d7da3ac5bab..1622574d59da 100644 --- a/gfx/layers/ipc/CrossProcessCompositorBridgeParent.h +++ b/gfx/layers/ipc/CrossProcessCompositorBridgeParent.h @@ -95,6 +95,12 @@ public: const TimeStamp& aTime) override; void LeaveTestMode(const uint64_t& aId) override; void ApplyAsyncProperties(LayerTransactionParent* aLayerTree) override; + void SetTestAsyncScrollOffset(const uint64_t& aLayersId, + const FrameMetrics::ViewID& aScrollId, + const CSSPoint& aPoint) override; + void SetTestAsyncZoom(const uint64_t& aLayersId, + const FrameMetrics::ViewID& aScrollId, + const LayerToParentLayerScale& aZoom) override; void FlushApzRepaints(const uint64_t& aLayersId) override; void GetAPZTestData(const uint64_t& aLayersId, APZTestData* aOutData) override; diff --git a/gfx/layers/ipc/LayerTransactionParent.cpp b/gfx/layers/ipc/LayerTransactionParent.cpp index dc043ce78c14..b0d24e86456c 100644 --- a/gfx/layers/ipc/LayerTransactionParent.cpp +++ b/gfx/layers/ipc/LayerTransactionParent.cpp @@ -6,7 +6,6 @@ #include "LayerTransactionParent.h" #include // for vector -#include "apz/src/AsyncPanZoomController.h" #include "CompositableHost.h" // for CompositableParent, Get, etc #include "ImageLayers.h" // for ImageLayer #include "Layers.h" // for Layer, ContainerLayer, etc @@ -751,25 +750,6 @@ LayerTransactionParent::RecvGetAnimationTransform(const uint64_t& aCompositorAni return IPC_OK(); } -static AsyncPanZoomController* -GetAPZCForViewID(Layer* aLayer, FrameMetrics::ViewID aScrollID) -{ - AsyncPanZoomController* resultApzc = nullptr; - ForEachNode( - aLayer, - [aScrollID, &resultApzc] (Layer* layer) - { - for (uint32_t i = 0; i < layer->GetScrollMetadataCount(); i++) { - if (layer->GetFrameMetrics(i).GetScrollId() == aScrollID) { - resultApzc = layer->GetAsyncPanZoomController(i); - return TraversalFlag::Abort; - } - } - return TraversalFlag::Continue; - }); - return resultApzc; -} - mozilla::ipc::IPCResult LayerTransactionParent::RecvSetAsyncScrollOffset(const FrameMetrics::ViewID& aScrollID, const float& aX, const float& aY) @@ -778,11 +758,7 @@ LayerTransactionParent::RecvSetAsyncScrollOffset(const FrameMetrics::ViewID& aSc return IPC_FAIL_NO_REASON(this); } - AsyncPanZoomController* controller = GetAPZCForViewID(mRoot, aScrollID); - if (!controller) { - return IPC_FAIL_NO_REASON(this); - } - controller->SetTestAsyncScrollOffset(CSSPoint(aX, aY)); + mCompositorBridge->SetTestAsyncScrollOffset(GetId(), aScrollID, CSSPoint(aX, aY)); return IPC_OK(); } @@ -794,11 +770,7 @@ LayerTransactionParent::RecvSetAsyncZoom(const FrameMetrics::ViewID& aScrollID, return IPC_FAIL_NO_REASON(this); } - AsyncPanZoomController* controller = GetAPZCForViewID(mRoot, aScrollID); - if (!controller) { - return IPC_FAIL_NO_REASON(this); - } - controller->SetTestAsyncZoom(LayerToParentLayerScale(aValue)); + mCompositorBridge->SetTestAsyncZoom(GetId(), aScrollID, LayerToParentLayerScale(aValue)); return IPC_OK(); } diff --git a/gfx/layers/wr/WebRenderBridgeParent.cpp b/gfx/layers/wr/WebRenderBridgeParent.cpp index c4554496105d..16574dbcfdd9 100644 --- a/gfx/layers/wr/WebRenderBridgeParent.cpp +++ b/gfx/layers/wr/WebRenderBridgeParent.cpp @@ -6,7 +6,6 @@ #include "mozilla/layers/WebRenderBridgeParent.h" -#include "apz/src/AsyncPanZoomController.h" #include "CompositableHost.h" #include "gfxEnv.h" #include "gfxPrefs.h" @@ -16,7 +15,6 @@ #include "GLContextProvider.h" #include "mozilla/Range.h" #include "mozilla/layers/AnimationHelper.h" -#include "mozilla/layers/APZCTreeManager.h" #include "mozilla/layers/APZSampler.h" #include "mozilla/layers/Compositor.h" #include "mozilla/layers/CompositorBridgeParent.h" @@ -1017,18 +1015,6 @@ WebRenderBridgeParent::RecvCapture() return IPC_OK(); } -already_AddRefed -WebRenderBridgeParent::GetTargetAPZC(const FrameMetrics::ViewID& aScrollId) -{ - RefPtr apzc; - if (CompositorBridgeParent* cbp = GetRootCompositorBridgeParent()) { - if (RefPtr apzctm = cbp->GetAPZCTreeManager()) { - apzc = apzctm->GetTargetAPZC(GetLayersId(), aScrollId); - } - } - return apzc.forget(); -} - mozilla::ipc::IPCResult WebRenderBridgeParent::RecvSetConfirmedTargetAPZC(const uint64_t& aBlockId, nsTArray&& aTargets) @@ -1106,11 +1092,7 @@ WebRenderBridgeParent::RecvSetAsyncScrollOffset(const FrameMetrics::ViewID& aScr if (mDestroyed) { return IPC_OK(); } - RefPtr apzc = GetTargetAPZC(aScrollId); - if (!apzc) { - return IPC_FAIL_NO_REASON(this); - } - apzc->SetTestAsyncScrollOffset(CSSPoint(aX, aY)); + mCompositorBridge->SetTestAsyncScrollOffset(GetLayersId(), aScrollId, CSSPoint(aX, aY)); return IPC_OK(); } @@ -1121,11 +1103,7 @@ WebRenderBridgeParent::RecvSetAsyncZoom(const FrameMetrics::ViewID& aScrollId, if (mDestroyed) { return IPC_OK(); } - RefPtr apzc = GetTargetAPZC(aScrollId); - if (!apzc) { - return IPC_FAIL_NO_REASON(this); - } - apzc->SetTestAsyncZoom(LayerToParentLayerScale(aZoom)); + mCompositorBridge->SetTestAsyncZoom(GetLayersId(), aScrollId, LayerToParentLayerScale(aZoom)); return IPC_OK(); } diff --git a/gfx/layers/wr/WebRenderBridgeParent.h b/gfx/layers/wr/WebRenderBridgeParent.h index 825b8c82286a..452a3454283a 100644 --- a/gfx/layers/wr/WebRenderBridgeParent.h +++ b/gfx/layers/wr/WebRenderBridgeParent.h @@ -228,10 +228,6 @@ private: bool PushAPZStateToWR(wr::TransactionBuilder& aTxn, nsTArray& aTransformArray); - // Helper method to get an APZC reference from a scroll id. Uses the layers - // id of this bridge, and may return null if the APZC wasn't found. - already_AddRefed GetTargetAPZC(const FrameMetrics::ViewID& aId); - uint32_t GetNextWrEpoch(); private: