| John Reck | ba6adf6 | 2015-02-19 14:36:50 -0800 | [diff] [blame] | 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 |  | 
| Ady Abraham | e088dcd | 2023-08-10 11:45:58 -0700 | [diff] [blame] | 18 | #include <gui/TraceUtils.h> | 
|  | 19 |  | 
| John Reck | ba6adf6 | 2015-02-19 14:36:50 -0800 | [diff] [blame] | 20 | #include <cstring> | 
|  | 21 |  | 
|  | 22 | namespace android { | 
|  | 23 | namespace uirenderer { | 
|  | 24 |  | 
| Alec Mouri | 3afb397 | 2022-05-27 22:03:11 +0000 | [diff] [blame] | 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 | "FrameInterval", | 
|  | 36 | "FrameStartTime", | 
|  | 37 | "SyncQueued", | 
|  | 38 | "SyncStart", | 
|  | 39 | "IssueDrawCommandsStart", | 
|  | 40 | "SwapBuffers", | 
|  | 41 | "FrameCompleted", | 
|  | 42 | "DequeueBufferDuration", | 
|  | 43 | "QueueBufferDuration", | 
|  | 44 | "GpuCompleted", | 
|  | 45 | "SwapBuffersCompleted", | 
|  | 46 | "DisplayPresentTime", | 
|  | 47 | "CommandSubmissionCompleted" | 
| Jorim Jaggi | 10f328c | 2021-01-19 00:08:02 +0100 | [diff] [blame] | 48 |  | 
| John Reck | 4db3d17 | 2015-06-02 15:58:43 -0700 | [diff] [blame] | 49 | }; | 
|  | 50 |  | 
| Alec Mouri | 3afb397 | 2022-05-27 22:03:11 +0000 | [diff] [blame] | 51 | static_assert(static_cast<int>(FrameInfoIndex::NumIndexes) == 23, | 
| John Reck | 1bcacfd | 2017-11-03 10:12:19 -0700 | [diff] [blame] | 52 | "Must update value in FrameMetrics.java#FRAME_STATS_COUNT (and here)"); | 
| John Reck | 65ddb15 | 2016-08-02 09:38:26 -0700 | [diff] [blame] | 53 |  | 
| John Reck | ba6adf6 | 2015-02-19 14:36:50 -0800 | [diff] [blame] | 54 | void FrameInfo::importUiThreadInfo(int64_t* info) { | 
|  | 55 | memcpy(mFrameInfo, info, UI_THREAD_FRAME_INFO_SIZE * sizeof(int64_t)); | 
| Ady Abraham | e088dcd | 2023-08-10 11:45:58 -0700 | [diff] [blame] | 56 | mSkippedFrameReason.reset(); | 
|  | 57 | } | 
|  | 58 |  | 
|  | 59 | const char* toString(SkippedFrameReason reason) { | 
|  | 60 | switch (reason) { | 
|  | 61 | case SkippedFrameReason::DrawingOff: | 
|  | 62 | return "DrawingOff"; | 
|  | 63 | case SkippedFrameReason::ContextIsStopped: | 
|  | 64 | return "ContextIsStopped"; | 
|  | 65 | case SkippedFrameReason::NothingToDraw: | 
|  | 66 | return "NothingToDraw"; | 
|  | 67 | case SkippedFrameReason::NoOutputTarget: | 
|  | 68 | return "NoOutputTarget"; | 
|  | 69 | case SkippedFrameReason::NoBuffer: | 
|  | 70 | return "NoBuffer"; | 
|  | 71 | case SkippedFrameReason::AlreadyDrawn: | 
|  | 72 | return "AlreadyDrawn"; | 
|  | 73 | } | 
|  | 74 | } | 
|  | 75 |  | 
|  | 76 | void FrameInfo::setSkippedFrameReason(android::uirenderer::SkippedFrameReason reason) { | 
|  | 77 | ATRACE_FORMAT_INSTANT("Frame skipped: %s", toString(reason)); | 
|  | 78 | addFlag(FrameInfoFlags::SkippedFrame); | 
|  | 79 | mSkippedFrameReason = reason; | 
| John Reck | ba6adf6 | 2015-02-19 14:36:50 -0800 | [diff] [blame] | 80 | } | 
|  | 81 |  | 
|  | 82 | } /* namespace uirenderer */ | 
|  | 83 | } /* namespace android */ |