SF: Move present timing to FrameTargeter
Split out from I2c27dc709afd1f33bddbf9c2ca1cd61dd335f66c.
Store earliestPresentTime on the FrameTarget, like expectedPresentTime,
so it can be stored per display.
Add FrameTargeter::computeEarliestPresentTime. This calculation was
previously done in SurfaceFlinger, using data mostly contained in the
FrameTargeter. This will simplify computing this per display.
Move computation of the earliestPresentTime to
FrameTargeter::beginFrame. Add a scheduler::Feature to track whether
ExpectedPresentTime is supported.
Make previousFrameVsyncTime and wouldPresentEarly protected, now that
they are only called by FrameTargeter (subclass) and tests.
Make the test a friend of FrameTarget for accessing the above methods.
Bug: 255601557
Bug: 256196556
Bug: 259132483
Test: atest libscheduler_test:FrameTargeterTest
Test: atest
libscheduler_test:FrameTargeterWithExpectedPresentSupportTest
Change-Id: Ib927935de6ba2b7b8d5037b42eb635ae92019634
diff --git a/services/surfaceflinger/Scheduler/src/FrameTargeter.cpp b/services/surfaceflinger/Scheduler/src/FrameTargeter.cpp
index e80372b..68c277d 100644
--- a/services/surfaceflinger/Scheduler/src/FrameTargeter.cpp
+++ b/services/surfaceflinger/Scheduler/src/FrameTargeter.cpp
@@ -82,6 +82,10 @@
}
}
+ if (!mSupportsExpectedPresentTime) {
+ mEarliestPresentTime = computeEarliestPresentTime(minFramePeriod, args.hwcMinWorkDuration);
+ }
+
ATRACE_FORMAT("%s %" PRId64 " vsyncIn %.2fms%s", __func__, ftl::to_underlying(args.vsyncId),
ticks<std::milli, float>(mExpectedPresentTime - TimePoint::now()),
mExpectedPresentTime == args.expectedVsyncTime ? "" : " (adjusted)");
@@ -121,6 +125,14 @@
if (mGpuFrameMissed) mGpuFrameMissedCount++;
}
+std::optional<TimePoint> FrameTargeter::computeEarliestPresentTime(Period minFramePeriod,
+ Duration hwcMinWorkDuration) {
+ if (wouldPresentEarly(minFramePeriod)) {
+ return previousFrameVsyncTime(minFramePeriod) - hwcMinWorkDuration;
+ }
+ return {};
+}
+
void FrameTargeter::endFrame(const CompositeResult& result) {
mCompositionCoverage = result.compositionCoverage;
}