Bug 1435022 - Make the Composite function private and document/clean it. r?sotaro
MozReview-Commit-ID: 3UQKwwC3Fav
--- a/gfx/layers/ipc/CompositorVsyncScheduler.cpp
+++ b/gfx/layers/ipc/CompositorVsyncScheduler.cpp
@@ -206,42 +206,49 @@ CompositorVsyncScheduler::CancelCurrentC
mCurrentCompositeTask = nullptr;
}
}
void
CompositorVsyncScheduler::Composite(TimeStamp aVsyncTimestamp)
{
MOZ_ASSERT(CompositorThreadHolder::IsInCompositorThread());
- {
+ MOZ_ASSERT(mVsyncSchedulerOwner);
+
+ { // scope lock
MonitorAutoLock lock(mCurrentCompositeTaskMonitor);
mCurrentCompositeTask = nullptr;
}
- if ((aVsyncTimestamp < mLastCompose) && !mAsapScheduling) {
- // We can sometimes get vsync timestamps that are in the past
- // compared to the last compose with force composites.
- // In those cases, wait until the next vsync;
- return;
- }
+ if (!mAsapScheduling) {
+ // Some early exit conditions if we're not in ASAP mode
+ if (aVsyncTimestamp < mLastCompose) {
+ // We can sometimes get vsync timestamps that are in the past
+ // compared to the last compose with force composites.
+ // In those cases, wait until the next vsync;
+ return;
+ }
- MOZ_ASSERT(mVsyncSchedulerOwner);
- if (!mAsapScheduling && mVsyncSchedulerOwner->IsPendingComposite()) {
- // If previous composite is still on going, finish it and does a next
- // composite in a next vsync.
- mVsyncSchedulerOwner->FinishPendingComposite();
- return;
+ if (mVsyncSchedulerOwner->IsPendingComposite()) {
+ // If previous composite is still on going, finish it and wait for the
+ // next vsync.
+ mVsyncSchedulerOwner->FinishPendingComposite();
+ return;
+ }
}
DispatchTouchEvents(aVsyncTimestamp);
if (mNeedsComposite || mAsapScheduling) {
mNeedsComposite = 0;
mLastCompose = aVsyncTimestamp;
+
+ // Tell the owner to do a composite
mVsyncSchedulerOwner->CompositeToTarget(nullptr, nullptr);
+
mVsyncNotificationsSkipped = 0;
TimeDuration compositeFrameTotal = TimeStamp::Now() - aVsyncTimestamp;
mozilla::Telemetry::Accumulate(mozilla::Telemetry::COMPOSITE_FRAME_ROUNDTRIP_TIME,
compositeFrameTotal.ToMilliseconds());
} else if (mVsyncNotificationsSkipped++ > gfxPrefs::CompositorUnobserveCount()) {
UnobserveVsync();
}
--- a/gfx/layers/ipc/CompositorVsyncScheduler.h
+++ b/gfx/layers/ipc/CompositorVsyncScheduler.h
@@ -53,17 +53,16 @@ public:
/**
* Do cleanup. This must be called on the compositor thread.
*/
void Destroy();
void ScheduleComposition();
void CancelCurrentCompositeTask();
bool NeedsComposite();
- void Composite(TimeStamp aVsyncTimestamp);
void ForceComposeToTarget(gfx::DrawTarget* aTarget, const gfx::IntRect* aRect);
const TimeStamp& GetLastComposeTime()
{
return mLastCompose;
}
#ifdef COMPOSITOR_PERFORMANCE_WARNING
@@ -82,16 +81,20 @@ private:
// Post a task to run Composite() on the compositor thread, if there isn't
// such a task already queued. Can be called from any thread.
void PostCompositeTask(TimeStamp aCompositeTimestamp);
// Post a task to run DispatchVREvents() on the VR thread, if there isn't
// such a task already queued. Can be called from any thread.
void PostVRTask(TimeStamp aTimestamp);
+ // This gets run at vsync time and "does" a composite (which really means
+ // update internal state and call the owner to do the composite).
+ void Composite(TimeStamp aVsyncTimestamp);
+
void NotifyCompositeTaskExecuted();
void ObserveVsync();
void UnobserveVsync();
void DispatchTouchEvents(TimeStamp aVsyncTimestamp);
void DispatchVREvents(TimeStamp aVsyncTimestamp);
class Observer final : public VsyncObserver
{