SF: Fix two queries for the past VSYNC's fence
...which did not consider the case of targeting two VSYNCs ahead.
Bug: 241285475
Test: libscheduler_test after Idf9f43b37f3479c94a478d154eaa46f43e0c6c9d
Change-Id: Ib114ffc1866aa32e6d493e06dcf5a27652d19a39
diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp
index 7171adc..c39122a 100644
--- a/services/surfaceflinger/SurfaceFlinger.cpp
+++ b/services/surfaceflinger/SurfaceFlinger.cpp
@@ -2149,7 +2149,8 @@
bool SurfaceFlinger::wouldPresentEarly(TimePoint frameTime, Period vsyncPeriod) const {
const bool isThreeVsyncsAhead = mExpectedPresentTime - frameTime > 2 * vsyncPeriod;
return isThreeVsyncsAhead ||
- mPreviousPresentFences[0].fenceTime->getSignalTime() != Fence::SIGNAL_TIME_PENDING;
+ getPreviousPresentFence(frameTime, vsyncPeriod)->getSignalTime() !=
+ Fence::SIGNAL_TIME_PENDING;
}
auto SurfaceFlinger::getPreviousPresentFence(TimePoint frameTime, Period vsyncPeriod) const
@@ -2657,9 +2658,10 @@
// Send a power hint hint after presentation is finished
if (mPowerHintSessionEnabled) {
- mPowerAdvisor->setSfPresentTiming(TimePoint::fromNs(mPreviousPresentFences[0]
- .fenceTime->getSignalTime()),
- TimePoint::now());
+ const nsecs_t pastPresentTime =
+ getPreviousPresentFence(frameTime, vsyncPeriod)->getSignalTime();
+
+ mPowerAdvisor->setSfPresentTiming(TimePoint::fromNs(pastPresentTime), TimePoint::now());
mPowerAdvisor->reportActualWorkDuration();
}