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 FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_WINDOW_SCENE_LAYOUT_MANAGER_H 17 #define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_WINDOW_SCENE_LAYOUT_MANAGER_H 18 19 #include <event_handler.h> 20 21 #include "core/components_ng/base/frame_node.h" 22 23 namespace OHOS::Rosen { 24 struct SessionUIParam; 25 class RSObjAbsGeometry; 26 enum class RSUINodeType : uint32_t; 27 } 28 29 namespace OHOS::Ace::NG { 30 struct TraverseResult { 31 uint32_t zOrderCnt_ = 0; 32 std::unordered_map<int32_t, OHOS::Rosen::SessionUIParam> uiParams_; 33 uint64_t screenId_ = -1; 34 }; 35 36 class WindowSceneLayoutManager { 37 public: 38 static WindowSceneLayoutManager* GetInstance(); 39 void FlushWindowPatternInfo(const RefPtr<FrameNode>& screenNode); 40 void RegisterScreenNode(uint64_t screenId, const RefPtr<FrameNode>& node); 41 void UnregisterScreenNode(uint64_t screenId); 42 43 private: 44 WindowSceneLayoutManager() = default; 45 ~WindowSceneLayoutManager() = default; 46 void Init(); 47 void TraverseTree(const RefPtr<FrameNode>& rootNode, TraverseResult& res, 48 bool isAncestorRecent, bool isAncestorDirty, bool notSyncPosition); 49 void FillWindowSceneInfo(const RefPtr<FrameNode>& node, TraverseResult& res, bool isAncestorRecent, 50 bool notSyncPosition); 51 bool IsNodeVisible(const RefPtr<FrameNode>& node); 52 bool IsNodeDirty(const RefPtr<FrameNode>& node); 53 bool IsRecentContainerState(const RefPtr<FrameNode>& node); 54 bool NoNeedSyncScenePanelGlobalPosition(const RefPtr<FrameNode>& node); 55 std::shared_ptr<Rosen::RSNode> GetRSNode(const RefPtr<FrameNode>& node); 56 std::shared_ptr<Rosen::RSObjAbsGeometry> GetGlobalGeometry(const RefPtr<FrameNode>& node); 57 std::shared_ptr<Rosen::RSObjAbsGeometry> GetLocalGeometry(const RefPtr<FrameNode>& node); 58 void UpdateGeometry(const RefPtr<FrameNode>& node, const RefPtr<FrameNode>& parentNode, 59 bool isParentTransformScene); 60 int32_t GetNodeZIndex(const RefPtr<FrameNode>& node); 61 uint64_t GetScreenId(const RefPtr<FrameNode>& screenNode); 62 uint64_t GetRSNodeId(const RefPtr<FrameNode>& node); 63 std::string GetWindowName(const RefPtr<FrameNode>& node); 64 template<typename T> 65 std::string GetWindowNameInner(const RefPtr<T>& windowPattern); 66 uint32_t GetWindowId(const RefPtr<FrameNode>& node); 67 template<typename T> 68 uint32_t GetWindowIdInner(const RefPtr<T>& windowPattern); 69 void DumpFlushInfo(uint64_t screenId, TraverseResult& res); 70 void DumpNodeInfo(const RefPtr<FrameNode>& node, const RefPtr<FrameNode>& parentNode, const std::string& reason); 71 void GetUINodeInfo(const RefPtr<FrameNode>& node, int32_t parentId, std::ostringstream& oss); 72 void GetUITreeInfo(const RefPtr<FrameNode>& node, int32_t depth, int32_t parentId, std::ostringstream& oss); 73 void GetTotalUITreeInfo(std::string& info); 74 void DumpRSNodeType(Rosen::RSUINodeType rsNode, std::ostringstream& oss); 75 void GetRSNodeTreeInfo(const std::shared_ptr<RSNode>& rsNode, int32_t depth, 76 std::ostringstream& oss); 77 void GetRSNodeInfo(const std::shared_ptr<RSNode>& rsNode, 78 std::ostringstream& oss); 79 void IsFrameNodeAbnormal(const RefPtr<FrameNode>& node); 80 std::unordered_map<uint64_t, WeakPtr<FrameNode>> screenNodeMap_; 81 std::shared_ptr<AppExecFwk::EventHandler> mainHandler_; 82 bool isCoreDebugEnable_ = false; 83 }; 84 } // namespace OHOS::Ace::NG 85 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_WINDOW_SCENE_LAYOUT_MANAGER_H 86