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 #ifndef RENDER_SERVICE_CLIENT_CORE_PIPELINE_RS_ROOT_RENDER_NODE_H 16 #define RENDER_SERVICE_CLIENT_CORE_PIPELINE_RS_ROOT_RENDER_NODE_H 17 18 #include "common/rs_macros.h" 19 #include "pipeline/rs_canvas_render_node.h" 20 21 namespace OHOS { 22 namespace Rosen { 23 class RSSurface; 24 class RSDirtyRegionManager; 25 class RSB_EXPORT RSRootRenderNode : public RSCanvasRenderNode { 26 public: 27 static inline constexpr RSRenderNodeType Type = RSRenderNodeType::ROOT_NODE; GetType()28 RSRenderNodeType GetType() const override 29 { 30 return Type; 31 } 32 33 explicit RSRootRenderNode(NodeId id, std::weak_ptr<RSContext> context = {}); 34 ~RSRootRenderNode() override; 35 36 virtual void Prepare(const std::shared_ptr<RSNodeVisitor>& visitor) override; 37 virtual void Process(const std::shared_ptr<RSNodeVisitor>& visitor) override; 38 39 void AttachRSSurfaceNode(NodeId SurfaceNodeId); 40 41 std::shared_ptr<RSDirtyRegionManager> GetDirtyManager() const; 42 std::shared_ptr<RSSurface> GetSurface(); 43 NodeId GetRSSurfaceNodeId(); 44 float GetSuggestedBufferWidth() const; 45 float GetSuggestedBufferHeight() const; 46 void UpdateSuggestedBufferSize(float width, float height); SetEnableRender(bool enableRender)47 void SetEnableRender(bool enableRender) 48 { 49 if (enableRender_ != enableRender) { 50 enableRender_ = enableRender; 51 SetDirty(); 52 } 53 } 54 GetEnableRender()55 bool GetEnableRender() const 56 { 57 return enableRender_; 58 } 59 SetNeedUpdateSurfaceNode(bool needUpdate)60 void SetNeedUpdateSurfaceNode(bool needUpdate) 61 { 62 needUpdateSurfaceNode_ = needUpdate; 63 } 64 GetNeedUpdateSurfaceNode()65 bool GetNeedUpdateSurfaceNode() const 66 { 67 return needUpdateSurfaceNode_; 68 } 69 70 private: 71 std::shared_ptr<RSDirtyRegionManager> dirtyManager_ = nullptr; 72 std::shared_ptr<RSSurface> rsSurface_ = nullptr; 73 NodeId surfaceNodeId_ = 0; 74 bool enableRender_ = true; 75 bool needUpdateSurfaceNode_ = false; 76 float suggestedBufferWidth_ = 0.f; 77 float suggestedBufferHeight_ = 0.f; 78 79 std::vector<NodeId> childSurfaceNodeIds_; 80 friend class RSRenderThreadVisitor; 81 }; 82 } // namespace Rosen 83 } // namespace OHOS 84 85 #endif // RENDER_SERVICE_CLIENT_CORE_PIPELINE_RS_ROOT_RENDER_NODE_H 86