Bug 1435248 - Use a Maybe<TimeStamp> instead of a bool+TimeStamp. r=nical
authorKartikaya Gupta <kgupta@mozilla.com>
Fri, 02 Feb 2018 08:57:35 -0500
changeset 402782 54134ad6f663dd42551c50f3cde5876f4941bee5
parent 402781 9ce1b89f874463196844012b121aada56d56f8a8
child 402783 8482ce1b16bb572771a50ea63439d1b8bb28c8dd
push id99659
push useraciure@mozilla.com
push dateWed, 07 Feb 2018 22:33:57 +0000
treeherdermozilla-inbound@5ceb1098fef3 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersnical
bugs1435248
milestone60.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1435248 - Use a Maybe<TimeStamp> instead of a bool+TimeStamp. r=nical Minor refactoring, no functional changes. MozReview-Commit-ID: Ct8SBxrTz8Y
gfx/layers/ipc/CompositorBridgeParent.cpp
gfx/layers/ipc/CompositorBridgeParent.h
--- a/gfx/layers/ipc/CompositorBridgeParent.cpp
+++ b/gfx/layers/ipc/CompositorBridgeParent.cpp
@@ -319,17 +319,16 @@ CompositorBridgeParent::CompositorBridge
                                                const TimeDuration& aVsyncRate,
                                                const CompositorOptions& aOptions,
                                                bool aUseExternalSurfaceSize,
                                                const gfx::IntSize& aSurfaceSize)
   : CompositorBridgeParentBase(aManager)
   , mWidget(nullptr)
   , mScale(aScale)
   , mVsyncRate(aVsyncRate)
-  , mIsTesting(false)
   , mPendingTransaction(0)
   , mPaused(false)
   , mUseExternalSurfaceSize(aUseExternalSurfaceSize)
   , mEGLSurfaceSize(aSurfaceSize)
   , mOptions(aOptions)
   , mPauseCompositionMonitor("PauseCompositionMonitor")
   , mResumeCompositionMonitor("ResumeCompositionMonitor")
   , mRootLayerTreeID(0)
@@ -1010,17 +1009,17 @@ CompositorBridgeParent::CompositeToTarge
       mForceCompositionTask = nullptr;
     } else {
       return;
     }
   }
 
   mCompositionManager->ComputeRotation();
 
-  TimeStamp time = mIsTesting ? mTestTime : mCompositorScheduler->GetLastComposeTime();
+  TimeStamp time = mTestTime.valueOr(mCompositorScheduler->GetLastComposeTime());
   bool requestNextFrame = mCompositionManager->TransformShadowTree(time, mVsyncRate);
   if (requestNextFrame) {
     ScheduleComposition();
 #if defined(XP_WIN) || defined(MOZ_WIDGET_GTK)
     // If we have visible windowed plugins then we need to wait for content (and
     // then the plugins) to have been updated by the active animation.
     if (!mPluginWindowsHidden && mCachedPluginData.Length()) {
       mWaitForPluginsUntil = mCompositorScheduler->GetLastComposeTime() + (mVsyncRate * 2);
@@ -1280,18 +1279,17 @@ CompositorBridgeParent::SetTestSampleTim
                                           const TimeStamp& aTime)
 {
   MOZ_ASSERT(CompositorThreadHolder::IsInCompositorThread());
 
   if (aTime.IsNull()) {
     return false;
   }
 
-  mIsTesting = true;
-  mTestTime = aTime;
+  mTestTime = Some(aTime);
 
   if (mWrBridge) {
     mWrBridge->FlushRendering();
     return true;
   }
 
   bool testComposite = mCompositionManager &&
                        mCompositorScheduler->NeedsComposite();
@@ -1309,32 +1307,32 @@ CompositorBridgeParent::SetTestSampleTim
   }
 
   return true;
 }
 
 void
 CompositorBridgeParent::LeaveTestMode(const uint64_t& aId)
 {
-  mIsTesting = false;
+  mTestTime = Nothing();
 }
 
 void
 CompositorBridgeParent::ApplyAsyncProperties(LayerTransactionParent* aLayerTree)
 {
-  // NOTE: This should only be used for testing. For example, when mIsTesting is
-  // true or when called from test-only methods like
+  // NOTE: This should only be used for testing. For example, when mTestTime is
+  // non-empty, or when called from test-only methods like
   // LayerTransactionParent::RecvGetAnimationTransform.
 
   // Synchronously update the layer tree
   if (aLayerTree->GetRoot()) {
     AutoResolveRefLayers resolve(mCompositionManager);
     SetShadowProperties(mLayerManager->GetRoot());
 
-    TimeStamp time = mIsTesting ? mTestTime : mCompositorScheduler->GetLastComposeTime();
+    TimeStamp time = mTestTime.valueOr(mCompositorScheduler->GetLastComposeTime());
     bool requestNextFrame =
       mCompositionManager->TransformShadowTree(time, mVsyncRate,
         AsyncCompositionManager::TransformsToSkip::APZ);
     if (!requestNextFrame) {
       CancelCurrentCompositeTask();
       // Pretend we composited in case someone is waiting for this event.
       TimeStamp now = TimeStamp::Now();
       DidComposite(now, now);
@@ -1768,17 +1766,17 @@ RefPtr<WebRenderBridgeParent>
 CompositorBridgeParent::GetWebRenderBridgeParent() const
 {
   return mWrBridge;
 }
 
 Maybe<TimeStamp>
 CompositorBridgeParent::GetTestingTimeStamp() const
 {
-  return mIsTesting ? Some(mTestTime) : Nothing();
+  return mTestTime;
 }
 
 void
 EraseLayerState(uint64_t aId)
 {
   MonitorAutoLock lock(*sIndirectLayerTreesLock);
 
   auto iter = sIndirectLayerTrees.find(aId);
--- a/gfx/layers/ipc/CompositorBridgeParent.h
+++ b/gfx/layers/ipc/CompositorBridgeParent.h
@@ -572,20 +572,19 @@ protected:
   inline void ForEachIndirectLayerTree(const Lambda& aCallback);
 
   RefPtr<HostLayerManager> mLayerManager;
   RefPtr<Compositor> mCompositor;
   RefPtr<AsyncCompositionManager> mCompositionManager;
   RefPtr<AsyncImagePipelineManager> mAsyncImageManager;
   RefPtr<WebRenderBridgeParent> mWrBridge;
   widget::CompositorWidget* mWidget;
-  TimeStamp mTestTime;
+  Maybe<TimeStamp> mTestTime;
   CSSToLayoutDeviceScale mScale;
   TimeDuration mVsyncRate;
-  bool mIsTesting;
 
   uint64_t mPendingTransaction;
   TimeStamp mTxnStartTime;
   TimeStamp mFwdTime;
 
   bool mPaused;
 
   bool mUseExternalSurfaceSize;