SF: Move isWithin into implementation
Update the comment for the freeze timeline at the vsync time.
BUG: 343603085
Test: atest VSyncPredictorTest
Flag: com.android.graphics.surfaceflinger.flags.vrr_bugfix_24q4
Change-Id: I78cbe386983d7f8cefaab1d3b0e94f0a034815af
diff --git a/services/surfaceflinger/Scheduler/VSyncPredictor.cpp b/services/surfaceflinger/Scheduler/VSyncPredictor.cpp
index 16799bd..3fc3901 100644
--- a/services/surfaceflinger/Scheduler/VSyncPredictor.cpp
+++ b/services/surfaceflinger/Scheduler/VSyncPredictor.cpp
@@ -400,8 +400,9 @@
} else {
if (FlagManager::getInstance().vrr_bugfix_24q4()) {
- // We need to freeze the timeline at the committed vsync so that we don't
- // overshoot the deadline.
+ // We need to freeze the timeline at the committed vsync, and
+ // then use with threshold adjustments when required to avoid
+ // marginal errors when checking the vsync on the timeline.
mTimelines.back().freeze(mLastCommittedVsync);
} else {
mTimelines.back().freeze(
@@ -779,6 +780,20 @@
}
}
+VSyncPredictor::VsyncTimeline::VsyncOnTimeline VSyncPredictor::VsyncTimeline::isWithin(
+ TimePoint vsync) {
+ const auto threshold = mIdealPeriod.ns() / 2;
+ if (!mValidUntil || vsync.ns() < mValidUntil->ns() - threshold) {
+ // if mValidUntil is absent then timeline is not frozen and
+ // vsync should be unique to that timeline.
+ return VsyncOnTimeline::Unique;
+ }
+ if (vsync.ns() > mValidUntil->ns() + threshold) {
+ return VsyncOnTimeline::Outside;
+ }
+ return VsyncOnTimeline::Shared;
+}
+
} // namespace android::scheduler
// TODO(b/129481165): remove the #pragma below and fix conversion issues