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