Bug 1765399 - Add RefreshDriverVsyncDispatcher::GetVsyncRate so that VsyncRefreshDriverTimer no longer needs a pointer to the VsyncSource. r=smaug

Differential Revision: https://phabricator.services.mozilla.com/D144367
This commit is contained in:
Markus Stange 2022-05-04 16:13:36 +00:00
Родитель 77efabb139
Коммит adc1d5dcf1
2 изменённых файлов: 13 добавлений и 16 удалений

Просмотреть файл

@ -449,8 +449,8 @@ class VsyncRefreshDriverTimer : public RefreshDriverTimer {
RefPtr<gfx::VsyncSource> vsyncSource = RefPtr<gfx::VsyncSource> vsyncSource =
gfxPlatform::GetPlatform()->GetHardwareVsync(); gfxPlatform::GetPlatform()->GetHardwareVsync();
RefPtr<VsyncDispatcher> vsyncDispatcher = vsyncSource->GetVsyncDispatcher(); RefPtr<VsyncDispatcher> vsyncDispatcher = vsyncSource->GetVsyncDispatcher();
RefPtr<VsyncRefreshDriverTimer> timer = new VsyncRefreshDriverTimer( RefPtr<VsyncRefreshDriverTimer> timer =
std::move(vsyncSource), std::move(vsyncDispatcher), nullptr); new VsyncRefreshDriverTimer(std::move(vsyncDispatcher), nullptr);
return timer.forget(); return timer.forget();
} }
@ -464,8 +464,8 @@ class VsyncRefreshDriverTimer : public RefreshDriverTimer {
MOZ_RELEASE_ASSERT(NS_IsMainThread()); MOZ_RELEASE_ASSERT(NS_IsMainThread());
RefPtr<VsyncDispatcher> vsyncDispatcher = RefPtr<VsyncDispatcher> vsyncDispatcher =
aVsyncSource->GetVsyncDispatcher(); aVsyncSource->GetVsyncDispatcher();
RefPtr<VsyncRefreshDriverTimer> timer = new VsyncRefreshDriverTimer( RefPtr<VsyncRefreshDriverTimer> timer =
std::move(aVsyncSource), std::move(vsyncDispatcher), nullptr); new VsyncRefreshDriverTimer(std::move(vsyncDispatcher), nullptr);
return timer.forget(); return timer.forget();
} }
@ -475,13 +475,13 @@ class VsyncRefreshDriverTimer : public RefreshDriverTimer {
MOZ_RELEASE_ASSERT(XRE_IsContentProcess()); MOZ_RELEASE_ASSERT(XRE_IsContentProcess());
MOZ_RELEASE_ASSERT(NS_IsMainThread()); MOZ_RELEASE_ASSERT(NS_IsMainThread());
RefPtr<VsyncRefreshDriverTimer> timer = RefPtr<VsyncRefreshDriverTimer> timer =
new VsyncRefreshDriverTimer(nullptr, nullptr, std::move(aVsyncChild)); new VsyncRefreshDriverTimer(nullptr, std::move(aVsyncChild));
return timer.forget(); return timer.forget();
} }
TimeDuration GetTimerRate() override { TimeDuration GetTimerRate() override {
if (mVsyncSource) { if (mVsyncDispatcher) {
mVsyncRate = mVsyncSource->GetVsyncRate(); mVsyncRate = mVsyncDispatcher->GetVsyncRate();
} else if (mVsyncChild) { } else if (mVsyncChild) {
mVsyncRate = mVsyncChild->GetVsyncRate(); mVsyncRate = mVsyncChild->GetVsyncRate();
} }
@ -617,11 +617,9 @@ class VsyncRefreshDriverTimer : public RefreshDriverTimer {
}; // RefreshDriverVsyncObserver }; // RefreshDriverVsyncObserver
VsyncRefreshDriverTimer(RefPtr<gfx::VsyncSource>&& aVsyncSource, VsyncRefreshDriverTimer(RefPtr<VsyncDispatcher>&& aVsyncDispatcher,
RefPtr<VsyncDispatcher>&& aVsyncDispatcher,
RefPtr<VsyncMainChild>&& aVsyncChild) RefPtr<VsyncMainChild>&& aVsyncChild)
: mVsyncSource(aVsyncSource), : mVsyncDispatcher(aVsyncDispatcher),
mVsyncDispatcher(aVsyncDispatcher),
mVsyncChild(aVsyncChild), mVsyncChild(aVsyncChild),
mVsyncRate(TimeDuration::Forever()), mVsyncRate(TimeDuration::Forever()),
mRecentVsync(TimeStamp::Now()), mRecentVsync(TimeStamp::Now()),
@ -895,15 +893,12 @@ class VsyncRefreshDriverTimer : public RefreshDriverTimer {
} }
} }
// Used in the parent process when we have a per-widget vsync source
// (currently only on Linux Wayland), to re-query the vsync rate.
RefPtr<gfx::VsyncSource> mVsyncSource;
// Always non-null. Has a weak pointer to us and notifies us of vsync. // Always non-null. Has a weak pointer to us and notifies us of vsync.
RefPtr<RefreshDriverVsyncObserver> mVsyncObserver; RefPtr<RefreshDriverVsyncObserver> mVsyncObserver;
// Used in the parent process. We register mVsyncObserver with it for the // Used in the parent process. We register mVsyncObserver with it for the
// duration during which we want to receive vsync notifications. // duration during which we want to receive vsync notifications. We also
// use it to query the current vsync rate.
RefPtr<VsyncDispatcher> mVsyncDispatcher; RefPtr<VsyncDispatcher> mVsyncDispatcher;
// Used it the content process. We register mVsyncObserver with it for the // Used it the content process. We register mVsyncObserver with it for the
// duration during which we want to receive vsync notifications. The // duration during which we want to receive vsync notifications. The

Просмотреть файл

@ -95,6 +95,8 @@ class VsyncDispatcher final {
void MoveToSource(gfx::VsyncSource* aVsyncSource); void MoveToSource(gfx::VsyncSource* aVsyncSource);
TimeDuration GetVsyncRate() { return mVsyncSource->GetVsyncRate(); }
// Add a vsync observer to this dispatcher. This is a no-op if the observer is // Add a vsync observer to this dispatcher. This is a no-op if the observer is
// already registered. Can be called from any thread. // already registered. Can be called from any thread.
void AddVsyncObserver(VsyncObserver* aVsyncObserver); void AddVsyncObserver(VsyncObserver* aVsyncObserver);