1 /****************************************************************************
2 *
3 *    Copyright 2012 - 2023 Vivante Corporation, Santa Clara, California.
4 *    All Rights Reserved.
5 *
6 *    Permission is hereby granted, free of charge, to any person obtaining
7 *    a copy of this software and associated documentation files (the
8 *    'Software'), to deal in the Software without restriction, including
9 *    without limitation the rights to use, copy, modify, merge, publish,
10 *    distribute, sub license, and/or sell copies of the Software, and to
11 *    permit persons to whom the Software is furnished to do so, subject
12 *    to the following conditions:
13 *
14 *    The above copyright notice and this permission notice (including the
15 *    next paragraph) shall be included in all copies or substantial
16 *    portions of the Software.
17 *
18 *    THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
19 *    EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20 *    MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
21 *    IN NO EVENT SHALL VIVANTE AND/OR ITS SUPPLIERS BE LIABLE FOR ANY
22 *    CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
23 *    TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
24 *    SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25 *
26 *****************************************************************************/
27 
28 #ifndef _vg_lite_h_
29 #define _vg_lite_h_
30 
31 #ifdef __cplusplus
32 extern "C" {
33 #endif
34 
35 /**
36  * causes MSVC error C1189.
37  * Not needed because "The __inline keyword is equivalent to inline."
38  * See: https://learn.microsoft.com/en-us/cpp/cpp/inline-functions-cpp?view=msvc-170
39 */
40 /*
41 #if defined(_MSC_VER)
42 #define inline __inline
43 #endif
44 */
45 
46 #include <stddef.h>
47 #include <stdint.h>
48 
49 
50 /*  VGLite API Constants *******************************************************************************************************************/
51 
52 #define VGLITE_HEADER_VERSION       7
53 
54 #ifndef VGLITE_VERSION_3_0
55 #define VGLITE_VERSION_3_0          1
56 
57 #define VGLITE_MAKE_VERSION(major, minor, patch) (((major) << 16) | ((minor) << 8) | (patch))
58 #define VGLITE_VERSION_MAJOR(version) (((uint32_t)(version) >> 16) & 0xff)
59 #define VGLITE_VERSION_MINOR(version) (((uint32_t)(version) >> 8) & 0xff)
60 #define VGLITE_VERSION_PATCH(version) ((uint32_t)(version) & 0xff)
61 
62 #define VGLITE_API_VERSION_3_0      VGLITE_MAKE_VERSION(3, 0, 0)
63 
64 #define VGLITE_RELEASE_VERSION      VGLITE_MAKE_VERSION(4,0,47)
65 
66 #define VGL_FALSE                   0
67 #define VGL_TRUE                    1
68 
69 /* Path command (op code). */
70 #define VLC_OP_END                  0x00
71 #define VLC_OP_CLOSE                0x01
72 #define VLC_OP_MOVE                 0x02
73 #define VLC_OP_MOVE_REL             0x03
74 #define VLC_OP_LINE                 0x04
75 #define VLC_OP_LINE_REL             0x05
76 #define VLC_OP_QUAD                 0x06
77 #define VLC_OP_QUAD_REL             0x07
78 #define VLC_OP_CUBIC                0x08
79 #define VLC_OP_CUBIC_REL            0x09
80 #define VLC_OP_BREAK                0x0A
81 #define VLC_OP_HLINE                0x0B
82 #define VLC_OP_HLINE_REL            0x0C
83 #define VLC_OP_VLINE                0x0D
84 #define VLC_OP_VLINE_REL            0x0E
85 #define VLC_OP_SQUAD                0x0F
86 #define VLC_OP_SQUAD_REL            0x10
87 #define VLC_OP_SCUBIC               0x11
88 #define VLC_OP_SCUBIC_REL           0x12
89 #define VLC_OP_SCCWARC              0x13
90 #define VLC_OP_SCCWARC_REL          0x14
91 #define VLC_OP_SCWARC               0x15
92 #define VLC_OP_SCWARC_REL           0x16
93 #define VLC_OP_LCCWARC              0x17
94 #define VLC_OP_LCCWARC_REL          0x18
95 #define VLC_OP_LCWARC               0x19
96 #define VLC_OP_LCWARC_REL           0x1A
97 
98 /* Macros for path manipulating: See path definitions. */
99 #define VLM_PATH_ENABLE_UPLOAD(path)    (path).uploaded.property |= 1
100 #define VLM_PATH_DISABLE_UPLOAD(path)   (path).uploaded.property &= (~1)
101 #define VLM_PATH_GET_UPLOAD_BIT(path)   ((path).uploaded.property & 1)
102 
103 /* Gradient constants. */
104 #define VLC_MAX_COLOR_RAMP_STOPS    256             /*! The max number of radial gradient stops. */
105 #define VLC_MAX_GRADIENT_STOPS      16              /*! The max number of gradient stops. */
106 #define VLC_GRADIENT_BUFFER_WIDTH   1024            /*! The internal gradient buffer width.*/
107 
108 
109 /* API name defines for backward compatibility to VGLite 2.0 APIs */
110 #define vg_lite_buffer_upload                   vg_lite_upload_buffer
111 #define vg_lite_path_append                     vg_lite_append_path
112 #define vg_lite_path_calc_length                vg_lite_get_path_length
113 #define vg_lite_set_ts_buffer                   vg_lite_set_tess_buffer
114 #define vg_lite_set_draw_path_type              vg_lite_set_path_type
115 #define vg_lite_create_mask_layer               vg_lite_create_masklayer
116 #define vg_lite_fill_mask_layer                 vg_lite_fill_masklayer
117 #define vg_lite_blend_mask_layer                vg_lite_blend_masklayer
118 #define vg_lite_generate_mask_layer_by_path     vg_lite_render_masklayer
119 #define vg_lite_set_mask_layer                  vg_lite_set_masklayer
120 #define vg_lite_destroy_mask_layer              vg_lite_destroy_masklayer
121 #define vg_lite_enable_mask                     vg_lite_enable_masklayer
122 #define vg_lite_enable_color_transformation     vg_lite_enable_color_transform
123 #define vg_lite_set_color_transformation        vg_lite_set_color_transform
124 #define vg_lite_set_image_global_alpha          vg_lite_source_global_alpha
125 #define vg_lite_set_dest_global_alpha           vg_lite_dest_global_alpha
126 #define vg_lite_clear_rad_grad                  vg_lite_clear_radial_grad
127 #define vg_lite_update_rad_grad                 vg_lite_update_radial_grad
128 #define vg_lite_get_rad_grad_matrix             vg_lite_get_radial_grad_matrix
129 #define vg_lite_set_rad_grad                    vg_lite_set_radial_grad
130 #define vg_lite_draw_linear_gradient            vg_lite_draw_linear_grad
131 #define vg_lite_draw_radial_gradient            vg_lite_draw_radial_grad
132 #define vg_lite_draw_gradient                   vg_lite_draw_grad
133 #define vg_lite_mem_avail                       vg_lite_get_mem_size
134 #define vg_lite_set_update_stroke               vg_lite_update_stroke
135 
136 #define vg_lite_buffer_image_mode_t             vg_lite_image_mode_t
137 #define vg_lite_draw_path_type_t                vg_lite_path_type_t
138 #define vg_lite_linear_gradient_ext_t           vg_lite_ext_linear_gradient_t
139 #define vg_lite_buffer_transparency_mode_t      vg_lite_transparency_t
140 
141 
142 /* VGLite API Types ***********************************************************************************************************************/
143 
144 typedef unsigned char       vg_lite_uint8_t;
145 typedef char                vg_lite_int8_t;
146 typedef short               vg_lite_int16_t;
147 typedef unsigned short      vg_lite_uint16_t;
148 typedef int                 vg_lite_int32_t;
149 typedef unsigned int        vg_lite_uint32_t;
150 typedef unsigned long long  vg_lite_uint64_t;
151 typedef float               vg_lite_float_t;
152 typedef double              vg_lite_double_t;
153 typedef char                vg_lite_char;
154 typedef char*               vg_lite_string;
155 typedef void*               vg_lite_pointer;
156 typedef void                vg_lite_void;
157 typedef unsigned int        vg_lite_color_t;
158 
159 
160 /* VGLite API Enumerations ****************************************************************************************************************/
161 
162 #ifndef VG_LITE_ERROR
163 #define VG_LITE_ERROR  1
164 
165     /* Error codes that the vg_lite functions can return. */
166     typedef enum vg_lite_error
167     {
168         VG_LITE_SUCCESS = 0,            /*! Success. */
169         VG_LITE_INVALID_ARGUMENT,       /*! An invalid argument was specified. */
170         VG_LITE_OUT_OF_MEMORY,          /*! Out of memory. */
171         VG_LITE_NO_CONTEXT,             /*! No context or an uninitialized context specified. */
172         VG_LITE_TIMEOUT,                /*! A timeout has occurred during a wait. */
173         VG_LITE_OUT_OF_RESOURCES,       /*! Out of system resources. */
174         VG_LITE_GENERIC_IO,             /*! Cannot communicate with the kernel driver. */
175         VG_LITE_NOT_SUPPORT,            /*! Function call not supported. */
176         VG_LITE_ALREADY_EXISTS,         /*! Object already exists */
177         VG_LITE_NOT_ALIGNED,            /*! Data alignment error */
178         VG_LITE_FLEXA_TIME_OUT,         /*! VG timeout requesting for segment buffer */
179         VG_LITE_FLEXA_HANDSHAKE_FAIL,   /*! VG and SBI synchronizer handshake failed */
180     } vg_lite_error_t;
181 #endif
182 
183     /* Chip features bit */
184     typedef enum vg_lite_feature
185     {
186         gcFEATURE_BIT_VG_IM_INDEX_FORMAT,
187         gcFEATURE_BIT_VG_SCISSOR,
188         gcFEATURE_BIT_VG_BORDER_CULLING,
189         gcFEATURE_BIT_VG_RGBA2_FORMAT,
190         gcFEATURE_BIT_VG_QUALITY_8X,
191         gcFEATURE_BIT_VG_IM_FASTCLAER,
192         gcFEATURE_BIT_VG_RADIAL_GRADIENT,
193         gcFEATURE_BIT_VG_GLOBAL_ALPHA,
194         gcFEATURE_BIT_VG_RGBA8_ETC2_EAC,
195         gcFEATURE_BIT_VG_COLOR_KEY,
196         gcFEATURE_BIT_VG_DOUBLE_IMAGE,
197         gcFEATURE_BIT_VG_YUV_OUTPUT,
198         gcFEATURE_BIT_VG_FLEXA,
199         gcFEATURE_BIT_VG_24BIT,
200         gcFEATURE_BIT_VG_DITHER,
201         gcFEATURE_BIT_VG_USE_DST,
202         gcFEATURE_BIT_VG_PE_CLEAR,
203         gcFEATURE_BIT_VG_IM_INPUT,
204         gcFEATURE_BIT_VG_DEC_COMPRESS,
205         gcFEATURE_BIT_VG_LINEAR_GRADIENT_EXT,
206         gcFEATURE_BIT_VG_MASK,
207         gcFEATURE_BIT_VG_MIRROR,
208         gcFEATURE_BIT_VG_GAMMA,
209         gcFEATURE_BIT_VG_NEW_BLEND_MODE,
210         gcFEATURE_BIT_VG_STENCIL,
211         gcFEATURE_BIT_VG_SRC_PREMULTIPLIED, /*! Valid only if gcFEATURE_BIT_VG_HW_PREMULTIPLY is 0   */
212         gcFEATURE_BIT_VG_HW_PREMULTIPLY,    /*! HW multiplier can accept either premultiplied or not */
213         gcFEATURE_BIT_VG_COLOR_TRANSFORMATION,
214         gcFEATURE_BIT_VG_LVGL_SUPPORT,
215         gcFEATURE_BIT_VG_INDEX_ENDIAN,
216         gcFEATURE_BIT_VG_24BIT_PLANAR,
217         gcFEATURE_BIT_VG_PIXEL_MATRIX,
218         gcFEATURE_BIT_VG_NEW_IMAGE_INDEX,
219         gcFEATURE_BIT_VG_PARALLEL_PATHS,
220         gcFEATURE_BIT_VG_STRIPE_MODE,
221         gcFEATURE_BIT_VG_IM_DEC_INPUT,
222         gcFEATURE_BIT_VG_GAUSSIAN_BLUR,
223         gcFEATURE_BIT_VG_RECTANGLE_TILED_OUT,
224         gcFEATURE_BIT_VG_TESSELLATION_TILED_OUT,
225         gcFEATURE_BIT_VG_IM_REPEAT_REFLECT,
226         gcFEATURE_BIT_VG_YUY2_INPUT,
227         gcFEATURE_BIT_VG_YUV_INPUT,
228         gcFEATURE_BIT_VG_YUV_TILED_INPUT,
229         gcFEATURE_BIT_VG_AYUV_INPUT,
230         gcFEATURE_BIT_VG_16PIXELS_ALIGN,
231         gcFEATURE_BIT_VG_DEC_COMPRESS_2_0,
232         gcFEATURE_COUNT
233     } vg_lite_feature_t;
234 
235     /* Rendering quality enums. */
236     typedef enum vg_lite_quality
237     {
238         VG_LITE_HIGH,   /*! High quality 16x anti-aliasing path. */
239         VG_LITE_UPPER,  /*! Upper quality 8x anti-aliasing path. */
240         VG_LITE_MEDIUM, /*! Medium quality 4x anti-aliasing path. */
241         VG_LITE_LOW,    /*! Low quality path without any anti-aliasing. */
242     } vg_lite_quality_t;
243 
244     /* Format of path coordinates. */
245     typedef enum vg_lite_format
246     {
247         VG_LITE_S8,     /*! Signed 8-bit coordinates. */
248         VG_LITE_S16,    /*! Signed 16-bit coordinates. */
249         VG_LITE_S32,    /*! Signed 32-bit coordinates. */
250         VG_LITE_FP32,   /*! 32-bit floating point coordinates. */
251     } vg_lite_format_t;
252 
253     /* Format of pixel buffer. */
254     typedef enum vg_lite_buffer_format
255     {
256         /* OpenVG VGImageFormat enums:
257          * Note: The bits for each color channel are stored within a machine word
258          * from MSB to LSB in the order indicated by the pixel format name.
259          * This is opposite of VG_LITE_* formats (from LSB to MSB).
260          */
261 
262         /* RGB{A,X} channel ordering */
263         VG_sRGBX_8888                               =  0,
264         VG_sRGBA_8888                               =  1,
265         VG_sRGBA_8888_PRE                           =  2,
266         VG_sRGB_565                                 =  3,
267         VG_sRGBA_5551                               =  4,
268         VG_sRGBA_4444                               =  5,
269         VG_sL_8                                     =  6,
270         VG_lRGBX_8888                               =  7,
271         VG_lRGBA_8888                               =  8,
272         VG_lRGBA_8888_PRE                           =  9,
273         VG_lL_8                                     = 10,
274         VG_A_8                                      = 11,
275         VG_BW_1                                     = 12,
276         VG_A_1                                      = 13,
277         VG_A_4                                      = 14,
278 
279         VG_sRGBX_8888_PRE                           = 15,
280         VG_sRGB_565_PRE                             = 16,
281         VG_sRGBA_5551_PRE                           = 17,
282         VG_sRGBA_4444_PRE                           = 18,
283         VG_lRGBX_8888_PRE                           = 19,
284         VG_lRGB_565                                 = 20,
285         VG_lRGB_565_PRE                             = 21,
286         VG_lRGBA_5551                               = 22,
287         VG_lRGBA_5551_PRE                           = 23,
288         VG_lRGBA_4444                               = 24,
289         VG_lRGBA_4444_PRE                           = 25,
290 
291         /* {A,X}RGB channel ordering */
292         VG_sXRGB_8888                               =  0 | (1 << 6),
293         VG_sARGB_8888                               =  1 | (1 << 6),
294         VG_sARGB_8888_PRE                           =  2 | (1 << 6),
295         VG_sARGB_1555                               =  4 | (1 << 6),
296         VG_sARGB_4444                               =  5 | (1 << 6),
297         VG_lXRGB_8888                               =  7 | (1 << 6),
298         VG_lARGB_8888                               =  8 | (1 << 6),
299         VG_lARGB_8888_PRE                           =  9 | (1 << 6),
300 
301         /* BGR{A,X} channel ordering */
302         VG_sBGRX_8888                               =  0 | (1 << 7),
303         VG_sBGRA_8888                               =  1 | (1 << 7),
304         VG_sBGRA_8888_PRE                           =  2 | (1 << 7),
305         VG_sBGR_565                                 =  3 | (1 << 7),
306         VG_sBGRA_5551                               =  4 | (1 << 7),
307         VG_sBGRA_4444                               =  5 | (1 << 7),
308         VG_lBGRX_8888                               =  7 | (1 << 7),
309         VG_lBGRA_8888                               =  8 | (1 << 7),
310         VG_lBGRA_8888_PRE                           =  9 | (1 << 7),
311 
312         /* {A,X}BGR channel ordering */
313         VG_sXBGR_8888                               =  0 | (1 << 6) | (1 << 7),
314         VG_sABGR_8888                               =  1 | (1 << 6) | (1 << 7),
315         VG_sABGR_8888_PRE                           =  2 | (1 << 6) | (1 << 7),
316         VG_sABGR_1555                               =  4 | (1 << 6) | (1 << 7),
317         VG_sABGR_4444                               =  5 | (1 << 6) | (1 << 7),
318         VG_lXBGR_8888                               =  7 | (1 << 6) | (1 << 7),
319         VG_lABGR_8888                               =  8 | (1 << 6) | (1 << 7),
320         VG_lABGR_8888_PRE                           =  9 | (1 << 6) | (1 << 7),
321 
322         /* Original VGLite API image format enums:
323          * Note: The bits for each color channel are stored within a machine word
324          * from LSB to MSB in the order indicated by the pixel format name.
325          * This is opposite of OPENVG VG_* formats (from MSB to LSB).
326          */
327         VG_LITE_RGBA8888                        =  0 | (1 << 10),
328         VG_LITE_BGRA8888                        =  1 | (1 << 10),
329         VG_LITE_RGBX8888                        =  2 | (1 << 10),
330         VG_LITE_BGRX8888                        =  3 | (1 << 10),
331         VG_LITE_RGB565                          =  4 | (1 << 10),
332         VG_LITE_BGR565                          =  5 | (1 << 10),
333         VG_LITE_RGBA4444                        =  6 | (1 << 10),
334         VG_LITE_BGRA4444                        =  7 | (1 << 10),
335         VG_LITE_BGRA5551                        =  8 | (1 << 10),
336         VG_LITE_A4                              =  9 | (1 << 10),
337         VG_LITE_A8                              = 10 | (1 << 10),
338         VG_LITE_L8                              = 11 | (1 << 10),
339         VG_LITE_YUYV                            = 12 | (1 << 10),
340         VG_LITE_YUY2                            = 13 | (1 << 10),
341         VG_LITE_ANV12                           = 14 | (1 << 10),
342         VG_LITE_AYUY2                           = 15 | (1 << 10),
343         VG_LITE_NV12                            = 16 | (1 << 10),
344         VG_LITE_YV12                            = 17 | (1 << 10),
345         VG_LITE_YV24                            = 18 | (1 << 10),
346         VG_LITE_YV16                            = 19 | (1 << 10),
347         VG_LITE_NV16                            = 20 | (1 << 10),
348         VG_LITE_YUY2_TILED                      = 21 | (1 << 10),
349         VG_LITE_NV12_TILED                      = 22 | (1 << 10),
350         VG_LITE_ANV12_TILED                     = 23 | (1 << 10),
351         VG_LITE_AYUY2_TILED                     = 24 | (1 << 10),
352         VG_LITE_RGBA2222                        = 25 | (1 << 10),
353         VG_LITE_BGRA2222                        = 26 | (1 << 10),
354         VG_LITE_ABGR2222                        = 27 | (1 << 10),
355         VG_LITE_ARGB2222                        = 28 | (1 << 10),
356         VG_LITE_ABGR4444                        = 29 | (1 << 10),
357         VG_LITE_ARGB4444                        = 30 | (1 << 10),
358         VG_LITE_ABGR8888                        = 31 | (1 << 10),
359         VG_LITE_ARGB8888                        = 32 | (1 << 10),
360         VG_LITE_ABGR1555                        = 33 | (1 << 10),
361         VG_LITE_RGBA5551                        = 34 | (1 << 10),
362         VG_LITE_ARGB1555                        = 35 | (1 << 10),
363         VG_LITE_XBGR8888                        = 36 | (1 << 10),
364         VG_LITE_XRGB8888                        = 37 | (1 << 10),
365         VG_LITE_RGBA8888_ETC2_EAC               = 38 | (1 << 10),
366         VG_LITE_RGB888                          = 39 | (1 << 10),
367         VG_LITE_BGR888                          = 40 | (1 << 10),
368         VG_LITE_ABGR8565                        = 41 | (1 << 10),
369         VG_LITE_BGRA5658                        = 42 | (1 << 10),
370         VG_LITE_ARGB8565                        = 43 | (1 << 10),
371         VG_LITE_RGBA5658                        = 44 | (1 << 10),
372         VG_LITE_ABGR8565_PLANAR                 = 45 | (1 << 10),
373         VG_LITE_BGRA5658_PLANAR                 = 46 | (1 << 10),
374         VG_LITE_ARGB8565_PLANAR                 = 47 | (1 << 10),
375         VG_LITE_RGBA5658_PLANAR                 = 48 | (1 << 10),
376 
377         VG_LITE_INDEX_1 = 0 | (1 << 11),  /*! Indexed format. */
378         VG_LITE_INDEX_2 = 1 | (1 << 11),
379         VG_LITE_INDEX_4 = 2 | (1 << 11),
380         VG_LITE_INDEX_8 = 3 | (1 << 11),
381 
382     } vg_lite_buffer_format_t;
383 
384     /* Swizzle of packed YUV format UV channels. */
385     typedef enum vg_lite_swizzle
386     {
387         VG_LITE_SWIZZLE_UV,
388         VG_LITE_SWIZZLE_VU,
389     } vg_lite_swizzle_t;
390 
391     /* The YUV<->RGB conversion rule. */
392     typedef enum vg_lite_yuv2rgb
393     {
394         VG_LITE_YUV601,
395         VG_LITE_YUV709,
396     } vg_lite_yuv2rgb_t;
397 
398     /* The pixel layout in a buffer. */
399     typedef enum vg_lite_buffer_layout
400     {
401         VG_LITE_LINEAR,
402         VG_LITE_TILED,
403     } vg_lite_buffer_layout_t;
404 
405     /* The image (buffer) rendering mode. Match OpenVG enum VGImageMode */
406     typedef enum vg_lite_image_mode
407     {
408         /* For enum value backward compatibility */
409         VG_LITE_ZERO                            = 0,
410         VG_LITE_NORMAL_IMAGE_MODE               = 0x1F00,
411         VG_LITE_MULTIPLY_IMAGE_MODE             = 0x1F01,
412         VG_LITE_STENCIL_MODE                    = 0x1F02,
413         VG_LITE_NONE_IMAGE_MODE                 = 0x1F03,
414         VG_LITE_RECOLOR_MODE                    = 0x1F04,
415     } vg_lite_image_mode_t;
416 
417     /* The image (buffer) transparency mode. */
418     typedef enum vg_lite_transparency
419     {
420         VG_LITE_IMAGE_OPAQUE,
421         VG_LITE_IMAGE_TRANSPARENT
422     } vg_lite_transparency_t;
423 
424     /* Blending modes. VG_BLEND_* match OpenVG enum VGBlendMode.
425      * S and D represent source and destination color channels.
426      * Sa and Da represent the source and destination alpha channels.
427      */
428     typedef enum vg_lite_blend
429     {
430         VG_LITE_BLEND_NONE                      = 0,        /*! S, No blend, Non-premultiplied */
431         VG_LITE_BLEND_SRC_OVER                  = 1,        /*! S + (1 - Sa) * D , Non-premultiplied */
432         VG_LITE_BLEND_DST_OVER                  = 2,        /*! (1 - Da) * S + D , Non-premultiplied */
433         VG_LITE_BLEND_SRC_IN                    = 3,        /*! Da * S , Non-premultiplied */
434         VG_LITE_BLEND_DST_IN                    = 4,        /*! Sa * D , Non-premultiplied */
435         VG_LITE_BLEND_MULTIPLY                  = 5,        /*! S * (1 - Da) + D * (1 - Sa) + S * D , Non-premultiplied */
436         VG_LITE_BLEND_SCREEN                    = 6,        /*! S + D - S * D , Non-premultiplied */
437         VG_LITE_BLEND_DARKEN                    = 7,        /*! min(SrcOver, DstOver) , Non-premultiplied */
438         VG_LITE_BLEND_LIGHTEN                   = 8,        /*! max(SrcOver, DstOver) , Non-premultiplied */
439         VG_LITE_BLEND_ADDITIVE                  = 9,        /*! S + D , Non-premultiplied */
440         VG_LITE_BLEND_SUBTRACT                  = 10,       /*! D * (1 - Sa) , Non-premultiplied */
441         VG_LITE_BLEND_SUBTRACT_LVGL             = 11,       /*! D - S , Non-premultiplied */
442         VG_LITE_BLEND_NORMAL_LVGL               = 12,       /*! S * Sa + (1 - Sa) * D , Non-premultiplied */
443         VG_LITE_BLEND_ADDITIVE_LVGL             = 13,       /*! (S + D) * Sa + D * (1 - Sa) , Non-premultiplied */
444         VG_LITE_BLEND_MULTIPLY_LVGL             = 14,       /*! (S * D) * Sa + D * (1 - Sa) , Non-premultiplied */
445         VG_LITE_BLEND_PREMULTIPLY_SRC_OVER      = 15,       /*! S * Sa + (1 - Sa) * D , Non-premultiplied */
446 
447         OPENVG_BLEND_SRC                        = 0x2000,   /*! Copy SRC, no blend, Premultiplied */
448         OPENVG_BLEND_SRC_OVER                   = 0x2001,   /*! Porter-Duff SRC_OVER blend, Premultiplied */
449         OPENVG_BLEND_DST_OVER                   = 0x2002,   /*! Porter-Duff DST_OVER blend, Premultiplied */
450         OPENVG_BLEND_SRC_IN                     = 0x2003,   /*! Porter-Duff SRC_IN blend, Premultiplied */
451         OPENVG_BLEND_DST_IN                     = 0x2004,   /*! Porter-Duff DST_IN blend, Premultiplied */
452         OPENVG_BLEND_MULTIPLY                   = 0x2005,   /*! Porter-Duff MULTIPLY blend, Premultiplied */
453         OPENVG_BLEND_SCREEN                     = 0x2006,   /*! Porter-Duff SCREEN blend, Premultiplied */
454         OPENVG_BLEND_DARKEN                     = 0x2007,   /*! Porter-Duff DARKEN blend, Premultiplied */
455         OPENVG_BLEND_LIGHTEN                    = 0x2008,   /*! Porter-Duff LIGHTEN blend, Premultiplied */
456         OPENVG_BLEND_ADDITIVE                   = 0x2009,   /*! Porter-Duff ADDITIVE blend, Premultiplied */
457     } vg_lite_blend_t;
458 
459     /* Fill rules. Match OpenVG enum VGFillRule */
460     typedef enum vg_lite_fill
461     {
462         VG_LITE_FILL_EVEN_ODD                   = 0x1900,   /*! A pixel is drawn it it crosses an odd number of path pixels. */
463         VG_LITE_FILL_NON_ZERO                   = 0x1901,   /*! A pixel is drawn if it crosses at least one path pixel. */
464     } vg_lite_fill_t;
465 
466     /* Global alpha modes. */
467     typedef enum vg_lite_global_alpha
468     {
469         VG_LITE_NORMAL = 0,                     /*! Use original src/dst alpha value. */
470         VG_LITE_GLOBAL,                         /*! Use global src/dst alpha value to replace original src/dst alpha value. */
471         VG_LITE_SCALED,                         /*! Multiply global src/dst alpha value and original src/dst alpha value. */
472     } vg_lite_global_alpha_t;
473 
474     /* Filter modes. */
475     typedef enum vg_lite_filter
476     {
477         VG_LITE_FILTER_POINT     = 0,           /*! Fetch the nearest image pixel. */
478         VG_LITE_FILTER_LINEAR    = 0x1000,      /*! Used for linear paint. */
479         VG_LITE_FILTER_BI_LINEAR = 0x2000,      /*! Use a 2x2 box around the image pixel and perform an interpolation. */
480         VG_LITE_FILTER_GAUSSIAN  = 0x3000,      /*! Perform 3x3 gaussian blur with the convolution for image pixel. */
481     } vg_lite_filter_t;
482 
483     /* Pattern padding mode. Match OpenVG enum VGTilingMode. */
484     typedef enum vg_lite_pattern_mode
485     {
486         VG_LITE_PATTERN_COLOR   = 0x1D00,       /*! Pixel outside the bounds of sourceimage should be taken as the color */
487         VG_LITE_PATTERN_PAD     = 0x1D01,       /*! Pixel outside the bounds of sourceimage should be taken as having the same color as the closest edge pixel */
488         VG_LITE_PATTERN_REPEAT  = 0x1D02,       /*! Pixel outside the bounds of sourceimage should be repeated indefinitely in all directions */
489         VG_LITE_PATTERN_REFLECT = 0x1D03,       /*! Pixel outside the bounds of sourceimage should be reflected indefinitely in all directions */
490     } vg_lite_pattern_mode_t;
491 
492     /* Paint type. Match OpenVG enum VGPaintType. */
493     typedef enum vg_lite_paint_type
494     {
495         /* For enum value backward compatibility */
496         VG_LITE_PAINT_ZERO            = 0,
497         VG_LITE_PAINT_COLOR           = 0x1B00,
498         VG_LITE_PAINT_LINEAR_GRADIENT = 0x1B01,
499         VG_LITE_PAINT_RADIAL_GRADIENT = 0x1B02,
500         VG_LITE_PAINT_PATTERN         = 0x1B03,
501     } vg_lite_paint_type_t;
502 
503     /* Radial gradient padding mode. Match OpenVG enum VGColorRampSpreadMode */
504     typedef enum
505     {
506         VG_LITE_GRADIENT_SPREAD_FILL     = 0,
507         VG_LITE_GRADIENT_SPREAD_PAD      = 0x1C00,
508         VG_LITE_GRADIENT_SPREAD_REPEAT   = 0x1C01,
509         VG_LITE_GRADIENT_SPREAD_REFLECT  = 0x1C02,
510     } vg_lite_gradient_spreadmode_t;
511 
512     /* Decnano Compress mode. */
513     typedef enum vg_lite_compress_mode
514     {
515         VG_LITE_DEC_DISABLE = 0,                /*! disable compress */
516         VG_LITE_DEC_NON_SAMPLE,                 /*! compress ratio is 1.6 if use ARGB8888, compress ratio is 2 if use XRGB8888 */
517         VG_LITE_DEC_HSAMPLE,                    /*! compress ratio is 2 if use ARGB8888, compress ratio is 2.6 if use XRGB8888 */
518         VG_LITE_DEC_HV_SAMPLE,                  /*! compress ratio is 2.6 if use ARGB8888, compress ratio is 4 if use XRGB8888 */
519     } vg_lite_compress_mode_t;
520 
521     /* Draw path type. Match OpenVG enum VGPaintMode */
522     typedef enum vg_lite_path_type
523     {
524         /* For enum value backward compatibility */
525         VG_LITE_DRAW_ZERO                       = 0,
526         VG_LITE_DRAW_STROKE_PATH                = (1<<0),
527         VG_LITE_DRAW_FILL_PATH                  = (1<<1),
528         VG_LITE_DRAW_FILL_STROKE_PATH           = (1<<1 | 1<<0),
529     } vg_lite_path_type_t;
530 
531     /* End cap style. Match OpenVG enum VGCapStyle */
532     typedef enum vg_lite_cap_style
533     {
534         VG_LITE_CAP_BUTT                        = 0x1700,
535         VG_LITE_CAP_ROUND                       = 0x1701,
536         VG_LITE_CAP_SQUARE                      = 0x1702,
537     } vg_lite_cap_style_t;
538 
539     /* Line join styles. Match OpenVG enum VGJoinStyle */
540     typedef enum vg_lite_join_style
541     {
542         VG_LITE_JOIN_MITER                      = 0x1800,
543         VG_LITE_JOIN_ROUND                      = 0x1801,
544         VG_LITE_JOIN_BEVEL                      = 0x1802,
545     } vg_lite_join_style_t;
546 
547     /* Mask operation mode. Match OpenVG enum VGMaskOperation */
548     typedef enum vg_lite_mask_operation
549     {
550         VG_LITE_CLEAR_MASK                      = 0x1500,   /*! Set all dest mask values to 0 */
551         VG_LITE_FILL_MASK                       = 0x1501,   /*! Set all dest mask values to 1 */
552         VG_LITE_SET_MASK                        = 0x1502,   /*! Copy from src masklayer to dest masklayer. */
553         VG_LITE_UNION_MASK                      = 0x1503,   /*! Replace dest masklayer by its union with src masklayer. */
554         VG_LITE_INTERSECT_MASK                  = 0x1504,   /*! Replace dest masklayer by its intersection with src masklayer. */
555         VG_LITE_SUBTRACT_MASK                   = 0x1505,   /*! Subtract src mask in dest masklayer */
556     } vg_lite_mask_operation_t;
557 
558     /* Mirror orientation mode. */
559     typedef enum vg_lite_orientation
560     {
561         VG_LITE_ORIENTATION_TOP_BOTTOM,
562         VG_LITE_ORIENTATION_BOTTOM_TOP,
563     } vg_lite_orientation_t;
564 
565     /* Gamma conversion mode. */
566     typedef enum vg_lite_gamma_conversion
567     {
568         VG_LITE_GAMMA_NO_CONVERSION,            /*! Leave color as is. */
569         VG_LITE_GAMMA_LINEAR,                   /*! Convert from sRGB to linear space. */
570         VG_LITE_GAMMA_NON_LINEAR                /*! Convert from linear to sRGB space. */
571     } vg_lite_gamma_conversion_t;
572 
573     /* Index endian */
574     typedef enum vg_lite_index_endian
575     {
576         VG_LITE_INDEX_LITTLE_ENDIAN,            /*! Parse the index pixel from low to high,
577                                                  *! when using index1, the parsing order is bit0~bit7.
578                                                  *! when using index2, the parsing order is bit0:1,bit2:3,bit4:5.bit6:7.
579                                                  *! when using index4, the parsing order is bit0:3,bit4:7.
580                                                  */
581         VG_LITE_INDEX_BIG_ENDIAN,               /*! Parse the index pixel from low to high,
582                                                  *! when using index1, the parsing order is bit7~bit0.
583                                                  *! when using index2, the parsing order is bit7:6,bit5:4,bit3:2.bit1:0.
584                                                  *! when using index4, the parsing order is bit4:7,bit0:3.
585                                                  */
586     } vg_lite_index_endian_t;
587 
588     /* Map flag*/
589     typedef enum vg_lite_map_flag
590     {
591         VG_LITE_MAP_USER_MEMORY             = 0,
592         VG_LITE_MAP_DMABUF                  = 0x01,
593     } vg_lite_map_flag_t;
594 
595     /*VGLite parameters variable*/
596     typedef enum vg_lite_param_type
597     {
598         VG_LITE_SCISSOR_RECT,                   /*! count must be 4n for x, y, right, bottom */
599         VG_LITE_GPU_IDLE_STATE,                 /*! 0: busy, 1: idle */
600     } vg_lite_param_type_t;
601 
602 /* VGLite API Structures ******************************************************************************************************************/
603 
604     /* VGLite driver information */
605     typedef struct vg_lite_info {
606         vg_lite_uint32_t api_version;
607         vg_lite_uint32_t header_version;
608         vg_lite_uint32_t release_version;
609         vg_lite_uint32_t reserved;
610     } vg_lite_info_t;
611 
612     /* A 2D Point definition. */
613     typedef struct vg_lite_point {
614         vg_lite_int32_t x;
615         vg_lite_int32_t y;
616     } vg_lite_point_t;
617 
618     /* Four 2D Point that form a polygon */
619     typedef vg_lite_point_t vg_lite_point4_t[4];
620 
621     /* A rectangle.*/
622     typedef struct vg_lite_rectangle {
623         vg_lite_int32_t x;                      /*! Left coordinate of rectangle. */
624         vg_lite_int32_t y;                      /*! Top coordinate of rectangle. */
625         vg_lite_int32_t width;                  /*! Width of rectangle. */
626         vg_lite_int32_t height;                 /*! Height of rectangle. */
627     } vg_lite_rectangle_t;
628 
629     typedef struct vg_lite_matrix {
630         vg_lite_float_t m[3][3];                /*! The 3x3 matrix is in [row][column] order. */
631         vg_lite_float_t scaleX;
632         vg_lite_float_t scaleY;
633         vg_lite_float_t angle;
634     } vg_lite_matrix_t;
635 
636     typedef struct vg_lite_yuvinfo
637     {
638         vg_lite_swizzle_t swizzle;              /*! UV swizzle. */
639         vg_lite_yuv2rgb_t yuv2rgb;              /*! 601 or 709 conversion standard. */
640         vg_lite_uint32_t uv_planar;             /*! UV(U) planar address. */
641         vg_lite_uint32_t v_planar;              /*! V planar address. */
642         vg_lite_uint32_t alpha_planar;          /*! Alpha planar address. */
643         vg_lite_uint32_t uv_stride;             /*! UV(U) stride. */
644         vg_lite_uint32_t v_stride;              /*! V stride. */
645         vg_lite_uint32_t alpha_stride;          /*! Alpha stride. */
646         vg_lite_uint32_t uv_height;             /*! UV(U) height. */
647         vg_lite_uint32_t v_height;              /*! V height. */
648         vg_lite_pointer uv_memory;              /*! The logical pointer to the UV(U) planar memory. */
649         vg_lite_pointer v_memory;               /*! The logical pointer to the V planar memory. */
650         vg_lite_pointer uv_handle;              /*! The memory handle of the UV(U) planar. */
651         vg_lite_pointer v_handle;               /*! The memory handle of the V planar. */
652     } vg_lite_yuvinfo_t;
653 
654     typedef struct vg_lite_path_point* vg_lite_path_point_ptr;
655     typedef struct vg_lite_path_point
656     {
657         /* X coordinate. */
658         vg_lite_float_t x;
659 
660         /* Y coordinate. */
661         vg_lite_float_t y;
662 
663         /* Flatten flag for flattened path. */
664         vg_lite_uint8_t flatten_flag;
665 
666         /* Curve type for stroke path. */
667         vg_lite_uint8_t curve_type;
668 
669         /* X tangent. */
670         vg_lite_float_t tangentX;
671 
672         /* Y tangent. */
673         vg_lite_float_t tangentY;
674 
675         /* Length of the line. */
676         vg_lite_float_t length;
677 
678         /* Pointer to next point node. */
679         vg_lite_path_point_ptr next;
680 
681         /* Pointer to previous point node. */
682         vg_lite_path_point_ptr prev;
683 
684     } vg_lite_path_point_t;
685 
686     typedef struct vg_lite_sub_path* vg_lite_sub_path_ptr;
687     typedef struct vg_lite_sub_path
688     {
689         /* Pointer to next sub path. */
690         vg_lite_sub_path_ptr next;
691 
692         /* Number of points. */
693         vg_lite_uint32_t point_count;
694 
695         /* Point list. */
696         vg_lite_path_point_ptr point_list;
697 
698         /* Last point. */
699         vg_lite_path_point_ptr end_point;
700 
701         /* Whether is path is closed. */
702         vg_lite_uint8_t closed;
703 
704         /* Sub path length. */
705         vg_lite_float_t length;
706 
707     } vg_lite_sub_path_t;
708 
709     /* Save divided path data according to MOVE/MOVE_REL. */
710     typedef struct vg_lite_path_list* vg_lite_path_list_ptr;
711     typedef struct vg_lite_path_list
712     {
713         vg_lite_path_point_ptr              path_points;
714         vg_lite_path_point_ptr              path_end;
715         vg_lite_uint32_t                    point_count;
716         vg_lite_path_list_ptr               next;
717         vg_lite_uint8_t                     closed;
718 
719     } vg_lite_path_list_t;
720 
721     typedef struct vg_lite_stroke
722     {
723         /* Stroke parameters */
724         vg_lite_cap_style_t                 cap_style;
725         vg_lite_join_style_t                join_style;
726         vg_lite_float_t                     line_width;
727         vg_lite_float_t                     miter_limit;
728         vg_lite_float_t                    *dash_pattern;
729         vg_lite_uint32_t                    pattern_count;
730         vg_lite_float_t                     dash_phase;
731         vg_lite_float_t                     dash_length;
732         vg_lite_uint32_t                    dash_index;
733         vg_lite_float_t                     half_width;
734 
735         /* Total length of stroke dash patterns. */
736         vg_lite_float_t                     pattern_length;
737 
738         /* For fast checking. */
739         vg_lite_float_t                     miter_square;
740 
741         /* Temp storage of stroke subPath. */
742         vg_lite_path_point_ptr              path_points;
743         vg_lite_path_point_ptr              path_end;
744         vg_lite_uint32_t                    point_count;
745         vg_lite_path_point_ptr              left_point;
746         vg_lite_path_point_ptr              right_point;
747         vg_lite_path_point_ptr              stroke_points;
748         vg_lite_path_point_ptr              stroke_end;
749         vg_lite_uint32_t                    stroke_count;
750 
751         /* Divide stroke path according to move or move_rel for avoiding implicit closure. */
752         vg_lite_path_list_ptr               path_list_divide;
753 
754         /* pointer to current divided path data. */
755         vg_lite_path_list_ptr               cur_list;
756 
757         /* Flag that add end_path in driver. */
758         vg_lite_uint8_t                     add_end;
759         vg_lite_uint8_t                     dash_reset;
760 
761         /* Sub path list. */
762         vg_lite_sub_path_ptr                stroke_paths;
763 
764         /* Last sub path. */
765         vg_lite_sub_path_ptr                last_stroke;
766 
767         /* Swing area handling. */
768         vg_lite_uint32_t                    swing_handling;
769         vg_lite_float_t                     swing_deltax;
770         vg_lite_float_t                     swing_deltay;
771         vg_lite_path_point_ptr              swing_start;
772         vg_lite_path_point_ptr              swing_stroke;
773         vg_lite_float_t                     swing_length;
774         vg_lite_float_t                     swing_centlen;
775         vg_lite_uint32_t                    swing_count;
776         vg_lite_uint8_t                     need_swing;
777         vg_lite_uint8_t                     swing_ccw;
778 
779         vg_lite_float_t                     stroke_length;
780         vg_lite_uint32_t                    stroke_size;
781 
782         /* The stroke line is fat line. */
783         vg_lite_uint8_t                     fattened;
784         vg_lite_uint8_t                     closed;
785 
786     } vg_lite_stroke_t;
787 
788     /* Fast clear buffer. */
789     typedef struct vg_lite_fc_buffer
790     {
791         vg_lite_int32_t width;                  /*! Width of the buffer in pixels. */
792         vg_lite_int32_t height;                 /*! height of the buffer in pixels. */
793         vg_lite_int32_t stride;                 /*! The number of bytes to move from one line in the buffer to the next line. */
794         vg_lite_pointer handle;                 /*! The memory handle of the buffer's memory as allocated by the VGLite kernel. */
795         vg_lite_pointer memory;                 /*! The logical pointer to the buffer's memory for the CPU. */
796         vg_lite_uint32_t address;               /*! The address to the buffer's memory for the hardware. */
797         vg_lite_uint32_t color;                 /*! The fastclear color value. */
798     } vg_lite_fc_buffer_t;
799 
800     /* Structure for any image or render target. */
801     typedef struct vg_lite_buffer
802     {
803         vg_lite_int32_t width;                  /*! Width of the buffer in pixels. */
804         vg_lite_int32_t height;                 /*! Height of the buffer in pixels. */
805         vg_lite_int32_t stride;                 /*! The number of bytes to move from one line in the buffer to the next line. */
806         vg_lite_buffer_layout_t tiled;          /*! Indicating the buffer memory layout is linear or tiled. */
807         vg_lite_buffer_format_t format;         /*! The pixel format of the buffer. */
808         vg_lite_pointer handle;                 /*! The memory handle of the buffer's memory as allocated by the VGLite kernel. */
809         vg_lite_pointer memory;                 /*! The logical pointer to the buffer's memory for the CPU. */
810         vg_lite_uint32_t address;               /*! The address to the buffer's memory for the hardware. */
811         vg_lite_yuvinfo_t yuv;                  /*! The yuv format details. */
812         vg_lite_image_mode_t image_mode;        /*! The blit image mode. */
813         vg_lite_transparency_t transparency_mode; /*! image transparency mode. */
814         vg_lite_fc_buffer_t fc_buffer[3];       /*! 3 fastclear buffers,reserved YUV format. */
815         vg_lite_compress_mode_t compress_mode;  /*! Refer to the definition by vg_lite_compress_mode_t. */
816         vg_lite_index_endian_t index_endian;    /*! Refer to the definition by vg_lite_index_endian_t. */
817         vg_lite_paint_type_t paintType;         /*! Get paintcolor from different paint types. */
818         vg_lite_uint8_t fc_enable;              /*! enable im fastclear. */
819         vg_lite_uint8_t scissor_layer;          /*! The buffer is scissor buffer. */
820         vg_lite_uint8_t premultiplied;          /*! The RGB pixel values are alpha-premultiplied */
821     } vg_lite_buffer_t;
822 
823     /* Memory allocation info by kernel. */
824     typedef struct vg_lite_hw_memory
825     {
826         vg_lite_pointer handle;                 /*! gpu memory object handle. */
827         vg_lite_pointer memory;                 /*! logical memory address. */
828         vg_lite_uint32_t address;               /*! GPU memory address. */
829         vg_lite_uint32_t bytes;                 /*! Size of memory. */
830         vg_lite_uint32_t property;              /*! Currently bit0 is used for path upload state:
831                                                  *!   1 : enable auto path data uploading.
832                                                  *!   0 : disable path data uploading. path data is embedded in command buffer. */
833     } vg_lite_hw_memory_t;
834 
835     /* Path info for drawing command. */
836     typedef struct vg_lite_path
837     {
838         vg_lite_float_t bounding_box[4];        /*! Bounding box specified as left, top, right, and bottom. */
839         vg_lite_quality_t quality;              /*! Quality hint for the path. */
840         vg_lite_format_t format;                /*! Coordinate format. */
841         vg_lite_hw_memory_t uploaded;           /*! Path data that has been upload into GPU addressable memory. */
842         vg_lite_uint32_t path_length;           /*! Number of bytes in the path data. */
843         vg_lite_pointer path;                   /*! Pointer to the physical description of the path. */
844         vg_lite_int8_t path_changed;            /*! Indicate whether path data is synced with command buffer (uploaded) or not. */
845         vg_lite_int8_t pdata_internal;          /*! Indicate whether path data memory is allocated by driver. */
846         vg_lite_path_type_t path_type;          /*! Refer to the definition by vg_lite_path_type_t. */
847         vg_lite_stroke_t *stroke;               /*! Pointer to a vg_lite_stroke_t structure.*/
848         vg_lite_pointer stroke_path;            /*! Pointer to the physical description of the stroke path. */
849         vg_lite_uint32_t stroke_size;           /*! Number of bytes in the stroke path data. */
850         vg_lite_color_t stroke_color;           /*! The stroke path fill color. */
851         vg_lite_int8_t add_end;                 /*! Flag that add end_path in driver. */
852     } vg_lite_path_t;
853 
854     /* Color ramp definition. */
855     typedef struct vg_lite_color_ramp
856     {
857         vg_lite_float_t stop;                   /*! Value for the color stop. */
858         vg_lite_float_t red;                    /*! Red color channel value for the color stop. */
859         vg_lite_float_t green;                  /*! Green color channel value for the color stop. */
860         vg_lite_float_t blue;                   /*! Blue color channel value for the color stop. */
861         vg_lite_float_t alpha;                  /*! Alpha color channel value for the color stop. */
862     } vg_lite_color_ramp_t;
863 
864     /* Linear gradient parameter */
865     typedef struct vg_lite_linear_gradient_parameter
866     {
867         vg_lite_float_t X0;
868         vg_lite_float_t Y0;
869         vg_lite_float_t X1;
870         vg_lite_float_t Y1;
871     } vg_lite_linear_gradient_parameter_t;
872 
873     typedef struct vg_lite_radial_gradient_parameter
874     {
875         vg_lite_float_t cx;                                 /*! x coordinate of the center point. */
876         vg_lite_float_t cy;                                 /*! y coordinate of the center point. */
877         vg_lite_float_t r;                                  /*! radius. */
878         vg_lite_float_t fx;                                 /*! x coordinate of the focal point. */
879         vg_lite_float_t fy;                                 /*! y coordinate of the focal point. */
880     } vg_lite_radial_gradient_parameter_t;
881 
882     /* Linear gradient definition. */
883     typedef struct vg_lite_linear_gradient {
884         vg_lite_uint32_t colors[VLC_MAX_GRADIENT_STOPS];    /*! Colors for stops. */
885         vg_lite_uint32_t count;                             /*! Count of colors, up to 16. */
886         vg_lite_uint32_t stops[VLC_MAX_GRADIENT_STOPS];     /*! Color stops, value from 0 to 255. */
887         vg_lite_matrix_t matrix;                            /*! The matrix to transform the gradient. */
888         vg_lite_buffer_t image;                             /*! The image for rendering as gradient pattern. */
889     } vg_lite_linear_gradient_t;
890 
891     /* Extended linear gradient definition. */
892     typedef struct vg_lite_ext_linear_gradient {
893         vg_lite_uint32_t count;                             /*! Count of colors, up to 256. */
894         vg_lite_matrix_t matrix;                            /*! The matrix to transform the gradient. */
895         vg_lite_buffer_t image;                             /*! The image for rendering as gradient pattern. */
896         vg_lite_linear_gradient_parameter_t linear_grad;    /*!  Include center point,focal point and radius.*/
897 
898         vg_lite_uint32_t ramp_length;                       /*! Color ramp for gradient paints provided to driver. */
899         vg_lite_color_ramp_t color_ramp[VLC_MAX_COLOR_RAMP_STOPS];
900 
901         vg_lite_uint32_t converted_length;                  /*! Converted internal color ramp. */
902         vg_lite_color_ramp_t converted_ramp[VLC_MAX_COLOR_RAMP_STOPS + 2];
903 
904         vg_lite_uint8_t pre_multiplied;                     /*! If color values of color_ramp[] are multiply by alpha value of color_ramp[]. */
905         vg_lite_gradient_spreadmode_t spread_mode;          /*! The spread mode that applied to the pixels out of the image after transformed. */
906     } vg_lite_ext_linear_gradient_t;
907 
908     /* Radial gradient definition. */
909     typedef struct vg_lite_radial_gradient
910     {
911         vg_lite_uint32_t count;                             /*! Count of colors, up to 256. */
912         vg_lite_matrix_t matrix;                            /*! The matrix to transform the gradient. */
913         vg_lite_buffer_t image;                             /*! The image for rendering as gradient pattern. */
914         vg_lite_radial_gradient_parameter_t radial_grad;    /*!  Include center point,focal point and radius.*/
915 
916         vg_lite_uint32_t ramp_length;                       /*! Color ramp for gradient paints provided to the driver. */
917         vg_lite_color_ramp_t color_ramp[VLC_MAX_COLOR_RAMP_STOPS];
918 
919         vg_lite_uint32_t converted_length;                  /*! Converted internal color ramp. */
920         vg_lite_color_ramp_t converted_ramp[VLC_MAX_COLOR_RAMP_STOPS + 2];
921 
922         vg_lite_uint8_t pre_multiplied;                     /*! If color values of color_ramp[] are multiply by alpha value of color_ramp[]. */
923         vg_lite_gradient_spreadmode_t spread_mode;          /*! The spread mode that applied to the pixels out of the image after transformed. */
924     } vg_lite_radial_gradient_t;
925 
926     /* Colorkey definition */
927     typedef struct vg_lite_color_key
928     {
929         vg_lite_uint8_t enable;                 /*! The color key is effective only when "enable" is true, */
930         vg_lite_uint8_t low_r;                  /*! The R channel of low_rgb. */
931         vg_lite_uint8_t low_g;                  /*! The G channel of low_rgb. */
932         vg_lite_uint8_t low_b;                  /*! The B channel of low_rgb. */
933         vg_lite_uint8_t alpha;                  /*! The alpha channel to replace destination pixel alpha channel.*/
934         vg_lite_uint8_t hign_r;                 /*! The R channel of hign_rgb. */
935         vg_lite_uint8_t hign_g;                 /*! The G channel of hign_rgb. */
936         vg_lite_uint8_t hign_b;                 /*! The B channel of hign_rgb. */
937     } vg_lite_color_key_t;
938 
939     /* Four colorkey definition.
940      * rgb_hi_0, rgb_lo_0, alpha_0, enable_0;
941      * rgb_hi_1, rgb_lo_1, alpha_1, enable_1;
942      * rgb_hi_2, rgb_lo_2, alpha_2, enable_2;
943      * rgb_hi_3, rgb_lo_3, alpha_3, enable_3;
944      * Priority order: color_key_0 > color_key_1 > color_key_2 > color_key_3.
945     */
946     typedef vg_lite_color_key_t vg_lite_color_key4_t[4];
947 
948     /* Pixel matrix values */
949     typedef vg_lite_float_t vg_lite_pixel_matrix_t[20];
950 
951     /* HW pixel channel enable flags */
952     typedef struct vg_lite_pixel_channel_enable
953     {
954         vg_lite_uint8_t enable_a;               /*! Enable A channel.*/
955         vg_lite_uint8_t enable_b;               /*! Enable B channel. */
956         vg_lite_uint8_t enable_g;               /*! Enable G channel. */
957         vg_lite_uint8_t enable_r;               /*! Enable R channel. */
958     } vg_lite_pixel_channel_enable_t;
959 
960     /* Pixel color transform */
961     typedef struct vg_lite_color_transform
962     {
963         vg_lite_float_t a_scale;
964         vg_lite_float_t a_bias;
965         vg_lite_float_t r_scale;
966         vg_lite_float_t r_bias;
967         vg_lite_float_t g_scale;
968         vg_lite_float_t g_bias;
969         vg_lite_float_t b_scale;
970         vg_lite_float_t b_bias;
971     } vg_lite_color_transform_t;
972 
973 /* VGLite API Functions *******************************************************************************************************************/
974 
975     /* Initialize a vglite context. */
976     vg_lite_error_t vg_lite_init(vg_lite_int32_t tess_width, vg_lite_int32_t tess_height);
977 
978     /* Destroy a vglite context. */
979     vg_lite_error_t vg_lite_close(void);
980 
981     /* Get the VGLite driver information. */
982     vg_lite_error_t vg_lite_get_info(vg_lite_info_t* info);
983 
984     /* Get the GPU chip information. */
985     vg_lite_uint32_t vg_lite_get_product_info(vg_lite_char *name, vg_lite_uint32_t *chip_id, vg_lite_uint32_t *chip_rev);
986 
987     /* Query if a specific feature is supported. */
988     vg_lite_uint32_t vg_lite_query_feature(vg_lite_feature_t feature);
989 
990     /* Flush command buffer and wait for GPU to complete. */
991     vg_lite_error_t vg_lite_finish(void);
992 
993     /* Flush the command buffer without waiting for GPU to complete. */
994     vg_lite_error_t vg_lite_flush(void);
995 
996     /* Get the value of register from register's address. */
997     vg_lite_error_t vg_lite_get_register(vg_lite_uint32_t address, vg_lite_uint32_t* result);
998 
999     /* Generate a 3x3 homogeneous matrix to transform 4 source coordinates to 4 target coordinates. */
1000     vg_lite_error_t vg_lite_get_transform_matrix(vg_lite_point4_t src, vg_lite_point4_t dst, vg_lite_matrix_t *mat);
1001 
1002     /* Allocate a buffer from GPU hardware accessible memory. */
1003     vg_lite_error_t vg_lite_allocate(vg_lite_buffer_t *buffer);
1004 
1005     /* Free a buffer allocated by vg_lite_allocate() */
1006     vg_lite_error_t vg_lite_free(vg_lite_buffer_t *buffer);
1007 
1008     /* Upload RGB or YUV pixel data to an allocated buffer. */
1009     vg_lite_error_t vg_lite_upload_buffer(vg_lite_buffer_t *buffer, vg_lite_uint8_t *data[3], vg_lite_uint32_t stride[3]);
1010 
1011     /* Map a buffer into hardware accessible address space. */
1012     vg_lite_error_t vg_lite_map(vg_lite_buffer_t *buffer, vg_lite_map_flag_t flag, int32_t fd);
1013 
1014     /* Unmap a buffer that is mapped */
1015     vg_lite_error_t vg_lite_unmap(vg_lite_buffer_t *buffer);
1016 
1017     /* flush cache */
1018     vg_lite_error_t vg_lite_flush_mapped_buffer(vg_lite_buffer_t * buffer);
1019 
1020     /* Fill a buffer rectangle area with a specified color. */
1021     vg_lite_error_t vg_lite_clear(vg_lite_buffer_t *target, vg_lite_rectangle_t *rect, vg_lite_color_t color);
1022 
1023     /* Copy a source image to target buffer with transformation, blending, color mixing, and filtering. */
1024     vg_lite_error_t vg_lite_blit(vg_lite_buffer_t *target,
1025                                     vg_lite_buffer_t *source,
1026                                     vg_lite_matrix_t *matrix,
1027                                     vg_lite_blend_t   blend,
1028                                     vg_lite_color_t   color,
1029                                     vg_lite_filter_t  filter);
1030 
1031     /* Copy a rectangle area of source image to target buffer with transformation, blending, color mixing, and filtering. */
1032     vg_lite_error_t vg_lite_blit_rect(vg_lite_buffer_t *target,
1033                                     vg_lite_buffer_t *source,
1034                                     vg_lite_rectangle_t *rect,
1035                                     vg_lite_matrix_t *matrix,
1036                                     vg_lite_blend_t   blend,
1037                                     vg_lite_color_t   color,
1038                                     vg_lite_filter_t  filter);
1039 
1040     /* Copy two source images to the target buffer with transformation, blending, and filtering. */
1041     vg_lite_error_t vg_lite_blit2(vg_lite_buffer_t *target,
1042                                     vg_lite_buffer_t *source0,
1043                                     vg_lite_buffer_t *source1,
1044                                     vg_lite_matrix_t *matrix0,
1045                                     vg_lite_matrix_t *matrix1,
1046                                     vg_lite_blend_t blend,
1047                                     vg_lite_filter_t  filter);
1048 
1049     /* Copy a rectangle area of source image to target buffer without transformation, blending, color mixing, and filtering. */
1050     vg_lite_error_t vg_lite_copy_image(vg_lite_buffer_t *target,
1051                                     vg_lite_buffer_t *source,
1052                                     vg_lite_int32_t   sx,
1053                                     vg_lite_int32_t   sy,
1054                                     vg_lite_int32_t   dx,
1055                                     vg_lite_int32_t   dy,
1056                                     vg_lite_int32_t   width,
1057                                     vg_lite_int32_t   height);
1058 
1059     /* Draw a path to a target buffer with transformation, color, and blending */
1060     vg_lite_error_t vg_lite_draw(vg_lite_buffer_t *target,
1061                                     vg_lite_path_t   *path,
1062                                     vg_lite_fill_t    fill_rule,
1063                                     vg_lite_matrix_t *matrix,
1064                                     vg_lite_blend_t   blend,
1065                                     vg_lite_color_t   color);
1066 
1067     /* Set stroke path attributes. */
1068     vg_lite_error_t vg_lite_set_stroke(vg_lite_path_t *path,
1069                                     vg_lite_cap_style_t cap_style,
1070                                     vg_lite_join_style_t join_style,
1071                                     vg_lite_float_t line_width,
1072                                     vg_lite_float_t miter_limit,
1073                                     vg_lite_float_t *dash_pattern,
1074                                     vg_lite_uint32_t pattern_count,
1075                                     vg_lite_float_t dash_phase,
1076                                     vg_lite_color_t color);
1077 
1078     /* Update stroke path. */
1079     vg_lite_error_t vg_lite_update_stroke(vg_lite_path_t *path);
1080 
1081     /* Set path type. */
1082     vg_lite_error_t vg_lite_set_path_type(vg_lite_path_t *path, vg_lite_path_type_t path_type);
1083 
1084     /* Clears all attributes of a path. */
1085     vg_lite_error_t vg_lite_clear_path(vg_lite_path_t *path);
1086 
1087     /* Upload a path to GPU memory so GPU can access it directly. */
1088     vg_lite_error_t vg_lite_upload_path(vg_lite_path_t *path);
1089 
1090     /* Initialize a path object with attributes. */
1091     vg_lite_error_t vg_lite_init_path(vg_lite_path_t *path,
1092                                     vg_lite_format_t format,
1093                                     vg_lite_quality_t quality,
1094                                     vg_lite_uint32_t length,
1095                                     vg_lite_pointer data,
1096                                     vg_lite_float_t min_x,
1097                                     vg_lite_float_t min_y,
1098                                     vg_lite_float_t max_x,
1099                                     vg_lite_float_t max_y);
1100 
1101      /* Initializes a arc path with attributes. */
1102     vg_lite_error_t vg_lite_init_arc_path(vg_lite_path_t *path,
1103                                     vg_lite_format_t format,
1104                                     vg_lite_quality_t quality,
1105                                     vg_lite_uint32_t length,
1106                                     vg_lite_pointer data,
1107                                     vg_lite_float_t min_x,
1108                                     vg_lite_float_t min_y,
1109                                     vg_lite_float_t max_x,
1110                                     vg_lite_float_t max_y);
1111 
1112     /* Return the size (in bytes) of command buffer for a path opcode array. */
1113     vg_lite_uint32_t vg_lite_get_path_length(vg_lite_uint8_t *opcode,
1114                                     vg_lite_uint32_t count,
1115                                     vg_lite_format_t format);
1116 
1117     /* Generate command buffer for the (path) based on input opcodes (opcode) and coordinates (data). */
1118     vg_lite_error_t vg_lite_append_path(vg_lite_path_t *path,
1119                                     vg_lite_uint8_t *opcode,
1120                                     vg_lite_pointer data,
1121                                     vg_lite_uint32_t seg_count);
1122 
1123     /* Set CLUT (Color Look Up Table) for index image. The (colors) is in ARGB format. */
1124     vg_lite_error_t vg_lite_set_CLUT(vg_lite_uint32_t count, vg_lite_uint32_t *colors);
1125 
1126     /* Draw a path that is filled by a transformed image pattern. */
1127     vg_lite_error_t vg_lite_draw_pattern(vg_lite_buffer_t *target,
1128                                     vg_lite_path_t *path,
1129                                     vg_lite_fill_t fill_rule,
1130                                     vg_lite_matrix_t *path_matrix,
1131                                     vg_lite_buffer_t *pattern_image,
1132                                     vg_lite_matrix_t *pattern_matrix,
1133                                     vg_lite_blend_t blend,
1134                                     vg_lite_pattern_mode_t pattern_mode,
1135                                     vg_lite_color_t  pattern_color,
1136                                     vg_lite_color_t  color,
1137                                     vg_lite_filter_t filter);
1138 
1139     /* Initialize a linear gradient object with default attributes. */
1140     vg_lite_error_t vg_lite_init_grad(vg_lite_linear_gradient_t *grad);
1141 
1142     /* Reset a linear gradient object attributes. */
1143     vg_lite_error_t vg_lite_clear_grad(vg_lite_linear_gradient_t *grad);
1144 
1145     /* Update a linear gradient object. */
1146     vg_lite_error_t vg_lite_update_grad(vg_lite_linear_gradient_t *grad);
1147 
1148     /* Return pointer to a linear gradient object's matrix. */
1149     vg_lite_matrix_t* vg_lite_get_grad_matrix(vg_lite_linear_gradient_t *grad);
1150 
1151     /* Set attributes for a linear gradient object. */
1152     vg_lite_error_t vg_lite_set_grad(vg_lite_linear_gradient_t *grad,
1153                                     vg_lite_uint32_t count,
1154                                     vg_lite_uint32_t *colors,
1155                                     vg_lite_uint32_t *stops);
1156 
1157     /* Draw a path with a linear gradient object pattern. */
1158     vg_lite_error_t vg_lite_draw_grad(vg_lite_buffer_t *target,
1159                                     vg_lite_path_t *path,
1160                                     vg_lite_fill_t fill_rule,
1161                                     vg_lite_matrix_t *matrix,
1162                                     vg_lite_linear_gradient_t *grad,
1163                                     vg_lite_blend_t blend);
1164 
1165     /* Reset an extended linear gradient object attributes and free image buffer. */
1166     vg_lite_error_t vg_lite_clear_linear_grad(vg_lite_ext_linear_gradient_t *grad);
1167 
1168     /* Update an extended linear gradient object. */
1169     vg_lite_error_t vg_lite_update_linear_grad(vg_lite_ext_linear_gradient_t *grad);
1170 
1171     /* Return pointer to an extended linear gradient object's matrix. */
1172     vg_lite_matrix_t* vg_lite_get_linear_grad_matrix(vg_lite_ext_linear_gradient_t *grad);
1173 
1174     /* Set attributes for an extended linear gradient object. */
1175     vg_lite_error_t vg_lite_set_linear_grad(vg_lite_ext_linear_gradient_t *grad,
1176                                     vg_lite_uint32_t count,
1177                                     vg_lite_color_ramp_t *color_ramp,
1178                                     vg_lite_linear_gradient_parameter_t grad_param,
1179                                     vg_lite_gradient_spreadmode_t spread_mode,
1180                                     vg_lite_uint8_t pre_mult);
1181 
1182     /* Draw a path with an extended linear gradient object. */
1183     vg_lite_error_t vg_lite_draw_linear_grad(vg_lite_buffer_t *target,
1184                                     vg_lite_path_t *path,
1185                                     vg_lite_fill_t fill_rule,
1186                                     vg_lite_matrix_t *path_matrix,
1187                                     vg_lite_ext_linear_gradient_t *grad,
1188                                     vg_lite_color_t paint_color,
1189                                     vg_lite_blend_t blend,
1190                                     vg_lite_filter_t filter);
1191 
1192     /* Reset a radial gradient object attributes and free image buffer. */
1193     vg_lite_error_t vg_lite_clear_radial_grad(vg_lite_radial_gradient_t *grad);
1194 
1195     /* Update a radial gradient object. */
1196     vg_lite_error_t vg_lite_update_radial_grad(vg_lite_radial_gradient_t *grad);
1197 
1198     /* Return pointer to a radial gradient object's matrix. */
1199     vg_lite_matrix_t* vg_lite_get_radial_grad_matrix(vg_lite_radial_gradient_t *grad);
1200 
1201     /* Set attributes for a radial gradient object. */
1202     vg_lite_error_t vg_lite_set_radial_grad(vg_lite_radial_gradient_t *grad,
1203                                     vg_lite_uint32_t count,
1204                                     vg_lite_color_ramp_t *color_ramp,
1205                                     vg_lite_radial_gradient_parameter_t grad_param,
1206                                     vg_lite_gradient_spreadmode_t spread_mode,
1207                                     vg_lite_uint8_t pre_mult);
1208 
1209     /* Draw a path with a radial gradient object pattern. */
1210     vg_lite_error_t vg_lite_draw_radial_grad(vg_lite_buffer_t *target,
1211                                     vg_lite_path_t *path,
1212                                     vg_lite_fill_t fill_rule,
1213                                     vg_lite_matrix_t *path_matrix,
1214                                     vg_lite_radial_gradient_t *grad,
1215                                     vg_lite_color_t  paint_color,
1216                                     vg_lite_blend_t blend,
1217                                     vg_lite_filter_t filter);
1218 
1219     /* Load an identity matrix. */
1220     vg_lite_error_t vg_lite_identity(vg_lite_matrix_t *matrix);
1221 
1222     /* Translate a matrix. */
1223     vg_lite_error_t vg_lite_translate(vg_lite_float_t x, vg_lite_float_t y, vg_lite_matrix_t *matrix);
1224 
1225     /* Scale a matrix. */
1226     vg_lite_error_t vg_lite_scale(vg_lite_float_t scale_x, vg_lite_float_t scale_y, vg_lite_matrix_t *matrix);
1227 
1228     /* Rotate a matrix. */
1229     vg_lite_error_t vg_lite_rotate(vg_lite_float_t degrees, vg_lite_matrix_t *matrix);
1230 
1231     /* Set and enable a scissor rectangle for render target. */
1232     vg_lite_error_t vg_lite_set_scissor(vg_lite_int32_t x, vg_lite_int32_t y, vg_lite_int32_t right, vg_lite_int32_t bottom);
1233 
1234     /* Set scissor rectangles on mask layer. Scissor rects are enabled/disabled by following APIs. */
1235     vg_lite_error_t vg_lite_scissor_rects(vg_lite_uint32_t nums, vg_lite_rectangle_t rect[]);
1236 
1237     /* Enable scissor rects defined on mask layer. */
1238     vg_lite_error_t vg_lite_enable_scissor(void);
1239 
1240     /* Disable scissor rects defined on mask layer. */
1241     vg_lite_error_t vg_lite_disable_scissor(void);
1242 
1243     /* Query size of available contiguous video memory. */
1244     vg_lite_error_t vg_lite_get_mem_size(vg_lite_uint32_t *size);
1245 
1246     /* Set global alpha value for source image */
1247     vg_lite_error_t vg_lite_source_global_alpha(vg_lite_global_alpha_t alpha_mode, vg_lite_uint8_t alpha_value);
1248 
1249     /* Set global alpha value for destination image. */
1250     vg_lite_error_t vg_lite_dest_global_alpha(vg_lite_global_alpha_t alpha_mode, vg_lite_uint8_t alpha_value);
1251 
1252     /* Set colorkey. */
1253     vg_lite_error_t vg_lite_set_color_key(vg_lite_color_key4_t colorkey);
1254 
1255     /* Enable dither function. Dither is OFF by default. */
1256     vg_lite_error_t vg_lite_enable_dither(void);
1257 
1258     /* Disable dither function. Dither is OFF by default. */
1259     vg_lite_error_t vg_lite_disable_dither(void);
1260 
1261     /* Set a 64-byte aligned memory buffer (physical) as VGLite tessellation buffer. */
1262     vg_lite_error_t vg_lite_set_tess_buffer(vg_lite_uint32_t physical, vg_lite_uint32_t size);
1263 
1264     /* Can be called before vg_lite_init() to overwrite the default VG_LITE_COMMAND_BUFFER_SIZE */
1265     vg_lite_error_t vg_lite_set_command_buffer_size(vg_lite_uint32_t size);
1266 
1267     /* Set a user-defined external memory buffer (physical, 64-byte aligned) as VGLite command buffer. */
1268     vg_lite_error_t vg_lite_set_command_buffer(vg_lite_uint32_t physical, vg_lite_uint32_t size);
1269 
1270     /* Setup a pixel transform matrix m[20] which transforms each pixel as following:
1271      *
1272      *              |a'|   |m0  m1  m2  m3  m4 | |a|
1273      *              |r'|   |m5  m6  m7  m8  m9 | |r|
1274      *              |g'| = |m10 m11 m12 m13 m14|.|g|
1275      *              |b'|   |m15 m16 m17 m18 m19| |b|
1276      *              |1 |   |0   0   0   0   1  | |1|
1277      *
1278      *  The pixel transform for A, R, G, B channel can be enabled/disabled individually with (channel) parameter.
1279      */
1280     vg_lite_error_t vg_lite_set_pixel_matrix(vg_lite_pixel_matrix_t matrix, vg_lite_pixel_channel_enable_t *channel);
1281 
1282     /* Setup 3x3 gaussian blur weight values to filter image pixels.
1283      *
1284      *  Parameters w0, w1, w2 define a 3x3 gaussian blur weight matrix as below
1285      *
1286      *                  |  w2   w1   w2 |
1287      *                  |  w1   w0   w1 |
1288      *                  |  w2   w1   w2 |
1289      *
1290      *  The sum of 9 kernel weights must be 1.0 to avoid convolution overflow ( w0 + 4*w1 + 4*w2 = 1.0 ).
1291      *  The 3x3 weight matrix applies to a 3x3 pixel block
1292      *
1293      *                  | pixel[i-1][j-1]     pixel[i][j-1]       pixel[i+1][j-1]|
1294      *                  | pixel[i-1][j]       pixel[i][j]         pixel[i+1][j]  |
1295      *                  | pixel[i-1][j+1]     pixel[i][j+1]       pixel[i+1][j+1]|
1296      *
1297      *  With the following dot product equation:
1298      *
1299      *     color[i][j] = w2*pixel[i-1][j-1] + w1*pixel[i][j-1] + w2*pixel[i+1][j-1]
1300      *                 + w1*pixel[i-1][j]   + w0*pixel[i][j]   + w1*pixel[i+1][j]
1301      *                 + w2*pixel[i-1][j+1] + w1*pixel[i][j+1] + w2*pixel[i+1][j+1];
1302      */
1303     vg_lite_error_t vg_lite_gaussian_filter(vg_lite_float_t w0, vg_lite_float_t w1, vg_lite_float_t w2);
1304 
1305     /*  Enable masklayer function. Masklayer is OFF by default. */
1306     vg_lite_error_t vg_lite_enable_masklayer(void);
1307 
1308     /*  Disable masklayer function. Masklayer is OFF by default. */
1309     vg_lite_error_t vg_lite_disable_masklayer(void);
1310 
1311     /* Setup a masklayer. */
1312     vg_lite_error_t vg_lite_set_masklayer(vg_lite_buffer_t *masklayer);
1313 
1314     /* Free a masklayer and disable mask operation. */
1315     vg_lite_error_t vg_lite_destroy_masklayer(vg_lite_buffer_t *masklayer);
1316 
1317     /* Create a masklayer with default format A8 and default pixel value 255. */
1318     vg_lite_error_t vg_lite_create_masklayer(vg_lite_buffer_t *masklayer,
1319                                     vg_lite_uint32_t width,
1320                                     vg_lite_uint32_t height);
1321 
1322     /* Set pixel values for a rectangle area in a masklayer */
1323     vg_lite_error_t vg_lite_fill_masklayer(vg_lite_buffer_t *masklayer,
1324                                     vg_lite_rectangle_t *rect,
1325                                     vg_lite_uint8_t value);
1326 
1327     /* Blend a rectangle area of src masklayer with dst masklayer according to (operation). */
1328     vg_lite_error_t vg_lite_blend_masklayer(vg_lite_buffer_t *dst,
1329                                     vg_lite_buffer_t *src,
1330                                     vg_lite_mask_operation_t operation,
1331                                     vg_lite_rectangle_t *rect);
1332 
1333     /* Render a (path) with (fill_rule), (color), (matrix) to the masklayer. */
1334     vg_lite_error_t vg_lite_render_masklayer(vg_lite_buffer_t *masklayer,
1335                                     vg_lite_mask_operation_t operation,
1336                                     vg_lite_path_t *path,
1337                                     vg_lite_fill_t fill_rule,
1338                                     vg_lite_color_t color,
1339                                     vg_lite_matrix_t *matrix);
1340 
1341     /* Set mirror orientation. */
1342     vg_lite_error_t vg_lite_set_mirror(vg_lite_orientation_t orientation);
1343 
1344     /* Set gamma value. */
1345     vg_lite_error_t vg_lite_set_gamma(vg_lite_gamma_conversion_t gamma_value);
1346 
1347     /* Enable color transformation, which is OFF by default. */
1348     vg_lite_error_t vg_lite_enable_color_transform(void);
1349 
1350     /* Disable color transformation, which is OFF by default. */
1351     vg_lite_error_t vg_lite_disable_color_transform(void);
1352 
1353     /* Set pixel color transformation scale and bias values for each pixel channel. */
1354     vg_lite_error_t vg_lite_set_color_transform(vg_lite_color_transform_t *values);
1355 
1356     /* Set flexa stream id. */
1357     vg_lite_error_t vg_lite_flexa_set_stream(vg_lite_uint8_t stream_id);
1358 
1359     /* set flexa background buffer.*/
1360     vg_lite_error_t vg_lite_flexa_bg_buffer(vg_lite_uint8_t stream_id,
1361                                     vg_lite_buffer_t *buffer,
1362                                     vg_lite_uint32_t seg_count,
1363                                     vg_lite_uint32_t seg_size);
1364 
1365     /* Enable flexa. */
1366     vg_lite_error_t vg_lite_flexa_enable(void);
1367 
1368     /* Disable flexa.*/
1369     vg_lite_error_t vg_lite_flexa_disable(void);
1370 
1371     /* Set flexa stop flag after the last frame. */
1372     vg_lite_error_t vg_lite_flexa_stop_frame(void);
1373 
1374     /* Dump command buffer */
1375     vg_lite_error_t vg_lite_dump_command_buffer(void);
1376 
1377     /* Return VGLite parameters in params[] array */
1378     vg_lite_error_t vg_lite_get_parameter(vg_lite_param_type_t type,
1379                                     vg_lite_int32_t count,
1380                                     vg_lite_float_t* params);
1381 
1382 #endif /* VGLITE_VERSION_3_0 */
1383 
1384 #ifdef __cplusplus
1385 }
1386 #endif
1387 #endif /* _vg_lite_h_ */
1388