зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1726712
- Provide nsRefreshDriver::IsRegularRateTimerTicking() r=smaug
Differential Revision: https://phabricator.services.mozilla.com/D126753
This commit is contained in:
Родитель
67b8150596
Коммит
b3f8450984
|
@ -293,6 +293,10 @@ class RefreshDriverTimer {
|
|||
virtual void StopTimer() = 0;
|
||||
virtual void ScheduleNextTick(TimeStamp aNowTime) = 0;
|
||||
|
||||
public:
|
||||
virtual bool IsTicking() const = 0;
|
||||
|
||||
protected:
|
||||
bool IsRootRefreshDriver(nsRefreshDriver* aDriver) {
|
||||
nsPresContext* pc = aDriver->GetPresContext();
|
||||
nsPresContext* rootContext = pc ? pc->GetRootPresContext() : nullptr;
|
||||
|
@ -751,6 +755,7 @@ class VsyncRefreshDriverTimer : public RefreshDriverTimer {
|
|||
mVsyncChild->AddChildRefreshTimer(mVsyncObserver);
|
||||
mVsyncObserver->OnTimerStart();
|
||||
}
|
||||
mIsTicking = true;
|
||||
}
|
||||
|
||||
void StopTimer() override {
|
||||
|
@ -761,8 +766,13 @@ class VsyncRefreshDriverTimer : public RefreshDriverTimer {
|
|||
} else if (mVsyncChild) {
|
||||
mVsyncChild->RemoveChildRefreshTimer(mVsyncObserver);
|
||||
}
|
||||
mIsTicking = false;
|
||||
}
|
||||
|
||||
public:
|
||||
bool IsTicking() const override { return mIsTicking; }
|
||||
|
||||
protected:
|
||||
void ScheduleNextTick(TimeStamp aNowTime) override {
|
||||
// Do nothing since we just wait for the next vsync from
|
||||
// RefreshDriverVsyncObserver.
|
||||
|
@ -791,6 +801,7 @@ class VsyncRefreshDriverTimer : public RefreshDriverTimer {
|
|||
// After ActorDestroy(), StartTimer() and StopTimer() calls will be non-op.
|
||||
RefPtr<VsyncChild> mVsyncChild;
|
||||
TimeDuration mVsyncRate;
|
||||
bool mIsTicking = false;
|
||||
}; // VsyncRefreshDriverTimer
|
||||
|
||||
NS_IMPL_ISUPPORTS_INHERITED(
|
||||
|
@ -826,6 +837,9 @@ class StartupRefreshDriverTimer : public SimpleTimerBasedRefreshDriverTimer {
|
|||
"StartupRefreshDriverTimer::ScheduleNextTick");
|
||||
mTargetTime = newTarget;
|
||||
}
|
||||
|
||||
public:
|
||||
bool IsTicking() const override { return true; }
|
||||
};
|
||||
|
||||
/*
|
||||
|
@ -893,9 +907,13 @@ class InactiveRefreshDriverTimer final
|
|||
mTimer->InitWithNamedFuncCallback(TimerTickOne, this, delay,
|
||||
nsITimer::TYPE_ONE_SHOT,
|
||||
"InactiveRefreshDriverTimer::StartTimer");
|
||||
mIsTicking = true;
|
||||
}
|
||||
|
||||
void StopTimer() override { mTimer->Cancel(); }
|
||||
void StopTimer() override {
|
||||
mTimer->Cancel();
|
||||
mIsTicking = false;
|
||||
}
|
||||
|
||||
void ScheduleNextTick(TimeStamp aNowTime) override {
|
||||
if (mDisableAfterMilliseconds > 0.0 &&
|
||||
|
@ -922,6 +940,10 @@ class InactiveRefreshDriverTimer final
|
|||
mNextTickDuration, mNextDriverIndex, GetRefreshDriverCount());
|
||||
}
|
||||
|
||||
public:
|
||||
bool IsTicking() const override { return mIsTicking; }
|
||||
|
||||
protected:
|
||||
/* Runs just one driver's tick. */
|
||||
void TickOne() {
|
||||
TimeStamp now = TimeStamp::Now();
|
||||
|
@ -952,6 +974,7 @@ class InactiveRefreshDriverTimer final
|
|||
double mNextTickDuration;
|
||||
double mDisableAfterMilliseconds;
|
||||
uint32_t mNextDriverIndex;
|
||||
bool mIsTicking = false;
|
||||
};
|
||||
|
||||
} // namespace mozilla
|
||||
|
@ -2930,6 +2953,27 @@ Maybe<TimeStamp> nsRefreshDriver::GetNextTickHint() {
|
|||
return hint;
|
||||
}
|
||||
|
||||
/* static */
|
||||
bool nsRefreshDriver::IsRegularRateTimerTicking() {
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
|
||||
if (sRegularRateTimer) {
|
||||
if (sRegularRateTimer->IsTicking()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if (sRegularRateTimerList) {
|
||||
for (RefreshDriverTimer* timer : *sRegularRateTimerList) {
|
||||
if (timer->IsTicking()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void nsRefreshDriver::Disconnect() {
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
|
||||
|
|
|
@ -368,6 +368,8 @@ class nsRefreshDriver final : public mozilla::layers::TransactionIdAllocator,
|
|||
*/
|
||||
static mozilla::Maybe<mozilla::TimeStamp> GetNextTickHint();
|
||||
|
||||
static bool IsRegularRateTimerTicking();
|
||||
|
||||
static void DispatchIdleTaskAfterTickUnlessExists(mozilla::Task* aTask);
|
||||
static void CancelIdleTask(mozilla::Task* aTask);
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче