blob: 0e52f4e177c5430e80347c40e8f090b114c0e0c7 [file] [log] [blame]
John Reckba6adf62015-02-19 14:36:50 -08001/*
2 * Copyright (C) 2015 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#include "FrameInfo.h"
17
Ady Abrahame088dcd2023-08-10 11:45:58 -070018#include <gui/TraceUtils.h>
19
John Reckba6adf62015-02-19 14:36:50 -080020#include <cstring>
21
22namespace android {
23namespace uirenderer {
24
Alec Mouri3afb3972022-05-27 22:03:11 +000025const std::array FrameInfoNames{"Flags",
26 "FrameTimelineVsyncId",
27 "IntendedVsync",
28 "Vsync",
29 "InputEventId",
30 "HandleInputStart",
31 "AnimationStart",
32 "PerformTraversalsStart",
33 "DrawStart",
34 "FrameDeadline",
Alec Mouri3afb3972022-05-27 22:03:11 +000035 "FrameStartTime",
Melody Hsu92b519b2025-02-05 22:01:40 +000036 "FrameInterval",
37 "WorkloadTarget",
Alec Mouri3afb3972022-05-27 22:03:11 +000038 "SyncQueued",
39 "SyncStart",
40 "IssueDrawCommandsStart",
41 "SwapBuffers",
42 "FrameCompleted",
43 "DequeueBufferDuration",
44 "QueueBufferDuration",
45 "GpuCompleted",
46 "SwapBuffersCompleted",
47 "DisplayPresentTime",
48 "CommandSubmissionCompleted"
Jorim Jaggi10f328c2021-01-19 00:08:02 +010049
John Reck4db3d172015-06-02 15:58:43 -070050};
51
Melody Hsu92b519b2025-02-05 22:01:40 +000052static_assert(static_cast<int>(FrameInfoIndex::NumIndexes) == 24,
John Reck1bcacfd2017-11-03 10:12:19 -070053 "Must update value in FrameMetrics.java#FRAME_STATS_COUNT (and here)");
John Reck65ddb152016-08-02 09:38:26 -070054
Siarhei Vishniakoub07fe1d2025-02-13 13:23:53 -080055void FrameInfo::importUiThreadInfo(const int64_t* info) {
Siarhei Vishniakouaed22822025-02-18 11:35:58 -080056 memcpy(mFrameInfo.data(), info, UI_THREAD_FRAME_INFO_SIZE * sizeof(int64_t));
Ady Abrahame088dcd2023-08-10 11:45:58 -070057 mSkippedFrameReason.reset();
58}
59
60const char* toString(SkippedFrameReason reason) {
61 switch (reason) {
62 case SkippedFrameReason::DrawingOff:
63 return "DrawingOff";
64 case SkippedFrameReason::ContextIsStopped:
65 return "ContextIsStopped";
66 case SkippedFrameReason::NothingToDraw:
67 return "NothingToDraw";
68 case SkippedFrameReason::NoOutputTarget:
69 return "NoOutputTarget";
70 case SkippedFrameReason::NoBuffer:
71 return "NoBuffer";
72 case SkippedFrameReason::AlreadyDrawn:
73 return "AlreadyDrawn";
74 }
75}
76
77void FrameInfo::setSkippedFrameReason(android::uirenderer::SkippedFrameReason reason) {
78 ATRACE_FORMAT_INSTANT("Frame skipped: %s", toString(reason));
79 addFlag(FrameInfoFlags::SkippedFrame);
80 mSkippedFrameReason = reason;
John Reckba6adf62015-02-19 14:36:50 -080081}
82
83} /* namespace uirenderer */
84} /* namespace android */