• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 /**
17  * @addtogroup RenderNodeDisplay
18  * @{
19  *
20  * @brief Display render nodes.
21  */
22 
23 /**
24  * @file rs_root_node.h
25  *
26  * @brief Defines the properties and methods for RSRootNode class.
27  */
28 
29 #ifndef RENDER_SERVICE_CLIENT_CORE_UI_RS_ROOT_NODE_H
30 #define RENDER_SERVICE_CLIENT_CORE_UI_RS_ROOT_NODE_H
31 
32 #include "ui/rs_canvas_node.h"
33 
34 namespace OHOS {
35 namespace Rosen {
36 class RSSurfaceNode;
37 
38 /**
39  * @class RSRootNode
40  *
41  * @brief Represents the root node in the rendering service.
42  */
43 class RSC_EXPORT RSRootNode : public RSCanvasNode {
44 public:
45     using WeakPtr = std::weak_ptr<RSRootNode>;
46     using SharedPtr = std::shared_ptr<RSRootNode>;
47     static inline constexpr RSUINodeType Type = RSUINodeType::ROOT_NODE;
48     /**
49      * @brief Get the type of the RSNode.
50      *
51      * @return The type of the RSNode.
52      */
GetType()53     RSUINodeType GetType() const override
54     {
55         return Type;
56     }
57 
58     /**
59      * @brief Destructor for RSRootNode.
60      */
61     ~RSRootNode() override = default;
62 
63     /**
64      * @brief Creates a shared pointer to an RSRootNode instance.
65      *
66      * @param isRenderServiceNode Indicates whether the node is a render service node.
67      * @param isTextureExportNode Indicates whether the node is a texture export node.
68      * @param rsUIContext A shared pointer to the RSUIContext. Defaults to nullptr if not specified.
69      * @return A shared pointer to the created RSRootNode instance.
70      */
71     static std::shared_ptr<RSNode> Create(bool isRenderServiceNode = false, bool isTextureExportNode = false,
72         std::shared_ptr<RSUIContext> rsUIContext = nullptr);
73 
74 protected:
75     void AttachRSSurfaceNode(std::shared_ptr<RSSurfaceNode> surfaceNode);
76     void SetEnableRender(bool flag) const;
77     /**
78      * @brief Called when the bounds size of the node has changed.
79      */
80     void OnBoundsSizeChanged() const override;
81 
82     explicit RSRootNode(
83         bool isRenderServiceNode, bool isTextureExportNode = false, std::shared_ptr<RSUIContext> rsUIContext = nullptr);
84     RSRootNode(const RSRootNode&) = delete;
85     RSRootNode(const RSRootNode&&) = delete;
86     RSRootNode& operator=(const RSRootNode&) = delete;
87     RSRootNode& operator=(const RSRootNode&&) = delete;
88 
89 private:
90 /**
91      * @brief Registers the node in the node map.
92      */
93     void RegisterNodeMap() override;
94     friend class RSUIDirector;
95 };
96 } // namespace Rosen
97 } // namespace OHOS
98 
99 /** @} */
100 #endif // RENDER_SERVICE_CLIENT_CORE_UI_RS_ROOT_NODE_H