blob: 36bf53201e6f2406edb7da5773b3f22011fdee71 [file] [log] [blame]
Aurimas Liutikas93554f22022-04-19 16:51:35 -07001/*
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
17package android.view;
18
19import android.graphics.FrameInfo;
20import android.os.IInputConstants;
21
22/**
23 * The timing information of events taking place in ViewRootImpl
24 * @hide
25 */
26public 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 /**
38 * Populate the missing fields using the data from ViewFrameInfo
39 * @param frameInfo : the structure FrameInfo object to populate
40 */
41 public void populateFrameInfo(FrameInfo frameInfo) {
42 frameInfo.frameInfo[FrameInfo.FLAGS] |= flags;
43 frameInfo.frameInfo[FrameInfo.DRAW_START] = drawStart;
44 frameInfo.frameInfo[FrameInfo.INPUT_EVENT_ID] = mInputEventId;
45 }
46
47 /**
48 * Reset this data. Should typically be invoked after calling "populateFrameInfo".
49 */
50 public void reset() {
51 drawStart = 0;
52 mInputEventId = IInputConstants.INVALID_INPUT_EVENT_ID;
53 flags = 0;
54 }
55
56 /**
57 * Record the current time, and store it in 'drawStart'
58 */
59 public void markDrawStart() {
60 drawStart = System.nanoTime();
61 }
62
63 /**
64 * Assign the value for input event id
65 * @param eventId the id of the input event
66 */
67 public void setInputEvent(int eventId) {
68 mInputEventId = eventId;
69 }
70}