diff --git a/gfx/layers/ipc/CompositorVsyncScheduler.cpp b/gfx/layers/ipc/CompositorVsyncScheduler.cpp index e685daf39d16..6bd2f55e3e48 100644 --- a/gfx/layers/ipc/CompositorVsyncScheduler.cpp +++ b/gfx/layers/ipc/CompositorVsyncScheduler.cpp @@ -82,8 +82,6 @@ CompositorVsyncScheduler::CompositorVsyncScheduler(CompositorVsyncSchedulerOwner , mWidget(aWidget) , mCurrentCompositeTaskMonitor("CurrentCompositeTaskMonitor") , mCurrentCompositeTask(nullptr) - , mSetNeedsCompositeMonitor("SetNeedsCompositeMonitor") - , mSetNeedsCompositeTask(nullptr) , mCurrentVRListenerTaskMonitor("CurrentVRTaskMonitor") , mCurrentVRListenerTask(nullptr) { @@ -116,7 +114,7 @@ CompositorVsyncScheduler::Destroy() mVsyncObserver->Destroy(); mVsyncObserver = nullptr; - CancelCurrentSetNeedsCompositeTask(); + mNeedsComposite = 0; CancelCurrentCompositeTask(); } @@ -173,54 +171,15 @@ CompositorVsyncScheduler::ScheduleComposition() PostCompositeTask(TimeStamp::Now()); #endif } else { - SetNeedsComposite(); - } -} - -void -CompositorVsyncScheduler::CancelCurrentSetNeedsCompositeTask() -{ - MOZ_ASSERT(CompositorThreadHolder::IsInCompositorThread()); - MonitorAutoLock lock(mSetNeedsCompositeMonitor); - if (mSetNeedsCompositeTask) { - mSetNeedsCompositeTask->Cancel(); - mSetNeedsCompositeTask = nullptr; - } - mNeedsComposite = 0; -} - -/** - * TODO Potential performance heuristics: - * If a composite takes 17 ms, do we composite ASAP or wait until next vsync? - * If a layer transaction comes after vsync, do we composite ASAP or wait until - * next vsync? - * How many skipped vsync events until we stop listening to vsync events? - */ -void -CompositorVsyncScheduler::SetNeedsComposite() -{ - if (!CompositorThreadHolder::IsInCompositorThread()) { - MonitorAutoLock lock(mSetNeedsCompositeMonitor); - RefPtr task = NewCancelableRunnableMethod( - "layers::CompositorVsyncScheduler::SetNeedsComposite", - this, - &CompositorVsyncScheduler::SetNeedsComposite); - mSetNeedsCompositeTask = task; - ScheduleTask(task.forget()); - return; - } else { - MonitorAutoLock lock(mSetNeedsCompositeMonitor); - mSetNeedsCompositeTask = nullptr; - } - - mNeedsComposite++; - if (!mIsObservingVsync && mNeedsComposite) { - ObserveVsync(); - // Starting to observe vsync is an async operation that goes - // through the main thread of the UI process. It's possible that - // we're blocking there waiting on a composite, so schedule an initial - // one now to get things started. - PostCompositeTask(TimeStamp::Now()); + mNeedsComposite++; + if (!mIsObservingVsync && mNeedsComposite) { + ObserveVsync(); + // Starting to observe vsync is an async operation that goes + // through the main thread of the UI process. It's possible that + // we're blocking there waiting on a composite, so schedule an initial + // one now to get things started. + PostCompositeTask(TimeStamp::Now()); + } } } diff --git a/gfx/layers/ipc/CompositorVsyncScheduler.h b/gfx/layers/ipc/CompositorVsyncScheduler.h index 44e6252fab09..070d5d4ad7f1 100644 --- a/gfx/layers/ipc/CompositorVsyncScheduler.h +++ b/gfx/layers/ipc/CompositorVsyncScheduler.h @@ -49,7 +49,6 @@ public: widget::CompositorWidget* aWidget); bool NotifyVsync(TimeStamp aVsyncTimestamp); - void SetNeedsComposite(); /** * Do cleanup. This must be called on the compositor thread. @@ -93,7 +92,6 @@ private: void UnobserveVsync(); void DispatchTouchEvents(TimeStamp aVsyncTimestamp); void DispatchVREvents(TimeStamp aVsyncTimestamp); - void CancelCurrentSetNeedsCompositeTask(); class Observer final : public VsyncObserver { @@ -126,9 +124,6 @@ private: mozilla::Monitor mCurrentCompositeTaskMonitor; RefPtr mCurrentCompositeTask; - mozilla::Monitor mSetNeedsCompositeMonitor; - RefPtr mSetNeedsCompositeTask; - mozilla::Monitor mCurrentVRListenerTaskMonitor; RefPtr mCurrentVRListenerTask; };