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