1 /* 2 * Copyright (c) 2022-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 FOUNDATION_ACE_FRAMEWORKS_CORE_COMMON_LAYOUT_INSPECTOR_H 17 #define FOUNDATION_ACE_FRAMEWORKS_CORE_COMMON_LAYOUT_INSPECTOR_H 18 19 #include "core/common/container.h" 20 #include "core/components_ng/base/inspector.h" 21 22 namespace OHOS::Ace { 23 typedef struct { 24 uint64_t rsNodeId = 0; 25 int32_t frameNodeId = 0; 26 std::string nodeType; 27 std::string debugline; 28 } FrameNodeInfo; 29 30 typedef std::function<void(bool)> ProfilerStatusCallback; 31 typedef std::function<void(FrameNodeInfo)> RsProfilerNodeMountCallback; 32 33 class LayoutInspector { 34 public: 35 static void SupportInspector(); 36 static void SetlayoutInspectorStatus(int32_t containerId); 37 static void GetInspectorTreeJsonStr(std::string& treeJsonStr, int32_t containerId); 38 static void CreateLayoutInfo(int32_t containerId); 39 static void SetCallback(int32_t instanceId); 40 static void SetStatus(bool layoutInspectorStatus); 41 static void GetSnapshotJson(int32_t containerId, std::unique_ptr<JsonValue>& message); 42 43 // state profiler 44 static bool GetStateProfilerStatus(); 45 static void SetStateProfilerStatus(bool status); 46 static void TriggerJsStateProfilerStatusCallback(bool status); 47 static void SendStateProfilerMessage(const std::string& message); 48 static void SetJsStateProfilerStatusCallback(ProfilerStatusCallback&& callback); 49 50 // rs profiler 51 static RsProfilerNodeMountCallback GetRsProfilerNodeMountCallback(); 52 static void SetRsProfilerNodeMountCallback(RsProfilerNodeMountCallback&& callback); 53 static void HandleStartRecord(); 54 static void HandleStopRecord(); 55 static void HandleInnerCallback(FrameNodeInfo node); 56 static void ConnectServerCallback(); 57 58 private: 59 static bool stateProfilerStatus_; 60 static bool layoutInspectorStatus_; 61 static NG::InspectorTreeMap recNodeInfos_; 62 static std::mutex recMutex_; 63 static ProfilerStatusCallback jsStateProfilerStatusCallback_; 64 static RsProfilerNodeMountCallback rsProfilerNodeMountCallback_; 65 static bool isUseStageModel_; 66 }; 67 } // namespace OHOS::Ace 68 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMMON_LAYOUT_INSPECTOR_H