1 /* 2 * Copyright (C) 2020 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package android.view; 18 19 import android.graphics.FrameInfo; 20 import android.os.IInputConstants; 21 22 /** 23 * The timing information of events taking place in ViewRootImpl 24 * @hide 25 */ 26 public class ViewFrameInfo { 27 public long drawStart; 28 29 30 // Various flags set to provide extra metadata about the current frame. See flag definitions 31 // inside FrameInfo. 32 // @see android.graphics.FrameInfo.FLAG_WINDOW_LAYOUT_CHANGED 33 public long flags; 34 35 private int mInputEventId; 36 37 private int mViewsMeasuredCounts; 38 39 /** 40 * Populate the missing fields using the data from ViewFrameInfo 41 * @param frameInfo : the structure FrameInfo object to populate 42 */ populateFrameInfo(FrameInfo frameInfo)43 public void populateFrameInfo(FrameInfo frameInfo) { 44 frameInfo.frameInfo[FrameInfo.FLAGS] |= flags; 45 frameInfo.frameInfo[FrameInfo.DRAW_START] = drawStart; 46 frameInfo.frameInfo[FrameInfo.INPUT_EVENT_ID] = mInputEventId; 47 } 48 49 /** 50 * Reset this data. Should typically be invoked after calling "populateFrameInfo". 51 */ reset()52 public void reset() { 53 drawStart = 0; 54 mInputEventId = IInputConstants.INVALID_INPUT_EVENT_ID; 55 flags = 0; 56 mViewsMeasuredCounts = 0; 57 } 58 59 /** 60 * Record the current time, and store it in 'drawStart' 61 */ markDrawStart()62 public void markDrawStart() { 63 drawStart = System.nanoTime(); 64 } 65 66 /** 67 * Record the number of view being measured for the current frame. 68 */ getAndIncreaseViewMeasuredCount()69 public int getAndIncreaseViewMeasuredCount() { 70 return ++mViewsMeasuredCounts; 71 } 72 73 /** 74 * Assign the value for input event id 75 * @param eventId the id of the input event 76 */ setInputEvent(int eventId)77 public void setInputEvent(int eventId) { 78 mInputEventId = eventId; 79 } 80 } 81