• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 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 #ifndef INTERFACES_INNERKITS_SURFACE_SURFACE_TYPE_H
17 #define INTERFACES_INNERKITS_SURFACE_SURFACE_TYPE_H
18 
19 #include <cstdint>
20 #include <string>
21 #include <vector>
22 #include <graphic_common.h>
23 
24 namespace OHOS {
25 #define SURFACE_MAX_USER_DATA_COUNT 1000
26 #define SURFACE_MAX_QUEUE_SIZE 64
27 #define SURFACE_DEFAULT_QUEUE_SIZE 3
28 #define SURFACE_MAX_SIZE 58982400 // 8K * 8K
29 
30 #ifndef _WIN32
31 #define SURFACE_HIDDEN __attribute__((visibility("hidden")))
32 #endif
33 
34 constexpr uint32_t SURFACE_PARCEL_SIZE_LIMIT = 1024;
35 
36 /*
37  * @brief Enumerates return values of the functions.
38  */
39 using GraphicDispErrCode = enum {
40     GRAPHIC_DISPLAY_SUCCESS = 0,           /**< Success */
41     GRAPHIC_DISPLAY_FAILURE = -1,          /**< Failure */
42     GRAPHIC_DISPLAY_FD_ERR = -2,           /**< File handle (FD) error */
43     GRAPHIC_DISPLAY_PARAM_ERR = -3,        /**< Parameter error */
44     GRAPHIC_DISPLAY_NULL_PTR = -4,         /**< Null pointer */
45     GRAPHIC_DISPLAY_NOT_SUPPORT = -5,      /**< Unsupported feature */
46     GRAPHIC_DISPLAY_NOMEM = -6,            /**< Insufficient memory */
47     GRAPHIC_DISPLAY_SYS_BUSY = -7,         /**< System busy */
48     GRAPHIC_DISPLAY_NOT_PERM = -8          /**< Forbidden operation */
49 };
50 
51 using GraphicCompositionType = enum {
52     GRAPHIC_COMPOSITION_CLIENT,       /**< Client composition type. The composer should be the CPU or GPU. */
53     GRAPHIC_COMPOSITION_DEVICE,       /**< Device composition type. The composer should be the hardware. */
54     GRAPHIC_COMPOSITION_CURSOR,       /**< Cursor composition type, used for cursor. */
55     GRAPHIC_COMPOSITION_VIDEO,        /**< Video composition type, used for video. */
56     GRAPHIC_COMPOSITION_DEVICE_CLEAR, /**< Device clear composition type, the device will clear the target region. */
57     GRAPHIC_COMPOSITION_CLIENT_CLEAR, /**< Client clear composition type, the service will clear the target region. */
58     GRAPHIC_COMPOSITION_TUNNEL,       /**< Tunnel composition type, used for tunnel. */
59     GRAPHIC_COMPOSITION_SOLID_COLOR,  /**< used for SetLayerColor. */
60     GRAPHIC_COMPOSITION_BUTT
61 };
62 
63 using GraphicLayerAlpha = struct {
64     bool enGlobalAlpha;   /**< Global alpha enable bit */
65     bool enPixelAlpha;    /**< Pixel alpha enable bit */
66     uint8_t alpha0;       /**< Alpha0 value, ranging from 0 to 255 */
67     uint8_t alpha1;       /**< Alpha1 value, ranging from 0 to 255 */
68     uint8_t gAlpha;       /**< Global alpha value, ranging from 0 to 255 */
69 };
70 
71 using GraphicBlendType = enum {
72     GRAPHIC_BLEND_NONE = 0,         /**< No blending */
73     GRAPHIC_BLEND_CLEAR,            /**< CLEAR blending */
74     GRAPHIC_BLEND_SRC,              /**< SRC blending */
75     GRAPHIC_BLEND_SRCOVER,          /**< SRC_OVER blending */
76     GRAPHIC_BLEND_DSTOVER,          /**< DST_OVER blending */
77     GRAPHIC_BLEND_SRCIN,            /**< SRC_IN blending */
78     GRAPHIC_BLEND_DSTIN,            /**< DST_IN blending */
79     GRAPHIC_BLEND_SRCOUT,           /**< SRC_OUT blending */
80     GRAPHIC_BLEND_DSTOUT,           /**< DST_OUT blending */
81     GRAPHIC_BLEND_SRCATOP,          /**< SRC_ATOP blending */
82     GRAPHIC_BLEND_DSTATOP,          /**< DST_ATOP blending */
83     GRAPHIC_BLEND_ADD,              /**< ADD blending */
84     GRAPHIC_BLEND_XOR,              /**< XOR blending */
85     GRAPHIC_BLEND_DST,              /**< DST blending */
86     GRAPHIC_BLEND_AKS,              /**< AKS blending */
87     GRAPHIC_BLEND_AKD,              /**< AKD blending */
88     GRAPHIC_BLEND_BUTT              /**< Null operation */
89 };
90 
91 /*
92  * @brief Enumeration values are indicated for external consistency.
93  */
94 using GraphicPixelFormat = enum {
95     GRAPHIC_PIXEL_FMT_CLUT8 = 0,                    /**< CLUT8 format */
96     GRAPHIC_PIXEL_FMT_CLUT1 = 1,                    /**< CLUT1 format */
97     GRAPHIC_PIXEL_FMT_CLUT4 = 2,                    /**< CLUT4 format */
98     GRAPHIC_PIXEL_FMT_RGB_565 = 3,                  /**< RGB565 format */
99     GRAPHIC_PIXEL_FMT_RGBA_5658 = 4,                /**< RGBA5658 format */
100     GRAPHIC_PIXEL_FMT_RGBX_4444 = 5,                /**< RGBX4444 format */
101     GRAPHIC_PIXEL_FMT_RGBA_4444 = 6,                /**< RGBA4444 format */
102     GRAPHIC_PIXEL_FMT_RGB_444 = 7,                  /**< RGB444 format */
103     GRAPHIC_PIXEL_FMT_RGBX_5551 = 8,                /**< RGBX5551 format */
104     GRAPHIC_PIXEL_FMT_RGBA_5551 = 9,                /**< RGBA5551 format */
105     GRAPHIC_PIXEL_FMT_RGB_555 = 10,                 /**< RGB555 format */
106     GRAPHIC_PIXEL_FMT_RGBX_8888 = 11,               /**< RGBX8888 format */
107     GRAPHIC_PIXEL_FMT_RGBA_8888 = 12,               /**< RGBA8888 format */
108     GRAPHIC_PIXEL_FMT_RGB_888 = 13,                 /**< RGB888 format */
109     GRAPHIC_PIXEL_FMT_BGR_565 = 14,                 /**< BGR565 format */
110     GRAPHIC_PIXEL_FMT_BGRX_4444 = 15,               /**< BGRX4444 format */
111     GRAPHIC_PIXEL_FMT_BGRA_4444 = 16,               /**< BGRA4444 format */
112     GRAPHIC_PIXEL_FMT_BGRX_5551 = 17,               /**< BGRX5551 format */
113     GRAPHIC_PIXEL_FMT_BGRA_5551 = 18,               /**< BGRA5551 format */
114     GRAPHIC_PIXEL_FMT_BGRX_8888 = 19,               /**< BGRX8888 format */
115     GRAPHIC_PIXEL_FMT_BGRA_8888 = 20,               /**< BGRA8888 format */
116     GRAPHIC_PIXEL_FMT_YUV_422_I = 21,               /**< YUV422 interleaved format */
117     GRAPHIC_PIXEL_FMT_YCBCR_422_SP = 22,            /**< YCBCR422 semi-planar format */
118     GRAPHIC_PIXEL_FMT_YCRCB_422_SP = 23,            /**< YCRCB422 semi-planar format */
119     GRAPHIC_PIXEL_FMT_YCBCR_420_SP = 24,            /**< YCBCR420 semi-planar format */
120     GRAPHIC_PIXEL_FMT_YCRCB_420_SP = 25,            /**< YCRCB420 semi-planar format */
121     GRAPHIC_PIXEL_FMT_YCBCR_422_P = 26,             /**< YCBCR422 planar format */
122     GRAPHIC_PIXEL_FMT_YCRCB_422_P = 27,             /**< YCRCB422 planar format */
123     GRAPHIC_PIXEL_FMT_YCBCR_420_P = 28,             /**< YCBCR420 planar format */
124     GRAPHIC_PIXEL_FMT_YCRCB_420_P = 29,             /**< YCRCB420 planar format */
125     GRAPHIC_PIXEL_FMT_YUYV_422_PKG = 30,            /**< YUYV422 packed format */
126     GRAPHIC_PIXEL_FMT_UYVY_422_PKG = 31,            /**< UYVY422 packed format */
127     GRAPHIC_PIXEL_FMT_YVYU_422_PKG = 32,            /**< YVYU422 packed format */
128     GRAPHIC_PIXEL_FMT_VYUY_422_PKG = 33,            /**< VYUY422 packed format */
129     GRAPHIC_PIXEL_FMT_RGBA_1010102 = 34,            /**< RGBA_1010102 packed format */
130     GRAPHIC_PIXEL_FMT_YCBCR_P010 = 35,              /**< YCBCR420 semi-planar 10bit packed format */
131     GRAPHIC_PIXEL_FMT_YCRCB_P010 = 36,              /**< YCRCB420 semi-planar 10bit packed format */
132     GRAPHIC_PIXEL_FMT_RAW10 = 37,                   /**< Raw 10bit packed format */
133     GRAPHIC_PIXEL_FMT_BLOB = 38,                    /**< BLOB format */
134     GRAPHIC_PIXEL_FMT_RGBA16_FLOAT = 39,            /**< RGBA16 float format */
135     GRAPHIC_PIXEL_FMT_Y8 = 40,                      /**< Y8 format */
136     GRAPHIC_PIXEL_FMT_Y16 = 41,                     /**< Y16 format */
137     /**<
138      * RGBA format where the Red and Green channels use 16 bits each.
139      * Typically used in scenarios requiring higher color precision for specific channels.
140      */
141     GRAPHIC_PIXEL_FMT_RGBA_R16G16 = 42,
142     /**<
143      * RGBA format with 10 bits for Red, Green, and Blue channels, and 8 bits for Alpha.
144      * Commonly used in high dynamic range (HDR) rendering to improve color depth while keeping 32-bit alignment.
145      */
146     GRAPHIC_PIXEL_FMT_RGBA_1010108 = 43,
147     /**< End marker for valid enums, new entries MUST be added above this line */
148     GRAPHIC_PIXEL_FMT_END_OF_VALID,
149     /**< Fixed value strictly corresponding to HDI, cannot be contiguous with normal enums */
150     GRAPHIC_PIXEL_FMT_VENDER_MASK = 0X7FFF0000,     /**< vendor mask format */
151     GRAPHIC_PIXEL_FMT_BUTT = 0X7FFFFFFF             /**< Invalid pixel format */
152 };
153 
154 using GraphicLayerType = enum {
155     GRAPHIC_LAYER_TYPE_GRAPHIC,         /**< Graphic layer */
156     GRAPHIC_LAYER_TYPE_OVERLAY,         /**< Overlay layer */
157     GRAPHIC_LAYER_TYPE_SDIEBAND,        /**< Sideband layer */
158     GRAPHIC_LAYER_TYPE_CURSOR,          /**< Cursor Layer */
159     GRAPHIC_LAYER_TYPE_BUTT,            /**< Empty layer */
160     GRAPHIC_LAYER_TYPE_TUNNEL           /**< Tunnel Layer */
161 };
162 
163 using TunnelLayerProperty = enum {
164     TUNNEL_PROP_INVALID = 0,            /**< invalid tunnel layer property */
165     TUNNEL_PROP_POSTION = 1 << 0,       /**< update layer position by tunnel */
166     TUNNEL_PROP_BUFFER_ADDR = 1 << 1,   /**< update layer buffer address by tunnel */
167     TUNNEL_PROP_CLIENT_COMMIT = 1 << 2,    /**< tunnel layer update by client */
168     TUNNEL_PROP_DEVICE_COMMIT = 1 << 3,    /**< tunnel layer update by device */
169 };
170 
171 using GraphicLayerInfo = struct {
172     int32_t width;                /**< Layer width */
173     int32_t height;               /**< Layer height */
174     GraphicLayerType type;        /**< Layer type, which can be a graphic layer, overlay layer, or sideband layer */
175     int32_t bpp;                  /**< Number of bits occupied by each pixel */
176     GraphicPixelFormat pixFormat; /**< Pixel format of the layer */
177 };
178 
179 using GraphicIRect = struct GraphicIRect {
180     int32_t x;      /**< Start X coordinate of the rectangle */
181     int32_t y;      /**< Start Y coordinate of the rectangle */
182     int32_t w;      /**< Width of the rectangle */
183     int32_t h;      /**< Height of the rectangle */
184 
185     bool operator==(const GraphicIRect& rect) const
186     {
187         return (x == rect.x) && (y == rect.y) && (w == rect.w) && (h == rect.h);
188     }
189 };
190 
191 using GraphicMatrix = struct GraphicMatrix {
192     float scaleX;   /* horizontal scale factor */
193     float skewX;    /* horizontal skew factor */
194     float transX;   /* horizontal translation */
195     float skewY;    /* vertical scale factor */
196     float scaleY;   /* vertical skew factor */
197     float transY;   /* vertical translation */
198     float pers0;    /* input x-axis perspective factor */
199     float pers1;    /* input y-axis perspective factor */
200     float pers2;    /* perspective scale factor */
201 
floatEqualGraphicMatrix202     inline static bool floatEqual(float x, float y)
203     {
204         return (std::abs((x) - (y)) <= (std::numeric_limits<float>::epsilon()));
205     }
206 
207     bool operator==(const GraphicMatrix& matrix) const
208     {
209         return floatEqual(scaleX, matrix.scaleX) && floatEqual(skewX, matrix.skewX) &&
210                floatEqual(transX, matrix.transX) && floatEqual(skewY, matrix.skewY) &&
211                floatEqual(scaleY, matrix.scaleY) && floatEqual(transY, matrix.transY) &&
212                floatEqual(pers0, matrix.pers0) && floatEqual(pers1, matrix.pers1) && floatEqual(pers2, matrix.pers2);
213     }
214 };
215 
216 using BufferAllocInfo = struct {
217     uint32_t width;                 /**< Width of the requested memory */
218     uint32_t height;                /**< Height of the requested memory */
219     uint64_t usage;                 /**< Usage of the requested memory */
220     GraphicPixelFormat format;      /**< Format of the requested memory */
221     uint32_t expectedSize;          /**< Size assigned by memory requester */
222 };
223 
224 
225 using BufferVerifyAllocInfo = struct {
226     uint32_t width;               /**< Width of the memory to allocate */
227     uint32_t height;              /**< Height of the memory to allocate */
228     uint64_t usage;               /**< Usage of the memory */
229     GraphicPixelFormat format;    /**< Format of the memory to allocate */
230 };
231 
232 using GraphicPresentTimestampType = enum {
233     GRAPHIC_DISPLAY_PTS_UNSUPPORTED = 0,        /**< Unsupported */
234     GRAPHIC_DISPLAY_PTS_DELAY = 1 << 0,         /**< Delay */
235     GRAPHIC_DISPLAY_PTS_TIMESTAMP = 1 << 1,     /**< Timestamp */
236 };
237 
238 using GraphicPresentTimestamp = struct {
239     GraphicPresentTimestampType type;     /**< Present timestamp type */
240     int64_t time;                         /**< Present timestamp value */
241 };
242 
243 using Rect = struct Rect {
244     int32_t x;
245     int32_t y;
246     int32_t w;
247     int32_t h;
248 
249     bool operator==(const Rect& other) const
250     {
251         return x == other.x &&
252                y == other.y &&
253                w == other.w &&
254                h == other.h;
255     }
256 
257     bool operator!=(const Rect& other) const
258     {
259         return !(*this == other);
260     }
261 };
262 
263 using ScalingMode = enum {
264     SCALING_MODE_FREEZE = 0,
265     SCALING_MODE_SCALE_TO_WINDOW,
266     SCALING_MODE_SCALE_CROP,
267     SCALING_MODE_NO_SCALE_CROP,
268     SCALING_MODE_SCALE_FIT,
269 };
270 
271 using HDRMetaDataType = enum {
272     HDR_NOT_USED = 0,
273     HDR_META_DATA,
274     HDR_META_DATA_SET,
275 };
276 
277 using GraphicHDRMetadataKey = enum {
278     GRAPHIC_MATAKEY_RED_PRIMARY_X = 0,
279     GRAPHIC_MATAKEY_RED_PRIMARY_Y = 1,
280     GRAPHIC_MATAKEY_GREEN_PRIMARY_X = 2,
281     GRAPHIC_MATAKEY_GREEN_PRIMARY_Y = 3,
282     GRAPHIC_MATAKEY_BLUE_PRIMARY_X = 4,
283     GRAPHIC_MATAKEY_BLUE_PRIMARY_Y = 5,
284     GRAPHIC_MATAKEY_WHITE_PRIMARY_X = 6,
285     GRAPHIC_MATAKEY_WHITE_PRIMARY_Y = 7,
286     GRAPHIC_MATAKEY_MAX_LUMINANCE = 8,
287     GRAPHIC_MATAKEY_MIN_LUMINANCE = 9,
288     GRAPHIC_MATAKEY_MAX_CONTENT_LIGHT_LEVEL = 10,
289     GRAPHIC_MATAKEY_MAX_FRAME_AVERAGE_LIGHT_LEVEL = 11,
290     GRAPHIC_MATAKEY_HDR10_PLUS = 12,
291     GRAPHIC_MATAKEY_HDR_VIVID = 13,
292 };
293 
294 using GraphicHDRMetaDataSet = struct GraphicHDRMetaDataSet {
295     GraphicHDRMetadataKey key = GraphicHDRMetadataKey::GRAPHIC_MATAKEY_RED_PRIMARY_X;
296     std::vector<uint8_t> metaData;
297 };
298 
299 typedef struct {
300     GraphicHDRMetadataKey key;
301     float value;
302 } GraphicHDRMetaData;
303 
304 using SurfaceBufferUsage = enum {
305     BUFFER_USAGE_CPU_READ = (1ULL << 0),            /**< CPU read buffer */
306     BUFFER_USAGE_CPU_WRITE = (1ULL << 1),           /**< CPU write memory */
307     BUFFER_USAGE_MEM_MMZ = (1ULL << 2),             /**< Media memory zone (MMZ) */
308     BUFFER_USAGE_MEM_DMA = (1ULL << 3),             /**< Direct memory access (DMA) buffer */
309     BUFFER_USAGE_MEM_SHARE = (1ULL << 4),           /**< Shared memory buffer*/
310     BUFFER_USAGE_MEM_MMZ_CACHE = (1ULL << 5),       /**< MMZ with cache*/
311     BUFFER_USAGE_MEM_FB = (1ULL << 6),              /**< Framebuffer */
312     BUFFER_USAGE_ASSIGN_SIZE = (1ULL << 7),         /**< Memory assigned */
313     BUFFER_USAGE_HW_RENDER = (1ULL << 8),           /**< For GPU write case */
314     BUFFER_USAGE_HW_TEXTURE = (1ULL << 9),          /**< For GPU read case */
315     BUFFER_USAGE_HW_COMPOSER = (1ULL << 10),        /**< For hardware composer */
316     BUFFER_USAGE_PROTECTED = (1ULL << 11),          /**< For safe buffer case, such as DRM */
317     BUFFER_USAGE_CAMERA_READ = (1ULL << 12),        /**< For camera read case */
318     BUFFER_USAGE_CAMERA_WRITE = (1ULL << 13),       /**< For camera write case */
319     BUFFER_USAGE_VIDEO_ENCODER = (1ULL << 14),      /**< For encode case */
320     BUFFER_USAGE_VIDEO_DECODER = (1ULL << 15),      /**< For decode case */
321     BUFFER_USAGE_CPU_READ_OFTEN = (1ULL << 16),     /**< CPU read often buffer */
322     BUFFER_USAGE_CPU_HW_BOTH = (1ULL << 17),        /**< CPU read often buffer */
323     BUFFER_USAGE_ALIGNMENT_512 = (1ULL << 18),      /**< 512 bytes alignment */
324     BUFFER_USAGE_AUXILLARY_BUFFER0 = (1ULL << 20),  /**< reserved for individual meta size */
325     BUFFER_USAGE_DRM_REDRAW  = (1ULL << 24),        /**< For drm redraw framebuffer allocate */
326     BUFFER_USAGE_GRAPHIC_2D_ACCEL = (1ULL << 25),   /**< 2D graphics accelerator to 3D graphics HW_TEXTURE/HW_RENDER */
327     BUFFER_USAGE_PREFER_NO_PADDING = (1ULL << 26),  /**< For no padding buffer, use for CPU | HW_TEXTURE */
328     BUFFER_USAGE_ALLOC_NO_IPC = (1ULL << 27),       /**< For allocmem no ipc binder */
329     BUFFER_USAGE_VENDOR_PRI0 = (1ULL << 44),        /**< Reserverd for vendor */
330     BUFFER_USAGE_VENDOR_PRI1 = (1ULL << 45),        /**< Reserverd for vendor */
331     BUFFER_USAGE_VENDOR_PRI2 = (1ULL << 46),        /**< Reserverd for vendor */
332     BUFFER_USAGE_VENDOR_PRI3 = (1ULL << 47),        /**< Reserverd for vendor */
333     BUFFER_USAGE_VENDOR_PRI4 = (1ULL << 48),        /**< Reserverd for vendor */
334     BUFFER_USAGE_VENDOR_PRI5 = (1ULL << 49),        /**< Reserverd for vendor */
335     BUFFER_USAGE_VENDOR_PRI6 = (1ULL << 50),        /**< Reserverd for vendor */
336     BUFFER_USAGE_VENDOR_PRI7 = (1ULL << 51),        /**< Reserverd for vendor */
337     BUFFER_USAGE_VENDOR_PRI8 = (1ULL << 52),        /**< Reserverd for vendor */
338     BUFFER_USAGE_VENDOR_PRI9 = (1ULL << 53),        /**< Reserverd for vendor */
339     BUFFER_USAGE_VENDOR_PRI10 = (1ULL << 54),       /**< Reserverd for vendor */
340     BUFFER_USAGE_VENDOR_PRI11 = (1ULL << 55),       /**< Reserverd for vendor */
341     BUFFER_USAGE_VENDOR_PRI12 = (1ULL << 56),       /**< Reserverd for vendor */
342     BUFFER_USAGE_VENDOR_PRI13 = (1ULL << 57),       /**< Reserverd for vendor */
343     BUFFER_USAGE_VENDOR_PRI14 = (1ULL << 58),       /**< Reserverd for vendor */
344     BUFFER_USAGE_VENDOR_PRI15 = (1ULL << 59),       /**< Reserverd for vendor */
345     BUFFER_USAGE_VENDOR_PRI16 = (1ULL << 60),       /**< Reserverd for vendor */
346     BUFFER_USAGE_VENDOR_PRI17 = (1ULL << 61),       /**< Reserverd for vendor */
347     BUFFER_USAGE_VENDOR_PRI18 = (1ULL << 62),       /**< Reserverd for vendor */
348     BUFFER_USAGE_VENDOR_PRI19 = (1ULL << 63),       /**< Reserverd for vendor */
349 };
350 
351 using GraphicColorGamut = enum {
352     GRAPHIC_COLOR_GAMUT_INVALID = -1,            /**< Invalid */
353     GRAPHIC_COLOR_GAMUT_NATIVE = 0,              /**< Native or default */
354     GRAPHIC_COLOR_GAMUT_STANDARD_BT601 = 1,      /**< Standard BT601 */
355     GRAPHIC_COLOR_GAMUT_STANDARD_BT709 = 2,      /**< Standard BT709 */
356     GRAPHIC_COLOR_GAMUT_DCI_P3 = 3,              /**< DCI P3 */
357     GRAPHIC_COLOR_GAMUT_SRGB = 4,                /**< SRGB */
358     GRAPHIC_COLOR_GAMUT_ADOBE_RGB = 5,           /**< Adobe RGB */
359     GRAPHIC_COLOR_GAMUT_DISPLAY_P3 = 6,          /**< display P3 */
360     GRAPHIC_COLOR_GAMUT_BT2020 = 7,              /**< BT2020 */
361     GRAPHIC_COLOR_GAMUT_BT2100_PQ = 8,           /**< BT2100 PQ */
362     GRAPHIC_COLOR_GAMUT_BT2100_HLG = 9,          /**< BT2100 HLG */
363     GRAPHIC_COLOR_GAMUT_DISPLAY_BT2020 = 10,     /**< Display BT2020 */
364 };
365 
366 using GraphicCM_ColorSpaceType = enum {
367     GRAPHIC_CM_COLORSPACE_NONE,
368 
369     /* COLORPRIMARIES_BT601_P | (TRANSFUNC_BT709 << 8) | (MATRIX_BT601_P << 16) | (RANGE_FULL << 21) */
370     GRAPHIC_CM_BT601_EBU_FULL      = 2 | (1 << 8) | (2 << 16) | (1 << 21),
371     /* COLORPRIMARIES_BT601_N | (TRANSFUNC_BT709 << 8) | (MATRIX_BT601_N << 16) | (RANGE_FULL << 21) */
372     GRAPHIC_CM_BT601_SMPTE_C_FULL  = 3 | (1 << 8) | (3 << 16) | (1 << 21),
373     /* COLORPRIMARIES_BT709   | (TRANSFUNC_BT709 << 8) | (MATRIX_BT709   << 16) | (RANGE_FULL << 21) */
374     GRAPHIC_CM_BT709_FULL          = 1 | (1 << 8) | (1 << 16) | (1 << 21),
375     /* COLORPRIMARIES_BT2020  | (TRANSFUNC_HLG   << 8) | (MATRIX_BT2020  << 16) | (RANGE_FULL << 21) */
376     GRAPHIC_CM_BT2020_HLG_FULL     = 4 | (5 << 8) | (4 << 16) | (1 << 21),
377     /* COLORPRIMARIES_BT2020  | (TRANSFUNC_PQ    << 8) | (MATRIX_BT2020  << 16) | (RANGE_FULL << 21) */
378     GRAPHIC_CM_BT2020_PQ_FULL      = 4 | (4 << 8) | (4 << 16) | (1 << 21),
379 
380     /* COLORPRIMARIES_BT601_P | (TRANSFUNC_BT709 << 8) | (MATRIX_BT601_P << 16) | (RANGE_LIMITED << 21) */
381     GRAPHIC_CM_BT601_EBU_LIMIT     = 2 | (1 << 8) | (2 << 16) | (2 << 21),
382     /* COLORPRIMARIES_BT601_N | (TRANSFUNC_BT709 << 8) | (MATRIX_BT601_N << 16) | (RANGE_LIMITED << 21) */
383     GRAPHIC_CM_BT601_SMPTE_C_LIMIT = 3 | (1 << 8) | (3 << 16) | (2 << 21),
384     /* COLORPRIMARIES_BT709   | (TRANSFUNC_BT709 << 8) | (MATRIX_BT709   << 16) | (RANGE_LIMITED << 21) */
385     GRAPHIC_CM_BT709_LIMIT         = 1 | (1 << 8) | (1 << 16) | (2 << 21),
386     /* COLORPRIMARIES_BT2020  | (TRANSFUNC_HLG   << 8) | (MATRIX_BT2020  << 16) | (RANGE_LIMITED << 21) */
387     GRAPHIC_CM_BT2020_HLG_LIMIT    = 4 | (5 << 8) | (4 << 16) | (2 << 21),
388     /* COLORPRIMARIES_BT2020  | (TRANSFUNC_PQ    << 8) | (MATRIX_BT2020  << 16) | (RANGE_LIMITED << 21) */
389     GRAPHIC_CM_BT2020_PQ_LIMIT     = 4 | (4 << 8) | (4 << 16) | (2 << 21),
390 
391     /* COLORPRIMARIES_SRGB     | (TRANSFUNC_SRGB     << 8) | (MATRIX_BT601_N  << 16) | (RANGE_FULL << 21) */
392     GRAPHIC_CM_SRGB_FULL           = 1 | (2 << 8) | (3 << 16) | (1 << 21),
393     /* COLORPRIMARIES_P3_D65   | (TRANSFUNC_SRGB     << 8) | (MATRIX_P3       << 16) | (RANGE_FULL << 21) */
394     GRAPHIC_CM_P3_FULL             = 6 | (2 << 8) | (3 << 16) | (1 << 21),
395     /* COLORPRIMARIES_P3_D65   | (TRANSFUNC_HLG      << 8) | (MATRIX_P3       << 16) | (RANGE_FULL << 21) */
396     GRAPHIC_CM_P3_HLG_FULL         = 6 | (5 << 8) | (3 << 16) | (1 << 21),
397     /* COLORPRIMARIES_P3_D65   | (TRANSFUNC_PQ       << 8) | (MATRIX_P3       << 16) | (RANGE_FULL << 21) */
398     GRAPHIC_CM_P3_PQ_FULL          = 6 | (4 << 8) | (3 << 16) | (1 << 21),
399     /* COLORPRIMARIES_ADOBERGB | (TRANSFUNC_ADOBERGB << 8) | (MATRIX_ADOBERGB << 16) | (RANGE_FULL << 21) */
400     GRAPHIC_CM_ADOBERGB_FULL       = 23 | (6 << 8) | (0 << 16) | (1 << 21),
401 
402     /* COLORPRIMARIES_SRGB     | (TRANSFUNC_SRGB     << 8) | (MATRIX_BT601_N  << 16) | (RANGE_LIMITED << 21) */
403     GRAPHIC_CM_SRGB_LIMIT          = 1 | (2 << 8) | (3 << 16) | (2 << 21),
404     /* COLORPRIMARIES_P3_D65   | (TRANSFUNC_SRGB     << 8) | (MATRIX_P3       << 16) | (RANGE_LIMITED << 21) */
405     GRAPHIC_CM_P3_LIMIT            = 6 | (2 << 8) | (3 << 16) | (2 << 21),
406     /* COLORPRIMARIES_P3_D65   | (TRANSFUNC_HLG      << 8) | (MATRIX_P3       << 16) | (RANGE_LIMITED << 21) */
407     GRAPHIC_CM_P3_HLG_LIMIT        = 6 | (5 << 8) | (3 << 16) | (2 << 21),
408     /* COLORPRIMARIES_P3_D65   | (TRANSFUNC_PQ       << 8) | (MATRIX_P3       << 16) | (RANGE_LIMITED << 21) */
409     GRAPHIC_CM_P3_PQ_LIMIT         = 6 | (4 << 8) | (3 << 16) | (2 << 21),
410     /* COLORPRIMARIES_ADOBERGB | (TRANSFUNC_ADOBERGB << 8) | (MATRIX_ADOBERGB << 16) | (RANGE_LIMITED << 21) */
411     GRAPHIC_CM_ADOBERGB_LIMIT      = 23 | (6 << 8) | (0 << 16) | (2 << 21),
412 
413     /* COLORPRIMARIES_SRGB   | (TRANSFUNC_LINEAR << 8) */
414     GRAPHIC_CM_LINEAR_SRGB         = 1 | (3 << 8),
415     /* equal to GRAPHIC_CM_LINEAR_SRGB */
416     GRAPHIC_CM_LINEAR_BT709        = 1 | (3 << 8),
417     /* COLORPRIMARIES_P3_D65 | (TRANSFUNC_LINEAR << 8) */
418     GRAPHIC_CM_LINEAR_P3           = 6 | (3 << 8),
419     /* COLORPRIMARIES_BT2020 | (TRANSFUNC_LINEAR << 8) */
420     GRAPHIC_CM_LINEAR_BT2020       = 4 | (3 << 8),
421 
422     /* equal to GRAPHIC_CM_SRGB_FULL */
423     GRAPHIC_CM_DISPLAY_SRGB        = 1 | (2 << 8) | (3 << 16) | (1 << 21),
424     /* equal to GRAPHIC_CM_P3_FULL */
425     GRAPHIC_CM_DISPLAY_P3_SRGB     = 6 | (2 << 8) | (3 << 16) | (1 << 21),
426     /* equal to GRAPHIC_CM_P3_HLG_FULL */
427     GRAPHIC_CM_DISPLAY_P3_HLG      = 6 | (5 << 8) | (3 << 16) | (1 << 21),
428     /* equal to GRAPHIC_CM_P3_PQ_FULL */
429     GRAPHIC_CM_DISPLAY_P3_PQ       = 6 | (4 << 8) | (3 << 16) | (1 << 21),
430     /* COLORPRIMARIES_BT2020   | (TRANSFUNC_SRGB << 8)     | (MATRIX_BT2020 << 16)   | (RANGE_FULL << 21) */
431     GRAPHIC_CM_DISPLAY_BT2020_SRGB = 4 | (2 << 8) | (4 << 16) | (1 << 21),
432     /* equal to GRAPHIC_CM_BT2020_HLG_FULL */
433     GRAPHIC_CM_DISPLAY_BT2020_HLG  = 4 | (5 << 8) | (4 << 16) | (1 << 21),
434     /* equal to GRAPHIC_CM_BT2020_PQ_FULL */
435     GRAPHIC_CM_DISPLAY_BT2020_PQ   = 4 | (4 << 8) | (4 << 16) | (1 << 21)
436 };
437 
438 using GraphicColorDataSpace = enum {
439     GRAPHIC_COLOR_DATA_SPACE_UNKNOWN = 0,
440     GRAPHIC_GAMUT_BT601 = 0x00000001,
441     GRAPHIC_GAMUT_BT709 = 0x00000002,
442     GRAPHIC_GAMUT_DCI_P3 = 0x00000003,
443     GRAPHIC_GAMUT_SRGB = 0x00000004,
444     GRAPHIC_GAMUT_ADOBE_RGB = 0x00000005,
445     GRAPHIC_GAMUT_DISPLAY_P3 = 0x00000006,
446     GRAPHIC_GAMUT_BT2020 = 0x00000007,
447     GRAPHIC_GAMUT_BT2100_PQ = 0x00000008,
448     GRAPHIC_GAMUT_BT2100_HLG = 0x00000009,
449     GRAPHIC_GAMUT_DISPLAY_BT2020 = 0x0000000a,
450     GRAPHIC_TRANSFORM_FUNC_UNSPECIFIED = 0x00000100,
451     GRAPHIC_TRANSFORM_FUNC_LINEAR = 0x00000200,
452     GRAPHIC_TRANSFORM_FUNC_SRGB = 0x00000300,
453     GRAPHIC_TRANSFORM_FUNC_SMPTE_170M = 0x00000400,
454     GRAPHIC_TRANSFORM_FUNC_GM2_2 = 0x00000500,
455     GRAPHIC_TRANSFORM_FUNC_GM2_6 = 0x00000600,
456     GRAPHIC_TRANSFORM_FUNC_GM2_8 = 0x00000700,
457     GRAPHIC_TRANSFORM_FUNC_ST2084 = 0x00000800,
458     GRAPHIC_TRANSFORM_FUNC_HLG = 0x00000900,
459     GRAPHIC_PRECISION_UNSPECIFIED = 0x00010000,
460     GRAPHIC_PRECISION_FULL = 0x00020000,
461     GRAPHIC_PRESION_LIMITED = 0x00030000,
462     GRAPHIC_PRESION_EXTENDED = 0x00040000,
463     GRAPHIC_BT601_SMPTE170M_FULL = GRAPHIC_GAMUT_BT601 | GRAPHIC_TRANSFORM_FUNC_SMPTE_170M | GRAPHIC_PRECISION_FULL,
464     GRAPHIC_BT601_SMPTE170M_LIMITED = GRAPHIC_GAMUT_BT601 | GRAPHIC_TRANSFORM_FUNC_SMPTE_170M |
465         GRAPHIC_PRESION_LIMITED,
466     GRAPHIC_BT709_LINEAR_FULL = GRAPHIC_GAMUT_BT709 | GRAPHIC_TRANSFORM_FUNC_LINEAR | GRAPHIC_PRECISION_FULL,
467     GRAPHIC_BT709_LINEAR_EXTENDED = GRAPHIC_GAMUT_BT709 | GRAPHIC_TRANSFORM_FUNC_LINEAR | GRAPHIC_PRESION_EXTENDED,
468     GRAPHIC_BT709_SRGB_FULL = GRAPHIC_GAMUT_BT709 | GRAPHIC_TRANSFORM_FUNC_SRGB | GRAPHIC_PRECISION_FULL,
469     GRAPHIC_BT709_SRGB_EXTENDED = GRAPHIC_GAMUT_BT709 | GRAPHIC_TRANSFORM_FUNC_SRGB | GRAPHIC_PRESION_EXTENDED,
470     GRAPHIC_BT709_SMPTE170M_LIMITED = GRAPHIC_GAMUT_BT709 | GRAPHIC_TRANSFORM_FUNC_SMPTE_170M |
471         GRAPHIC_PRESION_LIMITED,
472     GRAPHIC_DCI_P3_LINEAR_FULL = GRAPHIC_GAMUT_DCI_P3 | GRAPHIC_TRANSFORM_FUNC_LINEAR | GRAPHIC_PRECISION_FULL,
473     GRAPHIC_DCI_P3_GAMMA26_FULL = GRAPHIC_GAMUT_DCI_P3 | GRAPHIC_TRANSFORM_FUNC_GM2_6 | GRAPHIC_PRECISION_FULL,
474     GRAPHIC_DISPLAY_P3_LINEAR_FULL = GRAPHIC_GAMUT_DISPLAY_P3 | GRAPHIC_TRANSFORM_FUNC_LINEAR | GRAPHIC_PRECISION_FULL,
475     GRAPHIC_DCI_P3_SRGB_FULL = GRAPHIC_GAMUT_DCI_P3 | GRAPHIC_TRANSFORM_FUNC_SRGB | GRAPHIC_PRECISION_FULL,
476     GRAPHIC_ADOBE_RGB_GAMMA22_FULL = GRAPHIC_GAMUT_ADOBE_RGB | GRAPHIC_TRANSFORM_FUNC_GM2_2 | GRAPHIC_PRECISION_FULL,
477     GRAPHIC_BT2020_LINEAR_FULL = GRAPHIC_GAMUT_BT2020 | GRAPHIC_TRANSFORM_FUNC_LINEAR | GRAPHIC_PRECISION_FULL,
478     GRAPHIC_BT2020_SRGB_FULL = GRAPHIC_GAMUT_BT2020 | GRAPHIC_TRANSFORM_FUNC_SRGB | GRAPHIC_PRECISION_FULL,
479     GRAPHIC_BT2020_SMPTE170M_FULL = GRAPHIC_GAMUT_BT2020 | GRAPHIC_TRANSFORM_FUNC_SMPTE_170M | GRAPHIC_PRECISION_FULL,
480     GRAPHIC_BT2020_ST2084_FULL = GRAPHIC_GAMUT_BT2020 | GRAPHIC_TRANSFORM_FUNC_ST2084 | GRAPHIC_PRECISION_FULL,
481     GRAPHIC_BT2020_HLG_FULL = GRAPHIC_GAMUT_BT2020 | GRAPHIC_TRANSFORM_FUNC_HLG | GRAPHIC_PRECISION_FULL,
482     GRAPHIC_BT2020_ST2084_LIMITED = GRAPHIC_GAMUT_BT2020 | GRAPHIC_TRANSFORM_FUNC_ST2084 | GRAPHIC_PRESION_LIMITED,
483 };
484 
485 using GraphicTransformType = enum {
486     GRAPHIC_ROTATE_NONE = 0,        /**< No rotation */
487     GRAPHIC_ROTATE_90,              /**< Rotation by 90 degrees */
488     GRAPHIC_ROTATE_180,             /**< Rotation by 180 degrees */
489     GRAPHIC_ROTATE_270,             /**< Rotation by 270 degrees */
490     GRAPHIC_FLIP_H,                 /**< Flip horizontally */
491     GRAPHIC_FLIP_V,                 /**< Flip vertically */
492     GRAPHIC_FLIP_H_ROT90,           /**< Flip horizontally and rotate 90 degrees */
493     GRAPHIC_FLIP_V_ROT90,           /**< Flip vertically and rotate 90 degrees */
494     GRAPHIC_FLIP_H_ROT180,          /**< Flip horizontally and rotate 180 degrees */
495     GRAPHIC_FLIP_V_ROT180,          /**< Flip vertically and rotate 180 degrees */
496     GRAPHIC_FLIP_H_ROT270,          /**< Flip horizontally and rotate 270 degrees */
497     GRAPHIC_FLIP_V_ROT270,          /**< Flip vertically and rotate 270 degrees */
498     GRAPHIC_ROTATE_BUTT            /**< Invalid operation */
499 };
500 
501 using GraphicSourceType = enum {
502     GRAPHIC_SDK_TYPE = 0,        /**< sdk type */
503     GRAPHIC_SOURCE_TYPE_BUTT     /**< Invalid operation */
504 };
505 
506 using BufferRequestConfig = struct BufferRequestConfig {
507     int32_t width;
508     int32_t height;
509     int32_t strideAlignment; // output parameter, system components can ignore it
510     int32_t format; // GraphicPixelFormat
511     uint64_t usage;
512     int32_t timeout;
513     GraphicColorGamut colorGamut = GraphicColorGamut::GRAPHIC_COLOR_GAMUT_SRGB;
514     GraphicTransformType transform = GraphicTransformType::GRAPHIC_ROTATE_NONE;
515     GraphicSourceType sourceType = GraphicSourceType::GRAPHIC_SOURCE_TYPE_BUTT;
516     bool operator ==(const struct BufferRequestConfig &config) const
517     {
518         return width == config.width && height == config.height &&
519                format == config.format && usage == config.usage;
520     }
521     bool operator != (const struct BufferRequestConfig &config) const
522     {
523         return !(*this == config);
524     }
525 };
526 
527 using BufferFlushConfig = struct {
528     Rect damage;
529     int64_t timestamp;
530     int64_t desiredPresentTimestamp;
531 };
532 
533 using BufferFlushConfigWithDamages = struct BufferFlushConfigWithDamages {
534     std::vector<Rect> damages = {};
535     int64_t timestamp;
536     int64_t desiredPresentTimestamp;
537 };
538 
539 using SceneType = enum {
540     SURFACE_SCENE_TYPE_EGL = 0,
541     SURFACE_SCENE_TYPE_MEDIA,
542     SURFACE_SCENE_TYPE_CAMERA,
543     SURFACE_SCENE_TYPE_CPU,
544 };
545 
546 using GraphicExtDataHandle = struct {
547     /**< Handle fd, -1 if not supported */
548     int32_t fd;
549     /**< the number of reserved integer value */
550     uint32_t reserveInts;
551     /**< the reserved data */
552     int32_t reserve[0];
553 };
554 
555 using GraphicAlphaType = enum {
556     GRAPHIC_ALPHATYPE_UNKNOWN = 0,
557     GRAPHIC_ALPHATYPE_OPAQUE,
558     GRAPHIC_ALPHATYPE_PREMUL,
559     GRAPHIC_ALPHATYPE_UNPREMUL,
560 };
561 } // namespace OHOS
562 
563 #endif // INTERFACES_INNERKITS_SURFACE_SURFACE_TYPE_H
564