diff --git a/dom/ipc/BrowserChild.cpp b/dom/ipc/BrowserChild.cpp index 8948d1da9fe1..bc68ba771941 100644 --- a/dom/ipc/BrowserChild.cpp +++ b/dom/ipc/BrowserChild.cpp @@ -1231,6 +1231,27 @@ mozilla::ipc::IPCResult BrowserChild::RecvInitRendering( return IPC_OK(); } +mozilla::ipc::IPCResult BrowserChild::RecvCompositorOptionsChanged( + const CompositorOptions& aNewOptions) { + MOZ_ASSERT(mCompositorOptions); + + // The only compositor option we currently support changing is APZ + // enablement. Even that is only partially supported for now: + // * Going from APZ to non-APZ is fine - we just flip the stored flag. + // Note that we keep the actors (mApzcTreeManager, and the APZChild + // created in InitAPZState()) around (read on for why). + // * Going from non-APZ to APZ is only supported if we were using + // APZ initially (at InitRendering() time) and we are transitioning + // back. In this case, we just reuse the actors which we kept around. + // Fully supporting a non-APZ to APZ transition (i.e. even in cases + // where we initialized as non-APZ) would require setting up the actors + // here. (In that case, we would also have the options of destroying + // the actors in the APZ --> non-APZ case, and always re-creating them + // during a non-APZ --> APZ transition). + mCompositorOptions->SetUseAPZ(aNewOptions.UseAPZ()); + return IPC_OK(); +} + mozilla::ipc::IPCResult BrowserChild::RecvUpdateDimensions( const DimensionInfo& aDimensionInfo) { // When recording/replaying we need to make sure the dimensions are up to diff --git a/dom/ipc/BrowserChild.h b/dom/ipc/BrowserChild.h index c75f124848d0..b684c3c4e27f 100644 --- a/dom/ipc/BrowserChild.h +++ b/dom/ipc/BrowserChild.h @@ -278,6 +278,9 @@ class BrowserChild final : public nsMessageManagerScriptExecutor, const mozilla::layers::CompositorOptions& aCompositorOptions, const bool& aLayersConnected); + mozilla::ipc::IPCResult RecvCompositorOptionsChanged( + const mozilla::layers::CompositorOptions& aNewOptions); + mozilla::ipc::IPCResult RecvUpdateDimensions( const mozilla::dom::DimensionInfo& aDimensionInfo); mozilla::ipc::IPCResult RecvSizeModeChanged(const nsSizeMode& aSizeMode); diff --git a/dom/ipc/PBrowser.ipdl b/dom/ipc/PBrowser.ipdl index 3ddcee84e06b..4f2302671e00 100644 --- a/dom/ipc/PBrowser.ipdl +++ b/dom/ipc/PBrowser.ipdl @@ -736,6 +736,8 @@ child: CompositorOptions compositorOptions, bool layersConnected); + async CompositorOptionsChanged(CompositorOptions newOptions); + async LoadURL(nsCString uri, ShowInfo info); async ResumeLoad(uint64_t pendingSwitchID, ShowInfo info); diff --git a/gfx/ipc/CompositorOptions.h b/gfx/ipc/CompositorOptions.h index 4794ef4fb7bb..31b538b772e2 100644 --- a/gfx/ipc/CompositorOptions.h +++ b/gfx/ipc/CompositorOptions.h @@ -46,6 +46,8 @@ class CompositorOptions { bool UseAdvancedLayers() const { return mUseAdvancedLayers; } bool InitiallyPaused() const { return mInitiallyPaused; } + void SetUseAPZ(bool aUseAPZ) { mUseAPZ = aUseAPZ; } + void SetUseAdvancedLayers(bool aUseAdvancedLayers) { mUseAdvancedLayers = aUseAdvancedLayers; } diff --git a/gfx/layers/ipc/CompositorBridgeChild.cpp b/gfx/layers/ipc/CompositorBridgeChild.cpp index bf3472911bf1..d4e6ff4a0799 100644 --- a/gfx/layers/ipc/CompositorBridgeChild.cpp +++ b/gfx/layers/ipc/CompositorBridgeChild.cpp @@ -839,6 +839,18 @@ mozilla::ipc::IPCResult CompositorBridgeChild::RecvObserveLayersUpdate( return IPC_OK(); } +mozilla::ipc::IPCResult CompositorBridgeChild::RecvCompositorOptionsChanged( + const LayersId& aLayersId, const CompositorOptions& aNewOptions) { + MOZ_ASSERT(aLayersId.IsValid()); + MOZ_ASSERT(XRE_IsParentProcess()); + + if (RefPtr tab = + dom::BrowserParent::GetBrowserParentFromLayersId(aLayersId)) { + Unused << tab->SendCompositorOptionsChanged(aNewOptions); + } + return IPC_OK(); +} + void CompositorBridgeChild::HoldUntilCompositableRefReleasedIfNecessary( TextureClient* aClient) { if (!aClient) { diff --git a/gfx/layers/ipc/CompositorBridgeChild.h b/gfx/layers/ipc/CompositorBridgeChild.h index 75f49f505f6a..25973caf831f 100644 --- a/gfx/layers/ipc/CompositorBridgeChild.h +++ b/gfx/layers/ipc/CompositorBridgeChild.h @@ -298,6 +298,9 @@ class CompositorBridgeChild final : public PCompositorBridgeChild, const LayersId& aLayersId, const LayersObserverEpoch& aEpoch, const bool& aActive); + mozilla::ipc::IPCResult RecvCompositorOptionsChanged( + const LayersId& aLayersId, const CompositorOptions& aNewOptions); + uint64_t GetNextResourceId(); void ClearSharedFrameMetricsData(LayersId aLayersId); diff --git a/gfx/layers/ipc/CompositorBridgeParent.cpp b/gfx/layers/ipc/CompositorBridgeParent.cpp index e63b7311a51d..22d863db201e 100644 --- a/gfx/layers/ipc/CompositorBridgeParent.cpp +++ b/gfx/layers/ipc/CompositorBridgeParent.cpp @@ -1760,6 +1760,7 @@ mozilla::ipc::IPCResult CompositorBridgeParent::RecvAdoptChild( RefPtr oldApzUpdater; APZCTreeManagerParent* parent; bool scheduleComposition = false; + bool apzEnablementChanged = false; RefPtr cpcp; RefPtr childWrBridge; @@ -1794,6 +1795,7 @@ mozilla::ipc::IPCResult CompositorBridgeParent::RecvAdoptChild( "Moving tab between windows with different APZ enablement. " "This is supported on a best-effort basis, but some things may " "break."); + apzEnablementChanged = true; break; } case CompositorOptionsChangeKind::eSupported: { @@ -1864,6 +1866,9 @@ mozilla::ipc::IPCResult CompositorBridgeParent::RecvAdoptChild( mApzUpdater->NotifyLayerTreeAdopted( WRRootId(child, gfxUtils::GetContentRenderRoot()), oldApzUpdater); } + if (apzEnablementChanged) { + Unused << SendCompositorOptionsChanged(child, mOptions); + } return IPC_OK(); } diff --git a/gfx/layers/ipc/PCompositorBridge.ipdl b/gfx/layers/ipc/PCompositorBridge.ipdl index 137bd824201b..7969c5486bda 100644 --- a/gfx/layers/ipc/PCompositorBridge.ipdl +++ b/gfx/layers/ipc/PCompositorBridge.ipdl @@ -155,6 +155,8 @@ child: async ObserveLayersUpdate(LayersId aLayersId, LayersObserverEpoch aEpoch, bool aActive); + async CompositorOptionsChanged(LayersId id, CompositorOptions newOptions); + parent: async __delete__();