1 /* 2 * Copyright (c) 2021 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 ROSEN_RENDER_SERVICE_BASE_PIPELINE_RS_CONTEXT_H 17 #define ROSEN_RENDER_SERVICE_BASE_PIPELINE_RS_CONTEXT_H 18 19 #include "pipeline/rs_render_node_map.h" 20 21 namespace OHOS { 22 namespace Rosen { 23 24 class RSContext : public std::enable_shared_from_this<RSContext> { 25 public: 26 RSContext() = default; 27 ~RSContext() = default; 28 GetMutableNodeMap()29 RSRenderNodeMap& GetMutableNodeMap() 30 { 31 return nodeMap; 32 } 33 GetNodeMap()34 const RSRenderNodeMap& GetNodeMap() const 35 { 36 return nodeMap; 37 } 38 GetGlobalRootRenderNode()39 const std::shared_ptr<RSBaseRenderNode>& GetGlobalRootRenderNode() const 40 { 41 return globalRootRenderNode_; 42 } 43 RegisterAnimatingRenderNode(const std::shared_ptr<RSBaseRenderNode> & nodePtr)44 void RegisterAnimatingRenderNode(const std::shared_ptr<RSBaseRenderNode>& nodePtr) 45 { 46 NodeId id = nodePtr->GetId(); 47 animatingNodeList_.emplace(id, nodePtr); 48 } 49 50 private: 51 RSRenderNodeMap nodeMap; 52 std::shared_ptr<RSBaseRenderNode> globalRootRenderNode_ = std::make_shared<RSBaseRenderNode>(0); 53 std::unordered_map<NodeId, std::weak_ptr<RSBaseRenderNode>> animatingNodeList_; 54 55 RSContext(const RSContext&) = delete; 56 RSContext(const RSContext&&) = delete; 57 RSContext& operator=(const RSContext&) = delete; 58 RSContext& operator=(const RSContext&&) = delete; 59 60 friend class RSRenderThread; 61 friend class RSMainThread; 62 }; 63 64 } // namespace Rosen 65 } // namespace OHOS 66 67 #endif // ROSEN_RENDER_SERVICE_BASE_PIPELINE_RS_CONTEXT_H 68