diff options
author | Justin Klaassen <justinklaassen@google.com> | 2017-09-15 17:58:39 -0400 |
---|---|---|
committer | Justin Klaassen <justinklaassen@google.com> | 2017-09-15 17:58:39 -0400 |
commit | 10d07c88d69cc64f73a069163e7ea5ba2519a099 (patch) | |
tree | 8dbd149eb350320a29c3d10e7ad3201de1c5cbee /android/view/FrameInfo.java | |
parent | 677516fb6b6f207d373984757d3d9450474b6b00 (diff) | |
download | android-28-10d07c88d69cc64f73a069163e7ea5ba2519a099.tar.gz |
Import Android SDK Platform PI [4335822]
/google/data/ro/projects/android/fetch_artifact \
--bid 4335822 \
--target sdk_phone_armv7-win_sdk \
sdk-repo-linux-sources-4335822.zip
AndroidVersion.ApiLevel has been modified to appear as 28
Change-Id: Ic8f04be005a71c2b9abeaac754d8da8d6f9a2c32
Diffstat (limited to 'android/view/FrameInfo.java')
-rw-r--r-- | android/view/FrameInfo.java | 118 |
1 files changed, 118 insertions, 0 deletions
diff --git a/android/view/FrameInfo.java b/android/view/FrameInfo.java new file mode 100644 index 00000000..c79547c8 --- /dev/null +++ b/android/view/FrameInfo.java @@ -0,0 +1,118 @@ +/* + * Copyright (C) 2015 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package android.view; + +import android.annotation.IntDef; + +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; + +/** + * Class that contains all the timing information for the current frame. This + * is used in conjunction with the hardware renderer to provide + * continous-monitoring jank events + * + * All times in nanoseconds from CLOCK_MONOTONIC/System.nanoTime() + * + * To minimize overhead from System.nanoTime() calls we infer durations of + * things by knowing the ordering of the events. For example, to know how + * long layout & measure took it's displayListRecordStart - performTraversalsStart. + * + * These constants must be kept in sync with FrameInfo.h in libhwui and are + * used for indexing into AttachInfo's mFrameInfo long[], which is intended + * to be quick to pass down to native via JNI, hence a pre-packed format + * + * @hide + */ +final class FrameInfo { + + long[] mFrameInfo = new long[9]; + + // Various flags set to provide extra metadata about the current frame + private static final int FLAGS = 0; + + // Is this the first-draw following a window layout? + public static final long FLAG_WINDOW_LAYOUT_CHANGED = 1; + + @IntDef(flag = true, value = { + FLAG_WINDOW_LAYOUT_CHANGED }) + @Retention(RetentionPolicy.SOURCE) + public @interface FrameInfoFlags {} + + // The intended vsync time, unadjusted by jitter + private static final int INTENDED_VSYNC = 1; + + // Jitter-adjusted vsync time, this is what was used as input into the + // animation & drawing system + private static final int VSYNC = 2; + + // The time of the oldest input event + private static final int OLDEST_INPUT_EVENT = 3; + + // The time of the newest input event + private static final int NEWEST_INPUT_EVENT = 4; + + // When input event handling started + private static final int HANDLE_INPUT_START = 5; + + // When animation evaluations started + private static final int ANIMATION_START = 6; + + // When ViewRootImpl#performTraversals() started + private static final int PERFORM_TRAVERSALS_START = 7; + + // When View:draw() started + private static final int DRAW_START = 8; + + public void setVsync(long intendedVsync, long usedVsync) { + mFrameInfo[INTENDED_VSYNC] = intendedVsync; + mFrameInfo[VSYNC] = usedVsync; + mFrameInfo[OLDEST_INPUT_EVENT] = Long.MAX_VALUE; + mFrameInfo[NEWEST_INPUT_EVENT] = 0; + mFrameInfo[FLAGS] = 0; + } + + public void updateInputEventTime(long inputEventTime, long inputEventOldestTime) { + if (inputEventOldestTime < mFrameInfo[OLDEST_INPUT_EVENT]) { + mFrameInfo[OLDEST_INPUT_EVENT] = inputEventOldestTime; + } + if (inputEventTime > mFrameInfo[NEWEST_INPUT_EVENT]) { + mFrameInfo[NEWEST_INPUT_EVENT] = inputEventTime; + } + } + + public void markInputHandlingStart() { + mFrameInfo[HANDLE_INPUT_START] = System.nanoTime(); + } + + public void markAnimationsStart() { + mFrameInfo[ANIMATION_START] = System.nanoTime(); + } + + public void markPerformTraversalsStart() { + mFrameInfo[PERFORM_TRAVERSALS_START] = System.nanoTime(); + } + + public void markDrawStart() { + mFrameInfo[DRAW_START] = System.nanoTime(); + } + + public void addFlags(@FrameInfoFlags long flags) { + mFrameInfo[FLAGS] |= flags; + } + +} |