SF: VSyncReactor add timestamp querying functions
Adds 2 more functions from the DispSync interface to VSyncReactor,
computeNextRefresh, and expectedPresentTime
Bug: 140303479
Test: 3 new units
Change-Id: I75ea79ed749f05daf3337ddc8ca145e2ecceabcd
diff --git a/services/surfaceflinger/Scheduler/VSyncReactor.cpp b/services/surfaceflinger/Scheduler/VSyncReactor.cpp
index 1398362..9ce440c 100644
--- a/services/surfaceflinger/Scheduler/VSyncReactor.cpp
+++ b/services/surfaceflinger/Scheduler/VSyncReactor.cpp
@@ -15,14 +15,18 @@
*/
#include "VSyncReactor.h"
+#include "TimeKeeper.h"
#include "VSyncDispatch.h"
#include "VSyncTracker.h"
namespace android::scheduler {
-VSyncReactor::VSyncReactor(std::unique_ptr<VSyncDispatch> dispatch,
+Clock::~Clock() = default;
+
+VSyncReactor::VSyncReactor(std::unique_ptr<Clock> clock, std::unique_ptr<VSyncDispatch> dispatch,
std::unique_ptr<VSyncTracker> tracker, size_t pendingFenceLimit)
- : mDispatch(std::move(dispatch)),
+ : mClock(std::move(clock)),
+ mDispatch(std::move(dispatch)),
mTracker(std::move(tracker)),
mPendingLimit(pendingFenceLimit) {}
@@ -73,4 +77,14 @@
}
}
+nsecs_t VSyncReactor::computeNextRefresh(int periodOffset) const {
+ auto const now = mClock->now();
+ auto const currentPeriod = periodOffset ? mTracker->currentPeriod() : 0;
+ return mTracker->nextAnticipatedVSyncTimeFrom(now + periodOffset * currentPeriod);
+}
+
+nsecs_t VSyncReactor::expectedPresentTime() {
+ return mTracker->nextAnticipatedVSyncTimeFrom(mClock->now());
+}
+
} // namespace android::scheduler