• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2020-2021 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 Display
18  * @{
19  *
20  * @brief Defines driver functions of the display module.
21  *
22  * This module provides driver functions for the graphics subsystem, including graphics layer management,
23  * device control, graphics hardware acceleration, display memory management, and callbacks.
24  *
25  * @since 1.0
26  * @version 1.0
27  */
28 
29 /**
30  * @file display_layer.h
31  *
32  * @brief Declares the driver functions for implementing layer operations.
33  *
34  * @since 1.0
35  * @version 2.0
36  */
37 
38 #ifndef OHOS_HDI_DISPLAY_LAYER_V1_0_INTERFACE_H
39 #define OHOS_HDI_DISPLAY_LAYER_V1_0_INTERFACE_H
40 
41 #include "display_type.h"
42 #include <iservmgr_hdi.h>
43 
44 namespace OHOS {
45 namespace HDI {
46 namespace Display {
47 namespace V1_0 {
48 
49 class IDisplayLayer {
50 public:
IDisplayLayer()51     explicit IDisplayLayer() {}
~IDisplayLayer()52     virtual ~IDisplayLayer() {}
53 
54     /**
55      * @brief Initializes a display device.
56      *
57      * @param devId Indicates the ID of a display device. The value ranges from 0 to 4, where 0 indicates the first
58      * display device and 4 indicates the last display device.
59      *
60      * @return Returns <b>0</b> if the operation is successful; returns an error code defined in {@link DispErrCode}
61      * otherwise.
62      * @see DeinitDisplay
63      * @since 1.0
64      * @version 1.0
65      */
66     virtual DispErrCode InitDisplay(unsigned int devId) = 0;
67 
68     /**
69      * @brief Deinitializes a display device.
70      *
71      * @param devId Indicates the ID of a display device. The value ranges from 0 to 4, where 0 indicates the first
72      * display device and 4 indicates the last display device.
73      *
74      * @return Returns <b>0</b> if the operation is successful; returns an error code defined in {@link DispErrCode}
75      * otherwise.
76      * @see InitDisplay
77      * @since 1.0
78      * @version 1.0
79      */
80     virtual DispErrCode DeinitDisplay(unsigned int devId) = 0;
81 
82     /**
83      * @brief Obtains information about a display device.
84      *
85      * @param devId Indicates the ID of a display device. The value ranges from 0 to 4, where 0 indicates the first
86      * display device and 4 indicates the last display device.
87      * @param dispInfo Indicates the pointer to the display device information obtained.
88      *
89      * @return Returns <b>0</b> if the operation is successful; returns an error code defined in {@link DispErrCode}
90      * otherwise.
91      * @since 1.0
92      * @version 1.0
93      */
94     virtual DispErrCode GetDisplayInfo(unsigned int devId, std::shared_ptr<DisplayInfo> &dispInfo) = 0;
95 
96     /**
97      * @brief Opens a layer on a specified display device.
98      *
99      * Before using a layer on the GUI, you must open the layer based on the layer information. After the layer is
100      * opened, you can obtain the layer ID and then use other functions based on the layer ID.
101      *
102      * @param devId Indicates the ID of a display device. The value ranges from 0 to 4, where 0 indicates the first
103      * display device and 4 indicates the last display device.
104      * @param layerInfo Indicates the pointer to the layer information passed to open a layer, including the layer
105      * type, layer size, and pixel format.
106      * @param layerId Indicates the pointer to the layer ID, which identifies a unique layer. The layer ID is returned
107      * to the GUI after the layer is successfully opened.
108      *
109      * @return Returns <b>0</b> if the operation is successful; returns an error code defined in {@link DispErrCode}
110      * otherwise.
111      * @see CloseLayer
112      * @since 1.0
113      * @version 1.0
114      */
115     virtual DispErrCode CreateLayer(unsigned int devId, LayerInfo &layerInfo, unsigned int &layerId) = 0;
116 
117     /**
118      * @brief Closes a layer that is no longer required on a specified display device.
119      *
120      * @param devId Indicates the ID of a display device. The value ranges from 0 to 4, where 0 indicates the first
121      * display device and 4 indicates the last display device.
122      * @param layerId Indicates the layer ID, which identifies a unique layer. You can perform operations on the layer
123      * with the specified layer ID.
124      *
125      * @return Returns <b>0</b> if the operation is successful; returns an error code defined in {@link DispErrCode}
126      * otherwise.
127      * @see OpenLayer
128      * @since 1.0
129      * @version 1.0
130      */
131     virtual DispErrCode CloseLayer(unsigned int devId, unsigned int layerId) = 0;
132 
133     /**
134      * @brief Sets whether a layer is visible.
135      *
136      * A visible layer is displayed on the screen, whereas an invisible layer is not displayed on the screen.
137      *
138      * @param devId Indicates the ID of a display device. The value ranges from 0 to 4, where 0 indicates the first
139      * display device and 4 indicates the last display device.
140      * @param layerId Indicates the layer ID, which identifies a unique layer. You can perform operations on the layer
141      * with the specified layer ID.
142      * @param visible Indicates the visibility to set for the layer. The value <b>true</b> means to set the layer to be
143      * visible, and <b>false</b> means the opposite.
144      *
145      * @return Returns <b>0</b> if the operation is successful; returns an error code defined in {@link DispErrCode}
146      * otherwise.
147      * @see GetLayerVisibleState
148      * @since 1.0
149      * @version 1.0
150      */
151     virtual DispErrCode SetLayerVisible(unsigned int devId, unsigned int layerId, bool visible) = 0;
152 
153     /**
154      * @brief Checks whether a layer is visible.
155      *
156      * @param devId Indicates the ID of a display device. The value ranges from 0 to 4, where 0 indicates the first
157      * display device and 4 indicates the last display device.
158      * @param layerId Indicates the layer ID, which identifies a unique layer. You can perform operations on the layer
159      * with the specified layer ID.
160      * @param visible Indicates the pointer to the obtained layer visibility. The value <b>true</b> indicates that the
161      * layer is visible, and <b>false</b> indicates that the layer is invisible.
162      *
163      * @return Returns <b>0</b> if the operation is successful; returns an error code defined in {@link DispErrCode}
164      * otherwise.
165      * @see SetLayerVisible
166      * @since 1.0
167      * @version 1.0
168      */
169     virtual DispErrCode GetLayerVisibleState(unsigned int devId, unsigned int layerId, bool &visible) = 0;
170 
171     /**
172      * @brief Sets the size of a layer.
173      *
174      * @param devId Indicates the ID of a display device. The value ranges from 0 to 4, where 0 indicates the first
175      * display device and 4 indicates the last display device.
176      * @param layerId Indicates the layer ID, which identifies a unique layer. You can perform operations on the layer
177      * with the specified layer ID.
178      * @param rect Indicates the pointer to the layer size to set, in pixels.
179      *
180      * @return Returns <b>0</b> if the operation is successful; returns an error code defined in {@link DispErrCode}
181      * otherwise.
182      * @see SetLayerRect
183      * @since 1.0
184      * @version 1.0
185      */
186     virtual DispErrCode SetLayerRect(unsigned int devId, unsigned int layerId, IRect &rect) = 0;
187 
188     /**
189      * @brief Obtains the size of a layer.
190      *
191      * @param devId Indicates the ID of a display device. The value ranges from 0 to 4, where 0 indicates the first
192      * display device and 4 indicates the last display device.
193      * @param layerId Indicates the layer ID, which identifies a unique layer. You can perform operations on the layer
194      * with the specified layer ID.
195      * @param rect Indicates the pointer to the obtained layer size.
196      *
197      * @return Returns <b>0</b> if the operation is successful; returns an error code defined in {@link DispErrCode}
198      * otherwise.
199      * @see SetLayerRect
200      * @since 1.0
201      * @version 1.0
202      */
203     virtual DispErrCode GetLayerRect(unsigned int devId, unsigned int layerId, std::shared_ptr<IRect> &rect) = 0;
204 
205     /**
206      * @brief Sets the z-order for a layer.
207      *
208      * A larger z-order value indicates a higher layer.
209      *
210      * @param devId Indicates the ID of a display device. The value ranges from 0 to 4, where 0 indicates the first
211      * display device and 4 indicates the last display device.
212      * @param layerId Indicates the layer ID, which identifies a unique layer. You can perform operations on the layer
213      * with the specified layer ID.
214      * @param zorder Indicates the z-order to set. The value is an integer ranging from 0 to 255.
215      *
216      * @return Returns <b>0</b> if the operation is successful; returns an error code defined in {@link DispErrCode}
217      * otherwise.
218      * @see GetLayerZorder
219      * @since 1.0
220      * @version 1.0
221      */
222     virtual DispErrCode SetLayerZorder(unsigned int devId, unsigned int layerId, unsigned int zorder) = 0;;
223 
224     /**
225      * @brief Obtains the z-order of a layer.
226      *
227      * @param devId Indicates the ID of a display device. The value ranges from 0 to 4, where 0 indicates the first
228      * display device and 4 indicates the last display device.
229      * @param layerId Indicates the layer ID, which identifies a unique layer. You can perform operations on the layer
230      * with the specified layer ID.
231      * @param zorder Indicates the pointer to the obtained z-order. The value is an integer ranging from 0 to 255.
232      * A larger z-order value indicates a higher layer.
233      *
234      * @return Returns <b>0</b> if the operation is successful; returns an error code defined in {@link DispErrCode}
235      * otherwise.
236      * @see SetLayerZorder
237      * @since 1.0
238      * @version 1.0
239      */
240     virtual DispErrCode GetLayerZorder(unsigned int devId, unsigned int layerId, unsigned int &zorder) = 0;
241 
242     /**
243      * @brief Sets the transform mode for rotating, scaling, or moving a layer.
244      *
245      * @param devId Indicates the ID of a display device. The value ranges from 0 to 4, where 0 indicates the first
246      * display device and 4 indicates the last display device.
247      * @param layerId Indicates the layer ID, which identifies a unique layer. You can perform operations on the layer
248      * with the specified layer ID.
249      * @param type Indicates the transformation mode to set.
250      *
251      * @return Returns <b>0</b> if the operation is successful; returns an error code defined in {@link DispErrCode}
252      * otherwise.
253      * @since 1.0
254      * @version 1.0
255      */
256     virtual DispErrCode SetTransformMode(unsigned int devId, unsigned int layerId, TransformType &type) = 0;
257 
258     /**
259      * @brief Set the buffer for a layer.
260      *
261      *
262      * @param devId Indicates the ID of a display device. The value ranges from 0 to 4, where 0 indicates the first
263      * display device and 4 indicates the last display device.
264      * @param layerId Indicates the layer ID, which identifies a unique layer. You can perform operations on the layer
265      * with the specified layer ID.
266      * @param buffer Indiactes pointer of the buffer handle, the buffer handle should contain all the information of the
267      * buffer which will been used for composition
268      * @param fence Indiactes the fd of a sync file
269      *
270      * @return Returns <b>0</b> if the operation is successful; returns an error code defined in {@link DispErrCode}
271      * otherwise.
272      * @since 2.0
273      * @version 2.0
274      */
275     virtual DispErrCode SetLayerBuffer(unsigned int devId, unsigned int layerId, const BufferHandle &buffer, int fence) = 0;
276 
277 }; // class IDisplayLayer
278 
279 } // namespace V1_0
280 } // namespace Display
281 } // namespace HDI
282 } // namespace OHOS
283 
284 #endif  // OHOS_HDI_DISPLAY_LAYER_V1_0_INTERFACE_H
285 /** @} */
286