diff options
| -rw-r--r-- | services/surfaceflinger/Scheduler/VSyncReactor.cpp | 5 | ||||
| -rw-r--r-- | services/surfaceflinger/tests/unittests/VSyncReactorTest.cpp | 16 |
2 files changed, 11 insertions, 10 deletions
diff --git a/services/surfaceflinger/Scheduler/VSyncReactor.cpp b/services/surfaceflinger/Scheduler/VSyncReactor.cpp index 186a2d6740..9b8f310e16 100644 --- a/services/surfaceflinger/Scheduler/VSyncReactor.cpp +++ b/services/surfaceflinger/Scheduler/VSyncReactor.cpp @@ -217,6 +217,11 @@ bool VSyncReactor::addHwVsyncTimestamp(nsecs_t timestamp, std::optional<nsecs_t> mMoreSamplesNeeded = mTracker.needsMoreSamples(); } + if (mExternalIgnoreFences) { + // keep HWVSync on as long as we ignore present fences. + mMoreSamplesNeeded = true; + } + if (!mMoreSamplesNeeded) { setIgnorePresentFencesInternal(false); } diff --git a/services/surfaceflinger/tests/unittests/VSyncReactorTest.cpp b/services/surfaceflinger/tests/unittests/VSyncReactorTest.cpp index 8d9623de1c..e3aa4ef77b 100644 --- a/services/surfaceflinger/tests/unittests/VSyncReactorTest.cpp +++ b/services/surfaceflinger/tests/unittests/VSyncReactorTest.cpp @@ -195,9 +195,7 @@ TEST_F(VSyncReactorTest, ignoresPresentFencesWhenToldTo) { TEST_F(VSyncReactorTest, ignoresProperlyAfterAPeriodConfirmation) { bool periodFlushed = true; - EXPECT_CALL(*mMockTracker, addVsyncTimestamp(_)).Times(2); - mReactor.setIgnorePresentFences(true); - + EXPECT_CALL(*mMockTracker, addVsyncTimestamp(_)).Times(3); nsecs_t const newPeriod = 5000; mReactor.onDisplayModeChanged(displayMode(newPeriod), false); @@ -207,7 +205,7 @@ TEST_F(VSyncReactorTest, ignoresProperlyAfterAPeriodConfirmation) { EXPECT_FALSE(mReactor.addHwVsyncTimestamp(newPeriod, std::nullopt, &periodFlushed)); EXPECT_TRUE(periodFlushed); - EXPECT_TRUE(mReactor.addPresentFence(generateSignalledFenceWithTime(0))); + EXPECT_FALSE(mReactor.addPresentFence(generateSignalledFenceWithTime(0))); } TEST_F(VSyncReactorTest, setPeriodCalledOnceConfirmedChange) { @@ -463,8 +461,7 @@ TEST_F(VSyncReactorTest, hwVsyncIsRequestedForTrackerMultiplePeriodChanges) { TEST_F(VSyncReactorTest, periodChangeWithGivenVsyncPeriod) { bool periodFlushed = true; - EXPECT_CALL(*mMockTracker, addVsyncTimestamp(_)).Times(2); - mReactor.setIgnorePresentFences(true); + EXPECT_CALL(*mMockTracker, addVsyncTimestamp(_)).Times(3); nsecs_t const newPeriod = 5000; mReactor.onDisplayModeChanged(displayMode(newPeriod), false); @@ -476,7 +473,7 @@ TEST_F(VSyncReactorTest, periodChangeWithGivenVsyncPeriod) { EXPECT_FALSE(mReactor.addHwVsyncTimestamp(newPeriod, newPeriod, &periodFlushed)); EXPECT_TRUE(periodFlushed); - EXPECT_TRUE(mReactor.addPresentFence(generateSignalledFenceWithTime(0))); + EXPECT_FALSE(mReactor.addPresentFence(generateSignalledFenceWithTime(0))); } TEST_F(VSyncReactorTest, periodIsMeasuredIfIgnoringComposer) { @@ -486,8 +483,7 @@ TEST_F(VSyncReactorTest, periodIsMeasuredIfIgnoringComposer) { *mMockTracker, kPendingLimit, true /* supportKernelIdleTimer */); bool periodFlushed = true; - EXPECT_CALL(*mMockTracker, addVsyncTimestamp(_)).Times(4); - idleReactor.setIgnorePresentFences(true); + EXPECT_CALL(*mMockTracker, addVsyncTimestamp(_)).Times(5); // First, set the same period, which should only be confirmed when we receive two // matching callbacks @@ -512,7 +508,7 @@ TEST_F(VSyncReactorTest, periodIsMeasuredIfIgnoringComposer) { EXPECT_FALSE(idleReactor.addHwVsyncTimestamp(20000, 5000, &periodFlushed)); EXPECT_TRUE(periodFlushed); - EXPECT_TRUE(idleReactor.addPresentFence(generateSignalledFenceWithTime(0))); + EXPECT_FALSE(idleReactor.addPresentFence(generateSignalledFenceWithTime(0))); } } // namespace android::scheduler |