diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-06-12 05:35:29 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-06-12 05:35:29 +0000 |
commit | 59203c63bb777a3bacec32fb8830fba33540e809 (patch) | |
tree | 58298e711c0ff0575818c30485b44a2f21bf28a0 /gfx/layers/ipc | |
parent | Adding upstream version 126.0.1. (diff) | |
download | firefox-59203c63bb777a3bacec32fb8830fba33540e809.tar.xz firefox-59203c63bb777a3bacec32fb8830fba33540e809.zip |
Adding upstream version 127.0.upstream/127.0
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'gfx/layers/ipc')
-rw-r--r-- | gfx/layers/ipc/APZCTreeManagerChild.cpp | 42 | ||||
-rw-r--r-- | gfx/layers/ipc/APZCTreeManagerChild.h | 7 | ||||
-rw-r--r-- | gfx/layers/ipc/APZInputBridgeChild.cpp | 74 | ||||
-rw-r--r-- | gfx/layers/ipc/APZInputBridgeChild.h | 22 | ||||
-rw-r--r-- | gfx/layers/ipc/APZInputBridgeParent.cpp | 10 | ||||
-rw-r--r-- | gfx/layers/ipc/APZInputBridgeParent.h | 3 | ||||
-rw-r--r-- | gfx/layers/ipc/CanvasChild.cpp | 9 | ||||
-rw-r--r-- | gfx/layers/ipc/CanvasTranslator.cpp | 47 | ||||
-rw-r--r-- | gfx/layers/ipc/CompositorBridgeParent.cpp | 22 | ||||
-rw-r--r-- | gfx/layers/ipc/CompositorBridgeParent.h | 15 | ||||
-rw-r--r-- | gfx/layers/ipc/PAPZCTreeManager.ipdl | 4 | ||||
-rw-r--r-- | gfx/layers/ipc/PAPZInputBridge.ipdl | 8 | ||||
-rw-r--r-- | gfx/layers/ipc/RemoteContentController.cpp | 62 | ||||
-rw-r--r-- | gfx/layers/ipc/RemoteContentController.h | 8 |
14 files changed, 230 insertions, 103 deletions
diff --git a/gfx/layers/ipc/APZCTreeManagerChild.cpp b/gfx/layers/ipc/APZCTreeManagerChild.cpp index b7f50c1c92..5dec4ca065 100644 --- a/gfx/layers/ipc/APZCTreeManagerChild.cpp +++ b/gfx/layers/ipc/APZCTreeManagerChild.cpp @@ -31,6 +31,9 @@ void APZCTreeManagerChild::SetCompositorSession( // we're setting mCompositorSession or we're clearing it). MOZ_ASSERT(!mCompositorSession ^ !aSession); mCompositorSession = aSession; + if (mInputBridge) { + mInputBridge->SetCompositorSession(aSession); + } } void APZCTreeManagerChild::SetInputBridge(APZInputBridgeChild* aInputBridge) { @@ -143,45 +146,6 @@ void APZCTreeManagerChild::ActorDestroy(ActorDestroyReason aWhy) { mIPCOpen = false; } -mozilla::ipc::IPCResult APZCTreeManagerChild::RecvHandleTap( - const TapType& aType, const LayoutDevicePoint& aPoint, - const Modifiers& aModifiers, const ScrollableLayerGuid& aGuid, - const uint64_t& aInputBlockId, - const Maybe<DoubleTapToZoomMetrics>& aDoubleTapToZoomMetrics) { - MOZ_ASSERT(XRE_IsParentProcess()); - if (mCompositorSession && - mCompositorSession->RootLayerTreeId() == aGuid.mLayersId && - mCompositorSession->GetContentController()) { - RefPtr<GeckoContentController> controller = - mCompositorSession->GetContentController(); - controller->HandleTap(aType, aPoint, aModifiers, aGuid, aInputBlockId, - aDoubleTapToZoomMetrics); - return IPC_OK(); - } - dom::BrowserParent* tab = - dom::BrowserParent::GetBrowserParentFromLayersId(aGuid.mLayersId); - if (tab) { -#ifdef MOZ_WIDGET_ANDROID - // On Android, touch events are dispatched from the UI thread to the main - // thread using the Android priority queue. It is possible that this tap has - // made it to the GPU process and back before they have been processed. We - // must therefore dispatch this message to the same queue, otherwise the tab - // may receive the tap event before the touch events that synthesized it. - mozilla::jni::DispatchToGeckoPriorityQueue( - NewRunnableMethod<TapType, LayoutDevicePoint, Modifiers, - ScrollableLayerGuid, uint64_t, - Maybe<DoubleTapToZoomMetrics>>( - "dom::BrowserParent::SendHandleTap", tab, - &dom::BrowserParent::SendHandleTap, aType, aPoint, aModifiers, - aGuid, aInputBlockId, aDoubleTapToZoomMetrics)); -#else - tab->SendHandleTap(aType, aPoint, aModifiers, aGuid, aInputBlockId, - aDoubleTapToZoomMetrics); -#endif - } - return IPC_OK(); -} - mozilla::ipc::IPCResult APZCTreeManagerChild::RecvNotifyPinchGesture( const PinchGestureType& aType, const ScrollableLayerGuid& aGuid, const LayoutDevicePoint& aFocusPoint, const LayoutDeviceCoord& aSpanChange, diff --git a/gfx/layers/ipc/APZCTreeManagerChild.h b/gfx/layers/ipc/APZCTreeManagerChild.h index 756677e1e3..4d79a18d5a 100644 --- a/gfx/layers/ipc/APZCTreeManagerChild.h +++ b/gfx/layers/ipc/APZCTreeManagerChild.h @@ -73,13 +73,6 @@ class APZCTreeManagerChild : public IAPZCTreeManager, void ActorDestroy(ActorDestroyReason aWhy) override; protected: - MOZ_CAN_RUN_SCRIPT_BOUNDARY - mozilla::ipc::IPCResult RecvHandleTap( - const TapType& aType, const LayoutDevicePoint& aPoint, - const Modifiers& aModifiers, const ScrollableLayerGuid& aGuid, - const uint64_t& aInputBlockId, - const Maybe<DoubleTapToZoomMetrics>& aDoubleTapToZoomMetrics); - mozilla::ipc::IPCResult RecvNotifyPinchGesture( const PinchGestureType& aType, const ScrollableLayerGuid& aGuid, const LayoutDevicePoint& aFocusPoint, diff --git a/gfx/layers/ipc/APZInputBridgeChild.cpp b/gfx/layers/ipc/APZInputBridgeChild.cpp index bf059143ec..f9de8575a6 100644 --- a/gfx/layers/ipc/APZInputBridgeChild.cpp +++ b/gfx/layers/ipc/APZInputBridgeChild.cpp @@ -12,6 +12,14 @@ #include "mozilla/layers/APZThreadUtils.h" #include "mozilla/layers/SynchronousTask.h" +#include "mozilla/layers/GeckoContentController.h" // for GeckoContentController +#include "mozilla/layers/DoubleTapToZoom.h" // for DoubleTapToZoomMetrics +#include "mozilla/layers/RemoteCompositorSession.h" // for RemoteCompositorSession +#include "mozilla/dom/BrowserParent.h" // for BrowserParent +#ifdef MOZ_WIDGET_ANDROID +# include "mozilla/jni/Utils.h" // for DispatchToGeckoPriorityQueue +#endif + namespace mozilla { namespace layers { @@ -31,13 +39,20 @@ RefPtr<APZInputBridgeChild> APZInputBridgeChild::Create( } APZInputBridgeChild::APZInputBridgeChild(const uint64_t& aProcessToken) - : mIsOpen(false), mProcessToken(aProcessToken) { + : mIsOpen(false), + mProcessToken(aProcessToken), + mCompositorSession(nullptr) { MOZ_ASSERT(XRE_IsParentProcess()); MOZ_ASSERT(NS_IsMainThread()); } APZInputBridgeChild::~APZInputBridgeChild() = default; +void APZInputBridgeChild::SetCompositorSession( + RemoteCompositorSession* aSession) { + mCompositorSession = aSession; +} + void APZInputBridgeChild::Open(Endpoint<PAPZInputBridgeChild>&& aEndpoint) { APZThreadUtils::AssertOnControllerThread(); @@ -176,6 +191,63 @@ APZEventResult APZInputBridgeChild::ReceiveInputEvent( return res; } +void APZInputBridgeChild::HandleTapOnMainThread( + const TapType& aType, const LayoutDevicePoint& aPoint, + const Modifiers& aModifiers, const ScrollableLayerGuid& aGuid, + const uint64_t& aInputBlockId, + const Maybe<DoubleTapToZoomMetrics>& aDoubleTapToZoomMetrics) { + if (mCompositorSession && + mCompositorSession->RootLayerTreeId() == aGuid.mLayersId && + mCompositorSession->GetContentController()) { + RefPtr<GeckoContentController> controller = + mCompositorSession->GetContentController(); + controller->HandleTap(aType, aPoint, aModifiers, aGuid, aInputBlockId, + aDoubleTapToZoomMetrics); + return; + } + dom::BrowserParent* tab = + dom::BrowserParent::GetBrowserParentFromLayersId(aGuid.mLayersId); + if (tab) { +#ifdef MOZ_WIDGET_ANDROID + // On Android, touch events are dispatched from the UI thread to the main + // thread using the Android priority queue. It is possible that this tap has + // made it to the GPU process and back before they have been processed. We + // must therefore dispatch this message to the same queue, otherwise the tab + // may receive the tap event before the touch events that synthesized it. + mozilla::jni::DispatchToGeckoPriorityQueue( + NewRunnableMethod<TapType, LayoutDevicePoint, Modifiers, + ScrollableLayerGuid, uint64_t, + Maybe<DoubleTapToZoomMetrics>>( + "dom::BrowserParent::SendHandleTap", tab, + &dom::BrowserParent::SendHandleTap, aType, aPoint, aModifiers, + aGuid, aInputBlockId, aDoubleTapToZoomMetrics)); +#else + tab->SendHandleTap(aType, aPoint, aModifiers, aGuid, aInputBlockId, + aDoubleTapToZoomMetrics); +#endif + } +} + +mozilla::ipc::IPCResult APZInputBridgeChild::RecvHandleTap( + const TapType& aType, const LayoutDevicePoint& aPoint, + const Modifiers& aModifiers, const ScrollableLayerGuid& aGuid, + const uint64_t& aInputBlockId, + const Maybe<DoubleTapToZoomMetrics>& aDoubleTapToZoomMetrics) { + if (NS_IsMainThread()) { + HandleTapOnMainThread(aType, aPoint, aModifiers, aGuid, aInputBlockId, + aDoubleTapToZoomMetrics); + } else { + NS_DispatchToMainThread( + NewRunnableMethod<TapType, LayoutDevicePoint, Modifiers, + ScrollableLayerGuid, uint64_t, + Maybe<DoubleTapToZoomMetrics>>( + "layers::APZInputBridgeChild::HandleTapOnMainThread", this, + &APZInputBridgeChild::HandleTapOnMainThread, aType, aPoint, + aModifiers, aGuid, aInputBlockId, aDoubleTapToZoomMetrics)); + } + return IPC_OK(); +} + mozilla::ipc::IPCResult APZInputBridgeChild::RecvCallInputBlockCallback( uint64_t aInputBlockId, const APZHandledResult& aHandledResult) { auto it = mInputBlockCallbacks.find(aInputBlockId); diff --git a/gfx/layers/ipc/APZInputBridgeChild.h b/gfx/layers/ipc/APZInputBridgeChild.h index dd77d95f36..4b14e3aa0d 100644 --- a/gfx/layers/ipc/APZInputBridgeChild.h +++ b/gfx/layers/ipc/APZInputBridgeChild.h @@ -10,11 +10,16 @@ #include "mozilla/layers/APZInputBridge.h" #include "mozilla/layers/PAPZInputBridgeChild.h" +#include "mozilla/layers/GeckoContentControllerTypes.h" + namespace mozilla { namespace layers { +class RemoteCompositorSession; + class APZInputBridgeChild : public PAPZInputBridgeChild, public APZInputBridge { NS_INLINE_DECL_THREADSAFE_REFCOUNTING(APZInputBridgeChild, final) + using TapType = GeckoContentController_TapType; public: static RefPtr<APZInputBridgeChild> Create( @@ -23,10 +28,19 @@ class APZInputBridgeChild : public PAPZInputBridgeChild, public APZInputBridge { void Destroy(); + void SetCompositorSession(RemoteCompositorSession* aSession); + APZEventResult ReceiveInputEvent( InputData& aEvent, InputBlockCallback&& aCallback = InputBlockCallback()) override; + MOZ_CAN_RUN_SCRIPT_BOUNDARY + mozilla::ipc::IPCResult RecvHandleTap( + const TapType& aType, const LayoutDevicePoint& aPoint, + const Modifiers& aModifiers, const ScrollableLayerGuid& aGuid, + const uint64_t& aInputBlockId, + const Maybe<DoubleTapToZoomMetrics>& aDoubleTapToZoomMetrics); + mozilla::ipc::IPCResult RecvCallInputBlockCallback( uint64_t aInputBlockId, const APZHandledResult& handledResult); @@ -48,8 +62,16 @@ class APZInputBridgeChild : public PAPZInputBridgeChild, public APZInputBridge { private: void Open(Endpoint<PAPZInputBridgeChild>&& aEndpoint); + MOZ_CAN_RUN_SCRIPT_BOUNDARY + void HandleTapOnMainThread( + const TapType& aType, const LayoutDevicePoint& aPoint, + const Modifiers& aModifiers, const ScrollableLayerGuid& aGuid, + const uint64_t& aInputBlockId, + const Maybe<DoubleTapToZoomMetrics>& aDoubleTapToZoomMetrics); + bool mIsOpen; uint64_t mProcessToken; + MOZ_NON_OWNING_REF RemoteCompositorSession* mCompositorSession = nullptr; using InputBlockCallbackMap = std::unordered_map<uint64_t, InputBlockCallback>; diff --git a/gfx/layers/ipc/APZInputBridgeParent.cpp b/gfx/layers/ipc/APZInputBridgeParent.cpp index fcc642ff7a..475c15abca 100644 --- a/gfx/layers/ipc/APZInputBridgeParent.cpp +++ b/gfx/layers/ipc/APZInputBridgeParent.cpp @@ -16,14 +16,15 @@ namespace mozilla { namespace layers { /* static */ -RefPtr<APZInputBridgeParent> APZInputBridgeParent::Create( +APZInputBridgeParent* APZInputBridgeParent::Create( const LayersId& aLayersId, Endpoint<PAPZInputBridgeParent>&& aEndpoint) { - RefPtr<APZInputBridgeParent> parent = new APZInputBridgeParent(aLayersId); + APZInputBridgeParent* parent = new APZInputBridgeParent(aLayersId); if (!aEndpoint.Bind(parent)) { // We can't recover from this. MOZ_CRASH("Failed to bind APZInputBridgeParent to endpoint"); } + CompositorBridgeParent::SetAPZInputBridgeParent(aLayersId, parent); return parent; } @@ -31,6 +32,7 @@ APZInputBridgeParent::APZInputBridgeParent(const LayersId& aLayersId) { MOZ_ASSERT(XRE_IsGPUProcess()); MOZ_ASSERT(NS_IsMainThread()); + mLayersId = aLayersId; mTreeManager = CompositorBridgeParent::GetAPZCTreeManager(aLayersId); MOZ_ASSERT(mTreeManager); } @@ -205,6 +207,10 @@ mozilla::ipc::IPCResult APZInputBridgeParent::RecvProcessUnhandledEvent( } void APZInputBridgeParent::ActorDestroy(ActorDestroyReason aWhy) { + StaticMonitorAutoLock lock(CompositorBridgeParent::sIndirectLayerTreesLock); + CompositorBridgeParent::LayerTreeState& state = + CompositorBridgeParent::sIndirectLayerTrees[mLayersId]; + state.mApzInputBridgeParent = nullptr; // We shouldn't need it after this mTreeManager = nullptr; } diff --git a/gfx/layers/ipc/APZInputBridgeParent.h b/gfx/layers/ipc/APZInputBridgeParent.h index 71f43d092b..62e6427bb5 100644 --- a/gfx/layers/ipc/APZInputBridgeParent.h +++ b/gfx/layers/ipc/APZInputBridgeParent.h @@ -18,7 +18,7 @@ class APZInputBridgeParent : public PAPZInputBridgeParent { NS_INLINE_DECL_REFCOUNTING(APZInputBridgeParent, final) public: - static RefPtr<APZInputBridgeParent> Create( + static APZInputBridgeParent* Create( const LayersId& aLayersId, Endpoint<PAPZInputBridgeParent>&& aEndpoint); mozilla::ipc::IPCResult RecvReceiveMultiTouchInputEvent( @@ -67,6 +67,7 @@ class APZInputBridgeParent : public PAPZInputBridgeParent { private: RefPtr<IAPZCTreeManager> mTreeManager; + LayersId mLayersId; }; } // namespace layers diff --git a/gfx/layers/ipc/CanvasChild.cpp b/gfx/layers/ipc/CanvasChild.cpp index a25d5e6799..efcd520300 100644 --- a/gfx/layers/ipc/CanvasChild.cpp +++ b/gfx/layers/ipc/CanvasChild.cpp @@ -206,13 +206,11 @@ class CanvasDataShmemHolder { } void Destroy() { - class DestroyRunnable final : public dom::WorkerRunnable { + class DestroyRunnable final : public dom::WorkerThreadRunnable { public: DestroyRunnable(dom::WorkerPrivate* aWorkerPrivate, CanvasDataShmemHolder* aShmemHolder) - : dom::WorkerRunnable(aWorkerPrivate, - "CanvasDataShmemHolder::Destroy", - dom::WorkerRunnable::WorkerThread), + : dom::WorkerThreadRunnable("CanvasDataShmemHolder::Destroy"), mShmemHolder(aShmemHolder) {} bool WorkerRun(JSContext* aCx, @@ -241,8 +239,9 @@ class CanvasDataShmemHolder { if (mWorkerRef) { if (!mWorkerRef->Private()->IsOnCurrentThread()) { auto task = MakeRefPtr<DestroyRunnable>(mWorkerRef->Private(), this); + dom::WorkerPrivate* worker = mWorkerRef->Private(); mMutex.Unlock(); - task->Dispatch(); + task->Dispatch(worker); return; } } else if (!NS_IsMainThread()) { diff --git a/gfx/layers/ipc/CanvasTranslator.cpp b/gfx/layers/ipc/CanvasTranslator.cpp index 3fd7a4c4c4..46cab838de 100644 --- a/gfx/layers/ipc/CanvasTranslator.cpp +++ b/gfx/layers/ipc/CanvasTranslator.cpp @@ -1190,23 +1190,42 @@ already_AddRefed<gfx::SourceSurface> CanvasTranslator::LookupExternalSurface( // Check if the surface descriptor describes a GPUVideo texture for which we // only have an opaque source/handle from SurfaceDescriptorRemoteDecoder to // derive the actual texture from. -static bool SDIsNullRemoteDecoder(const SurfaceDescriptor& sd) { - return sd.type() == SurfaceDescriptor::TSurfaceDescriptorGPUVideo && - sd.get_SurfaceDescriptorGPUVideo() - .get_SurfaceDescriptorRemoteDecoder() - .subdesc() - .type() == RemoteDecoderVideoSubDescriptor::Tnull_t; +static bool SDIsSupportedRemoteDecoder(const SurfaceDescriptor& sd) { + if (sd.type() != SurfaceDescriptor::TSurfaceDescriptorGPUVideo) { + return false; + } + + const auto& sdv = sd.get_SurfaceDescriptorGPUVideo(); + const auto& sdvType = sdv.type(); + if (sdvType != SurfaceDescriptorGPUVideo::TSurfaceDescriptorRemoteDecoder) { + return false; + } + + const auto& sdrd = sdv.get_SurfaceDescriptorRemoteDecoder(); + const auto& subdesc = sdrd.subdesc(); + const auto& subdescType = subdesc.type(); + + if (subdescType == RemoteDecoderVideoSubDescriptor::Tnull_t || + subdescType == + RemoteDecoderVideoSubDescriptor::TSurfaceDescriptorMacIOSurface) { + return true; + } + + return false; } already_AddRefed<gfx::SourceSurface> CanvasTranslator::LookupSourceSurfaceFromSurfaceDescriptor( const SurfaceDescriptor& aDesc) { - if (!SDIsNullRemoteDecoder(aDesc)) { + if (!SDIsSupportedRemoteDecoder(aDesc)) { return nullptr; } const auto& sdrd = aDesc.get_SurfaceDescriptorGPUVideo() .get_SurfaceDescriptorRemoteDecoder(); + const auto& subdesc = sdrd.subdesc(); + const auto& subdescType = subdesc.type(); + RefPtr<VideoBridgeParent> parent = VideoBridgeParent::GetSingleton(sdrd.source()); if (!parent) { @@ -1222,9 +1241,19 @@ CanvasTranslator::LookupSourceSurfaceFromSurfaceDescriptor( return nullptr; } - RefPtr<gfx::DataSourceSurface> surf = texture->GetAsSurface(); + if (subdescType == + RemoteDecoderVideoSubDescriptor::TSurfaceDescriptorMacIOSurface) { + MOZ_ASSERT(texture->AsMacIOSurfaceTextureHost()); + return texture->GetAsSurface(); + } + + if (subdescType == RemoteDecoderVideoSubDescriptor::Tnull_t) { + RefPtr<gfx::DataSourceSurface> surf = texture->GetAsSurface(); + return surf.forget(); + } - return surf.forget(); + MOZ_ASSERT_UNREACHABLE("unexpected to be called"); + return nullptr; } void CanvasTranslator::CheckpointReached() { CheckAndSignalWriter(); } diff --git a/gfx/layers/ipc/CompositorBridgeParent.cpp b/gfx/layers/ipc/CompositorBridgeParent.cpp index 767ea47b2f..d6efb2c991 100644 --- a/gfx/layers/ipc/CompositorBridgeParent.cpp +++ b/gfx/layers/ipc/CompositorBridgeParent.cpp @@ -167,6 +167,7 @@ bool CompositorBridgeParentBase::DeallocShmem(ipc::Shmem& aShmem) { CompositorBridgeParent::LayerTreeState::LayerTreeState() : mApzcTreeManagerParent(nullptr), + mApzInputBridgeParent(nullptr), mParent(nullptr), mContentCompositorBridgeParent(nullptr) {} @@ -645,9 +646,21 @@ bool CompositorBridgeParent::DeallocPAPZCTreeManagerParent( return true; } +void CompositorBridgeParent::SetAPZInputBridgeParent( + const LayersId& aLayersId, APZInputBridgeParent* aInputBridgeParent) { + MOZ_RELEASE_ASSERT(XRE_IsGPUProcess()); + MOZ_ASSERT(NS_IsMainThread()); + StaticMonitorAutoLock lock(CompositorBridgeParent::sIndirectLayerTreesLock); + CompositorBridgeParent::LayerTreeState& state = + CompositorBridgeParent::sIndirectLayerTrees[aLayersId]; + MOZ_ASSERT(!state.mApzInputBridgeParent); + state.mApzInputBridgeParent = aInputBridgeParent; +} + void CompositorBridgeParent::AllocateAPZCTreeManagerParent( const StaticMonitorAutoLock& aProofOfLayerTreeStateLock, const LayersId& aLayersId, LayerTreeState& aState) { + MOZ_ASSERT(CompositorThreadHolder::IsInCompositorThread()); MOZ_ASSERT(aState.mParent == this); MOZ_ASSERT(mApzcTreeManager); MOZ_ASSERT(mApzUpdater); @@ -1713,6 +1726,15 @@ APZCTreeManagerParent* CompositorBridgeParent::GetApzcTreeManagerParentForRoot( } /* static */ +APZInputBridgeParent* CompositorBridgeParent::GetApzInputBridgeParentForRoot( + LayersId aContentLayersId) { + StaticMonitorAutoLock lock(sIndirectLayerTreesLock); + CompositorBridgeParent::LayerTreeState* state = + GetStateForRoot(aContentLayersId, lock); + return state ? state->mApzInputBridgeParent : nullptr; +} + +/* static */ GeckoContentController* CompositorBridgeParent::GetGeckoContentControllerForRoot( LayersId aContentLayersId) { diff --git a/gfx/layers/ipc/CompositorBridgeParent.h b/gfx/layers/ipc/CompositorBridgeParent.h index 0e6bd48f9a..c7cb530989 100644 --- a/gfx/layers/ipc/CompositorBridgeParent.h +++ b/gfx/layers/ipc/CompositorBridgeParent.h @@ -24,6 +24,7 @@ #include "mozilla/layers/ISurfaceAllocator.h" // for IShmemAllocator #include "mozilla/layers/LayersTypes.h" #include "mozilla/layers/PCompositorBridgeParent.h" +#include "mozilla/layers/APZInputBridgeParent.h" #include "mozilla/webrender/WebRenderTypes.h" namespace mozilla { @@ -394,6 +395,10 @@ class CompositorBridgeParent final : public CompositorBridgeParentBase, ~LayerTreeState(); RefPtr<GeckoContentController> mController; APZCTreeManagerParent* mApzcTreeManagerParent; + // The mApzInputBridgeParent is only populated for LayerTreeState + // objects corresponding to root LayerIds (one for each top-level + // window). + APZInputBridgeParent* mApzInputBridgeParent; RefPtr<CompositorBridgeParent> mParent; RefPtr<WebRenderBridgeParent> mWrBridge; // Pointer to the ContentCompositorBridgeParent. Used by APZCs to share @@ -438,6 +443,13 @@ class CompositorBridgeParent final : public CompositorBridgeParentBase, LayersId aContentLayersId); /** + * Same as the GetApzcTreeManagerParentForRoot function, but returns + * the APZInputBridge for the parent process. + */ + static APZInputBridgeParent* GetApzInputBridgeParentForRoot( + LayersId aContentLayersId); + + /** * Used by the profiler to denote when a vsync occured */ static void PostInsertVsyncProfilerMarker(mozilla::TimeStamp aVsyncTimestamp); @@ -454,6 +466,9 @@ class CompositorBridgeParent final : public CompositorBridgeParentBase, const StaticMonitorAutoLock& aProofOfLayerTreeStateLock, const LayersId& aLayersId, LayerTreeState& aLayerTreeStateToUpdate); + static void SetAPZInputBridgeParent(const LayersId& aLayersId, + APZInputBridgeParent* aInputBridgeParent); + PAPZParent* AllocPAPZParent(const LayersId& aLayersId) override; bool DeallocPAPZParent(PAPZParent* aActor) override; diff --git a/gfx/layers/ipc/PAPZCTreeManager.ipdl b/gfx/layers/ipc/PAPZCTreeManager.ipdl index a08e2cfeb1..75cb04bea6 100644 --- a/gfx/layers/ipc/PAPZCTreeManager.ipdl +++ b/gfx/layers/ipc/PAPZCTreeManager.ipdl @@ -80,10 +80,6 @@ parent: child: - async HandleTap(GeckoContentController_TapType aType, LayoutDevicePoint point, Modifiers aModifiers, - ScrollableLayerGuid aGuid, uint64_t aInputBlockId, - DoubleTapToZoomMetrics? aDoubleTapToZoomMetrics); - async NotifyPinchGesture(PinchGestureType aType, ScrollableLayerGuid aGuid, LayoutDevicePoint aFocusPoint, LayoutDeviceCoord aSpanChange, Modifiers aModifiers); diff --git a/gfx/layers/ipc/PAPZInputBridge.ipdl b/gfx/layers/ipc/PAPZInputBridge.ipdl index 7564757b28..35ca82c018 100644 --- a/gfx/layers/ipc/PAPZInputBridge.ipdl +++ b/gfx/layers/ipc/PAPZInputBridge.ipdl @@ -6,11 +6,15 @@ include "ipc/nsGUIEventIPC.h"; using mozilla::LayoutDeviceIntPoint from "Units.h"; +using mozilla::LayoutDevicePoint from "Units.h"; +using mozilla::layers::GeckoContentController_TapType from "mozilla/layers/GeckoContentControllerTypes.h"; +using mozilla::layers::DoubleTapToZoomMetrics from "mozilla/layers/DoubleTapToZoom.h"; using struct mozilla::layers::ScrollableLayerGuid from "mozilla/layers/ScrollableLayerGuid.h"; using struct mozilla::layers::APZEventResult from "mozilla/layers/APZInputBridge.h"; using struct mozilla::layers::APZHandledResult from "mozilla/layers/APZInputBridge.h"; using mozilla::EventMessage from "mozilla/EventForwards.h"; +using mozilla::Modifiers from "mozilla/EventForwards.h"; using class mozilla::MultiTouchInput from "InputData.h"; using class mozilla::MouseInput from "InputData.h"; using class mozilla::PanGestureInput from "InputData.h"; @@ -82,6 +86,10 @@ parent: child: async CallInputBlockCallback(uint64_t aInputBlockId, APZHandledResult aHandledResult); + + async HandleTap(GeckoContentController_TapType aType, LayoutDevicePoint point, + Modifiers aModifiers, ScrollableLayerGuid aGuid, + uint64_t aInputBlockId, DoubleTapToZoomMetrics? aDoubleTapToZoomMetrics); }; } // namespace gfx diff --git a/gfx/layers/ipc/RemoteContentController.cpp b/gfx/layers/ipc/RemoteContentController.cpp index 682331362b..8c6ab22acd 100644 --- a/gfx/layers/ipc/RemoteContentController.cpp +++ b/gfx/layers/ipc/RemoteContentController.cpp @@ -62,7 +62,7 @@ void RemoteContentController::RequestContentRepaint( } } -void RemoteContentController::HandleTapOnMainThread( +void RemoteContentController::HandleTapOnParentProcessMainThread( TapType aTapType, LayoutDevicePoint aPoint, Modifiers aModifiers, ScrollableLayerGuid aGuid, uint64_t aInputBlockId, const Maybe<DoubleTapToZoomMetrics>& aDoubleTapToZoomMetrics) { @@ -78,20 +78,19 @@ void RemoteContentController::HandleTapOnMainThread( } } -void RemoteContentController::HandleTapOnCompositorThread( +void RemoteContentController::HandleTapOnGPUProcessMainThread( TapType aTapType, LayoutDevicePoint aPoint, Modifiers aModifiers, ScrollableLayerGuid aGuid, uint64_t aInputBlockId, const Maybe<DoubleTapToZoomMetrics>& aDoubleTapToZoomMetrics) { MOZ_ASSERT(XRE_IsGPUProcess()); - MOZ_ASSERT(mCompositorThread->IsOnCurrentThread()); + MOZ_ASSERT(NS_IsMainThread()); - // The raw pointer to APZCTreeManagerParent is ok here because we are on - // the compositor thread. - APZCTreeManagerParent* apzctmp = - CompositorBridgeParent::GetApzcTreeManagerParentForRoot(aGuid.mLayersId); - if (apzctmp) { - Unused << apzctmp->SendHandleTap(aTapType, aPoint, aModifiers, aGuid, - aInputBlockId, aDoubleTapToZoomMetrics); + // Send a message to the controller thread to handle the single-tap gesture. + APZInputBridgeParent* apzib = + CompositorBridgeParent::GetApzInputBridgeParentForRoot(aGuid.mLayersId); + if (apzib) { + Unused << apzib->SendHandleTap(aTapType, aPoint, aModifiers, aGuid, + aInputBlockId, aDoubleTapToZoomMetrics); } } @@ -103,19 +102,18 @@ void RemoteContentController::HandleTap( APZThreadUtils::AssertOnControllerThread(); if (XRE_GetProcessType() == GeckoProcessType_GPU) { - if (mCompositorThread->IsOnCurrentThread()) { - HandleTapOnCompositorThread(aTapType, aPoint, aModifiers, aGuid, - aInputBlockId, aDoubleTapToZoomMetrics); + if (NS_IsMainThread()) { + HandleTapOnGPUProcessMainThread(aTapType, aPoint, aModifiers, aGuid, + aInputBlockId, aDoubleTapToZoomMetrics); } else { - // We have to send messages from the compositor thread - mCompositorThread->Dispatch( - NewRunnableMethod<TapType, LayoutDevicePoint, Modifiers, - ScrollableLayerGuid, uint64_t, - Maybe<DoubleTapToZoomMetrics>>( - "layers::RemoteContentController::HandleTapOnCompositorThread", - this, &RemoteContentController::HandleTapOnCompositorThread, - aTapType, aPoint, aModifiers, aGuid, aInputBlockId, - aDoubleTapToZoomMetrics)); + NS_DispatchToMainThread(NewRunnableMethod<TapType, LayoutDevicePoint, + Modifiers, ScrollableLayerGuid, + uint64_t, + Maybe<DoubleTapToZoomMetrics>>( + "layers::RemoteContentController::HandleTapOnGPUProcessMainThread", + this, &RemoteContentController::HandleTapOnGPUProcessMainThread, + aTapType, aPoint, aModifiers, aGuid, aInputBlockId, + aDoubleTapToZoomMetrics)); } return; } @@ -123,8 +121,8 @@ void RemoteContentController::HandleTap( MOZ_ASSERT(XRE_IsParentProcess()); if (NS_IsMainThread()) { - HandleTapOnMainThread(aTapType, aPoint, aModifiers, aGuid, aInputBlockId, - aDoubleTapToZoomMetrics); + HandleTapOnParentProcessMainThread(aTapType, aPoint, aModifiers, aGuid, + aInputBlockId, aDoubleTapToZoomMetrics); } else { // We must be on Android, running on the Java UI thread #ifndef MOZ_WIDGET_ANDROID @@ -138,13 +136,15 @@ void RemoteContentController::HandleTap( // using NS_DispatchToMainThread would post to a different message loop, // and introduces the possibility of this tap event getting processed // out of order with respect to the touch events that synthesized it. - mozilla::jni::DispatchToGeckoPriorityQueue( - NewRunnableMethod<TapType, LayoutDevicePoint, Modifiers, - ScrollableLayerGuid, uint64_t, - Maybe<DoubleTapToZoomMetrics>>( - "layers::RemoteContentController::HandleTapOnMainThread", this, - &RemoteContentController::HandleTapOnMainThread, aTapType, aPoint, - aModifiers, aGuid, aInputBlockId, aDoubleTapToZoomMetrics)); + mozilla::jni::DispatchToGeckoPriorityQueue(NewRunnableMethod< + TapType, LayoutDevicePoint, + Modifiers, ScrollableLayerGuid, + uint64_t, + Maybe<DoubleTapToZoomMetrics>>( + "layers::RemoteContentController::HandleTapOnParentProcessMainThread", + this, &RemoteContentController::HandleTapOnParentProcessMainThread, + aTapType, aPoint, aModifiers, aGuid, aInputBlockId, + aDoubleTapToZoomMetrics)); #endif } } diff --git a/gfx/layers/ipc/RemoteContentController.h b/gfx/layers/ipc/RemoteContentController.h index 7c2ef3789f..34f85004d2 100644 --- a/gfx/layers/ipc/RemoteContentController.h +++ b/gfx/layers/ipc/RemoteContentController.h @@ -98,12 +98,12 @@ class RemoteContentController : public GeckoContentController, nsCOMPtr<nsISerialEventTarget> mCompositorThread; bool mCanSend; - void HandleTapOnMainThread( - TapType aType, LayoutDevicePoint aPoint, Modifiers aModifiers, + void HandleTapOnParentProcessMainThread( + TapType aTapType, LayoutDevicePoint aPoint, Modifiers aModifiers, ScrollableLayerGuid aGuid, uint64_t aInputBlockId, const Maybe<DoubleTapToZoomMetrics>& aDoubleTapToZoomMetrics); - void HandleTapOnCompositorThread( - TapType aType, LayoutDevicePoint aPoint, Modifiers aModifiers, + void HandleTapOnGPUProcessMainThread( + TapType aTapType, LayoutDevicePoint aPoint, Modifiers aModifiers, ScrollableLayerGuid aGuid, uint64_t aInputBlockId, const Maybe<DoubleTapToZoomMetrics>& aDoubleTapToZoomMetrics); void NotifyPinchGestureOnCompositorThread( |