Bug 1435248 - Use a Maybe<TimeStamp> instead of a bool+TimeStamp. r?nical
Minor refactoring, no functional changes.
MozReview-Commit-ID: Ct8SBxrTz8Y
--- 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)
@@ -1019,17 +1018,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);
@@ -1289,18 +1288,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(/*aIsSync*/ false);
return true;
}
bool testComposite = mCompositionManager &&
mCompositorScheduler->NeedsComposite();
@@ -1318,32 +1316,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);
@@ -1777,17 +1775,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;