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_UI_RS_ROOT_NODE_H
16 #define RENDER_SERVICE_CLIENT_CORE_UI_RS_ROOT_NODE_H
17 
18 #include "ui/rs_canvas_node.h"
19 
20 namespace OHOS {
21 namespace Rosen {
22 class RSSurfaceNode;
23 class RSC_EXPORT RSRootNode : public RSCanvasNode {
24 public:
25     using WeakPtr = std::weak_ptr<RSRootNode>;
26     using SharedPtr = std::shared_ptr<RSRootNode>;
27     static inline constexpr RSUINodeType Type = RSUINodeType::ROOT_NODE;
GetType()28     RSUINodeType GetType() const override
29     {
30         return Type;
31     }
32 
33     ~RSRootNode() override = default;
34 
35     static std::shared_ptr<RSNode> Create(bool isRenderServiceNode = false, bool isTextureExportNode = false);
36 
37 protected:
38     void AttachRSSurfaceNode(std::shared_ptr<RSSurfaceNode> surfaceNode) const;
39     void SetEnableRender(bool flag) const;
40     void OnBoundsSizeChanged() const override;
41 
42     explicit RSRootNode(bool isRenderServiceNode, bool isTextureExportNode = false);
43     RSRootNode(const RSRootNode&) = delete;
44     RSRootNode(const RSRootNode&&) = delete;
45     RSRootNode& operator=(const RSRootNode&) = delete;
46     RSRootNode& operator=(const RSRootNode&&) = delete;
47 
48     friend class RSUIDirector;
49 };
50 } // namespace Rosen
51 } // namespace OHOS
52 
53 #endif // RENDER_SERVICE_CLIENT_CORE_UI_RS_ROOT_NODE_H