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