mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-12-01 17:23:59 +00:00
Bug 1435022 - Inline the SetNeedsComposite function. r=sotaro
SetNeedsComposite is only ever called from one place on the compositor thread, but it has a bunch of generic boilerplate to handle being called from any thread. If we inline it we don't need the extra boilerplate and it's much simpler to follow the code. MozReview-Commit-ID: E1AcMh80KsH --HG-- extra : rebase_source : 717fe101a3b23e30f8443110de5b6bf1a84cddda
This commit is contained in:
parent
88a5174812
commit
00c2abf4c9
@ -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<CancelableRunnable> 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());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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<CancelableRunnable> mCurrentCompositeTask;
|
||||
|
||||
mozilla::Monitor mSetNeedsCompositeMonitor;
|
||||
RefPtr<CancelableRunnable> mSetNeedsCompositeTask;
|
||||
|
||||
mozilla::Monitor mCurrentVRListenerTaskMonitor;
|
||||
RefPtr<Runnable> mCurrentVRListenerTask;
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user