diff options
| author | Siarhei Vishniakou <svv@google.com> | 2021-02-27 08:38:31 +0000 |
|---|---|---|
| committer | Siarhei Vishniakou <svv@google.com> | 2021-03-04 03:11:19 +0000 |
| commit | dca1946d4cb70f4aef13ed8c81c8ded15ceb02da (patch) | |
| tree | 468987c97d58929b95e17c3c8edadc61946a3835 /core/java/android/view/ViewRootImpl.java | |
| parent | 4a08dabf99d899cf2609fbad35ccedd1318b9f17 (diff) | |
Use InputEventAssigner to assign input to frame
When a frame is determined to be caused by an input event, it will be
labeled with a specific input event id. The newly added entity,
InputEventAssigner, is responsible for determining which input
event we should use.
For regular ACTION_MOVE events, we will take the latest input event as
the event that has caused the frame. For the initial gesture
(ACTION_DOWN), we will use the first event (the ACTION_DOWN itself) to
figure out the down latency. This will allow us to split up 'down' and
'scroll' latencies.
Bug: 169866723
Test: looked at the data printed locally to logcat
Test: atest InputTests
Change-Id: I8513a36960e5d652d07655d1267e758d0c59ced7
Diffstat (limited to 'core/java/android/view/ViewRootImpl.java')
| -rw-r--r-- | core/java/android/view/ViewRootImpl.java | 17 |
1 files changed, 7 insertions, 10 deletions
diff --git a/core/java/android/view/ViewRootImpl.java b/core/java/android/view/ViewRootImpl.java index f8e65bd0d056..390e3ae78143 100644 --- a/core/java/android/view/ViewRootImpl.java +++ b/core/java/android/view/ViewRootImpl.java @@ -457,6 +457,7 @@ public final class ViewRootImpl implements ViewParent, FallbackEventHandler mFallbackEventHandler; final Choreographer mChoreographer; protected final ViewFrameInfo mViewFrameInfo = new ViewFrameInfo(); + private final InputEventAssigner mInputEventAssigner = new InputEventAssigner(); /** * Update the Choreographer's FrameInfo object with the timing information for the current @@ -8352,16 +8353,7 @@ public final class ViewRootImpl implements ViewParent, Trace.traceCounter(Trace.TRACE_TAG_INPUT, mPendingInputEventQueueLengthCounterName, mPendingInputEventCount); - long eventTime = q.mEvent.getEventTimeNano(); - long oldestEventTime = eventTime; - if (q.mEvent instanceof MotionEvent) { - MotionEvent me = (MotionEvent)q.mEvent; - if (me.getHistorySize() > 0) { - oldestEventTime = me.getHistoricalEventTimeNano(0); - } - } - mViewFrameInfo.updateOldestInputEvent(oldestEventTime); - mViewFrameInfo.updateNewestInputEvent(eventTime); + mViewFrameInfo.setInputEvent(mInputEventAssigner.processEvent(q.mEvent)); deliverInputEvent(q); } @@ -8497,6 +8489,11 @@ public final class ViewRootImpl implements ViewParent, consumedBatches = false; } doProcessInputEvents(); + if (consumedBatches) { + // Must be done after we processed the input events, to mark the completion of the frame + // from the input point of view + mInputEventAssigner.onChoreographerCallback(); + } return consumedBatches; } |
