From 39167fa7cd9e9cc1c076ad8c1bcddeca1d4fd82e Mon Sep 17 00:00:00 2001 From: Kartikaya Gupta Date: Wed, 5 Aug 2020 21:42:06 +0000 Subject: [PATCH] Bug 1251612 - Support the GetFrameUniformity API in content processes. r=botond,froydnj This moves the IPC mechanism from PCompositorBridge to PLayerTransaction/ PWebRenderBridge, so that it can be used by content processes like the other test APIs. It still only produces actual data for the layers backend; for WR it will just return empty datasets. Differential Revision: https://phabricator.services.mozilla.com/D86016 --- gfx/layers/client/ClientLayerManager.cpp | 9 +-------- gfx/layers/ipc/CompositorBridgeParent.cpp | 13 +++++++------ gfx/layers/ipc/CompositorBridgeParent.h | 8 ++++---- gfx/layers/ipc/ContentCompositorBridgeParent.cpp | 12 ++++++++++++ gfx/layers/ipc/ContentCompositorBridgeParent.h | 10 ++-------- gfx/layers/ipc/LayerTransactionParent.cpp | 6 ++++++ gfx/layers/ipc/LayerTransactionParent.h | 1 + gfx/layers/ipc/PCompositorBridge.ipdl | 4 ---- gfx/layers/ipc/PLayerTransaction.ipdl | 4 ++++ gfx/layers/ipc/PWebRenderBridge.ipdl | 2 ++ gfx/layers/wr/WebRenderBridgeParent.cpp | 6 ++++++ gfx/layers/wr/WebRenderBridgeParent.h | 2 ++ gfx/layers/wr/WebRenderLayerManager.cpp | 4 ++++ gfx/layers/wr/WebRenderLayerManager.h | 2 ++ ipc/ipdl/sync-messages.ini | 6 ++++-- 15 files changed, 57 insertions(+), 32 deletions(-) diff --git a/gfx/layers/client/ClientLayerManager.cpp b/gfx/layers/client/ClientLayerManager.cpp index 14fa18cf45d0..ba390dd14aed 100644 --- a/gfx/layers/client/ClientLayerManager.cpp +++ b/gfx/layers/client/ClientLayerManager.cpp @@ -573,16 +573,9 @@ void ClientLayerManager::StartNewRepaintRequest( } void ClientLayerManager::GetFrameUniformity(FrameUniformityData* aOutData) { - MOZ_ASSERT(XRE_IsParentProcess(), - "Frame Uniformity only supported in parent process"); - if (HasShadowManager()) { - CompositorBridgeChild* child = GetRemoteRenderer(); - child->SendGetFrameUniformity(aOutData); - return; + mForwarder->GetShadowManager()->SendGetFrameUniformity(aOutData); } - - return LayerManager::GetFrameUniformity(aOutData); } void ClientLayerManager::MakeSnapshotIfRequired() { diff --git a/gfx/layers/ipc/CompositorBridgeParent.cpp b/gfx/layers/ipc/CompositorBridgeParent.cpp index 211279dfdd97..c5b2e53741e9 100644 --- a/gfx/layers/ipc/CompositorBridgeParent.cpp +++ b/gfx/layers/ipc/CompositorBridgeParent.cpp @@ -1404,12 +1404,6 @@ void CompositorBridgeParent::NotifyJankedAnimations( } } -mozilla::ipc::IPCResult CompositorBridgeParent::RecvGetFrameUniformity( - FrameUniformityData* aOutData) { - mCompositionManager->GetFrameUniformity(aOutData); - return IPC_OK(); -} - void CompositorBridgeParent::SetTestAsyncScrollOffset( const LayersId& aLayersId, const ScrollableLayerGuid::ViewID& aScrollId, const CSSPoint& aPoint) { @@ -1445,6 +1439,13 @@ void CompositorBridgeParent::GetAPZTestData(const LayersId& aLayersId, } } +void CompositorBridgeParent::GetFrameUniformity(const LayersId& aLayersId, + FrameUniformityData* aOutData) { + if (mCompositionManager) { + mCompositionManager->GetFrameUniformity(aOutData); + } +} + void CompositorBridgeParent::SetConfirmedTargetAPZC( const LayersId& aLayersId, const uint64_t& aInputBlockId, const nsTArray& aTargets) { diff --git a/gfx/layers/ipc/CompositorBridgeParent.h b/gfx/layers/ipc/CompositorBridgeParent.h index 96d6cfa0229e..81871b208b85 100644 --- a/gfx/layers/ipc/CompositorBridgeParent.h +++ b/gfx/layers/ipc/CompositorBridgeParent.h @@ -146,6 +146,8 @@ class CompositorBridgeParentBase : public PCompositorBridgeParent, virtual void FlushApzRepaints(const LayersId& aLayersId) = 0; virtual void GetAPZTestData(const LayersId& aLayersId, APZTestData* aOutData) {} + virtual void GetFrameUniformity(const LayersId& aLayersId, + FrameUniformityData* data) = 0; virtual void SetConfirmedTargetAPZC( const LayersId& aLayersId, const uint64_t& aInputBlockId, const nsTArray& aTargets) = 0; @@ -266,8 +268,6 @@ class CompositorBridgeParentBase : public PCompositorBridgeParent, EndRecordingToMemoryResolver&& aResolve) = 0; virtual mozilla::ipc::IPCResult RecvInitialize( const LayersId& rootLayerTreeId) = 0; - virtual mozilla::ipc::IPCResult RecvGetFrameUniformity( - FrameUniformityData* data) = 0; virtual mozilla::ipc::IPCResult RecvWillClose() = 0; virtual mozilla::ipc::IPCResult RecvPause() = 0; virtual mozilla::ipc::IPCResult RecvRequestFxrOutput() = 0; @@ -345,8 +345,6 @@ class CompositorBridgeParent final : public CompositorBridgeParentBase, mozilla::ipc::IPCResult RecvInitialize( const LayersId& aRootLayerTreeId) override; - mozilla::ipc::IPCResult RecvGetFrameUniformity( - FrameUniformityData* aOutData) override; mozilla::ipc::IPCResult RecvWillClose() override; mozilla::ipc::IPCResult RecvPause() override; mozilla::ipc::IPCResult RecvRequestFxrOutput() override; @@ -420,6 +418,8 @@ class CompositorBridgeParent final : public CompositorBridgeParentBase, void FlushApzRepaints(const LayersId& aLayersId) override; void GetAPZTestData(const LayersId& aLayersId, APZTestData* aOutData) override; + void GetFrameUniformity(const LayersId& aLayersId, + FrameUniformityData* data) override; void SetConfirmedTargetAPZC( const LayersId& aLayersId, const uint64_t& aInputBlockId, const nsTArray& aTargets) override; diff --git a/gfx/layers/ipc/ContentCompositorBridgeParent.cpp b/gfx/layers/ipc/ContentCompositorBridgeParent.cpp index 416dee10687d..fa04ec4abcaa 100644 --- a/gfx/layers/ipc/ContentCompositorBridgeParent.cpp +++ b/gfx/layers/ipc/ContentCompositorBridgeParent.cpp @@ -559,6 +559,18 @@ void ContentCompositorBridgeParent::GetAPZTestData(const LayersId& aLayersId, state->mParent->GetAPZTestData(aLayersId, aOutData); } +void ContentCompositorBridgeParent::GetFrameUniformity( + const LayersId& aLayersId, FrameUniformityData* aOutData) { + MOZ_ASSERT(aLayersId.IsValid()); + const CompositorBridgeParent::LayerTreeState* state = + CompositorBridgeParent::GetIndirectShadowTree(aLayersId); + if (!state || !state->mParent) { + return; + } + + state->mParent->GetFrameUniformity(aLayersId, aOutData); +} + void ContentCompositorBridgeParent::SetConfirmedTargetAPZC( const LayersId& aLayersId, const uint64_t& aInputBlockId, const nsTArray& aTargets) { diff --git a/gfx/layers/ipc/ContentCompositorBridgeParent.h b/gfx/layers/ipc/ContentCompositorBridgeParent.h index 03574bf947a2..67531508516d 100644 --- a/gfx/layers/ipc/ContentCompositorBridgeParent.h +++ b/gfx/layers/ipc/ContentCompositorBridgeParent.h @@ -112,14 +112,6 @@ class ContentCompositorBridgeParent final : public CompositorBridgeParentBase { return IPC_OK(); } - mozilla::ipc::IPCResult RecvGetFrameUniformity( - FrameUniformityData* aOutData) override { - // Don't support calculating frame uniformity on the child process and - // this is just a stub for now. - MOZ_ASSERT(false); - return IPC_OK(); - } - /** * Tells this CompositorBridgeParent to send a message when the compositor has * received the transaction. @@ -151,6 +143,8 @@ class ContentCompositorBridgeParent final : public CompositorBridgeParentBase { void FlushApzRepaints(const LayersId& aLayersId) override; void GetAPZTestData(const LayersId& aLayersId, APZTestData* aOutData) override; + void GetFrameUniformity(const LayersId& aLayersId, + FrameUniformityData* aOutData) override; void SetConfirmedTargetAPZC( const LayersId& aLayersId, const uint64_t& aInputBlockId, const nsTArray& aTargets) override; diff --git a/gfx/layers/ipc/LayerTransactionParent.cpp b/gfx/layers/ipc/LayerTransactionParent.cpp index ec987e473e1f..69f03fdb3917 100644 --- a/gfx/layers/ipc/LayerTransactionParent.cpp +++ b/gfx/layers/ipc/LayerTransactionParent.cpp @@ -772,6 +772,12 @@ mozilla::ipc::IPCResult LayerTransactionParent::RecvGetAPZTestData( return IPC_OK(); } +mozilla::ipc::IPCResult LayerTransactionParent::RecvGetFrameUniformity( + FrameUniformityData* aOutData) { + mCompositorBridge->GetFrameUniformity(GetId(), aOutData); + return IPC_OK(); +} + mozilla::ipc::IPCResult LayerTransactionParent::RecvRequestProperty( const nsString& aProperty, float* aValue) { *aValue = -1; diff --git a/gfx/layers/ipc/LayerTransactionParent.h b/gfx/layers/ipc/LayerTransactionParent.h index e4a4f7d3895d..73850a5e6b6e 100644 --- a/gfx/layers/ipc/LayerTransactionParent.h +++ b/gfx/layers/ipc/LayerTransactionParent.h @@ -127,6 +127,7 @@ class LayerTransactionParent final : public PLayerTransactionParent, const ScrollableLayerGuid::ViewID& aId, const float& aValue); mozilla::ipc::IPCResult RecvFlushApzRepaints(); mozilla::ipc::IPCResult RecvGetAPZTestData(APZTestData* aOutData); + mozilla::ipc::IPCResult RecvGetFrameUniformity(FrameUniformityData* aOutData); mozilla::ipc::IPCResult RecvRequestProperty(const nsString& aProperty, float* aValue); mozilla::ipc::IPCResult RecvSetConfirmedTargetAPZC( diff --git a/gfx/layers/ipc/PCompositorBridge.ipdl b/gfx/layers/ipc/PCompositorBridge.ipdl index 9d4021e99a63..16afdf1eaa14 100644 --- a/gfx/layers/ipc/PCompositorBridge.ipdl +++ b/gfx/layers/ipc/PCompositorBridge.ipdl @@ -38,7 +38,6 @@ using mozilla::LayoutDeviceIntPoint from "Units.h"; using mozilla::LayoutDeviceIntRegion from "Units.h"; using mozilla::LayoutDeviceIntSize from "Units.h"; using class mozilla::TimeStamp from "mozilla/TimeStamp.h"; -using class mozilla::layers::FrameUniformityData from "mozilla/layers/FrameUniformityData.h"; using mozilla::layers::TextureFlags from "mozilla/layers/CompositorTypes.h"; using mozilla::layers::CompositorOptions from "mozilla/layers/CompositorOptions.h"; using mozilla::wr::PipelineId from "mozilla/webrender/WebRenderTypes.h"; @@ -185,9 +184,6 @@ parent: */ async RemotePluginsReady(); - // Child requests frame uniformity measurements - sync GetFrameUniformity() returns (FrameUniformityData data); - // The child is about to be destroyed, so perform any necessary cleanup. sync WillClose(); diff --git a/gfx/layers/ipc/PLayerTransaction.ipdl b/gfx/layers/ipc/PLayerTransaction.ipdl index 28a566aa638d..e5128688f9b1 100644 --- a/gfx/layers/ipc/PLayerTransaction.ipdl +++ b/gfx/layers/ipc/PLayerTransaction.ipdl @@ -17,6 +17,7 @@ using struct mozilla::layers::TextureInfo from "mozilla/layers/CompositorTypes.h using struct mozilla::void_t from "ipc/IPCMessageUtils.h"; using struct mozilla::null_t from "ipc/IPCMessageUtils.h"; using class mozilla::layers::APZTestData from "mozilla/layers/APZTestData.h"; +using mozilla::layers::FrameUniformityData from "mozilla/layers/FrameUniformityData.h"; using mozilla::layers::ScrollableLayerGuid from "mozilla/layers/ScrollableLayerGuid.h"; using mozilla::layers::ScrollableLayerGuid::ViewID from "mozilla/layers/ScrollableLayerGuid.h"; using struct mozilla::layers::TextureFactoryIdentifier from "mozilla/layers/CompositorTypes.h"; @@ -107,6 +108,9 @@ parent: // layers id. sync GetAPZTestData() returns (APZTestData data); + // Child requests frame uniformity measurements + sync GetFrameUniformity() returns (FrameUniformityData data); + // Query a named property from the last frame sync RequestProperty(nsString property) returns (float value); diff --git a/gfx/layers/ipc/PWebRenderBridge.ipdl b/gfx/layers/ipc/PWebRenderBridge.ipdl index d4cda8db6108..dbb19dc7652a 100644 --- a/gfx/layers/ipc/PWebRenderBridge.ipdl +++ b/gfx/layers/ipc/PWebRenderBridge.ipdl @@ -15,6 +15,7 @@ include protocol PCompositorBridge; include protocol PTexture; using mozilla::layers::APZTestData from "mozilla/layers/APZTestData.h"; +using mozilla::layers::FrameUniformityData from "mozilla/layers/FrameUniformityData.h"; using mozilla::layers::ScrollableLayerGuid from "mozilla/layers/ScrollableLayerGuid.h"; using struct mozilla::layers::TextureFactoryIdentifier from "mozilla/layers/CompositorTypes.h"; using struct mozilla::layers::TextureInfo from "mozilla/layers/CompositorTypes.h"; @@ -91,6 +92,7 @@ parent: sync SetAsyncZoom(ViewID scrollId, float zoom); async FlushApzRepaints(); sync GetAPZTestData() returns (APZTestData data); + sync GetFrameUniformity() returns (FrameUniformityData data); async Shutdown(); sync ShutdownSync(); diff --git a/gfx/layers/wr/WebRenderBridgeParent.cpp b/gfx/layers/wr/WebRenderBridgeParent.cpp index 9aafd7f41e62..2f9ce0ff8091 100644 --- a/gfx/layers/wr/WebRenderBridgeParent.cpp +++ b/gfx/layers/wr/WebRenderBridgeParent.cpp @@ -1916,6 +1916,12 @@ mozilla::ipc::IPCResult WebRenderBridgeParent::RecvGetAPZTestData( return IPC_OK(); } +mozilla::ipc::IPCResult WebRenderBridgeParent::RecvGetFrameUniformity( + FrameUniformityData* aOutData) { + mCompositorBridge->GetFrameUniformity(GetLayersId(), aOutData); + return IPC_OK(); +} + void WebRenderBridgeParent::ActorDestroy(ActorDestroyReason aWhy) { Destroy(); } void WebRenderBridgeParent::ResetPreviousSampleTime() { diff --git a/gfx/layers/wr/WebRenderBridgeParent.h b/gfx/layers/wr/WebRenderBridgeParent.h index fee1c751efb6..adfff99a85a6 100644 --- a/gfx/layers/wr/WebRenderBridgeParent.h +++ b/gfx/layers/wr/WebRenderBridgeParent.h @@ -199,6 +199,8 @@ class WebRenderBridgeParent final : public PWebRenderBridgeParent, const float& aZoom) override; mozilla::ipc::IPCResult RecvFlushApzRepaints() override; mozilla::ipc::IPCResult RecvGetAPZTestData(APZTestData* data) override; + mozilla::ipc::IPCResult RecvGetFrameUniformity( + FrameUniformityData* aOutData) override; void ActorDestroy(ActorDestroyReason aWhy) override; diff --git a/gfx/layers/wr/WebRenderLayerManager.cpp b/gfx/layers/wr/WebRenderLayerManager.cpp index 73e24e874c3e..ccbc0db8804a 100644 --- a/gfx/layers/wr/WebRenderLayerManager.cpp +++ b/gfx/layers/wr/WebRenderLayerManager.cpp @@ -721,5 +721,9 @@ void WebRenderLayerManager::WrReleasedImages( mStateManager.WrReleasedImages(aPairs); } +void WebRenderLayerManager::GetFrameUniformity(FrameUniformityData* aOutData) { + WrBridge()->SendGetFrameUniformity(aOutData); +} + } // namespace layers } // namespace mozilla diff --git a/gfx/layers/wr/WebRenderLayerManager.h b/gfx/layers/wr/WebRenderLayerManager.h index f55f4e9bf431..dcd959b9b9b9 100644 --- a/gfx/layers/wr/WebRenderLayerManager.h +++ b/gfx/layers/wr/WebRenderLayerManager.h @@ -183,6 +183,8 @@ class WebRenderLayerManager final : public LayerManager { void TakeCompositionPayloads(nsTArray& aPayloads); + void GetFrameUniformity(FrameUniformityData* aOutData) override; + private: /** * Take a snapshot of the parent context, and copy diff --git a/ipc/ipdl/sync-messages.ini b/ipc/ipdl/sync-messages.ini index 12e799332d42..7f53607a10d9 100644 --- a/ipc/ipdl/sync-messages.ini +++ b/ipc/ipdl/sync-messages.ini @@ -906,8 +906,6 @@ description = legacy sync IPC - please add detailed description description = legacy sync IPC - please add detailed description [PCompositorBridge::Initialize] description = legacy sync IPC - please add detailed description -[PCompositorBridge::GetFrameUniformity] -description = legacy sync IPC - please add detailed description [PCompositorBridge::WillClose] description = legacy sync IPC - please add detailed description [PCompositorBridge::Pause] @@ -972,6 +970,8 @@ description = legacy sync IPC - please add detailed description description = legacy sync IPC - please add detailed description [PLayerTransaction::GetAPZTestData] description = legacy sync IPC - please add detailed description +[PLayerTransaction::GetFrameUniformity] +description = test only [PLayerTransaction::RequestProperty] description = legacy sync IPC - please add detailed description [PLayerTransaction::GetTextureFactoryIdentifier] @@ -998,6 +998,8 @@ description = test only description = test only [PWebRenderBridge::GetAPZTestData] description = test only +[PWebRenderBridge::GetFrameUniformity] +description = test only [PWebRenderBridge::ShutdownSync] description = bug 1377024 [PWebRenderBridge::SyncWithCompositor]