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