Pass actual present time to ViewRootImpl
To measure end-to-end touch latency, we need to report the actual
present time to ViewRootImpl. ViewRootImpl, in turn, will report this
information to InputDispatcher. Finally, InputDispatcher will combine
all known information for a specific input event, and will report this
data to westworld.
In another patch, we will add a new call, 'reportLatencyInfo', to
InputPublisher. This call will allow the app to send this latency data
to InputDispatcher.
Bug: 169866723
Test: printed the input event present times inside ViewRootImpl
Change-Id: Ibd3a2cfeb1a340eb15cd2165071df1f8589634af
diff --git a/libs/hwui/FrameMetricsReporter.h b/libs/hwui/FrameMetricsReporter.h
index 0643e79..3f2dc12 100644
--- a/libs/hwui/FrameMetricsReporter.h
+++ b/libs/hwui/FrameMetricsReporter.h
@@ -55,13 +55,24 @@
return mObservers.size() > 0;
}
- void reportFrameMetrics(const int64_t* stats) {
+ /**
+ * Notify observers about the metrics contained in 'stats'.
+ * If an observer is waiting for present time, notify when 'stats' has present time.
+ *
+ * If an observer does not want present time, only notify when 'hasPresentTime' is false.
+ * Never notify both types of observers from the same callback, because the callback with
+ * 'hasPresentTime' is sent at a different time than the one without.
+ */
+ void reportFrameMetrics(const int64_t* stats, bool hasPresentTime) {
FatVector<sp<FrameMetricsObserver>, 10> copy;
{
std::lock_guard lock(mObserversLock);
copy.reserve(mObservers.size());
for (size_t i = 0; i < mObservers.size(); i++) {
- copy.push_back(mObservers[i]);
+ const bool wantsPresentTime = mObservers[i]->waitForPresentTime();
+ if (hasPresentTime == wantsPresentTime) {
+ copy.push_back(mObservers[i]);
+ }
}
}
for (size_t i = 0; i < copy.size(); i++) {