1/*
2 * Copyright (c) 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#ifndef OHOS_HDI_DISPLAY_V1_0_IDISPLAY_COMPOSER_INTERFACE_H
17#define OHOS_HDI_DISPLAY_V1_0_IDISPLAY_COMPOSER_INTERFACE_H
18
19#include <vector>
20#include "buffer_handle.h"
21#include "common/include/display_common.h"
22#include "iproxy_broker.h"
23#include "v1_0/display_composer_type.h"
24
25namespace OHOS {
26namespace HDI {
27namespace Display {
28namespace Composer {
29namespace V1_0 {
30using namespace OHOS::HDI::Display::Composer::V1_0;
31
32class IDisplayComposerInterface : public virtual RefBase {
33public:
34    virtual ~IDisplayComposerInterface() = default;
35
36    /**
37     * @brief Obtains all interfaces of IDisplayComposerInterface.
38     *
39     * @return Returns <b>IDisplayComposerInterface*</b> if the operation is successful;
40     * returns an null point otherwise.
41     * @since 4.0
42     * @version 1.0
43     */
44    static IDisplayComposerInterface* Get(bool needSMQ = true);
45
46    /**
47     * @brief Adds a recipient for death notifications of a remote stub object.
48     *
49     * @param recipient Indicates the recipient of the DeathRecipient pointer.
50     *
51     * @return Returns <b>0</b> if the operation is successful; returns an error code defined
52     * in {@link DispErrCode} otherwise.
53     * @since 4.0
54     * @version 1.0
55     */
56    virtual bool AddDeathRecipient(const sptr<IRemoteObject::DeathRecipient>& recipient) = 0;
57
58    /**
59     * @brief Removes the recipient for death notifications of a remote stub object.
60     *
61     * @return Returns <b>0</b> if the operation is successful; returns an error code defined
62     * in {@link DispErrCode} otherwise.
63     * @since 4.0
64     * @version 1.0
65     */
66    virtual bool RemoveDeathRecipient() = 0;
67
68    /* device func */
69    /**
70     * @brief Registers the callback to be invoked when a hot plug event occurs.
71     *
72     * @param cb Indicates the instance used to notify the graphics service of a hot plug event occurred.
73     * @param data Indicates the pointer to the private data returned to the graphics service in the
74     * <b>HotPlugCallback</b> callback.
75
76     * @return Returns <b>0</b> if the operation is successful; returns an error code defined
77     * in {@link DispErrCode} otherwise.
78     * @since 4.0
79     * @version 1.0
80     */
81    virtual int32_t RegHotPlugCallback(HotPlugCallback cb, void* data) = 0;
82
83    /**
84     * @brief Sets the client buffer cache count of a display device.
85     *
86     * @param devId Indicates the ID of the display device.
87     * @param count client buffer cache count.
88     *
89     * @return Returns <b>0</b> if the operation is successful; returns an error code defined
90     * in {@link DispErrCode} otherwise.
91     * @since 4.0
92     * @version 1.0
93     */
94    virtual int32_t SetClientBufferCacheCount(uint32_t devId, uint32_t count) = 0;
95
96    /**
97     * @brief Obtains the capabilities of a display device.
98     *
99     * @param devId Indicates the ID of the display device.
100     * @param info Indicates the pointer to the capabilities supported by the display device. For details,
101     * see {@link DisplayCapability}.
102     *
103     * @return Returns <b>0</b> if the operation is successful; returns an error code defined
104     * in {@link DispErrCode} otherwise.
105     * @since 4.0
106     * @version 1.0
107     */
108    virtual int32_t GetDisplayCapability(uint32_t devId, DisplayCapability& info) = 0;
109
110    /**
111     * @brief Obtains the display modes supported by a display device.
112     *
113     * @param devId Indicates the ID of the display device.
114     * @param modes Indicates the vector of the information about all modes supported by the display device,
115     * including all supported resolutions and refresh rates. Each mode has an ID, which will be used when
116     * the mode is set or obtained. For details, see {@link DisplayModeInfo}.
117     *
118     * @return Returns <b>0</b> if the operation is successful; returns an error code defined
119     * in {@link DispErrCode} otherwise.
120     * @since 4.0
121     * @version 1.0
122     */
123    virtual int32_t GetDisplaySupportedModes(uint32_t devId, std::vector<DisplayModeInfo>& modes) = 0;
124
125    /**
126     * @brief Obtains the current display mode of a display device.
127     *
128     * @param devId Indicates the ID of the display device.
129     * @param modeId indicates the pointer to the ID of the current display mode of the device. The display mode ID
130     * is written by this API.
131     *
132     * @return Returns <b>0</b> if the operation is successful; returns an error code defined
133     * in {@link DispErrCode} otherwise.
134     * @since 4.0
135     * @version 1.0
136     */
137    virtual int32_t GetDisplayMode(uint32_t devId, uint32_t& modeId) = 0;
138
139    /**
140     * @brief Sets the display mode of a display device.
141     *
142     * @param devId Indicates the ID of the display device.
143     * @param modeId Indicates the ID of the display mode. The device is switched to the display mode specified by
144     * this parameter in this interface.
145     *
146     * @return Returns <b>0</b> if the operation is successful; returns an error code defined
147     * in {@link DispErrCode} otherwise.
148     * @since 4.0
149     * @version 1.0
150     */
151    virtual int32_t SetDisplayMode(uint32_t devId, uint32_t modeId) = 0;
152
153    /**
154     * @brief Obtains the power status of a display device.
155     *
156     * @param devId Indicates the ID of the display device.
157     * @param status Indicates the pointer to the power status of the device. The status is written by this interface.
158     *
159     * @return Returns <b>0</b> if the operation is successful; returns an error code defined
160     * in {@link DispErrCode} otherwise.
161     * @since 4.0
162     * @version 1.0
163     */
164    virtual int32_t GetDisplayPowerStatus(uint32_t devId, DispPowerStatus& status) = 0;
165
166    /**
167     * @brief Sets the power status of a display device.
168     *
169     * @param devId Indicates the ID of the display device.
170     * @param status Indicates the power status to set.
171     *
172     * @return Returns <b>0</b> if the operation is successful; returns an error code defined
173     * in {@link DispErrCode} otherwise.
174     * @since 4.0
175     * @version 1.0
176     */
177    virtual int32_t SetDisplayPowerStatus(uint32_t devId, DispPowerStatus status) = 0;
178
179    /**
180     * @brief Obtains the backlight value of a display device.
181     *
182     * @param devId Indicates the ID of the display device.
183     * @param level Indicates the pointer to the backlight value of the device. The backlight value is written
184     * by this interface.
185     *
186     * @return Returns <b>0</b> if the operation is successful; returns an error code defined
187     * in {@link DispErrCode} otherwise.
188     * @since 4.0
189     * @version 1.0
190     */
191    virtual int32_t GetDisplayBacklight(uint32_t devId, uint32_t& level) = 0;
192
193    /**
194     * @brief Sets the backlight value for a display device.
195     *
196     * @param devId Indicates the ID of the display device.
197     * @param level Indicates the backlight value to set.
198     *
199     * @return Returns <b>0</b> if the operation is successful; returns an error code defined
200     * in {@link DispErrCode} otherwise.
201     * @since 4.0
202     * @version 1.0
203     */
204    virtual int32_t SetDisplayBacklight(uint32_t devId, uint32_t level) = 0;
205
206    /**
207     * @brief Obtains the property for a display device.
208     *
209     * @param devId Indicates the ID of the display device.
210     * @param id Indicates the property ID returned by <b>GetDisplayCapability</b>.
211     * @param value Indicates the property to get.
212     *
213     * @return Returns <b>0</b> if the operation is successful; returns an error code defined
214     * in {@link DispErrCode} otherwise.
215     * @since 4.0
216     * @version 1.0
217     */
218    virtual int32_t GetDisplayProperty(uint32_t devId, uint32_t id, uint64_t& value) = 0;
219
220    /**
221     * @brief Obtains the layers whose composition types have changed.
222     *
223     * In the preparation for composition, the display device changes the composition type for each layer based on
224     * the composition capability of the device. This function returns the layers whose composition types have changed.
225     *
226     * @param devId Indicates the ID of the display device.
227     * @param layers Indicates the vector of the start address of the layer array.
228     * @param types Indicates the vector of the start address of the composition type array.
229     *
230     * @return Returns <b>0</b> if the operation is successful; returns an error code defined
231     * in {@link DispErrCode} otherwise.
232     * @since 4.0
233     * @version 1.0
234     */
235    virtual int32_t GetDisplayCompChange(uint32_t devId, std::vector<uint32_t>& layers,
236        std::vector<int32_t>& types) = 0;
237
238    /**
239     * @brief Sets the cropped region for a display device.
240     *
241     * You can use this interface to set the cropped region of the client buffer of the display device.
242     * The cropped region cannot exceed the size of the client buffer.
243     *
244     * @param devId Indicates the ID of the display device.
245     * @param rect Indicates the pointer to the cropped region of the client buffer.
246     *
247     * @return Returns <b>0</b> if the operation is successful; returns an error code defined
248     * in {@link DispErrCode} otherwise.
249     * @since 4.0
250     * @version 1.0
251     */
252    virtual int32_t SetDisplayClientCrop(uint32_t devId, const IRect& rect) = 0;
253
254    /**
255     * @brief Sets the display buffer for a display device.
256     *
257     * The display buffer stores the hardware composition result of the display device.
258     *
259     * @param devId Indicates the ID of the display device.
260     * @param buffer Indicates the pointer to the display buffer.
261     * @param seqNo Indicates the sequence number of buffer cache.
262     * @param fence Indicates the sync fence that specifies whether the display buffer can be accessed. The display
263     * buffer is created and released by the graphics service. It can be accessed only when the sync fence is in the
264     * signaled state.
265     *
266     * @return Returns <b>0</b> if the operation is successful; returns an error code defined
267     * in {@link DispErrCode} otherwise.
268     * @since 4.0
269     * @version 1.0
270     */
271    virtual int32_t SetDisplayClientBuffer(uint32_t devId, const BufferHandle* buffer, uint32_t seqNo,
272        int32_t fence) = 0;
273
274    /**
275     * @brief Sets the dirty region for a display device.
276     *
277     * The dirty region consists of multiple rectangular regions. The rectangular regions can be refreshed based on
278     * the settings.
279     *
280     * @param devId Indicates the ID of the display device.
281     * @param rects Indicates the vector of the start address of the rectangle array.
282     *
283     * @return Returns <b>0</b> if the operation is successful; returns an error code defined
284     * in {@link DispErrCode} otherwise.
285     * @since 4.0
286     * @version 1.0
287     */
288    virtual int32_t SetDisplayClientDamage(uint32_t devId, std::vector<IRect>& rects) = 0;
289    /**
290     * @brief Enables or disables the vertical sync signal.
291     *
292     * When the vertical sync signal is generated, the <b>VBlankCallback</b> callback registered
293     * by <b>RegDisplayVBlankCallback</b> will be invoked. The vertical sync signal must be enabled when the graphics
294     * service needs to refresh the display, and disabled when display refresh is not required. The display does not
295     * need to refresh when <b>VBlankCallback</b> is invoked and the graphics service composes layers and sends the
296     * composition result to the device for display.
297     *
298     * @param devId Indicates the ID of the display device.
299     * @param enabled Specifies whether to enable the vertical sync signal. The value <b>true</b> means to enable the
300     * vertical sync signal, and <b>false</b> means to disable it.
301     *
302     * @return Returns <b>0</b> if the operation is successful; returns an error code defined
303     * in {@link DispErrCode}otherwise.
304     * @since 4.0
305     * @version 1.0
306     */
307    virtual int32_t SetDisplayVsyncEnabled(uint32_t devId, bool enabled) = 0;
308
309    /**
310     * @brief Registers the callback to be invoked when a VBLANK event occurs.
311     *
312     * @param devId Indicates the ID of the display device.
313     * @param cb Indicates the instance used to notify the graphics service of the VBLANK event occurred when
314     * <b>DisplayVsync</b> is enabled.
315     * @param data Indicates the pointer to the private data returned to the graphics service in the
316     * <b>VBlankCallback</b> callback.
317     *
318     * @return Returns <b>0</b> if the operation is successful; returns an error code defined
319     * in {@link DispErrCode} otherwise.
320     * @since 4.0
321     * @version 1.0
322     */
323    virtual int32_t RegDisplayVBlankCallback(uint32_t devId, VBlankCallback cb, void* data) = 0;
324
325    /**
326     * @brief Obtains the fences of the display layers after the commit operation.
327     *
328     * @param devId Indicates the ID of the display device.
329     * @param layers Indicates the vector of the start address of the layer array.
330     * @param fences Indicates the vector of the start address of the fence array.
331     *
332     * @return Returns <b>0</b> if the operation is successful; returns an error code defined
333     * in {@link DispErrCode} otherwise.
334     * @since 4.0
335     * @version 1.0
336     */
337    virtual int32_t GetDisplayReleaseFence(uint32_t devId, std::vector<uint32_t>& layers,
338        std::vector<int32_t>& fences) = 0;
339
340    /**
341     * @brief Creates a virtual display device.
342     *
343     * @param width Indicates the pixel width of the display device.
344     * @param height Indicates the pixel height of the display device.
345     * @param format Indicates the pointer to the pixel format of the display device.
346     * For details, see {@link PixelFormat}. The <b>format</b> can be modified based on hardware requirements and
347     * returned to the graphics service.
348     * @param devId Indicates the pointer to the ID of the virtual display device created.
349     *
350     * @return Returns <b>0</b> if the operation is successful; returns an error code defined
351     * in {@link DispErrCode} otherwise.
352     * @since 4.0
353     * @version 1.0
354     */
355    virtual int32_t CreateVirtualDisplay(uint32_t width, uint32_t height, int32_t& format, uint32_t& devId) = 0;
356
357    /**
358     * @brief Destroys a virtual display device.
359     *
360     * @param devId Indicates the ID of the display device.
361     *
362     * @return Returns <b>0</b> if the operation is successful; returns an error code defined
363     * in {@link DispErrCode} otherwise.
364     * @since 4.0
365     * @version 1.0
366     */
367    virtual int32_t DestroyVirtualDisplay(uint32_t devId) = 0;
368
369    /**
370     * @brief Sets the output buffer for a virtual display device.
371     *
372     * This buffer stores the output of the virtual display device. The buffer can be used only after the sync fence
373     * is in the signaled state.
374     *
375     * @param devId Indicates the ID of the display device.
376     * @param buffer Indicates the pointer to the output buffer.
377     * @param fence Indicates the sync fence.
378     *
379     * @return Returns <b>0</b> if the operation is successful; returns an error code defined
380     * in {@link DispErrCode} otherwise.
381     * @since 4.0
382     * @version 1.0
383     */
384    virtual int32_t SetVirtualDisplayBuffer(uint32_t devId, const BufferHandle& buffer, const int32_t fence) = 0;
385
386    /**
387     * @brief Sets the property for a display device.
388     *
389     * @param devId Indicates the ID of the display device.
390     * @param id Indicates the property ID returned by <b>GetDisplayCapability</b>.
391     * @param value Indicates the property to set.
392     *
393     * @return Returns <b>0</b> if the operation is successful; returns an error code defined
394     * in {@link DispErrCode} otherwise.
395     * @since 4.0
396     * @version 1.0
397     */
398    virtual int32_t SetDisplayProperty(uint32_t devId, uint32_t id, uint64_t value) = 0;
399
400    /**
401     * @brief Commits the request for composition and display.
402     *
403     * If there is a hardware composition layer, the composition is performed and the composition result is sent to
404     * the hardware for display.
405     *
406     * @param devId Indicates the ID of the display device.
407     * @param fence Indicates the pointer to the start address of the fence array.
408     *
409     * @return Returns <b>0</b> if the operation is successful; returns an error code defined
410     * in {@link DispErrCode} otherwise.
411     * @since 4.0
412     * @version 1.0
413     */
414    virtual int32_t Commit(uint32_t devId, int32_t& fence) = 0;
415
416    /**
417     * @brief Obtains the color gamuts supported by a display device.
418     *
419     * @param devId Indicates the ID of the display device.
420     * @param gamuts Indicates the vector of the information about all color gamuts supported by the display device.
421     *
422     * @return Returns <b>0</b> if the operation is successful; returns an error code defined
423     * in {@link DispErrCode} otherwise.
424     * @since 4.0
425     * @version 1.0
426     */
427    virtual int32_t GetDisplaySupportedColorGamuts(uint32_t devId, std::vector<ColorGamut>& gamuts) = 0;
428
429    /**
430     * @brief Obtains the color gamut of a display device.
431     *
432     * @param devId Indicates the ID of the display device.
433     * @param gamut Indicates the pointer to the color gamut of the device. The color gamut is written
434     * by this interface.
435     *
436     * @return Returns <b>0</b> if the operation is successful; returns an error code defined
437     * in {@link DispErrCode} otherwise.
438     * @since 4.0
439     * @version 1.0
440     */
441    virtual int32_t GetDisplayColorGamut(uint32_t devId, ColorGamut& gamut) = 0;
442
443    /**
444     * @brief Sets the color gamut for a display device.
445     *
446     * @param devId Indicates the ID of the display device.
447     * @param gamut Indicates the color gamut to set.
448     *
449     * @return Returns <b>0</b> if the operation is successful; returns an error code defined
450     * in {@link DispErrCode} otherwise.
451     * @since 4.0
452     * @version 1.0
453     */
454    virtual int32_t SetDisplayColorGamut(uint32_t devId, const ColorGamut& gamut) = 0;
455
456    /**
457     * @brief Obtains the gamut map of a display device.
458     *
459     * @param devId Indicates the ID of the display device.
460     * @param gamutMap Indicates the pointer to the gamut map of the device. The gamut map is written
461     * by this interface.
462     *
463     * @return Returns <b>0</b> if the operation is successful; returns an error code defined
464     * in {@link DispErrCode} otherwise.
465     * @since 4.0
466     * @version 1.0
467     */
468    virtual int32_t GetDisplayGamutMap(uint32_t devId, GamutMap& gamutMap) = 0;
469
470    /**
471     * @brief Sets the gamut map for a display device.
472     *
473     * @param devId Indicates the ID of the display device.
474     * @param gamutMap Indicates the gamut map to set.
475     *
476     * @return Returns <b>0</b> if the operation is successful; returns an error code defined
477     * in {@link DispErrCode} otherwise.
478     * @since 4.0
479     * @version 1.0
480     */
481    virtual int32_t SetDisplayGamutMap(uint32_t devId, const GamutMap& gamutMap) = 0;
482
483    /**
484     * @brief Sets a 4x4 color transformation matrix for a display device.
485     *
486     * @param devId Indicates the ID of the display device.
487     * @param matrix Indicates the vector of the 4x4 color transformation matrix to set.
488     *
489     * @return Returns <b>0</b> if the operation is successful; returns an error code defined
490     * in {@link DispErrCode} otherwise.
491     * @since 4.0
492     * @version 1.0
493     */
494    virtual int32_t SetDisplayColorTransform(uint32_t devId, const std::vector<float>& matrix) = 0;
495
496    /**
497     * @brief Obtains the HDR capability of a display device.
498     *
499     * @param devId Indicates the ID of the display device.
500     * @param info Indicates the pointer to the HDR capability of the device. The <b>info</b> is written
501     * by this interface.
502     *
503     * @return Returns <b>0</b> if the operation is successful; returns an error code defined
504     * in {@link DispErrCode} otherwise.
505     * @since 4.0
506     * @version 1.0
507     */
508    virtual int32_t GetHDRCapabilityInfos(uint32_t devId, HDRCapability& info) = 0;
509
510    /**
511     * @brief Obtains the HDR metadata keys supported by a display device.
512     *
513     * @param devId Indicates the ID of the display device.
514     * @param keys Indicates the vector of the information about all HDR metadata keys supported by the display device.
515     *
516     * @return Returns <b>0</b> if the operation is successful; returns an error code defined
517     * in {@link DispErrCode} otherwise.
518     * @since 4.0
519     * @version 1.0
520     */
521    virtual int32_t GetSupportedMetadataKey(uint32_t devId, std::vector<HDRMetadataKey>& keys) = 0;
522
523    /* layer func */
524    /**
525     * @brief Opens a layer on a specified display device.
526     *
527     * Before using a layer on the GUI, you must open the layer based on the layer information. After the layer is
528     * opened, you can obtain the layer ID and then use other functions based on the layer ID.
529     *
530     * @param devId Indicates the ID of the display device. The value ranges from 0 to 4, where 0 indicates the first
531     * display device, and 4 indicates the last display device.
532     * @param layerInfo Indicates the pointer to the layer information passed to open a layer, including the layer
533     * type, layer size, and pixel format.
534     * @param cacheCount Indicates the count of buffer cache.
535     * @param layerId Indicates the pointer to the layer ID, which uniquely identifies a layer. The layer ID is returned
536     * to the GUI after the layer is successfully opened.
537     *
538     * @return Returns <b>0</b> if the operation is successful; returns an error code defined in {@link DispErrCode}
539     * otherwise.
540     * @see DestroyLayer
541     * @since 4.0
542     * @version 1.0
543     */
544    virtual int32_t CreateLayer(uint32_t devId, const LayerInfo& layerInfo, uint32_t cacheCount, uint32_t& layerId) = 0;
545
546    /**
547     * @brief Closes a layer that is no longer required on a specified display device.
548     *
549     * @param devId Indicates the ID of the display device. The value ranges from 0 to 4, where 0 indicates the first
550     * display device, and 4 indicates the last display device.
551     * @param layerId Indicates the layer ID, which uniquely identifies a layer. You can perform operations on the layer
552     * with the specified layer ID.
553     *
554     * @return Returns <b>0</b> if the operation is successful; returns an error code defined in {@link DispErrCode}
555     * otherwise.
556     * @see OpenLayer
557     * @since 4.0
558     * @version 1.0
559     */
560    virtual int32_t DestroyLayer(uint32_t devId, uint32_t layerId) = 0;
561
562    /**
563    * @brief Prepares for the composition to be performed by a display device.
564    *
565    * Before the composition, the graphics service needs to notify the display device of the preparation to be made
566    * through this interface.
567    *
568    * @param devId Indicates the ID of the display device.
569    * @param needFlushFb Indicates the pointer that specifies whether the graphics service needs to reset the display
570    * framebuffer by using <b>SetDisplayClientBuffer</b> before the commit operation.
571    * The value <b>true</b> means that the framebuffer needs to be reset, and <b>false</b> means the opposite.
572    *
573    * @return Returns <b>0</b> if the operation is successful; returns an error code defined
574    * in {@link DispErrCode} otherwise.
575    * @since 4.0
576    * @version 1.0
577    */
578    virtual int32_t PrepareDisplayLayers(uint32_t devId, bool& needFlushFb) = 0;
579
580    /**
581     * @brief Sets the alpha value for a layer.
582     *
583     * @param devId Indicates the ID of the display device. The value ranges from 0 to 4, where 0 indicates the first
584     * display device, and 4 indicates the last display device.
585     * @param layerId Indicates the layer ID, which uniquely identifies a layer. You can perform operations on the layer
586     * with the specified layer ID.
587     * @param alpha Indicates the pointer to the alpha value to set.
588     *
589     * @return Returns <b>0</b> if the operation is successful; returns an error code defined in {@link DispErrCode}
590     * otherwise.
591     * @see GetLayerAlpha
592     * @since 4.0
593     * @version 1.0
594     */
595    virtual int32_t SetLayerAlpha(uint32_t devId, uint32_t layerId, const LayerAlpha& alpha) = 0;
596
597    /**
598     * @brief Sets the region for a layer.
599     *
600     * @param devId Indicates the ID of the display device. The value ranges from 0 to 4, where 0 indicates the first
601     * display device, and 4 indicates the last display device.
602     * @param layerId Indicates the layer ID, which uniquely identifies a layer. You can perform operations on the layer
603     * with the specified layer ID.
604     * @param rect Indicates the pointer to the region where set.
605     *
606     * @return Returns <b>0</b> if the operation is successful; returns an error code defined in {@link DispErrCode}
607     * otherwise.
608     * @see GetLayerAlpha
609     * @since 4.0
610     * @version 1.0
611     */
612    virtual int32_t SetLayerRegion(uint32_t devId, uint32_t layerId, const IRect& rect) = 0;
613
614    /**
615     * @brief Sets the rectangular area to crop for a layer.
616     *
617     * @param devId Indicates the ID of the display device. The value ranges from 0 to 4, where 0 indicates the first
618     * display device, and 4 indicates the last display device.
619     * @param layerId Indicates the layer ID, which uniquely identifies a layer. You can perform operations on the layer
620     * with the specified layer ID.
621     * @param rect Indicates the pointer to the rectangular area to crop.
622     *
623     * @return Returns <b>0</b> if the operation is successful; returns an error code defined in {@link DispErrCode}
624     * otherwise.
625     * @since 4.0
626     * @version 1.0
627     */
628    virtual int32_t SetLayerCrop(uint32_t devId, uint32_t layerId, const IRect& rect) = 0;
629
630    /**
631     * @brief Sets the z-order for a layer.
632     *
633     * A larger z-order value indicates a higher layer.
634     *
635     * @param devId Indicates the ID of the display device. The value ranges from 0 to 4, where 0 indicates the first
636     * display device, and 4 indicates the last display device.
637     * @param layerId Indicates the layer ID, which uniquely identifies a layer. You can perform operations on the layer
638     * with the specified layer ID.
639     * @param zorder Indicates the z-order to set. The value is an integer ranging from 0 to 255.
640     *
641     * @return Returns <b>0</b> if the operation is successful; returns an error code defined in {@link DispErrCode}
642     * otherwise.
643     * @see GetLayerZorder
644     * @since 4.0
645     * @version 1.0
646     */
647    virtual int32_t SetLayerZorder(uint32_t devId, uint32_t layerId, uint32_t zorder) = 0;
648
649    /**
650     * @brief Sets layer premultiplication.
651     *
652     * @param devId Indicates the ID of the display device. The value ranges from 0 to 4, where 0 indicates the first
653     * display device, and 4 indicates the last display device.
654     * @param layerId Indicates the layer ID, which uniquely identifies a layer. You can perform operations on the layer
655     * with the specified layer ID.
656     * @param preMul Specifies whether to enable layer premultiplication. The value <b>1</b> means to enable layer
657     * premultiplication, and <b>0</b> means the opposite.
658     *
659     * @return Returns <b>0</b> if the operation is successful; returns an error code defined in {@link DispErrCode}
660     * otherwise.
661     * @see GetLayerPreMulti
662     * @since 4.0
663     * @version 1.0
664     */
665    virtual int32_t SetLayerPreMulti(uint32_t devId, uint32_t layerId, bool preMul) = 0;
666
667    /**
668     * @brief Sets the type of graphic rotation.
669     *
670     * @param devId Indicates the ID of the display device. The value ranges from 0 to 4, where 0 indicates the first
671     * display device, and 4 indicates the last display device.
672     * @param layerId Indicates the layer ID, which uniquely identifies a layer. You can perform operations on the layer
673     * with the specified layer ID.
674     * @param type Indicates the transform types of images.
675     *
676     * @return Returns <b>0</b> if the operation is successful; returns an error code defined in {@link DispErrCode}
677     * otherwise.
678     * @since 4.0
679     * @version 1.0
680     */
681    virtual int32_t SetLayerTransformMode(uint32_t devId, uint32_t layerId, TransformType type) = 0;
682
683    /**
684     * @brief Sets the flushing area for a layer.
685     *
686     * After the GUI draws an image, you must set the layer flushing area before calling the {@link Flush} function to
687     * flush the screen.
688     *
689     * @param devId Indicates the ID of the display device. The value ranges from 0 to 4, where 0 indicates the first
690     * display device, and 4 indicates the last display device.
691     * @param layerId Indicates the layer ID, which uniquely identifies a layer. You can perform operations on the layer
692     * with the specified layer ID.
693     * @param regions Indicates the vector of the flushing area to set.
694     *
695     * @return Returns <b>0</b> if the operation is successful; returns an error code defined in {@link DispErrCode}
696     * otherwise.
697     * @since 4.0
698     * @version 1.0
699     */
700    virtual int32_t SetLayerDirtyRegion(uint32_t devId, uint32_t layerId, std::vector<IRect>& regions) = 0;
701
702    /**
703     * @brief Set the visible region for a layer
704     *
705     *
706     * @param devId Indicates the ID of the display device. The value ranges from 0 to 4, where 0 indicates the first
707     * display device, and 4 indicates the last display device.
708     * @param layerId Indicates the layer ID, which uniquely identifies a layer. You can perform operations on the layer
709     * with the specified layer ID.
710     * @param rects Indicates the vector of the rectes.
711     *
712     * @return Returns <b>0</b> if the operation is successful; returns an error code defined in {@link DispErrCode}
713     * otherwise.
714     * @since 2.0
715     * @version 2.0
716     */
717    virtual int32_t SetLayerVisibleRegion(uint32_t devId, uint32_t layerId, std::vector<IRect>& rects) = 0;
718
719    /**
720     * @brief Set the buffer for a layer.
721     *
722     *
723     * @param devId Indicates the ID of the display device. The value ranges from 0 to 4, where 0 indicates the first
724     * display device, and 4 indicates the last display device.
725     * @param layerId Indicates the layer ID, which uniquely identifies a layer. You can perform operations on the layer
726     * with the specified layer ID.
727     * @param buffer Indicates the pointer of the buffer handle. The buffer handle should contain all information of the
728     * buffer which will be used for composition.
729     * @param seqNo Indicates the sequence number of buffer cache.
730     * @param fence Indicates the fd of a sync file.
731     * @param deletingList Indicates the list of buffer cache to delete.
732     *
733     * @return Returns <b>0</b> if the operation is successful; returns an error code defined in {@link DispErrCode}
734     * otherwise.
735     * @since 2.0
736     * @version 2.0
737     */
738    virtual int32_t SetLayerBuffer(uint32_t devId, uint32_t layerId, const BufferHandle* buffer, uint32_t seqNo,
739        int32_t fence, const std::vector<uint32_t>& deletingList) = 0;
740
741    /**
742     * @brief set the composition type which the client expect
743     *
744     *
745     * @param devId Indicates the ID of the display device. The value ranges from 0 to 4, where 0 indicates the first
746     * display device, and 4 indicates the last display device.
747     * @param layerId Indicates the layer ID, which uniquely identifies a layer. You can perform operations on the layer
748     * with the specified layer ID.
749     * @param type Indicates the composition type which the client expect. It may vary with the implementation.
750     *
751     * @return Returns <b>0</b> if the operation is successful; returns an error code defined in {@link DispErrCode}
752     * otherwise.
753     * @since 2.0
754     * @version 2.0
755     */
756    virtual int32_t SetLayerCompositionType(uint32_t devId, uint32_t layerId, CompositionType type) = 0;
757
758    /**
759     * @brief set the blend type
760     *
761     *
762     * @param devId Indicates the ID of the display device. The value ranges from 0 to 4, where 0 indicates the first
763     * display device, and 4 indicates the last display device.
764     * @param layerId Indicates the layer ID, which uniquely identifies a layer. You can perform operations on the layer
765     * with the specified layer ID.
766     * @param type Indicates blend type
767     *
768     * @return Returns <b>0</b> if the operation is successful; returns an error code defined in {@link DispErrCode}
769     * otherwise.
770     * @since 2.0
771     * @version 2.0
772     */
773    virtual int32_t SetLayerBlendType(uint32_t devId, uint32_t layerId, BlendType type) = 0;
774
775    /**
776     * @brief Sets a 4x4 color transformation matrix.
777     *
778     *
779     * @param devId Indicates the ID of the display device. The value ranges from 0 to 4, where 0 indicates the first
780     * display device, and 4 indicates the last display device.
781     * @param layerId Indicates the layer ID, which uniquely identifies a layer. You can perform operations on the layer
782     * with the specified layer ID.
783     * @param matrix Indicates the 4x4 color transformation matrix.
784     *
785     * @return Returns <b>0</b> if the operation is successful; returns an error code defined in {@link DispErrCode}
786     * otherwise.
787     * @since 4.0
788     * @version 1.0
789     */
790    virtual int32_t SetLayerColorTransform(uint32_t devId, uint32_t layerId, const std::vector<float>& matrix) = 0;
791
792    /**
793     * @brief Sets a color data space for a layer.
794     *
795     * @param devId Indicates the ID of the display device. The value ranges from 0 to 4, where 0 indicates the first
796     * display device, and 4 indicates the last display device.
797     * @param layerId Indicates the layer ID, which uniquely identifies a layer. You can perform operations on the layer
798     * with the specified layer ID.
799     * @param colorSpace Indicates the color data space to set.
800     *
801     * @return Returns <b>0</b> if the operation is successful; returns an error code defined in {@link DispErrCode}
802     * otherwise.
803     * @since 4.0
804     * @version 1.0
805     */
806    virtual int32_t SetLayerColorDataSpace(uint32_t devId, uint32_t layerId, const ColorDataSpace colorSpace) = 0;
807
808    /**
809     * @brief Obtains the color data space of a layer.
810     *
811     * @param devId Indicates the ID of the display device. The value ranges from 0 to 4, where 0 indicates the first
812     * display device, and 4 indicates the last display device.
813     * @param layerId Indicates the layer ID, which uniquely identifies a layer. You can perform operations on the layer
814     * with the specified layer ID.
815     * @param colorSpace Indicates the pointer to the color data space obtained.
816     *
817     * @return Returns <b>0</b> if the operation is successful; returns an error code defined in {@link DispErrCode}
818     * otherwise.
819     * @since 4.0
820     * @version 1.0
821     */
822    virtual int32_t GetLayerColorDataSpace(uint32_t devId, uint32_t layerId, ColorDataSpace& colorSpace) = 0;
823
824    /**
825     * @brief Sets metadata for a layer.
826     *
827     * @param devId Indicates the ID of the display device. The value ranges from 0 to 4, where 0 indicates the first
828     * display device, and 4 indicates the last display device.
829     * @param layerId Indicates the layer ID, which uniquely identifies a layer. You can perform operations on the layer
830     * with the specified layer ID.
831     * @param num Indicates the number of metadata records.
832     * @param metaData Indicates the vecter of the metadata to set.
833     *
834     * @return Returns <b>0</b> if the operation is successful; returns an error code defined in {@link DispErrCode}
835     * otherwise.
836     * @since 4.0
837     * @version 1.0
838     */
839    virtual int32_t SetLayerMetaData(uint32_t devId, uint32_t layerId, const std::vector<HDRMetaData>& metaData) = 0;
840
841    /**
842     * @brief Sets a metadata set for a layer.
843     *
844     * @param devId Indicates the ID of the display device. The value ranges from 0 to 4, where 0 indicates the first
845     * display device, and 4 indicates the last display device.
846     * @param layerId Indicates the layer ID, which uniquely identifies a layer. You can perform operations on the layer
847     * with the specified layer ID.
848     * @param key Indicates the metadata key.
849     * @param metaData Indicates the vector of the metadata set of the uint8_t type to set.
850     *
851     * @return Returns <b>0</b> if the operation is successful; returns an error code defined in {@link DispErrCode}
852     * otherwise.
853     * @since 4.0
854     * @version 1.0
855     */
856    virtual int32_t SetLayerMetaDataSet(uint32_t devId, uint32_t layerId, HDRMetadataKey key,
857         const std::vector<uint8_t>& metaData) = 0;
858
859    /**
860     * @brief Obtains the hardware display present timestamp type supported by a layer.
861     *
862     * @param devId Indicates the ID of the display device. The value ranges from 0 to 4, where 0 indicates the first
863     * display device, and 4 indicates the last display device.
864     * @param layerId Indicates the layer ID, which uniquely identifies a layer. You can perform operations on the layer
865     * with the specified layer ID.
866     * @param type Indicates the pointer to the present timestamp type obtained.
867     *
868     * @return Returns <b>0</b> if the operation is successful; returns an error code defined in {@link DispErrCode}
869     * otherwise.
870     * @since 4.0
871     * @version 1.0
872     */
873    virtual int32_t GetSupportedPresentTimestamp(uint32_t devId, uint32_t layerId, PresentTimestampType& type) = 0;
874
875    /**
876     * @brief Obtains the hardware display present timestamp of a layer.
877     *
878     * @param devId Indicates the ID of the display device. The value ranges from 0 to 4, where 0 indicates the first
879     * display device, and 4 indicates the last display device.
880     * @param layerId Indicates the layer ID, which uniquely identifies a layer. You can perform operations on the layer
881     * with the specified layer ID.
882     * @param pts Indicates the pointer to the present timestamp obtained.
883     *
884     * @return Returns <b>0</b> if the operation is successful; returns an error code defined in {@link DispErrCode}
885     * otherwise.
886     * @since 4.0
887     * @version 1.0
888     */
889    virtual int32_t GetHwPresentTimestamp(uint32_t devId, uint32_t layerId, PresentTimestamp& pts) = 0;
890
891    /**
892     * @brief Sets a tunnel handle for a layer.
893     *
894     * @param devId Indicates the ID of the display device. The value ranges from 0 to 4, where 0 indicates the first
895     * display device, and 4 indicates the last display device.
896     * @param layerId Indicates the layer ID, which uniquely identifies a layer. You can perform operations on the layer
897     * with the specified layer ID.
898     * @param handle Indicates the handle of ExtDataHandle.
899     *
900     * @return Returns <b>0</b> if the operation is successful; returns an error code defined in {@link DispErrCode}
901     * otherwise.
902     * @since 3.2
903     * @version 1.0
904     */
905    virtual int32_t SetLayerTunnelHandle(uint32_t devId, uint32_t layerId, const ExtDataHandle& handle) = 0;
906
907    /**
908     * @brief Sets the current mask frame information to the vendor driver.
909     *
910     * @param devId Indicates the ID of the display device. The value ranges from 0 to 4, where 0 indicates the first
911     * display device, and 4 indicates the last display device.
912     * @param layerId Indicates the layer ID, which uniquely identifies a layer. You can perform operations on the layer
913     * with the specified layer ID.
914     * @param maskInfo Indicates the contains all of the information for a single mask.
915     *
916     * @return Returns <b>0</b> if the operation is successful; returns an error code defined in {@link DispErrCode}
917     * otherwise.
918     * @since 3.2
919     * @version 1.0
920     */
921    virtual int32_t SetLayerMaskInfo(uint32_t devId, uint32_t layerId, const MaskInfo maskInfo) = 0;
922
923    /**
924     * @brief Sets the solid color layer.
925     *
926     * @param devId Indicates the ID of the display device. The value ranges from 0 to 4, where 0 indicates the first
927     * display device, and 4 indicates the last display device.
928     * @param layerId Indicates the layer ID, which uniquely identifies a layer. You can perform operations on the layer
929     * with the specified layer ID.
930     * @param layerColor Indicates the current color.
931     *
932     * @return Returns <b>0</b> if the operation is successful; returns an error code defined in {@link DispErrCode}
933     * otherwise.
934     * @since 3.2
935     * @version 1.0
936     */
937    virtual int32_t SetLayerColor(uint32_t devId, uint32_t layerId, const LayerColor& layerColor) = 0;
938};
939} // V1_0
940} // Composer
941} // Display
942} // HDI
943} // OHOS
944#endif // OHOS_HDI_DISPLAY_V1_0_IDISPLAY_COMPOSER_INTERFACE_H
945