From 4d7ae1cfa3872e47f933cc566ff5b669e82c7a3b Mon Sep 17 00:00:00 2001 From: Brian Birtles Date: Sat, 22 Mar 2014 05:59:57 +0800 Subject: [PATCH] Bug 986359 part 1 - Move SetTestSampleTime and LeaveTestMode to LayerTransactionParent; r=mattwoodrow --- dom/base/nsDOMWindowUtils.cpp | 19 ++++-- gfx/layers/ipc/CompositorParent.cpp | 78 ++++++++++++++--------- gfx/layers/ipc/CompositorParent.h | 6 +- gfx/layers/ipc/LayerTransactionParent.cpp | 13 ++++ gfx/layers/ipc/LayerTransactionParent.h | 2 + gfx/layers/ipc/PCompositor.ipdl | 6 -- gfx/layers/ipc/PLayerTransaction.ipdl | 7 ++ gfx/layers/ipc/ShadowLayersManager.h | 3 + 8 files changed, 90 insertions(+), 44 deletions(-) diff --git a/dom/base/nsDOMWindowUtils.cpp b/dom/base/nsDOMWindowUtils.cpp index 7579022cfcbf..7669d50f2ebf 100644 --- a/dom/base/nsDOMWindowUtils.cpp +++ b/dom/base/nsDOMWindowUtils.cpp @@ -2554,9 +2554,13 @@ nsDOMWindowUtils::AdvanceTimeAndRefresh(int64_t aMilliseconds) nsIWidget* widget = GetWidget(); if (widget) { - CompositorChild* compositor = widget->GetRemoteRenderer(); - if (compositor) { - compositor->SendSetTestSampleTime(driver->MostRecentRefresh()); + LayerManager* manager = widget->GetLayerManager(); + if (manager) { + ShadowLayerForwarder* forwarder = manager->AsShadowForwarder(); + if (forwarder && forwarder->HasShadowManager()) { + forwarder->GetShadowManager()->SendSetTestSampleTime( + driver->MostRecentRefresh()); + } } } @@ -2575,9 +2579,12 @@ nsDOMWindowUtils::RestoreNormalRefresh() // compositor. nsIWidget* widget = GetWidget(); if (widget) { - CompositorChild* compositor = widget->GetRemoteRenderer(); - if (compositor) { - compositor->SendLeaveTestMode(); + LayerManager* manager = widget->GetLayerManager(); + if (manager) { + ShadowLayerForwarder* forwarder = manager->AsShadowForwarder(); + if (forwarder && forwarder->HasShadowManager()) { + forwarder->GetShadowManager()->SendLeaveTestMode(); + } } } diff --git a/gfx/layers/ipc/CompositorParent.cpp b/gfx/layers/ipc/CompositorParent.cpp index 1b699cc52285..407e34a69def 100644 --- a/gfx/layers/ipc/CompositorParent.cpp +++ b/gfx/layers/ipc/CompositorParent.cpp @@ -366,34 +366,6 @@ CompositorParent::RecvStopFrameTimeRecording(const uint32_t& aStartIndex, return true; } -bool -CompositorParent::RecvSetTestSampleTime(const TimeStamp& aTime) -{ - if (aTime.IsNull()) { - return false; - } - - mIsTesting = true; - mTestTime = aTime; - - // Update but only if we were already scheduled to animate - if (mCompositionManager && mCurrentCompositeTask) { - bool requestNextFrame = mCompositionManager->TransformShadowTree(aTime); - if (!requestNextFrame) { - CancelCurrentCompositeTask(); - } - } - - return true; -} - -bool -CompositorParent::RecvLeaveTestMode() -{ - mIsTesting = false; - return true; -} - void CompositorParent::ActorDestroy(ActorDestroyReason why) { @@ -805,6 +777,34 @@ CompositorParent::ForceComposite(LayerTransactionParent* aLayerTree) ScheduleComposition(); } +bool +CompositorParent::SetTestSampleTime(LayerTransactionParent* aLayerTree, + const TimeStamp& aTime) +{ + if (aTime.IsNull()) { + return false; + } + + mIsTesting = true; + mTestTime = aTime; + + // Update but only if we were already scheduled to animate + if (mCompositionManager && mCurrentCompositeTask) { + bool requestNextFrame = mCompositionManager->TransformShadowTree(aTime); + if (!requestNextFrame) { + CancelCurrentCompositeTask(); + } + } + + return true; +} + +void +CompositorParent::LeaveTestMode(LayerTransactionParent* aLayerTree) +{ + mIsTesting = false; +} + void CompositorParent::InitializeLayerManager(const nsTArray& aBackendHints) { @@ -1067,8 +1067,6 @@ public: virtual bool RecvNotifyRegionInvalidated(const nsIntRegion& aRegion) { return true; } virtual bool RecvStartFrameTimeRecording(const int32_t& aBufferSize, uint32_t* aOutStartIndex) MOZ_OVERRIDE { return true; } virtual bool RecvStopFrameTimeRecording(const uint32_t& aStartIndex, InfallibleTArray* intervals) MOZ_OVERRIDE { return true; } - virtual bool RecvSetTestSampleTime(const TimeStamp& aTime) MOZ_OVERRIDE { return true; } - virtual bool RecvLeaveTestMode() MOZ_OVERRIDE { return true; } virtual PLayerTransactionParent* AllocPLayerTransactionParent(const nsTArray& aBackendHints, @@ -1083,6 +1081,9 @@ public: bool aIsFirstPaint, bool aScheduleComposite) MOZ_OVERRIDE; virtual void ForceComposite(LayerTransactionParent* aLayerTree) MOZ_OVERRIDE; + virtual bool SetTestSampleTime(LayerTransactionParent* aLayerTree, + const TimeStamp& aTime) MOZ_OVERRIDE; + virtual void LeaveTestMode(LayerTransactionParent* aLayerTree) MOZ_OVERRIDE; virtual AsyncCompositionManager* GetCompositionManager(LayerTransactionParent* aParent) MOZ_OVERRIDE; @@ -1243,6 +1244,23 @@ CrossProcessCompositorParent::ForceComposite(LayerTransactionParent* aLayerTree) sIndirectLayerTrees[id].mParent->ForceComposite(aLayerTree); } +bool +CrossProcessCompositorParent::SetTestSampleTime( + LayerTransactionParent* aLayerTree, const TimeStamp& aTime) +{ + uint64_t id = aLayerTree->GetId(); + MOZ_ASSERT(id != 0); + return sIndirectLayerTrees[id].mParent->SetTestSampleTime(aLayerTree, aTime); +} + +void +CrossProcessCompositorParent::LeaveTestMode(LayerTransactionParent* aLayerTree) +{ + uint64_t id = aLayerTree->GetId(); + MOZ_ASSERT(id != 0); + sIndirectLayerTrees[id].mParent->LeaveTestMode(aLayerTree); +} + AsyncCompositionManager* CrossProcessCompositorParent::GetCompositionManager(LayerTransactionParent* aLayerTree) { diff --git a/gfx/layers/ipc/CompositorParent.h b/gfx/layers/ipc/CompositorParent.h index 8509d2e4a258..25b7ebb61c17 100644 --- a/gfx/layers/ipc/CompositorParent.h +++ b/gfx/layers/ipc/CompositorParent.h @@ -92,8 +92,6 @@ public: virtual bool RecvNotifyRegionInvalidated(const nsIntRegion& aRegion) MOZ_OVERRIDE; virtual bool RecvStartFrameTimeRecording(const int32_t& aBufferSize, uint32_t* aOutStartIndex) MOZ_OVERRIDE; virtual bool RecvStopFrameTimeRecording(const uint32_t& aStartIndex, InfallibleTArray* intervals) MOZ_OVERRIDE; - virtual bool RecvSetTestSampleTime(const TimeStamp& aTime) MOZ_OVERRIDE; - virtual bool RecvLeaveTestMode() MOZ_OVERRIDE; virtual void ActorDestroy(ActorDestroyReason why) MOZ_OVERRIDE; @@ -102,7 +100,11 @@ public: bool aIsFirstPaint, bool aScheduleComposite) MOZ_OVERRIDE; virtual void ForceComposite(LayerTransactionParent* aLayerTree) MOZ_OVERRIDE; + virtual bool SetTestSampleTime(LayerTransactionParent* aLayerTree, + const TimeStamp& aTime) MOZ_OVERRIDE; + virtual void LeaveTestMode(LayerTransactionParent* aLayerTree) MOZ_OVERRIDE; virtual AsyncCompositionManager* GetCompositionManager(LayerTransactionParent* aLayerTree) MOZ_OVERRIDE { return mCompositionManager; } + /** * This forces the is-first-paint flag to true. This is intended to * be called by the widget code when it loses its viewport information diff --git a/gfx/layers/ipc/LayerTransactionParent.cpp b/gfx/layers/ipc/LayerTransactionParent.cpp index 051c31dd30b5..835296fc23b7 100644 --- a/gfx/layers/ipc/LayerTransactionParent.cpp +++ b/gfx/layers/ipc/LayerTransactionParent.cpp @@ -559,6 +559,19 @@ LayerTransactionParent::RecvUpdate(const InfallibleTArray& cset, return true; } +bool +LayerTransactionParent::RecvSetTestSampleTime(const TimeStamp& aTime) +{ + return mShadowLayersManager->SetTestSampleTime(this, aTime); +} + +bool +LayerTransactionParent::RecvLeaveTestMode() +{ + mShadowLayersManager->LeaveTestMode(this); + return true; +} + bool LayerTransactionParent::RecvGetOpacity(PLayerParent* aParent, float* aOpacity) diff --git a/gfx/layers/ipc/LayerTransactionParent.h b/gfx/layers/ipc/LayerTransactionParent.h index 23f53050d88e..422e973c372d 100644 --- a/gfx/layers/ipc/LayerTransactionParent.h +++ b/gfx/layers/ipc/LayerTransactionParent.h @@ -93,6 +93,8 @@ protected: virtual bool RecvClearCachedResources() MOZ_OVERRIDE; virtual bool RecvForceComposite() MOZ_OVERRIDE; + virtual bool RecvSetTestSampleTime(const TimeStamp& aTime) MOZ_OVERRIDE; + virtual bool RecvLeaveTestMode() MOZ_OVERRIDE; virtual bool RecvGetOpacity(PLayerParent* aParent, float* aOpacity) MOZ_OVERRIDE; virtual bool RecvGetAnimationTransform(PLayerParent* aParent, diff --git a/gfx/layers/ipc/PCompositor.ipdl b/gfx/layers/ipc/PCompositor.ipdl index 3a8f8678b552..05d1b33bc9c5 100644 --- a/gfx/layers/ipc/PCompositor.ipdl +++ b/gfx/layers/ipc/PCompositor.ipdl @@ -75,12 +75,6 @@ parent: sync StopFrameTimeRecording(uint32_t startIndex) returns (float[] intervals); - // Enter test mode, set the sample time to sampleTime, and resample animations. - // sampleTime must not be null. - sync SetTestSampleTime(TimeStamp sampleTime); - // Leave test mode and resume normal compositing - sync LeaveTestMode(); - // layersBackendHints is an ordered list of preffered backends where // layersBackendHints[0] is the best backend. If any hints are LayersBackend::LAYERS_NONE // that hint is ignored. diff --git a/gfx/layers/ipc/PLayerTransaction.ipdl b/gfx/layers/ipc/PLayerTransaction.ipdl index e866b37f1818..a6453c372d9f 100644 --- a/gfx/layers/ipc/PLayerTransaction.ipdl +++ b/gfx/layers/ipc/PLayerTransaction.ipdl @@ -82,6 +82,13 @@ parent: returns (EditReply[] reply); // Testing APIs + + // Enter test mode, set the sample time to sampleTime, and resample + // animations. sampleTime must not be null. + sync SetTestSampleTime(TimeStamp sampleTime); + // Leave test mode and resume normal compositing + sync LeaveTestMode(); + sync GetOpacity(PLayer layer) returns (float opacity); // Returns the value of the transform applied to the layer by animation after diff --git a/gfx/layers/ipc/ShadowLayersManager.h b/gfx/layers/ipc/ShadowLayersManager.h index ddaddbc92b47..95566682dd54 100644 --- a/gfx/layers/ipc/ShadowLayersManager.h +++ b/gfx/layers/ipc/ShadowLayersManager.h @@ -25,6 +25,9 @@ public: virtual AsyncCompositionManager* GetCompositionManager(LayerTransactionParent* aLayerTree) { return nullptr; } virtual void ForceComposite(LayerTransactionParent* aLayerTree) { } + virtual bool SetTestSampleTime(LayerTransactionParent* aLayerTree, + const TimeStamp& aTime) { return true; } + virtual void LeaveTestMode(LayerTransactionParent* aLayerTree) { } }; } // layers