1 /* 2 * Copyright (c) 2024 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 RENDER_SERVICE_PROFILER_H 17 #define RENDER_SERVICE_PROFILER_H 18 19 #ifdef RS_PROFILER_ENABLED 20 21 #include <map> 22 #include <string> 23 24 #include "recording/draw_cmd_list.h" 25 26 #include "common/rs_vector4.h" 27 #include "params/rs_display_render_params.h" 28 29 #define RS_PROFILER_INIT(renderSevice) RSProfiler::Init(renderSevice) 30 #define RS_PROFILER_ON_FRAME_BEGIN() RSProfiler::OnFrameBegin() 31 #define RS_PROFILER_ON_FRAME_END() RSProfiler::OnFrameEnd() 32 #define RS_PROFILER_ON_RENDER_BEGIN() RSProfiler::OnRenderBegin() 33 #define RS_PROFILER_ON_RENDER_END() RSProfiler::OnRenderEnd() 34 #define RS_PROFILER_ON_PROCESS_COMMAND() RSProfiler::OnProcessCommand() 35 #define RS_PROFILER_ON_CREATE_CONNECTION(pid) RSProfiler::OnCreateConnection(pid) 36 #define RS_PROFILER_ON_REMOTE_REQUEST(connection, code, data, reply, option) \ 37 RSProfiler::OnRemoteRequest(connection, code, data, reply, option) 38 #define RS_PROFILER_ON_PARCEL_RECEIVE(parcel, data) RSProfiler::OnRecvParcel(parcel, data) 39 #define RS_PROFILER_COPY_PARCEL(parcel) RSProfiler::CopyParcel(parcel) 40 #define RS_PROFILER_PATCH_NODE_ID(parcel, id) id = RSProfiler::PatchNodeId(parcel, id) 41 #define RS_PROFILER_PATCH_TYPEFACE_GLOBALID(parcel, id) id = RSProfiler::PatchNodeId(parcel, id) 42 #define RS_PROFILER_PATCH_PID(parcel, pid) pid = RSProfiler::PatchPid(parcel, pid) 43 #define RS_PROFILER_PATCH_TIME(time) time = RSProfiler::PatchTime(time) 44 #define RS_PROFILER_PATCH_TRANSACTION_TIME(parcel, time) time = RSProfiler::PatchTransactionTime(parcel, time) 45 #define RS_PROFILER_PATCH_COMMAND(parcel, command) RSProfiler::PatchCommand(parcel, command) 46 #define RS_PROFILER_EXECUTE_COMMAND(command) RSProfiler::ExecuteCommand(command) 47 #define RS_PROFILER_MARSHAL_PIXELMAP(parcel, map) RSProfiler::MarshalPixelMap(parcel, map) 48 #define RS_PROFILER_UNMARSHAL_PIXELMAP(parcel) RSProfiler::UnmarshalPixelMap(parcel) 49 #define RS_PROFILER_SKIP_PIXELMAP(parcel) RSProfiler::SkipPixelMap(parcel) 50 #define RS_PROFILER_MARSHAL_DRAWINGIMAGE(image, compressData) RSProfiler::MarshalDrawingImage(image, compressData) 51 #define RS_PROFILER_SET_DIRTY_REGION(dirtyRegion) RSProfiler::SetDirtyRegion(dirtyRegion) 52 #define RS_PROFILER_WRITE_PARCEL_DATA(parcel) RSProfiler::WriteParcelData(parcel) 53 #define RS_PROFILER_READ_PARCEL_DATA(parcel, size, isMalloc) RSProfiler::ReadParcelData(parcel, size, isMalloc) 54 #define RS_PROFILER_SKIP_PARCEL_DATA(parcel, size) RSProfiler::SkipParcelData(parcel, size) 55 #define RS_PROFILER_GET_FRAME_NUMBER() RSProfiler::GetFrameNumber() 56 #define RS_PROFILER_ON_PARALLEL_RENDER_BEGIN() RSProfiler::OnParallelRenderBegin() 57 #define RS_PROFILER_ON_PARALLEL_RENDER_END(renderFrameNumber) RSProfiler::OnParallelRenderEnd(renderFrameNumber) 58 #define RS_PROFILER_SHOULD_BLOCK_HWCNODE() RSProfiler::ShouldBlockHWCNode() 59 #define RS_PROFILER_ANIME_SET_START_TIME(id, time) RSProfiler::AnimeSetStartTime(id, time) 60 #define RS_PROFILER_REPLAY_FIX_TRINDEX(curIndex, lastIndex) RSProfiler::ReplayFixTrIndex(curIndex, lastIndex) 61 #define RS_PROFILER_PATCH_TYPEFACE_ID(parcel, val) RSProfiler::PatchTypefaceId(parcel, val) 62 #define RS_PROFILER_DRAWING_NODE_ADD_CLEAROP(drawCmdList) RSProfiler::DrawingNodeAddClearOp(drawCmdList) 63 #else 64 #define RS_PROFILER_INIT(renderSevice) 65 #define RS_PROFILER_ON_FRAME_BEGIN() 66 #define RS_PROFILER_ON_FRAME_END() 67 #define RS_PROFILER_ON_RENDER_BEGIN() 68 #define RS_PROFILER_ON_RENDER_END() 69 #define RS_PROFILER_ON_PROCESS_COMMAND() 70 #define RS_PROFILER_ON_CREATE_CONNECTION(pid) 71 #define RS_PROFILER_ON_REMOTE_REQUEST(connection, code, data, reply, option) 72 #define RS_PROFILER_ON_PARCEL_RECEIVE(parcel, data) 73 #define RS_PROFILER_COPY_PARCEL(parcel) std::make_shared<MessageParcel>() 74 #define RS_PROFILER_PATCH_NODE_ID(parcel, id) 75 #define RS_PROFILER_PATCH_TYPEFACE_GLOBALID(parcel, id) 76 #define RS_PROFILER_PATCH_PID(parcel, pid) 77 #define RS_PROFILER_PATCH_TIME(time) 78 #define RS_PROFILER_PATCH_TRANSACTION_TIME(parcel, time) 79 #define RS_PROFILER_PATCH_COMMAND(parcel, command) 80 #define RS_PROFILER_EXECUTE_COMMAND(command) 81 #define RS_PROFILER_MARSHAL_PIXELMAP(parcel, map) (map)->Marshalling(parcel) 82 #define RS_PROFILER_UNMARSHAL_PIXELMAP(parcel) Media::PixelMap::Unmarshalling(parcel) 83 #define RS_PROFILER_SKIP_PIXELMAP(parcel) false 84 #define RS_PROFILER_MARSHAL_DRAWINGIMAGE(image, compressData) 85 #define RS_PROFILER_SET_DIRTY_REGION(dirtyRegion) 86 #define RS_PROFILER_WRITE_PARCEL_DATA(parcel) 87 #define RS_PROFILER_READ_PARCEL_DATA(parcel, size, isMalloc) RSMarshallingHelper::ReadFromAshmem(parcel, size, isMalloc) 88 #define RS_PROFILER_SKIP_PARCEL_DATA(parcel, size) false 89 #define RS_PROFILER_GET_FRAME_NUMBER() 0 90 #define RS_PROFILER_ON_PARALLEL_RENDER_BEGIN() 91 #define RS_PROFILER_ON_PARALLEL_RENDER_END(renderFrameNumber) 92 #define RS_PROFILER_SHOULD_BLOCK_HWCNODE() false 93 #define RS_PROFILER_ANIME_SET_START_TIME(id, time) time 94 #define RS_PROFILER_REPLAY_FIX_TRINDEX(curIndex, lastIndex) 95 #define RS_PROFILER_PATCH_TYPEFACE_ID(parcel, val) 96 #define RS_PROFILER_DRAWING_NODE_ADD_CLEAROP(drawCmdList) (drawCmdList)->ClearOp() 97 #endif 98 99 #ifdef RS_PROFILER_ENABLED 100 101 namespace OHOS { 102 class Parcel; 103 class MessageParcel; 104 class MessageOption; 105 106 } // namespace OHOS 107 108 namespace OHOS::Media { 109 class PixelMap; 110 } // namespace OHOS::Media 111 112 namespace OHOS::Rosen { 113 114 class RSRenderService; 115 class RSMainThread; 116 class RSIRenderServiceConnection; 117 class RSRenderServiceConnection; 118 class RSTransactionData; 119 class RSRenderNode; 120 class RSRenderModifier; 121 class RSProperties; 122 class RSContext; 123 class RSDisplayRenderNode; 124 class RSRenderNodeMap; 125 class RSAnimationManager; 126 class RSRenderAnimation; 127 class RSCommand; 128 class ArgList; 129 class JsonWriter; 130 class RSFile; 131 132 enum class Mode { NONE = 0, READ = 1, WRITE = 2, READ_EMUL = 3, WRITE_EMUL = 4 }; 133 134 class RSProfiler final { 135 public: 136 static void Init(RSRenderService* renderService); 137 static void StartNetworkThread(); 138 139 // see RSMainThread::Init 140 static void OnFrameBegin(); 141 static void OnFrameEnd(); 142 static void OnRenderBegin(); 143 static void OnRenderEnd(); 144 static void OnParallelRenderBegin(); 145 static void OnParallelRenderEnd(uint32_t frameNumber); 146 static void OnProcessCommand(); 147 148 // see RSRenderService::CreateConnection 149 static void OnCreateConnection(pid_t pid); 150 151 // see RenderServiceConnection::OnRemoteRequest 152 static void OnRemoteRequest(RSIRenderServiceConnection* connection, uint32_t code, MessageParcel& parcel, 153 MessageParcel& reply, MessageOption& option); 154 155 // see UnmarshalThread::RecvParcel 156 static void OnRecvParcel(const MessageParcel* parcel, RSTransactionData* data); 157 158 RSB_EXPORT static std::shared_ptr<MessageParcel> CopyParcel(const MessageParcel& parcel); 159 RSB_EXPORT static uint64_t PatchTime(uint64_t time); 160 RSB_EXPORT static uint64_t PatchTransactionTime(const Parcel& parcel, uint64_t timeAtRecordProcess); 161 162 RSB_EXPORT static void PatchTypefaceId(const Parcel& parcel, std::shared_ptr<Drawing::DrawCmdList>& val); 163 164 template<typename T> PatchNodeId(const Parcel& parcel, T id)165 static T PatchNodeId(const Parcel& parcel, T id) 166 { 167 return static_cast<T>(PatchPlainNodeId(parcel, static_cast<NodeId>(id))); 168 } 169 170 template<typename T> PatchPid(const Parcel& parcel, T pid)171 static T PatchPid(const Parcel& parcel, T pid) 172 { 173 return static_cast<T>(PatchPlainPid(parcel, static_cast<pid_t>(pid))); 174 } 175 176 RSB_EXPORT static void PatchCommand(const Parcel& parcel, RSCommand* command); 177 RSB_EXPORT static void ExecuteCommand(const RSCommand* command); 178 RSB_EXPORT static bool MarshalPixelMap(Parcel& parcel, const std::shared_ptr<Media::PixelMap>& map); 179 RSB_EXPORT static Media::PixelMap* UnmarshalPixelMap(Parcel& parcel); 180 RSB_EXPORT static bool SkipPixelMap(Parcel& parcel); 181 RSB_EXPORT static void MarshalDrawingImage(std::shared_ptr<Drawing::Image>& image, 182 std::shared_ptr<Drawing::Data>& compressData); 183 RSB_EXPORT static void SetDirtyRegion(const Occlusion::Region& dirtyRegion); 184 185 RSB_EXPORT static void WriteParcelData(Parcel& parcel); 186 RSB_EXPORT static const void* ReadParcelData(Parcel& parcel, size_t size, bool& isMalloc); 187 RSB_EXPORT static bool SkipParcelData(Parcel& parcel, size_t size); 188 RSB_EXPORT static uint32_t GetFrameNumber(); 189 RSB_EXPORT static bool ShouldBlockHWCNode(); 190 191 RSB_EXPORT static std::unordered_map<AnimationId, std::vector<int64_t>> &AnimeGetStartTimes(); 192 RSB_EXPORT static int64_t AnimeSetStartTime(AnimationId id, int64_t nanoTime); 193 RSB_EXPORT static std::string SendMessageBase(); 194 RSB_EXPORT static void SendMessageBase(const std::string& msg); 195 RSB_EXPORT static void ReplayFixTrIndex(uint64_t curIndex, uint64_t& lastIndex); 196 197 public: 198 RSB_EXPORT static bool IsParcelMock(const Parcel& parcel); 199 RSB_EXPORT static bool IsSharedMemoryEnabled(); 200 RSB_EXPORT static bool IsBetaRecordEnabled(); 201 RSB_EXPORT static bool IsBetaRecordEnabledWithMetrics(); 202 RSB_EXPORT static Mode GetMode(); 203 204 RSB_EXPORT static void DrawingNodeAddClearOp(const std::shared_ptr<Drawing::DrawCmdList>& drawCmdList); 205 RSB_EXPORT static void SetDrawingCanvasNodeRedraw(bool enable); 206 207 private: 208 static const char* GetProcessNameByPid(int pid); 209 210 RSB_EXPORT static void EnableSharedMemory(); 211 RSB_EXPORT static void DisableSharedMemory(); 212 213 // Beta record 214 RSB_EXPORT static void EnableBetaRecord(); 215 RSB_EXPORT static bool IsBetaRecordSavingTriggered(); 216 static void StartBetaRecord(); 217 static void StopBetaRecord(); 218 static bool IsBetaRecordStarted(); 219 static void UpdateBetaRecord(); 220 static void SaveBetaRecord(); 221 static bool IsBetaRecordInactive(); 222 static void RequestVSyncOnBetaRecordInactivity(); 223 static void LaunchBetaRecordNotificationThread(); 224 static void LaunchBetaRecordMetricsUpdateThread(); 225 static void WriteBetaRecordFileThread(RSFile& file, const std::string& path); 226 static bool OpenBetaRecordFile(RSFile& file); 227 static bool SaveBetaRecordFile(RSFile& file); 228 static void WriteBetaRecordMetrics(RSFile& file, double time); 229 static void UpdateDirtyRegionBetaRecord(double currentFrameDirtyRegion); 230 231 RSB_EXPORT static void SetMode(Mode mode); 232 RSB_EXPORT static bool IsEnabled(); 233 234 RSB_EXPORT static uint32_t GetCommandCount(); 235 RSB_EXPORT static uint32_t GetCommandExecuteCount(); 236 RSB_EXPORT static std::string GetCommandParcelList(double recordStartTime); 237 238 RSB_EXPORT static const std::vector<pid_t>& GetPids(); 239 RSB_EXPORT static NodeId GetParentNode(); 240 RSB_EXPORT static void SetSubstitutingPid(const std::vector<pid_t>& pids, pid_t pid, NodeId parent); 241 RSB_EXPORT static pid_t GetSubstitutingPid(); 242 243 private: 244 RSB_EXPORT static void SetTransactionTimeCorrection(double replayStartTime, double recordStartTime); 245 RSB_EXPORT static void TimePauseAt(uint64_t curTime, uint64_t newPauseAfterTime); 246 RSB_EXPORT static void TimePauseResume(uint64_t curTime); 247 RSB_EXPORT static void TimePauseClear(); 248 RSB_EXPORT static uint64_t TimePauseGet(); 249 250 RSB_EXPORT static std::shared_ptr<RSDisplayRenderNode> GetDisplayNode(const RSContext& context); 251 RSB_EXPORT static Vector4f GetScreenRect(const RSContext& context); 252 253 // RSRenderNodeMap 254 RSB_EXPORT static void FilterForPlayback(RSContext& context, pid_t pid); 255 RSB_EXPORT static void FilterMockNode(RSContext& context); 256 257 RSB_EXPORT static void GetSurfacesTrees( 258 const RSContext& context, std::map<std::string, std::tuple<NodeId, std::string>>& list); 259 RSB_EXPORT static void GetSurfacesTrees(const RSContext& context, pid_t pid, std::map<NodeId, std::string>& list); 260 RSB_EXPORT static size_t GetRenderNodeCount(const RSContext& context); 261 RSB_EXPORT static NodeId GetRandomSurfaceNode(const RSContext& context); 262 263 RSB_EXPORT static void MarshalNodes(const RSContext& context, std::stringstream& data, uint32_t fileVersion); 264 RSB_EXPORT static void MarshalTree(const RSRenderNode& node, std::stringstream& data, uint32_t fileVersion); 265 RSB_EXPORT static void MarshalNode(const RSRenderNode& node, std::stringstream& data, uint32_t fileVersion); 266 RSB_EXPORT static void MarshalNodeModifiers( 267 const RSRenderNode& node, std::stringstream& data, uint32_t fileVersion); 268 269 RSB_EXPORT static void UnmarshalNodes(RSContext& context, std::stringstream& data, uint32_t fileVersion); 270 RSB_EXPORT static void UnmarshalTree(RSContext& context, std::stringstream& data, uint32_t fileVersion); 271 RSB_EXPORT static void UnmarshalNode(RSContext& context, std::stringstream& data, uint32_t fileVersion); 272 RSB_EXPORT static void UnmarshalNode( 273 RSContext& context, std::stringstream& data, NodeId nodeId, uint32_t fileVersion); 274 RSB_EXPORT static void UnmarshalNodeModifiers(RSRenderNode& node, std::stringstream& data, uint32_t fileVersion); 275 276 RSB_EXPORT static NodeId AdjustNodeId(NodeId nodeId, bool clearMockFlag); 277 278 // RSRenderNode 279 RSB_EXPORT static std::string DumpRenderProperties(const RSRenderNode& node); 280 RSB_EXPORT static std::string DumpModifiers(const RSRenderNode& node); 281 RSB_EXPORT static std::string DumpSurfaceNode(const RSRenderNode& node); 282 283 // JSON 284 static void RenderServiceTreeDump(JsonWriter& out, pid_t pid); 285 RSB_EXPORT static void DumpNode(const RSRenderNode& node, JsonWriter& out, 286 bool clearMockFlag = false, bool absRoot = false); 287 RSB_EXPORT static void DumpNodeAbsoluteProperties(const RSRenderNode& node, JsonWriter& out); 288 RSB_EXPORT static void DumpNodeAnimations(const RSAnimationManager& animationManager, JsonWriter& out); 289 RSB_EXPORT static void DumpNodeAnimation(const RSRenderAnimation& animation, JsonWriter& out); 290 RSB_EXPORT static void DumpNodeBaseInfo(const RSRenderNode& node, JsonWriter& out, bool clearMockFlag); 291 RSB_EXPORT static void DumpNodeSubsurfaces(const RSRenderNode& node, JsonWriter& out); 292 RSB_EXPORT static void DumpNodeSubClassNode(const RSRenderNode& node, JsonWriter& out); 293 RSB_EXPORT static void DumpNodeOptionalFlags(const RSRenderNode& node, JsonWriter& out); 294 RSB_EXPORT static void DumpNodeDrawCmdModifiers(const RSRenderNode& node, JsonWriter& out); 295 RSB_EXPORT static void DumpNodeDrawCmdModifier( 296 const RSRenderNode& node, JsonWriter& out, int type, RSRenderModifier& modifier); 297 RSB_EXPORT static void DumpNodeProperties(const RSProperties& properties, JsonWriter& out); 298 RSB_EXPORT static void DumpNodePropertiesClip(const RSProperties& properties, JsonWriter& out); 299 RSB_EXPORT static void DumpNodePropertiesTransform(const RSProperties& properties, JsonWriter& out); 300 RSB_EXPORT static void DumpNodePropertiesNonSpatial(const RSProperties& properties, JsonWriter& out); 301 RSB_EXPORT static void DumpNodePropertiesDecoration(const RSProperties& properties, JsonWriter& out); 302 RSB_EXPORT static void DumpNodePropertiesEffects(const RSProperties& properties, JsonWriter& out); 303 RSB_EXPORT static void DumpNodePropertiesShadow(const RSProperties& properties, JsonWriter& out); 304 RSB_EXPORT static void DumpNodePropertiesColor(const RSProperties& properties, JsonWriter& out); 305 RSB_EXPORT static void DumpNodeChildrenListUpdate(const RSRenderNode& node, JsonWriter& out); 306 307 // RSAnimationManager 308 RSB_EXPORT static void FilterAnimationForPlayback(RSAnimationManager& manager); 309 310 RSB_EXPORT static NodeId PatchPlainNodeId(const Parcel& parcel, NodeId id); 311 RSB_EXPORT static pid_t PatchPlainPid(const Parcel& parcel, pid_t pid); 312 313 RSB_EXPORT static uint32_t PerfTreeFlatten( 314 std::shared_ptr<RSRenderNode> node, std::vector<std::pair<NodeId, uint32_t>>& nodeSet, 315 std::unordered_map<NodeId, uint32_t>& mapNode2Count, int depth); 316 RSB_EXPORT static uint32_t CalcNodeCmdListCount(RSRenderNode& node); 317 RSB_EXPORT static void CalcPerfNodePrepare(NodeId nodeId, uint32_t timeCount, bool excludeDown); 318 RSB_EXPORT static void CalcPerfNodePrepareLo(const std::shared_ptr<RSRenderNode>& node, bool forceExcludeNode); 319 static void PrintNodeCacheLo(const std::shared_ptr<RSRenderNode>& node); 320 321 static uint64_t RawNowNano(); 322 static uint64_t NowNano(); 323 static double Now(); 324 325 static bool IsRecording(); 326 static bool IsPlaying(); 327 328 static bool IsLoadSaveFirstScreenInProgress(); 329 static std::string FirstFrameMarshalling(uint32_t fileVersion); 330 static void FirstFrameUnmarshalling(const std::string& data, uint32_t fileVersion); 331 static void HiddenSpaceTurnOff(); 332 static void HiddenSpaceTurnOn(); 333 334 static void ScheduleTask(std::function<void()> && task); 335 static void RequestNextVSync(); 336 static void AwakeRenderServiceThread(); 337 static void ResetAnimationStamp(); 338 339 static void CreateMockConnection(pid_t pid); 340 static RSRenderServiceConnection* GetConnection(pid_t pid); 341 static pid_t GetConnectionPid(RSIRenderServiceConnection* connection); 342 static std::vector<pid_t> GetConnectionsPids(); 343 344 static std::shared_ptr<RSRenderNode> GetRenderNode(uint64_t id); 345 static void ProcessSendingRdc(); 346 347 static void BlinkNodeUpdate(); 348 static void CalcPerfNodeUpdate(); 349 static void CalcPerfNodeAllStep(); 350 static void CalcNodeWeigthOnFrameEnd(uint64_t frameLength); 351 352 RSB_EXPORT static uint32_t GetNodeDepth(const std::shared_ptr<RSRenderNode> node); 353 354 static void TypefaceMarshalling(std::stringstream& stream, uint32_t fileVersion); 355 static void TypefaceUnmarshalling(std::stringstream& stream, uint32_t fileVersion); 356 357 // Network interface 358 static void Invoke(const std::vector<std::string>& line); 359 static void ProcessPauseMessage(); 360 static void ProcessCommands(); 361 static void Respond(const std::string& message); 362 static void SetSystemParameter(const ArgList& args); 363 static void GetSystemParameter(const ArgList& args); 364 static void Reset(const ArgList& args); 365 static void DumpSystemParameters(const ArgList& args); 366 static void DumpNodeModifiers(const ArgList& args); 367 static void DumpConnections(const ArgList& args); 368 static void DumpNodeProperties(const ArgList& args); 369 static void DumpTree(const ArgList& args); 370 static void DumpTreeToJson(const ArgList& args); 371 static void DumpSurfaces(const ArgList& args); 372 static void DumpNodeSurface(const ArgList& args); 373 static void ClearFilter(const ArgList& args); 374 static void PrintNodeCache(const ArgList& args); 375 static void PrintNodeCacheAll(const ArgList& args); 376 static void PatchNode(const ArgList& args); 377 static void KillNode(const ArgList& args); 378 static void BlinkNode(const ArgList& args); 379 static void AttachChild(const ArgList& args); 380 static void KillPid(const ArgList& args); 381 static void GetRoot(const ArgList& args); 382 static void GetDeviceInfo(const ArgList& args); 383 static void GetDeviceFrequency(const ArgList& args); 384 static void FixDeviceEnv(const ArgList& args); 385 static void GetPerfTree(const ArgList& args); 386 static void CalcPerfNode(const ArgList& args); 387 static void CalcPerfNodeAll(const ArgList& args); 388 static void SocketShutdown(const ArgList& args); 389 static void DumpDrawingCanvasNodes(const ArgList& args); 390 391 static void Version(const ArgList& args); 392 static void FileVersion(const ArgList& args); 393 394 static void SaveSkp(const ArgList& args); 395 static void SaveRdc(const ArgList& args); 396 static void DrawingCanvasRedrawEnable(const ArgList& args); 397 398 static void RecordStart(const ArgList& args); 399 static void RecordStop(const ArgList& args); 400 static void RecordUpdate(); 401 402 static void PlaybackStart(const ArgList& args); 403 static void PlaybackStop(const ArgList& args); 404 static double PlaybackUpdate(double deltaTime); 405 406 static void RecordSendBinary(const ArgList& args); 407 408 static void PlaybackPrepare(const ArgList& args); 409 static void PlaybackPrepareFirstFrame(const ArgList& args); 410 static void PlaybackPause(const ArgList& args); 411 static void PlaybackPauseAt(const ArgList& args); 412 static void PlaybackPauseClear(const ArgList& args); 413 static void PlaybackResume(const ArgList& args); 414 415 static void TestSaveFrame(const ArgList& args); 416 static void TestLoadFrame(const ArgList& args); 417 static void TestSwitch(const ArgList& args); 418 419 static void OnFlagChangedCallback(const char *key, const char *value, void *context); 420 static void OnWorkModeChanged(); 421 static void ProcessSignalFlag(); 422 423 private: 424 using CommandRegistry = std::map<std::string, void (*)(const ArgList&)>; 425 static const CommandRegistry COMMANDS; 426 // set to true in DT only 427 RSB_EXPORT static bool testing_; 428 429 // flag for enabling profiler 430 RSB_EXPORT static bool enabled_; 431 // flag for enabling profiler beta recording feature 432 RSB_EXPORT static bool betaRecordingEnabled_; 433 // flag to start network thread 434 RSB_EXPORT static int8_t signalFlagChanged_; 435 436 inline static const char SYS_KEY_ENABLED[] = "persist.graphic.profiler.enabled"; 437 inline static const char SYS_KEY_BETARECORDING[] = "persist.graphic.profiler.betarecording"; 438 // flag for enabling DRAWING_CANVAS_NODE redrawing 439 RSB_EXPORT static std::atomic_bool dcnRedraw_; 440 }; 441 442 } // namespace OHOS::Rosen 443 444 #endif // RS_PROFILER_ENABLED 445 446 #endif // RENDER_SERVICE_PROFILER_H