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