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