diff --git a/dom/base/nsDOMWindowUtils.cpp b/dom/base/nsDOMWindowUtils.cpp index ce8a5ad126a..2fb099538fa 100644 --- a/dom/base/nsDOMWindowUtils.cpp +++ b/dom/base/nsDOMWindowUtils.cpp @@ -3,13 +3,14 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#include "mozilla/layers/CompositorParent.h" +#include "nsDOMWindowUtils.h" + +#include "mozilla/layers/CompositorChild.h" #include "mozilla/layers/LayerTransactionChild.h" #include "nsPresContext.h" #include "nsDOMClassInfoID.h" #include "nsError.h" #include "nsIDOMEvent.h" -#include "nsDOMWindowUtils.h" #include "nsQueryContentEventResult.h" #include "CompositionStringSynthesizer.h" #include "nsGlobalWindow.h" @@ -2548,7 +2549,14 @@ nsDOMWindowUtils::AdvanceTimeAndRefresh(int64_t aMilliseconds) nsRefreshDriver* driver = GetPresContext()->RefreshDriver(); driver->AdvanceTimeAndRefresh(aMilliseconds); - CompositorParent::SetTimeAndSampleAnimations(driver->MostRecentRefresh(), true); + + nsIWidget* widget = GetWidget(); + if (widget) { + CompositorChild* compositor = widget->GetRemoteRenderer(); + if (compositor) { + compositor->SendSetTestSampleTime(driver->MostRecentRefresh()); + } + } return NS_OK; } @@ -2560,9 +2568,19 @@ nsDOMWindowUtils::RestoreNormalRefresh() return NS_ERROR_DOM_SECURITY_ERR; } + // Kick the compositor out of test mode before the refresh driver, so that + // the refresh driver doesn't send an update that gets ignored by the + // compositor. + nsIWidget* widget = GetWidget(); + if (widget) { + CompositorChild* compositor = widget->GetRemoteRenderer(); + if (compositor) { + compositor->SendLeaveTestMode(); + } + } + nsRefreshDriver* driver = GetPresContext()->RefreshDriver(); driver->RestoreNormalRefresh(); - CompositorParent::SetTimeAndSampleAnimations(driver->MostRecentRefresh(), false); return NS_OK; } diff --git a/dom/base/nsDOMWindowUtils.h b/dom/base/nsDOMWindowUtils.h index 21ddf7ee300..a7c7b7da033 100644 --- a/dom/base/nsDOMWindowUtils.h +++ b/dom/base/nsDOMWindowUtils.h @@ -10,9 +10,13 @@ #include "nsIDOMWindowUtils.h" #include "mozilla/Attributes.h" +#include "mozilla/BasicEvents.h" class nsGlobalWindow; class nsIPresShell; +class nsIWidget; +class nsPresContext; +class nsPoint; class nsDOMWindowUtils MOZ_FINAL : public nsIDOMWindowUtils, public nsSupportsWeakReference diff --git a/gfx/layers/ipc/CompositorParent.cpp b/gfx/layers/ipc/CompositorParent.cpp index cb8a6194b33..758c691fce1 100644 --- a/gfx/layers/ipc/CompositorParent.cpp +++ b/gfx/layers/ipc/CompositorParent.cpp @@ -373,6 +373,28 @@ CompositorParent::RecvStopFrameTimeRecording(const uint32_t& aStartIndex, return true; } +bool +CompositorParent::RecvSetTestSampleTime(const TimeStamp& aTime) +{ + if (aTime.IsNull()) { + return false; + } + + mIsTesting = true; + mTestTime = aTime; + if (mCompositionManager) { + mCompositionManager->TransformShadowTree(aTime); + } + return true; +} + +bool +CompositorParent::RecvLeaveTestMode() +{ + mIsTesting = false; + return true; +} + void CompositorParent::ActorDestroy(ActorDestroyReason why) { @@ -863,21 +885,6 @@ CompositorParent* CompositorParent::RemoveCompositor(uint64_t id) return retval; } -/* static */ void -CompositorParent::SetTimeAndSampleAnimations(TimeStamp aTime, bool aIsTesting) -{ - if (!sCompositorMap) { - return; - } - for (CompositorMap::iterator it = sCompositorMap->begin(); it != sCompositorMap->end(); ++it) { - it->second->mIsTesting = aIsTesting; - it->second->mTestTime = aTime; - if (it->second->mCompositionManager) { - it->second->mCompositionManager->TransformShadowTree(aTime); - } - } -} - bool CompositorParent::RecvNotifyChildCreated(const uint64_t& child) { @@ -1013,6 +1020,8 @@ 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, diff --git a/gfx/layers/ipc/CompositorParent.h b/gfx/layers/ipc/CompositorParent.h index 259f522ad62..3336ce6b121 100644 --- a/gfx/layers/ipc/CompositorParent.h +++ b/gfx/layers/ipc/CompositorParent.h @@ -93,6 +93,8 @@ 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; @@ -222,19 +224,11 @@ public: float ComputeRenderIntegrity(); - /** - * Tell all CompositorParents to update their last refresh to aTime and sample - * animations at this time stamp. If aIsTesting is true, the - * CompositorParents will become "paused" and continue sampling animations at - * this time stamp until this function is called again with aIsTesting set to - * false. - */ - static void SetTimeAndSampleAnimations(TimeStamp aTime, bool aIsTesting); - /** * Returns true if the calling thread is the compositor thread. */ static bool IsInCompositorThread(); + protected: virtual PLayerTransactionParent* AllocPLayerTransactionParent(const nsTArray& aBackendHints, diff --git a/gfx/layers/ipc/PCompositor.ipdl b/gfx/layers/ipc/PCompositor.ipdl index af2c3422b6e..5e0e20ea8ba 100644 --- a/gfx/layers/ipc/PCompositor.ipdl +++ b/gfx/layers/ipc/PCompositor.ipdl @@ -18,6 +18,7 @@ using mozilla::layers::FrameMetrics::ViewID from "FrameMetrics.h"; using mozilla::layers::LayersBackend from "mozilla/layers/LayersTypes.h"; using mozilla::CrossProcessMutexHandle from "mozilla/ipc/CrossProcessMutex.h"; using mozilla::ipc::SharedMemoryBasic::Handle from "mozilla/ipc/SharedMemoryBasic.h"; +using class mozilla::TimeStamp from "mozilla/TimeStamp.h"; namespace mozilla { namespace layers { @@ -77,6 +78,12 @@ 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.