Loading services/surfaceflinger/Scheduler/VSyncPredictor.cpp +3 −0 Original line number Diff line number Diff line Loading @@ -86,6 +86,9 @@ bool VSyncPredictor::addVsyncTimestamp(nsecs_t timestamp) { // in the learning phase we should just clear all timestamps and start // over. if (mTimestamps.size() < kMinimumSamplesForPrediction) { // Add the timestamp to mTimestamps before clearing it so we could // update mKnownTimestamp based on the new timestamp. mTimestamps.push_back(timestamp); clearTimestamps(); } else if (!mTimestamps.empty()) { mKnownTimestamp = Loading services/surfaceflinger/tests/unittests/VSyncPredictorTest.cpp +19 −1 Original line number Diff line number Diff line Loading @@ -478,7 +478,7 @@ TEST_F(VSyncPredictorTest, isVSyncInPhase) { } } TEST_F(VSyncPredictorTest, InconsistentVsyncValueIsFlushedEventually) { TEST_F(VSyncPredictorTest, inconsistentVsyncValueIsFlushedEventually) { EXPECT_TRUE(tracker.addVsyncTimestamp(600)); EXPECT_TRUE(tracker.needsMoreSamples()); Loading @@ -492,6 +492,24 @@ TEST_F(VSyncPredictorTest, InconsistentVsyncValueIsFlushedEventually) { EXPECT_FALSE(tracker.needsMoreSamples()); } TEST_F(VSyncPredictorTest, knownVsyncIsUpdated) { EXPECT_TRUE(tracker.addVsyncTimestamp(600)); EXPECT_TRUE(tracker.needsMoreSamples()); EXPECT_EQ(600, tracker.nextAnticipatedVSyncTimeFrom(mNow)); EXPECT_FALSE(tracker.addVsyncTimestamp(mNow += mPeriod)); EXPECT_EQ(mNow + 1000, tracker.nextAnticipatedVSyncTimeFrom(mNow)); for (auto i = 0u; i < kMinimumSamplesForPrediction; i++) { EXPECT_TRUE(tracker.needsMoreSamples()); EXPECT_TRUE(tracker.addVsyncTimestamp(mNow += mPeriod)); EXPECT_EQ(mNow + 1000, tracker.nextAnticipatedVSyncTimeFrom(mNow)); } EXPECT_FALSE(tracker.needsMoreSamples()); EXPECT_EQ(mNow + 1000, tracker.nextAnticipatedVSyncTimeFrom(mNow)); } } // namespace android::scheduler // TODO(b/129481165): remove the #pragma below and fix conversion issues Loading Loading
services/surfaceflinger/Scheduler/VSyncPredictor.cpp +3 −0 Original line number Diff line number Diff line Loading @@ -86,6 +86,9 @@ bool VSyncPredictor::addVsyncTimestamp(nsecs_t timestamp) { // in the learning phase we should just clear all timestamps and start // over. if (mTimestamps.size() < kMinimumSamplesForPrediction) { // Add the timestamp to mTimestamps before clearing it so we could // update mKnownTimestamp based on the new timestamp. mTimestamps.push_back(timestamp); clearTimestamps(); } else if (!mTimestamps.empty()) { mKnownTimestamp = Loading
services/surfaceflinger/tests/unittests/VSyncPredictorTest.cpp +19 −1 Original line number Diff line number Diff line Loading @@ -478,7 +478,7 @@ TEST_F(VSyncPredictorTest, isVSyncInPhase) { } } TEST_F(VSyncPredictorTest, InconsistentVsyncValueIsFlushedEventually) { TEST_F(VSyncPredictorTest, inconsistentVsyncValueIsFlushedEventually) { EXPECT_TRUE(tracker.addVsyncTimestamp(600)); EXPECT_TRUE(tracker.needsMoreSamples()); Loading @@ -492,6 +492,24 @@ TEST_F(VSyncPredictorTest, InconsistentVsyncValueIsFlushedEventually) { EXPECT_FALSE(tracker.needsMoreSamples()); } TEST_F(VSyncPredictorTest, knownVsyncIsUpdated) { EXPECT_TRUE(tracker.addVsyncTimestamp(600)); EXPECT_TRUE(tracker.needsMoreSamples()); EXPECT_EQ(600, tracker.nextAnticipatedVSyncTimeFrom(mNow)); EXPECT_FALSE(tracker.addVsyncTimestamp(mNow += mPeriod)); EXPECT_EQ(mNow + 1000, tracker.nextAnticipatedVSyncTimeFrom(mNow)); for (auto i = 0u; i < kMinimumSamplesForPrediction; i++) { EXPECT_TRUE(tracker.needsMoreSamples()); EXPECT_TRUE(tracker.addVsyncTimestamp(mNow += mPeriod)); EXPECT_EQ(mNow + 1000, tracker.nextAnticipatedVSyncTimeFrom(mNow)); } EXPECT_FALSE(tracker.needsMoreSamples()); EXPECT_EQ(mNow + 1000, tracker.nextAnticipatedVSyncTimeFrom(mNow)); } } // namespace android::scheduler // TODO(b/129481165): remove the #pragma below and fix conversion issues Loading