• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
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 
18 #include <gui/TraceUtils.h>
19 
20 #include <cstring>
21 
22 namespace android {
23 namespace uirenderer {
24 
25 const std::array FrameInfoNames{"Flags",
26                                 "FrameTimelineVsyncId",
27                                 "IntendedVsync",
28                                 "Vsync",
29                                 "InputEventId",
30                                 "HandleInputStart",
31                                 "AnimationStart",
32                                 "PerformTraversalsStart",
33                                 "DrawStart",
34                                 "FrameDeadline",
35                                 "FrameStartTime",
36                                 "FrameInterval",
37                                 "WorkloadTarget",
38                                 "SyncQueued",
39                                 "SyncStart",
40                                 "IssueDrawCommandsStart",
41                                 "SwapBuffers",
42                                 "FrameCompleted",
43                                 "DequeueBufferDuration",
44                                 "QueueBufferDuration",
45                                 "GpuCompleted",
46                                 "SwapBuffersCompleted",
47                                 "DisplayPresentTime",
48                                 "CommandSubmissionCompleted"
49 
50 };
51 
52 static_assert(static_cast<int>(FrameInfoIndex::NumIndexes) == 24,
53               "Must update value in FrameMetrics.java#FRAME_STATS_COUNT (and here)");
54 
importUiThreadInfo(const int64_t * info)55 void FrameInfo::importUiThreadInfo(const int64_t* info) {
56     memcpy(mFrameInfo.data(), info, UI_THREAD_FRAME_INFO_SIZE * sizeof(int64_t));
57     mSkippedFrameReason.reset();
58 }
59 
toString(SkippedFrameReason reason)60 const 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 
setSkippedFrameReason(android::uirenderer::SkippedFrameReason reason)77 void FrameInfo::setSkippedFrameReason(android::uirenderer::SkippedFrameReason reason) {
78     ATRACE_FORMAT_INSTANT("Frame skipped: %s", toString(reason));
79     addFlag(FrameInfoFlags::SkippedFrame);
80     mSkippedFrameReason = reason;
81 }
82 
83 } /* namespace uirenderer */
84 } /* namespace android */
85