1 /* 2 * Copyright (c) 2022 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #ifndef FOUNDATION_ACE_FRAMEWORKS_BASE_LOG_FRAME_REPORT_H 17 #define FOUNDATION_ACE_FRAMEWORKS_BASE_LOG_FRAME_REPORT_H 18 19 #include <string> 20 #include <unordered_map> 21 22 #include "base/utils/macros.h" 23 #include "base/utils/noncopyable.h" 24 25 namespace OHOS::Ace { 26 enum class FrameSchedEvent { 27 SCHED_EVENT_BASE = 0, 28 INIT, 29 UI_FLUSH_BEGIN = 20001, 30 UI_FLUSH_END, 31 UI_SCB_WORKER_BEGIN, 32 UI_SCB_WORKER_END, 33 SCHED_EVENT_MAX, 34 }; 35 using FrameInitFunc = void (*)(); 36 using FrameGetEnableFunc = int (*)(); 37 using BeginFlushAnimationFunc = void (*)(); 38 using EndFlushAnimationFunc = void (*)(); 39 using BeginFlushBuildFunc = void (*)(); 40 using EndFlushBuildFunc = void (*)(); 41 using BeginFlushLayoutFunc = void (*)(); 42 using EndFlushLayoutFunc = void (*)(); 43 using BeginFlushRenderFunc = void (*)(); 44 using EndFlushRenderFunc = void (*)(); 45 using BeginFlushRenderFinishFunc = void (*)(); 46 using EndFlushRenderFinishFunc = void (*)(); 47 using BeginProcessPostFlushFunc = void (*)(); 48 using BeginListFlingFunc = void (*)(); 49 using EndListFlingFunc = void (*)(); 50 using FlushBeginFunc = void (*)(); 51 using FlushEndFunc = void (*)(); 52 using SetFrameParamFunc = void (*)(int, int, int, int); 53 using EnableSelfRenderFunc = void (*)(); 54 using DisableSelfRenderFunc = void (*)(); 55 using ReportSchedEventFunc = 56 void (*)(FrameSchedEvent, const std::unordered_map<std::string, std::string>&); 57 58 class ACE_EXPORT FrameReport final { 59 public: 60 static FrameReport& GetInstance(); 61 void Init(); 62 int GetEnable(); 63 void BeginFlushAnimation(); 64 void EndFlushAnimation(); 65 66 void BeginFlushBuild(); 67 void EndFlushBuild(); 68 void BeginFlushLayout(); 69 void EndFlushLayout(); 70 void BeginFlushRender(); 71 void EndFlushRender(); 72 void BeginFlushRenderFinish(); 73 void EndFlushRenderFinish(); 74 void BeginProcessPostFlush(); 75 void BeginListFling(); 76 void EndListFling(); 77 void FlushBegin(); 78 void FlushEnd(); 79 void SetFrameParam(int requestId, int load, int schedFrameNum, int value); 80 void EnableSelfRender(); 81 void DisableSelfRender(); 82 void ReportSchedEvent( 83 FrameSchedEvent event, const std::unordered_map<std::string, std::string>& payLoad); 84 85 private: 86 FrameReport(); 87 ~FrameReport(); 88 bool LoadLibrary(); 89 void CloseLibrary(); 90 void* LoadSymbol(const char* symName); 91 int GetFrameReportEnable(); 92 void* frameSchedHandle_ = nullptr; 93 bool frameSchedSoLoaded_ = false; 94 bool enable_ = false; 95 96 ACE_EXPORT FrameInitFunc frameInitFunc_ = nullptr; 97 ACE_EXPORT FrameGetEnableFunc frameGetEnableFunc_ = nullptr; 98 ACE_EXPORT BeginFlushAnimationFunc beginFlushAnimationFunc_ = nullptr; 99 ACE_EXPORT EndFlushAnimationFunc endFlushAnimationFunc_ = nullptr; 100 ACE_EXPORT BeginFlushBuildFunc beginFlushBuildFunc_ = nullptr; 101 ACE_EXPORT EndFlushBuildFunc endFlushBuildFunc_ = nullptr; 102 ACE_EXPORT BeginFlushLayoutFunc beginFlushLayoutFunc_ = nullptr; 103 ACE_EXPORT EndFlushLayoutFunc endFlushLayoutFunc_ = nullptr; 104 ACE_EXPORT BeginFlushRenderFunc beginFlushRenderFunc_ = nullptr; 105 ACE_EXPORT EndFlushRenderFunc endFlushRenderFunc_ = nullptr; 106 ACE_EXPORT BeginFlushRenderFinishFunc beginFlushRenderFinishFunc_ = nullptr; 107 ACE_EXPORT EndFlushRenderFinishFunc endFlushRenderFinishFunc_ = nullptr; 108 ACE_EXPORT BeginProcessPostFlushFunc beginProcessPostFunc_ = nullptr; 109 ACE_EXPORT BeginListFlingFunc beginListFlingFunc_ = nullptr; 110 ACE_EXPORT EndListFlingFunc endListFlingFunc_ = nullptr; 111 ACE_EXPORT FlushBeginFunc flushBeginFunc_ = nullptr; 112 ACE_EXPORT FlushEndFunc flushEndFunc_ = nullptr; 113 ACE_EXPORT SetFrameParamFunc setFrameParamFunc_ = nullptr; 114 ACE_EXPORT EnableSelfRenderFunc enableSelfRenderFunc_ = nullptr; 115 ACE_EXPORT DisableSelfRenderFunc disableSelfRenderFunc_ = nullptr; 116 ACE_EXPORT ReportSchedEventFunc reportSchedEventFunc_ = nullptr; 117 }; 118 } // namespace OHOS::Ace 119 #endif // FOUNDATION_ACE_FRAMEWORKS_BASE_LOG_FRAME_REPORT_H 120