From efed16630a8cf71287f04cde5dc59c4e0db1d987 Mon Sep 17 00:00:00 2001 From: Siarhei Vishniakou Date: Mon, 30 Nov 2020 10:30:52 -1000 Subject: Track per-window information in ViewFrameInfo MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit FrameInfo will now be per-window; that is, per-ViewRootImpl. Some of the information should remain “global” (it remain in Choreographer), while some information is going to become ViewRootImpl-specific. Before the information gets passed to the native layer, the ViewRootImpl-specific info will be stitched together with the general Choreographer info. This change is useful in order to correctly correlate frames with a specific input event. In the unlikely scenario of a user touching two windows of the same app simultaneously, this change will allow us to correctly measure the latency of both frames produced by the windows. Design doc: https://docs.google.com/document/d/1KMpMBlOxnl7zkWBCbXZZE6ZlaHEA4efYnN6WYK8n3FE/edit?resourcekey=0-eqooVNP0SskupljlTFvtOQ Test: atest ViewFrameInfoTest Bug: 169866723 Change-Id: Ib0bf9cd51cbcc0b9b70460c929c480eb490ec322 --- core/java/android/view/ViewRootImpl.java | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) (limited to 'core/java/android/view/ViewRootImpl.java') diff --git a/core/java/android/view/ViewRootImpl.java b/core/java/android/view/ViewRootImpl.java index 2bea0d6b4b04..ae162ede2c70 100644 --- a/core/java/android/view/ViewRootImpl.java +++ b/core/java/android/view/ViewRootImpl.java @@ -423,7 +423,7 @@ public final class ViewRootImpl implements ViewParent, @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553) int mHeight; @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553) - Rect mDirty; + private Rect mDirty; public boolean mIsAnimating; private boolean mUseMTRenderer; @@ -446,6 +446,23 @@ public final class ViewRootImpl implements ViewParent, @UnsupportedAppUsage FallbackEventHandler mFallbackEventHandler; final Choreographer mChoreographer; + protected final ViewFrameInfo mViewFrameInfo = new ViewFrameInfo(); + + /** + * Update the Choreographer's FrameInfo object with the timing information for the current + * ViewRootImpl instance. Erase the data in the current ViewFrameInfo to prepare for the next + * frame. + * @return the updated FrameInfo object + */ + protected @NonNull FrameInfo getUpdatedFrameInfo() { + // Since Choreographer is a thread-local singleton while we can have multiple + // ViewRootImpl's, populate the frame information from the current viewRootImpl before + // starting the draw + FrameInfo frameInfo = mChoreographer.mFrameInfo; + mViewFrameInfo.populateFrameInfo(frameInfo); + mViewFrameInfo.reset(); + return frameInfo; + } // used in relayout to get SurfaceControl size // for BLAST adapter surface setup @@ -2675,7 +2692,7 @@ public final class ViewRootImpl implements ViewParent, // to resume them mDirty.set(0, 0, mWidth, mHeight); } - mChoreographer.mFrameInfo.addFlags(FrameInfo.FLAG_WINDOW_LAYOUT_CHANGED); + mViewFrameInfo.flags |= FrameInfo.FLAG_WINDOW_LAYOUT_CHANGED; } relayoutResult = relayoutWindow(params, viewVisibility, insetsPending); @@ -8138,7 +8155,8 @@ public final class ViewRootImpl implements ViewParent, oldestEventTime = me.getHistoricalEventTimeNano(0); } } - mChoreographer.mFrameInfo.updateInputEventTime(eventTime, oldestEventTime); + mViewFrameInfo.updateOldestInputEvent(oldestEventTime); + mViewFrameInfo.updateNewestInputEvent(eventTime); deliverInputEvent(q); } -- cgit v1.2.3