• 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_display_node.h
25  *
26  * @brief Defines the properties and methods for RSDisplayNode class.
27  */
28 
29 #ifndef RENDER_SERVICE_CLIENT_CORE_UI_RS_DISPLAY_NODE_H
30 #define RENDER_SERVICE_CLIENT_CORE_UI_RS_DISPLAY_NODE_H
31 
32 #include "ui/rs_node.h"
33 #include "screen_manager/screen_types.h"
34 
35 namespace OHOS {
36 namespace Rosen {
37 
38 /**
39  * @class RSDisplayNode
40  *
41  * @brief Represents a display node in the rendering service.
42  *
43  * Each screen corresponds to a display node.
44  */
45 class RSC_EXPORT RSDisplayNode : public RSNode {
46 public:
47     using WeakPtr = std::weak_ptr<RSDisplayNode>;
48     using SharedPtr = std::shared_ptr<RSDisplayNode>;
49     static inline constexpr RSUINodeType Type = RSUINodeType::DISPLAY_NODE;
50 
51     /**
52      * @brief Get the type of the RSUINode.
53      *
54      * @return The type of the RSUINode.
55      */
GetType()56     RSUINodeType GetType() const override
57     {
58         return Type;
59     }
60 
61     /**
62      * @brief Destructor for RSDisplayNode.
63      */
64     ~RSDisplayNode() override;
65 
66     /**
67      * @brief Removes all child nodes associated with this node.
68      */
69     void ClearChildren() override;
70 
71     /**
72      * @brief Creates a shared pointer to an RSDisplayNode instance.
73      *
74      * @param displayNodeConfig Indicates the configuration settings for the display node.
75      * @param rsUIContext An optional shared pointer to an RSUIContext instance. Defaults to nullptr if not provided.
76      * @return A shared pointer to the newly created RSDisplayNode instance.
77      */
78     static SharedPtr Create(
79         const RSDisplayNodeConfig& displayNodeConfig, std::shared_ptr<RSUIContext> rsUIContext = nullptr);
80 
81     /**
82      * @brief Add the display node to tree.
83      */
84     void AddDisplayNodeToTree();
85 
86     /**
87      * @brief Remove the display node from tree.
88      */
89     void RemoveDisplayNodeFromTree();
90 
91     /**
92      * @brief Serializes the RSDisplayNode into a parcel.
93      *
94      * @param parcel Indicates the Parcel object where the RSDisplayNode data will be written.
95      * @return true if the serialization is successful; false otherwise.
96      */
97     bool Marshalling(Parcel& parcel) const;
98 
99     /**
100      * @brief Deserializes the RSDisplayNode from a Parcel.
101      *
102      * @param parcel Indicates the Parcel object containing the serialized RSDisplayNode data.
103      * @return A shared pointer to the deserialized RSDisplayNode instance.
104      */
105     static SharedPtr Unmarshalling(Parcel& parcel);
106 
107     /**
108      * @brief Sets the screen ID.
109      *
110      * @param screenId Indicates the unique identifier of the screen.
111      */
112     void SetScreenId(uint64_t screenId);
113 
114     /**
115      * @brief Sets whether it is a security screen.
116      *
117      * The secure screen processes secure layers, while the non-secure screen processes insecure layers
118      *
119      * @param isSecurityDisplay true if the screen is security; false otherwise.
120      */
121     void SetSecurityDisplay(bool isSecurityDisplay);
122 
123     /**
124      * @brief Sets the rotation of screen.
125      *
126      * @param rotation Indicates the rotation value to be applied to the display node.
127      */
128     void SetScreenRotation(const uint32_t& rotation);
129 
130     /**
131      * @brief Sets the mirror configuration of screen.
132      *
133      * @param displayNodeConfig Indicates the configuration settings for the screen.
134      */
135     void SetDisplayNodeMirrorConfig(const RSDisplayNodeConfig& displayNodeConfig);
136 
137     /**
138      * @brief Gets whether it is a security screen.
139      *
140      * The secure screen processes secure layers, while the non-secure screen processes insecure layers
141      *
142      * @return true if the screen is security; false otherwise.
143      */
144     bool GetSecurityDisplay() const;
145 
146     /**
147      * @brief Set whether to forcibly close HDR.
148      *
149      * @param isForceCloseHdr true if HDR should be forcibly closed; false otherwise.
150      */
151     void SetForceCloseHdr(bool isForceCloseHdr);
152 
153     /**
154      * @brief Gets whether the screen mode is mirroring.
155      *
156      * @return true if the screen mode is mirroring; false otherwise.
157      */
158     bool IsMirrorDisplay() const;
159 
160     /**
161      * @brief Sets the boot animation.
162      *
163      * @param isBootAnimation true if boot animation is enabled; false otherwise.
164      */
165     void SetBootAnimation(bool isBootAnimation);
166 
167     /**
168      * @brief Gets whether has boot animation.
169      *
170      * @return true if has boot animation; false otherwise.
171      */
172     bool GetBootAnimation() const;
173 
174     /**
175      * @brief Sets the pid of Sceneboard node.
176      *
177      * @param oldPids Indicates the old PIDs to be removed.
178      * @param currentPid Indicates the current PID to be added.
179      */
180     void SetScbNodePid(const std::vector<int32_t>& oldPids, int32_t currentPid);
181 
182     /**
183      * @brief Sets the virtual screen mute status.
184      *
185      * @param virtualScreenMuteStatus Indicates the mute status of the virtual screen.
186      */
187     void SetVirtualScreenMuteStatus(bool virtualScreenMuteStatus);
188 
189 protected:
190     explicit RSDisplayNode(const RSDisplayNodeConfig& config, std::shared_ptr<RSUIContext> rsUIContext = nullptr);
191     RSDisplayNode(const RSDisplayNodeConfig& config, NodeId id, std::shared_ptr<RSUIContext> rsUIContext = nullptr);
192     RSDisplayNode(const RSDisplayNode&) = delete;
193     RSDisplayNode(const RSDisplayNode&&) = delete;
194     RSDisplayNode& operator=(const RSDisplayNode&) = delete;
195     RSDisplayNode& operator=(const RSDisplayNode&&) = delete;
196 
197 private:
198     bool CreateNode(const RSDisplayNodeConfig& displayNodeConfig, NodeId nodeId);
199     void RegisterNodeMap() override;
200     uint64_t screenId_;
201     bool isSecurityDisplay_ = false;
202     bool isMirrorDisplay_ = false;
203     bool isBootAnimation_ = false;
204 };
205 } // namespace Rosen
206 } // namespace OHOS
207 
208 /** @} */
209 #endif // RENDER_SERVICE_CLIENT_CORE_UI_RS_DISPLAY_NODE_H
210