Bug 1759581 - Use clamped(). r=smaug

Differential Revision: https://phabricator.services.mozilla.com/D141016
This commit is contained in:
Markus Stange 2022-04-20 16:16:40 +00:00
parent 2526d5e696
commit dace73a464

View File

@ -775,18 +775,11 @@ class VsyncRefreshDriverTimer : public RefreshDriverTimer {
// In case normal tasks are doing lots of work, we still want to paint
// every now and then, so only at maximum 4 * rate of work is counted
// here.
TimeDuration timeForOutsideTick = tickStart - mLastTickEnd;
TimeDuration maxOutsideTick = rate * 4;
if (timeForOutsideTick > maxOutsideTick) {
timeForOutsideTick = maxOutsideTick;
}
if (timeForOutsideTick > gracePeriod) {
// If we're giving extra time for tasks outside a tick, try to
// ensure the next vsync after that period is handled, so subtract
// a grace period.
timeForOutsideTick = timeForOutsideTick - gracePeriod;
}
// If we're giving extra time for tasks outside a tick, try to
// ensure the next vsync after that period is handled, so subtract
// a grace period.
TimeDuration timeForOutsideTick = clamped(
tickStart - mLastTickEnd - gracePeriod, TimeDuration(), rate * 4);
mSuspendVsyncPriorityTicksUntil = aVsyncTimestamp +
timeForOutsideTick +
(tickEnd - mostRecentTickStart);