Skip to content

Commit

Permalink
Bug 1676760 - Remove unused RefreshTimerVsyncDispatcher::SetParentRef…
Browse files Browse the repository at this point in the history
…reshTimer. r=smaug

Even in the parent process, VsyncRefreshDriverTimer uses AddChildRefreshTimer.

Differential Revision: https://phabricator.services.mozilla.com/D139768
  • Loading branch information
mstange committed Mar 1, 2022
1 parent 9912a6a commit d85ed11
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 52 deletions.
30 changes: 0 additions & 30 deletions gfx/tests/gtest/TestVsync.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -136,36 +136,6 @@ TEST_F(VsyncTester, CompositorGetVsyncNotifications) {
ASSERT_FALSE(globalDisplay.IsVsyncEnabled());
}

// Test that if we have vsync enabled, the parent refresh driver should get
// notifications
TEST_F(VsyncTester, ParentRefreshDriverGetVsyncNotifications) {
VsyncSource::Display& globalDisplay = mVsyncSource->GetGlobalDisplay();
globalDisplay.DisableVsync();
ASSERT_FALSE(globalDisplay.IsVsyncEnabled());

RefPtr<RefreshTimerVsyncDispatcher> vsyncDispatcher =
globalDisplay.GetRefreshTimerVsyncDispatcher();
ASSERT_TRUE(vsyncDispatcher != nullptr);

RefPtr<TestVsyncObserver> testVsyncObserver = new TestVsyncObserver();
vsyncDispatcher->SetParentRefreshTimer(testVsyncObserver);
ASSERT_TRUE(globalDisplay.IsVsyncEnabled());

testVsyncObserver->WaitForVsyncNotification();
ASSERT_TRUE(testVsyncObserver->DidGetVsyncNotification());
vsyncDispatcher->SetParentRefreshTimer(nullptr);

testVsyncObserver->ResetVsyncNotification();
testVsyncObserver->WaitForVsyncNotification();
ASSERT_FALSE(testVsyncObserver->DidGetVsyncNotification());

vsyncDispatcher = nullptr;
testVsyncObserver = nullptr;

globalDisplay.DisableVsync();
ASSERT_FALSE(globalDisplay.IsVsyncEnabled());
}

// Test that child refresh vsync observers get vsync notifications
TEST_F(VsyncTester, ChildRefreshDriverGetVsyncNotifications) {
VsyncSource::Display& globalDisplay = mVsyncSource->GetGlobalDisplay();
Expand Down
18 changes: 1 addition & 17 deletions widget/VsyncDispatcher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -134,22 +134,6 @@ void RefreshTimerVsyncDispatcher::NotifyVsync(const VsyncEvent& aVsync) {
for (size_t i = 0; i < mChildRefreshTimers.Length(); i++) {
mChildRefreshTimers[i]->NotifyVsync(aVsync);
}

if (mParentRefreshTimer) {
mParentRefreshTimer->NotifyVsync(aVsync);
}
}

void RefreshTimerVsyncDispatcher::SetParentRefreshTimer(
VsyncObserver* aVsyncObserver) {
MOZ_ASSERT(NS_IsMainThread());
{ // lock scope because UpdateVsyncStatus runs on main thread and will
// deadlock
MutexAutoLock lock(mRefreshTimersLock);
mParentRefreshTimer = aVsyncObserver;
}

UpdateVsyncStatus();
}

void RefreshTimerVsyncDispatcher::AddChildRefreshTimer(
Expand Down Expand Up @@ -190,7 +174,7 @@ void RefreshTimerVsyncDispatcher::UpdateVsyncStatus() {
bool RefreshTimerVsyncDispatcher::NeedsVsync() {
MOZ_ASSERT(NS_IsMainThread());
MutexAutoLock lock(mRefreshTimersLock);
return (mParentRefreshTimer != nullptr) || !mChildRefreshTimers.IsEmpty();
return !mChildRefreshTimers.IsEmpty();
}

} // namespace mozilla
5 changes: 0 additions & 5 deletions widget/VsyncDispatcher.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,6 @@ class RefreshTimerVsyncDispatcher final {

void MoveToDisplay(gfx::VsyncSource::Display* aDisplay);

// Set chrome process's RefreshTimer to this dispatcher.
// This function can be called from any thread.
void SetParentRefreshTimer(VsyncObserver* aVsyncObserver);

// Add or remove the content process' RefreshTimer to this dispatcher. This
// will be a no-op for AddChildRefreshTimer() if the observer is already
// registered.
Expand All @@ -102,7 +98,6 @@ class RefreshTimerVsyncDispatcher final {
// hold a RefPtr back without causing a cyclic dependency.
gfx::VsyncSource::Display* mDisplay;
Mutex mRefreshTimersLock;
RefPtr<VsyncObserver> mParentRefreshTimer;
nsTArray<RefPtr<VsyncObserver>> mChildRefreshTimers;
};

Expand Down

0 comments on commit d85ed11

Please sign in to comment.