1 /****************************************************************************
2 *
3 *    The MIT License (MIT)
4 *
5 *    Copyright 2012 - 2020 Vivante Corporation, Santa Clara, California.
6 *    All Rights Reserved.
7 *
8 *    Permission is hereby granted, free of charge, to any person obtaining
9 *    a copy of this software and associated documentation files (the
10 *    'Software'), to deal in the Software without restriction, including
11 *    without limitation the rights to use, copy, modify, merge, publish,
12 *    distribute, sub license, and/or sell copies of the Software, and to
13 *    permit persons to whom the Software is furnished to do so, subject
14 *    to the following conditions:
15 *
16 *    The above copyright notice and this permission notice (including the
17 *    next paragraph) shall be included in all copies or substantial
18 *    portions of the Software.
19 *
20 *    THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
21 *    EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
22 *    MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
23 *    IN NO EVENT SHALL VIVANTE AND/OR ITS SUPPLIERS BE LIABLE FOR ANY
24 *    CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
25 *    TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
26 *    SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
27 *
28 *****************************************************************************/
29 
30 #ifndef _vg_lite_h_
31 #define _vg_lite_h_
32 
33 #ifdef __cplusplus
34 extern "C" {
35 #endif
36 
37 #if defined(_MSC_VER)
38 #define inline __inline
39 #endif
40 
41 #include <stddef.h>
42 #include <stdint.h>
43 
44 #define VGLITE_RELEASE_VERSION   0x03000f
45 
46 #define VGLITE_HEADER_VERSION    6
47 
48 #ifndef VGLITE_VERSION_2_0
49 #define VGLITE_VERSION_2_0    1
50 
51 #define VGLITE_MAKE_VERSION(major, minor, patch) (((major) << 16) | ((minor) << 8) | (patch))
52 
53 #define VGLITE_VERSION_MAJOR(version) (((uint32_t)(version) >> 16) & 0xff)
54 #define VGLITE_VERSION_MINOR(version) (((uint32_t)(version) >> 8) & 0xff)
55 #define VGLITE_VERSION_PATCH(version) ((uint32_t)(version) & 0xff)
56 
57 #define VGLITE_API_VERSION_2_0    VGLITE_MAKE_VERSION(2, 0, 0)
58 
59 
60 #/* Macros *********************************************************************************************************************/
61 
62 /* Path command (op code). */
63 #define VLC_OP_END          0x00
64 #define VLC_OP_CLOSE        0x01
65 #define VLC_OP_MOVE         0x02
66 #define VLC_OP_MOVE_REL     0x03
67 #define VLC_OP_LINE         0x04
68 #define VLC_OP_LINE_REL     0x05
69 #define VLC_OP_QUAD         0x06
70 #define VLC_OP_QUAD_REL     0x07
71 #define VLC_OP_CUBIC        0x08
72 #define VLC_OP_CUBIC_REL    0x09
73 #define VLC_OP_SCCWARC      0x0A
74 #define VLC_OP_SCCWARC_REL  0x0B
75 #define VLC_OP_SCWARC       0x0C
76 #define VLC_OP_SCWARC_REL   0x0D
77 #define VLC_OP_LCCWARC      0x0E
78 #define VLC_OP_LCCWARC_REL  0x0F
79 #define VLC_OP_LCWARC       0x10
80 #define VLC_OP_LCWARC_REL   0x11
81 
82 /* Macros for path manipulating: See path definitions. "VLM" means "VGLite Macros" */
83 #define VLM_PATH_ENABLE_UPLOAD(path)    (path).uploaded.property |= 1
84 #define VLM_PATH_DISABLE_UPLOAD(path)   (path).uploaded.property &= (~1)
85 #define VLM_PATH_GET_UPLOAD_BIT(path)   ((path).uploaded.property & 1)
86 
87 /* Types ***********************************************************************************************************************/
88 
89 #ifndef VG_LITE_ERROR
90 #define VG_LITE_ERROR  1
91     /*!
92      @abstract Error codes that the vg_lite functions can return.
93 
94      @discussion
95      All API functions return a status code. On success, <code>VG_LITE_SUCCESS</code> will be returned when a function is
96      successful. This value is set to zero, so if any function returns a non-zero value, an error has occured.
97      */
98     typedef enum vg_lite_error
99     {
100         VG_LITE_SUCCESS = 0,        /*! Success. */
101         VG_LITE_INVALID_ARGUMENT,   /*! An invalid argument was specified. */
102         VG_LITE_OUT_OF_MEMORY,      /*! Out of memory. */
103         VG_LITE_NO_CONTEXT,         /*! No context or an unintialized context specified. */
104         VG_LITE_TIMEOUT,            /*! A timeout has occured during a wait. */
105         VG_LITE_OUT_OF_RESOURCES,   /*! Out of system resources. */
106         VG_LITE_GENERIC_IO,         /*! Cannot communicate with the kernel driver. */
107         VG_LITE_NOT_SUPPORT,        /*! Function call not supported. */
108         VG_LITE_MULTI_THREAD_FAIL,  /*! Multi-thread/tasks fail. */
109         VG_LITE_ALREADY_EXISTS,     /*! Object already exists */
110         VG_LITE_NOT_ALIGNED,        /*! Data alignment error */
111     }
112     vg_lite_error_t;
113 #endif
114 
115     /*!
116      @abstract The floating point type used by the VGLite API.
117      */
118     typedef float vg_lite_float_t;
119 
120     /*!
121      @abstract A 32-bit color value used by the VGLite API.
122 
123      @discussion
124      The color value specifies the color used in various functions. The color is formed using 8-bit RGBA channels. The red channel
125      is in the lower 8-bit of the color value, followed by the green and blue channels. The alpha channel is in the upper 8-bit of
126      the color value.
127 
128      For L8 target formats, the RGB color is converted to L8 by using the default ITU-R BT.709 conversion rules.
129      */
130     typedef uint32_t vg_lite_color_t;
131 
132 /* Enumerations ***********************************************************************************************************************/
133 
134     /*!
135      @abstract Quality enumeration for a given path.
136 
137      @discussion
138      Each path should specify a quality hint for the hardware. The path generation tool will generate the quality hint based on the
139      complexity of the path.
140      */
141     typedef enum vg_lite_quality {
142         VG_LITE_HIGH,   /*! High quality 16x anti-aliasing path. */
143         VG_LITE_UPPER,  /*! Upper quality 8x anti-aliasing path. */
144         VG_LITE_MEDIUM, /*! Medium quality 4x anti-aliasing path. */
145         VG_LITE_LOW,    /*! Low quality pat without any anti-aliasing. */
146     } vg_lite_quality_t;
147 
148     /*!
149      @abstract Format of path coordinates.
150 
151      @discussion
152      Each path can have a separate coordinate system. The path generation tool will find the most optimal coordinate system for any
153      given path based on its dimensions and input coordinates.
154      */
155     typedef enum vg_lite_format {
156         VG_LITE_S8,     /*! Signed 8-bit coordinates. */
157         VG_LITE_S16,    /*! Signed 16-bit coordinates. */
158         VG_LITE_S32,    /*! Signed 32-bit coordinates. */
159         VG_LITE_FP32,   /*! 32-bit floating point coordinates. */
160     } vg_lite_format_t;
161 
162     /*!
163      @abstract Format of a buffer.
164 
165      @discussion
166      The pixel type for a <code>vg_lite_buffer_t</code> structure.
167      */
168     typedef enum vg_lite_buffer_format {
169         VG_LITE_RGBA8888,   /*! 32-bit RGBA format with 8 bits per color channel. Red is in bits 7:0, green in bits 15:8, blue in
170                              bits 23:16, and the alpha channel is in bits 31:24. */
171         VG_LITE_BGRA8888,   /*! 32-bit RGBA format with 8 bits per color channel. Red is in bits 23:16, green in bits 15:8, blue in
172                              bits 7:0, and the alpha channel is in bits 31:24. */
173         VG_LITE_RGBX8888,   /*! 32-bit RGBX format with 8 bits per color channel. Red is in bits 7:0, green in bits 15:8, blue in
174                              bits 23:16, and the x channel is in bits 31:24. */
175         VG_LITE_BGRX8888,   /*! 32-bit RGBX format with 8 bits per color channel. Red is in bits 23:16, green in bits 15:8, blue in
176                              bits 7:0, and the x channel is in bits 31:24. */
177         VG_LITE_RGB565,     /*! 16-bit RGB format with 5 and 6 bits per color channel. Red is in bits 4:0, green in bits 10:5, and
178                              the blue color channel is in bits 15:11. */
179         VG_LITE_BGR565,     /*! 16-bit RGB format with 5 and 6 bits per color channel. Red is in bits 15:11, green in bits 10:5,
180                              and the blue color channel is in bits 4:0. */
181         VG_LITE_RGBA4444,   /*! 16-bit RGBA format with 4 bits per color channel. Red is in bits 3:0, green in bits 7:4, blue in
182                              bits 11:8 and the alpha channel is in bits 15:12. */
183         VG_LITE_BGRA4444,   /*! 16-bit RGBA format with 4 bits per color channel. Red is in bits 11:8, green in bits 7:4, blue in
184                              bits 3:0 and the alpha channel is in bits 15:12. */
185         VG_LITE_BGRA5551,   /*! 16-bit RGBA format with 4 bits per color channel. Red is in bits 14:10, green in bits 9:5, blue in
186                              bits 4:0 and the alpha channel is in bit 15:15. */
187         VG_LITE_A4,         /*! 4-bit alpha format. There are no RGB values. */
188         VG_LITE_A8,         /*! 8-bit alpha format. There are no RGB values. */
189         VG_LITE_L8,         /*! 8-bit luminance value. There is no alpha value. */
190         VG_LITE_YUYV,       /*! Packed YUV format, 32-bit for 2 pixels. Y0 is in bits 7:0 and V is in bits 31:23. */
191 
192         VG_LITE_YUY2,       /*! New formats. */
193         VG_LITE_NV12,
194         VG_LITE_ANV12,
195         VG_LITE_AYUY2,
196 
197         VG_LITE_YV12,
198         VG_LITE_YV24,
199         VG_LITE_YV16,
200         VG_LITE_NV16,
201 
202         VG_LITE_YUY2_TILED,  /*! Tiled YUV formats. */
203         VG_LITE_NV12_TILED,
204         VG_LITE_ANV12_TILED,
205         VG_LITE_AYUY2_TILED,
206 
207         VG_LITE_INDEX_1 = 100,    /*! Indexed format. */
208         VG_LITE_INDEX_2,
209         VG_LITE_INDEX_4,
210         VG_LITE_INDEX_8,
211 
212         VG_LITE_RGBA2222,      /*! 8-bit RGBA format with 2 bits per color channel.Red is in bits 1:0,green in bits 3:2,blue in
213                                bits 5:4 and the alpha channel is in bits 7:6*/
214         VG_LITE_BGRA2222,      /*! 8-bit RGBA format with 2 bits per color channel.Blue is in bits 1:0,green in bits 3:2,red in
215                                bits 5:4 and the alpha channel is in bits 7:6*/
216         VG_LITE_ABGR2222,      /*! 8-bit RGBA format with 2 bits per color channel.Alpha is in bits 1:0,blue in bits 3:2,green in
217                                bits 5:4 and the red channel is in bits 7:6*/
218         VG_LITE_ARGB2222,      /*! 8-bit RGBA format with 2 bits per color channel.Alpha is in bits 1:0,red in bits 3:2,green in
219                                bits 5:4 and the blue channel is in bits 7:6*/
220         VG_LITE_ABGR4444,      /*! 16-bit RGBA format with 4 bits per color channel. Alpha is in bits 3:0, blue in bits 7:4, green in
221                                bits 11:8 and the red channel is in bits 15:12. */
222         VG_LITE_ARGB4444,      /*! 16-bit RGBA format with 4 bits per color channel. Alpha is in bits 3:0, red in bits 7:4, green in
223                                bits 11:8 and the blue channel is in bits 15:12. */
224         VG_LITE_ABGR8888,      /*! 32-bit RGBA format with 8 bits per color channel. Alpha is in bits 7:0, blue in bits 15:8, green in
225                                bits 23:16, and the red channel is in bits 31:24. */
226         VG_LITE_ARGB8888,      /*! 32-bit RGBA format with 8 bits per color channel. Alpha is in bits 7:0, red in bits 15:8, green in
227                                bits 23:16, and the blue channel is in bits 31:24. */
228         VG_LITE_ABGR1555,      /*! 16-bit RGBA format with 4 bits per color channel. Red is in bits 15:11, green in bits 10:6, blue in
229                                bits 5:1 and the alpha channel is in bit 0:0. */
230         VG_LITE_RGBA5551,      /*! 16-bit RGBA format with 4 bits per color channel. Blue is in bits 14:10, green in bits 9:5, red in
231                                bits 4:0 and the alpha channel is in bit 15:15. */
232         VG_LITE_ARGB1555,      /*! 16-bit RGBA format with 4 bits per color channel. Blue is in bits 15:11, green in bits 10:6, red in
233                                bits 5:1 and the alpha channel is in bit 0:0. */
234         VG_LITE_XBGR8888,      /*! 32-bit RGBX format with 8 bits per color channel. X channel is in bits 7:0, blue in bits 15:8, green in
235                                bits 23:16, and the red is in bits 31:24. */
236         VG_LITE_XRGB8888       /*! 32-bit RGBX format with 8 bits per color channel. X channel is in bits 7:0, red in bits 15:8, green in
237                                bits 23:16, and the blue is in bits 31:24. */
238     } vg_lite_buffer_format_t;
239 
240     /*!
241      @abstract Swizzle of packed YUV format UV channels.
242 
243      @discussion
244      The swizzle of packed YUV format UV channels.
245      */
246     typedef enum vg_lite_swizzle {
247         VG_LITE_SWIZZLE_UV,
248         VG_LITE_SWIZZLE_VU,
249     } vg_lite_swizzle_t;
250 
251     /*!
252      @abstract The YUV<->RGB conversion rule.
253 
254      @discussion
255      Indicate the rule how to convert rgb and yuv colors.
256      */
257     typedef enum vg_lite_yuv2rgb {
258         VG_LITE_YUV601,
259         VG_LITE_YUV709,
260     } vg_lite_yuv2rgb_t;
261 
262     /*!
263      @abstract The pixel layout in a buffer.
264 
265      @discussion
266      Pixels in a buffer may be tiled  or linear.
267      */
268     typedef enum vg_lite_buffer_layout {
269         VG_LITE_LINEAR,
270         VG_LITE_TILED,
271     } vg_lite_buffer_layout_t;
272 
273     /*!
274      @abstract The image (buffer) rendering mode.
275 
276      @discussion
277      This defines how an image are rendered onto a buffer. There are 3 modes.
278      */
279     typedef enum vg_lite_buffer_image_mode {
280         VG_LITE_NORMAL_IMAGE_MODE,
281         VG_LITE_NONE_IMAGE_MODE,
282         VG_LITE_MULTIPLY_IMAGE_MODE
283     } vg_lite_buffer_image_mode_t;
284 
285     /*!
286      @abstract The image (buffer) transparency mode.
287      OPAQUE, All image pixels are copied to the VGPE for rasterization;
288      TRANSPARENT,Only the non-transparent image pixels are copied to the VGPE.
289      Note: This mode is valid when IMAGE_MODE(vg_lite_buffer_image_mode_t) isn't NONE.
290      */
291     typedef enum vg_lite_buffer_transparency_mode {
292         VG_LITE_IMAGE_OPAQUE,
293         VG_LITE_IMAGE_TRANSPARENT
294     } vg_lite_buffer_transparency_mode_t;
295 
296     typedef struct vg_lite_yuvinfo {
297         vg_lite_swizzle_t   swizzle;        /* UV swizzle. */
298         vg_lite_yuv2rgb_t   yuv2rgb;        /* 601 or 709 conversion standard. */
299         uint32_t            uv_planar;      /* UV(U) planar address. */
300         uint32_t            v_planar;       /* V planar address. */
301         uint32_t            alpha_planar;   /* Alpha planar address. */
302         uint32_t            uv_stride;      /* UV(U) stride. */
303         uint32_t            v_stride;       /* V stride. */
304         uint32_t            alpha_stride;   /* Alpha stride. */
305         uint32_t            uv_height;      /* UV(U) height. */
306         uint32_t            v_height;       /* V height. */
307         void *              uv_memory;      /* The logical pointer to the UV(U) planar memory. */
308         void *              v_memory;       /* The logical pointer to the V planar memory. */
309         void *              uv_handle;      /* The memory handle of the UV(U) planar. */
310         void *              v_handle;       /* The memory handle of the V planar. */
311     } vg_lite_yuvinfo_t;
312 
313     /*!
314      @abstract Blending modes.
315 
316      @discussion
317      Some of the VGLite API functions calls support blending. S and D represent source and destination color channels and Sa and Da
318      represent the source and destination alpha channels.
319      */
320     typedef enum vg_lite_blend {
321         VG_LITE_BLEND_NONE,     /*! S, i.e. no blending. */
322         VG_LITE_BLEND_SRC_OVER, /*! S + (1 - Sa) * D */
323         VG_LITE_BLEND_DST_OVER, /*! (1 - Da) * S + D */
324         VG_LITE_BLEND_SRC_IN,   /*! Da * S */
325         VG_LITE_BLEND_DST_IN,   /*! Sa * D */
326         VG_LITE_BLEND_SCREEN,   /*! S + D - S * D */
327         VG_LITE_BLEND_MULTIPLY, /*! S * (1 - Da) + D * (1 - Sa) + S * D */
328         VG_LITE_BLEND_ADDITIVE, /*! S + D */
329         VG_LITE_BLEND_SUBTRACT, /*! D * (1 - S) */
330     } vg_lite_blend_t;
331 
332     /*!
333      @abstract Fill rules.
334 
335      @discussion
336      For drawing any path, the hardware supports both non-zero and odd-even fill rules.
337 
338      To determine whether any point is contained inside an object, imagine drawing a line from that point out to infinity in any
339      direction such that the line does not cross any vertex of the path. For each edge that is crossed by the line, add 1 to the
340      counter if the edge crosses from left to right, as seen by an observer walking across the line towards infinity, and subtract 1
341      if the edge crosses from right to left. In this way, each region of the plane will receive an integer value.
342 
343      The non-zero fill rule says that a point is inside the shape if the resulting sum is not equal to zero. The even/odd rule says
344      that a point is inside the shape if the resulting sum is odd, regardless of sign.
345      */
346     typedef enum vg_lite_fill {
347         VG_LITE_FILL_NON_ZERO,  /*! Non-zero fill rule. A pixel is drawn if it crosses at least one path pixel. */
348         VG_LITE_FILL_EVEN_ODD,  /*! Even-odd fill rule. A pixel is drawn it it crosses an odd number of path pixels. */
349     } vg_lite_fill_t;
350 
351     /* Chip features. */
352     typedef enum vg_lite_feature
353     {
354         gcFEATURE_BIT_VG_IM_INDEX_FORMAT,
355         gcFEATURE_BIT_VG_PE_PREMULTIPLY,
356         gcFEATURE_BIT_VG_BORDER_CULLING,
357         gcFEATURE_BIT_VG_RGBA2_FORMAT,
358         gcFEATURE_BIT_VG_QUALITY_8X,
359         gcFEATURE_BIT_VG_RADIAL_GRADIENT,
360         gcFEATURE_BIT_VG_LINEAR_GRADIENT_EXT,
361         gcFEATURE_BIT_VG_COLOR_KEY,
362         gcFEATURE_BIT_VG_DITHER,
363         /* Insert features above this comment only. */
364         gcFEATURE_COUNT         /* Not a feature. */
365     }
366     vg_lite_feature_t;
367 
368     /* Filter modes. */
369     typedef enum vg_lite_filter
370     {
371         VG_LITE_FILTER_POINT     = 0,       /* Only the nearest image pixel is fetched. */
372         VG_LITE_FILTER_LINEAR    = 0x10000, /* Used for linear paint. */
373         VG_LITE_FILTER_BI_LINEAR = 0x20000, /* Use a 2x2 box around the image pixel and perform an interpolation. */
374     } vg_lite_filter_t;
375 
376     /* Pattern padding mode. */
377     typedef enum vg_lite_pattern_mode
378     {
379         VG_LITE_PATTERN_COLOR = 0,
380         VG_LITE_PATTERN_PAD,
381     } vg_lite_pattern_mode_t;
382 
383     /* radial gradient padding mode. */
384     typedef enum {
385       VG_LITE_RADIAL_GRADIENT_SPREAD_FILL = 0,
386       VG_LITE_RADIAL_GRADIENT_SPREAD_PAD,
387       VG_LITE_RADIAL_GRADIENT_SPREAD_REPEAT,
388       VG_LITE_RADIAL_GRADIENT_SPREAD_REFLECT,
389     } vg_lite_radial_gradient_spreadmode_t;
390 
391     /* draw path type. */
392     typedef enum vg_lite_draw_path_type{
393       VG_LITE_DRAW_FILL_PATH = 0, /*! draw fill path. */
394       VG_LITE_DRAW_STROKE_PATH,   /*! draw stroke path. */
395       VG_LITE_DRAW_FILL_STROKE_PATH, /*! draw both fill and stroke path. */
396     } vg_lite_draw_path_type_t;
397 
398     /* End cap style. */
399     typedef enum vg_lite_cap_style
400     {
401         VG_LITE_CAP_BUTT,  /*! The Butt end cap style terminates each segment with a line perpendicular to the tangent at each endpoint. */
402         VG_LITE_CAP_ROUND, /*! The Round end cap style appends a semicircle with a diameter equal to the line width centered around each endpoint. */
403         VG_LITE_CAP_SQUARE /*! The Square end cap style appends a rectangle with two sides of length equal to the line width
404                                perpendicular to the tangent, and two sides of length equal to half the line width parallel
405                                to the tangent, at each endpoint. */
406     }
407     vg_lite_cap_style_t;
408 
409     /* Line join styles. */
410     typedef enum vg_lite_join_style
411     {
412         VG_LITE_JOIN_MITER,/*! The Miter join style appends a trapezoid with one vertex at the intersection point of the two original
413                            lines, two adjacent vertices at the outer endpoints of the two “fattened” lines and a fourth vertex at
414                            the extrapolated intersection point of the outer perimeters of the two “fattened” lines. */
415         VG_LITE_JOIN_ROUND,/*! The Round join style appends a wedge-shaped portion of a circle,centered at the intersection point
416                            of the two original lines, having a radius equal to half the line width. */
417         VG_LITE_JOIN_BEVEL /*! The Bevel join style appends a triangle with two vertices at the outer endpoints of the two "fattened"
418                            lines and a third vertex at the intersection point of the two original lines. */
419     }
420     vg_lite_join_style_t;
421 
422 /* Structures *******************************************************************************************************************/
423 
424     typedef struct vg_lite_path_point *        vg_lite_path_point_ptr;
425     typedef struct vg_lite_path_point
426     {
427         /* X coordinate. */
428         vg_lite_float_t                      x;
429 
430         /* Y coordinate. */
431         vg_lite_float_t                      y;
432 
433         /* Flatten flag for flattened path. */
434         uint8_t                              flatten_flag;
435 
436         /* Curve type for stroke path. */
437         uint8_t                              curve_type;
438 
439         /* X tangent. */
440         vg_lite_float_t                      tangentX;
441 
442         /* Y tangent. */
443         vg_lite_float_t                      tangentY;
444 
445         /* Length of the line. */
446         vg_lite_float_t                      length;
447 
448         /* Pointer to next point node. */
449         vg_lite_path_point_ptr               next;
450 
451         /* Pointer to previous point node. */
452         vg_lite_path_point_ptr               prev;
453 
454     }vg_lite_path_point_t;
455 
456     typedef struct vg_lite_sub_path *    vg_lite_sub_path_ptr;
457     typedef struct vg_lite_sub_path
458     {
459         /* Pointer to next sub path. */
460         vg_lite_sub_path_ptr             next;
461 
462         /* Number of points. */
463         uint32_t                         point_count;
464 
465         /* Point list. */
466         vg_lite_path_point_ptr           point_list;
467 
468         /* Last point. */
469         vg_lite_path_point_ptr           last_point;
470 
471         /* Whether is path is closed. */
472         uint8_t                          closed;
473 
474         /* Sub path length. */
475         vg_lite_float_t                  length;
476     }
477     vg_lite_sub_path_t;
478 
479     typedef struct vg_lite_stroke_conversion
480     {
481         /* Stroke parameters */
482         vg_lite_cap_style_t                stroke_cap_style;
483         vg_lite_join_style_t               stroke_join_style;
484         vg_lite_float_t                    stroke_line_width;
485         vg_lite_float_t                    stroke_miter_limit;
486         vg_lite_float_t *                  stroke_dash_pattern;
487         uint32_t                           stroke_dash_pattern_count;
488         vg_lite_float_t                    stroke_dash_phase;
489         vg_lite_float_t                    stroke_dash_initial_length;
490         uint32_t                           stroke_dash_initial_index;
491 
492         vg_lite_float_t                    half_line_width;
493 
494         /* Total length of stroke dash patterns. */
495         vg_lite_float_t                    stroke_dash_pattern_length;
496 
497         /* For fast checking. */
498         vg_lite_float_t                    stroke_miter_limit_square;
499 
500         /* Temp storage of stroke subPath. */
501         vg_lite_path_point_ptr             path_point_list;
502         vg_lite_path_point_ptr             path_last_point;
503         uint32_t                           point_count;
504         vg_lite_path_point_ptr             left_stroke_point;
505         vg_lite_path_point_ptr             last_right_stroke_point;
506         vg_lite_path_point_ptr             stroke_point_list;
507         vg_lite_path_point_ptr             stroke_last_point;
508         uint32_t                           stroke_point_count;
509 
510         /* Sub path list. */
511         vg_lite_sub_path_ptr               stroke_sub_path_list;
512 
513         /* Last sub path. */
514         vg_lite_sub_path_ptr               last_stroke_sub_path;
515 
516         /* Swing area handling. */
517         uint8_t                            swing_need_to_handle;
518         uint32_t                           swing_handling;
519         uint8_t                            swing_counter_clockwise;
520         vg_lite_float_t                    swing_stroke_deltax;
521         vg_lite_float_t                    swing_stroke_deltay;
522         vg_lite_path_point_ptr             swing_start_point;
523         vg_lite_path_point_ptr             swing_start_stroke_point;
524         vg_lite_float_t                    swing_accu_length;
525         vg_lite_float_t                    swing_center_length;
526         uint32_t                           swing_count;
527 
528         vg_lite_float_t                    stroke_path_length;
529         uint32_t                           stroke_path_size;
530         /* The stroke line is fat line. */
531         uint8_t                            is_fat;
532         uint8_t                            closed;
533     }
534     vg_lite_stroke_conversion_t;
535 
536     /* A 2D Point definition. */
537     typedef struct vg_lite_point {
538         int x;
539         int y;
540     }
541     vg_lite_point_t;
542 
543     /* Four 2D Point that form a polygon */
544     typedef vg_lite_point_t vg_lite_point4_t[4];
545 
546     /* This structure is used to query VGLite driver information */
547     typedef struct vg_lite_info {
548         uint32_t  api_version;          /*! VGLite API version. */
549         uint32_t  header_version;       /*! VGLite API header version. */
550         uint32_t  release_version;      /*! VGLite release version. */
551         uint32_t  reserved;             /*! Reserved for future use. */
552     } vg_lite_info_t;
553 
554     /*!
555      @abstract A 3x3 matrix.
556 
557      @discussion
558      For those functions that need a matrix, this is the structure that defines it. The contents are a simple 3x3 matrix
559      consisting of floating pointer numbers.
560      */
561     typedef struct vg_lite_matrix {
562         vg_lite_float_t m[3][3];    /*! The 3x3 matrix itself, in [row][column] order. */
563     } vg_lite_matrix_t;
564 
565     /*!
566      @abstract A wrapper structure for any image or render target.
567 
568      @discussion
569      Each piece of memory, whether it is an image used as a source or a buffer used as a target, requires a structure to define it.
570      This structure contains all the information the VGLite API requires to access the buffer's memory by the hardware.
571      */
572     typedef struct vg_lite_buffer {
573         int32_t width;                  /*! Width of the buffer in pixels. */
574         int32_t height;                 /*! Height of the buffer in pixels. */
575         int32_t stride;                 /*! The number of bytes to move from one line in the buffer to the next line. */
576         vg_lite_buffer_layout_t tiled;  /*! Indicating the buffer memory layout is linear or tiled. */
577         vg_lite_buffer_format_t format; /*! The pixel format of the buffer. */
578         void * handle;                  /*! The memory handle of the buffer's memory as allocated by the VGLite kernel. */
579         void * memory;                  /*! The logical pointer to the buffer's memory for the CPU. */
580         uint32_t address;               /*! The address to the buffer's memory for the hardware. */
581         vg_lite_yuvinfo_t       yuv;    /*! The yuv format details. */
582         vg_lite_buffer_image_mode_t image_mode;             /*! The blit image mode. */
583         vg_lite_buffer_transparency_mode_t transparency_mode;  /*image transparency mode*/
584     } vg_lite_buffer_t;
585 
586     /* This structure simply records the memory allocation info by kernel. */
587     typedef struct vg_lite_hw_memory {
588         void    * handle;               /*! gpu memory object handle. */
589         void    * memory;               /*! logical memory address. */
590         uint32_t  address;              /*! GPU memory address. */
591         uint32_t  bytes;                /*! Size of memory. */
592         uint32_t  property;             /*! Currently bit0 is used for path upload:
593                                          1 to enable auto path data uploading;
594                                          0 to disable path data uploading (always embedded into command buffer).
595                                          */
596     } vg_lite_hw_memory_t;
597 
598     /*!
599      @abstract A path used by the drawing command.
600 
601      @discussion
602      Each path needs a few parameters. This structure defines those parameters, so the VGLite driver knows the detail of a path.
603      */
604     typedef struct vg_lite_path {
605         vg_lite_float_t bounding_box[4];    /*! Bounding box specified as left, top, right, and bottom. */
606         vg_lite_quality_t quality;          /*! Quality hint for the path. */
607         vg_lite_format_t format;            /*! Coordinate format. */
608         vg_lite_hw_memory_t uploaded;       /*! Path data that has been upload into GPU addressable memory. */
609         int32_t path_length;                /*! Number of bytes in the path data. */
610         void *path;                         /*! Pointer to the physical description of the path. */
611         int8_t path_changed;               /* Indicate whether path data is synced with command buffer (uploaded) or not. */
612         int8_t pdata_internal;             /*! Indicate whether path data memory is allocated by driver. */
613         vg_lite_stroke_conversion_t *stroke_conversion; /*! Refer to the definition by <code>vg_lite_stroke_conversion_t</code>.*/
614         vg_lite_draw_path_type_t path_type;            /*! Refer to the definition by <code>vg_lite_draw_path_type_t</code>. */
615         void *stroke_path_data;            /*! Pointer to the physical description of the stroke path. */
616         int32_t stroke_path_size;          /*! Number of bytes in the stroke path data. */
617         vg_lite_color_t stroke_color;      /*! The stroke path fill color.Refer to the definition by <code>vg_lite_color_t</code>.*/
618     } vg_lite_path_t;
619 
620     /*!
621      @abstract A rectangle.
622 
623      @discussion
624      A rectangle defines a rectangular definition of the screen.
625      */
626     typedef struct vg_lite_rectangle {
627         int32_t x;      /*! Left coordinate of the rectangle. */
628         int32_t y;      /*! Top coordinate of the rectangle. */
629         int32_t width;  /*! Width of the rectangle. */
630         int32_t height; /*! Height of the rectangle. */
631     } vg_lite_rectangle_t;
632 
633     /*!
634      @abstract Tessellation buffer information.
635 
636      @discussion
637      The tessellation buffer information for access.
638      */
639     typedef struct vg_lite_tsbuffer_info {
640         uint32_t tessellation_buffer_gpu[3];        /*! HW physical address. */
641         uint8_t *tessellation_buffer_logic[3];      /*! Logical address. */
642         uint32_t tessellation_buffer_size[3];       /*! Buffer size for tessellation buffer, l1, l2. */
643         uint32_t tessellation_stride;               /*! Buffer stride. */
644         uint32_t tessellation_width_height;         /*! Combination of buffer width and height. */
645         uint32_t tessellation_shift;                /*! Tessellation config: shift. */
646         uint32_t tessellation_origin[2];
647     } vg_lite_tsbuffer_info_t;
648 
649     /* Linear Gradient definitions. */
650 #define VLC_MAX_GRAD            16              /*! The max number of gradient stops. */
651 #define VLC_GRADBUFFER_WIDTH    256             /*! The internal buffer width.*/
652 
653     /*!
654      @abstract Linear gradient definition.
655 
656      @discussion
657      Linear gradient is applied to filling a path. It will generate a 256x1 image according the settings.
658      */
659     typedef struct vg_lite_linear_gradient {
660         uint32_t colors[VLC_MAX_GRAD];      /*! Colors for stops. */
661         uint32_t count;                     /*! Count of colors, up to 16. */
662         uint32_t stops[VLC_MAX_GRAD];       /*! Color stops, value from 0 to 255. */
663         vg_lite_matrix_t matrix;            /*! The matrix to transform the gradient. */
664         vg_lite_buffer_t image;             /*! The image for rendering as gradient pattern. */
665     } vg_lite_linear_gradient_t;
666 
667     /* radial Gradient definitions. */
668 #define MAX_COLOR_RAMP_STOPS            256              /*! The max number of radial gradient stops. */
669 
670     /*!
671      @abstract color ramp definition.
672 
673      @discussion
674      This is the stop for the radial gradient.The number of parameters is 5,and give the offset and
675      color of the stop.Each stop is defined by a floating-point offset value and four floating-point values
676      containing the sRGBA color and alpha value associated with each stop, in the form of a non-premultiplied
677      (R, G, B, alpha) quad.And the range of all parameters in it is [0,1].[0,1] of the color channel value is
678      mapped to [0,255].
679      */
680     typedef struct vg_lite_color_ramp
681     {
682         vg_lite_float_t stop;        /* Value for the color stop. */
683         vg_lite_float_t red;         /* Red color channel value for the color stop. */
684         vg_lite_float_t green;       /* Green color channel value for the color stop. */
685         vg_lite_float_t blue;        /* Blue color channel value for the color stop. */
686         vg_lite_float_t alpha;       /* Alpha color channel value for the color stop. */
687     }
688     vg_lite_color_ramp_t, *vg_lite_color_ramp_ptr;
689 
690     typedef struct vg_lite_radial_gradient_parameter
691     {
692         vg_lite_float_t cx;        /* the x coordinate of the center point. */
693         vg_lite_float_t cy;        /* the y coordinate of the center point. */
694         vg_lite_float_t r;         /* the radius. */
695         vg_lite_float_t fx;        /* the x coordinate of the focal point. */
696         vg_lite_float_t fy;        /* the y coordinate of the focal point. */
697     }
698     vg_lite_radial_gradient_parameter_t;
699 
700     /*!
701      @abstract radial gradient definition.
702 
703      @discussion
704      radial gradient is applied to filling a path.
705      */
706     typedef struct vg_lite_radial_gradient {
707         uint32_t count;                     /*! Count of colors, up to 256. */
708         vg_lite_matrix_t matrix;            /*! The matrix to transform the gradient. */
709         vg_lite_buffer_t image;             /*! The image for rendering as gradient pattern. */
710         vg_lite_radial_gradient_parameter_t radialGradient;      /* include center point,focal point and radius.*/
711         vg_lite_radial_gradient_spreadmode_t SpreadMode;    /* The tiling mode that applied to the pixels out of the image after transformed. */
712 
713         uint32_t vgColorRampLength;         /* Color ramp parameters for gradient paints provided to the driver. */
714         vg_lite_color_ramp_t vgColorRamp[MAX_COLOR_RAMP_STOPS];
715 
716         uint32_t intColorRampLength;        /* Converted internal color ramp. */
717         vg_lite_color_ramp_t intColorRamp[MAX_COLOR_RAMP_STOPS + 2];
718 
719         uint8_t colorRampPremultiplied;     /* if this value is set to 1,the color value of vgColorRamp will multiply by alpha value of vgColorRamp.*/
720     } vg_lite_radial_gradient_t;
721 
722     /*!
723      @abstract linear gradient parameter definition.
724 
725      @discussion
726      The line connecting point (X0,Y0) to point (X1,Y1) is the radial direction of the linear gradient.
727      This radial direction line called line0,the line perpendicular to line0 and passing through the point (X0,Y0)
728      called line1,the line perpendicular to line0 and passing through the point (X1,Y1) called line2,the linear gradient
729      starts form line1 and end to line2.
730      */
731     typedef struct vg_lite_linear_gradient_parameter
732     {
733         vg_lite_float_t X0;
734         vg_lite_float_t Y0;
735         vg_lite_float_t X1;
736         vg_lite_float_t Y1;
737     }
738     vg_lite_linear_gradient_parameter_t;
739 
740     /*!
741      @abstract linear gradient definition.
742 
743      @discussion
744      linear gradient is applied to filling a path.vg_lite_linear_gradient_ext and vg_lite_linear_gradient for hardware and software implementation
745      of linear gradient respectively.
746      */
747     typedef struct vg_lite_linear_gradient_ext {
748         uint32_t count;                     /*! Count of colors, up to 256. */
749         vg_lite_matrix_t matrix;            /*! The matrix to transform the gradient. */
750         vg_lite_buffer_t image;             /*! The image for rendering as gradient pattern. */
751         vg_lite_linear_gradient_parameter_t linear_gradient;      /* Refer to the definition by <code>vg_lite_linear_gradient_parameter_t</code>.*/
752 
753         uint32_t vg_color_ramp_length;         /* Color ramp parameters for gradient paints provided to the driver. */
754         vg_lite_color_ramp_t vg_color_ramp[MAX_COLOR_RAMP_STOPS];
755 
756         uint32_t int_color_ramp_length;        /* Converted internal color ramp. */
757         vg_lite_color_ramp_t int_color_ramp[MAX_COLOR_RAMP_STOPS + 2];
758 
759         uint8_t color_ramp_premultiplied;     /* if this value is set to 1,the color value of vgColorRamp will multiply by alpha value of vgColorRamp.*/
760         vg_lite_radial_gradient_spreadmode_t spread_mode;    /* Use tge same spread mode enumeration type as radial gradient. */
761     } vg_lite_linear_gradient_ext_t;
762 
763     /*!
764      @abstract color key definition.
765 
766      @discussion
767      The colorkey have two sections,each section contain R,G,B chanels.Debited as hign_rgb and low_rgb respectively.
768      Can be used for blit operation or draw_pattern operation.when enable is ture,the alpha value is used to replace
769      the alpha channel of destination pixel when its RGB channels in range [low_rgb,hign_rgb].After use color key this
770      frame,and if the color key is not need in the next frame,disable the color key before next frame.
771      */
772     typedef struct vg_lite_color_key
773     {
774         uint8_t enable;        /* when enable is ture,this color key is effective. */
775         uint8_t low_r;         /* The R chanel of low_rgb. */
776         uint8_t low_g;         /* The G chanel of low_rgb. */
777         uint8_t low_b;         /* The B chanel of low_rgb. */
778         uint8_t alpha;         /* The alpha channel to replace destination pixel alpha channel.*/
779         uint8_t hign_r;        /* The R chanel of hign_rgb. */
780         uint8_t hign_g;        /* The G chanel of hign_rgb. */
781         uint8_t hign_b;        /* The B chanel of hign_rgb. */
782     } vg_lite_color_key_t;
783 
784     /*!
785      @abstract colorkey definition.
786 
787      @discussion
788      There are 4 groups of color key states.
789      rgb_hi_0, rgb_lo_0, alpha_0, enable_0;
790      rgb_hi_1, rgb_lo_1, alpha_1, enable_1;
791      rgb_hi_2, rgb_lo_2, alpha_2, enable_2;
792      rgb_hi_3, rgb_lo_3, alpha_3, enable_3;
793      Priority order:color_key_0 > color_key_1 > color_key_2 > color_key_3.
794     */
795     typedef vg_lite_color_key_t vg_lite_color_key4_t[4];
796 
797 /* API Function prototypes *****************************************************************************************************/
798 
799     /*!
800      @abstract Get a 3*3 homogenous transform matrix by source coordinates and target coordinates.
801 
802      @param src
803      Pointer to the four 2D points that form a source polygon.
804 
805      @param dst
806      Pointer to the four 2D points that form a destination polygon.
807 
808      @param mat
809      Output parameter,pointer to 3*3 homogenous matrix that transform source polygon to destination polygon.
810 
811      @result
812      Returns the status as defined by <code>vg_lite_error_t</code>.
813      */
814     vg_lite_error_t vg_lite_get_transform_matrix(vg_lite_point4_t src, vg_lite_point4_t dst,vg_lite_matrix_t *mat);
815 
816     /*!
817      @abstract Allocate a buffer from hardware accessible memory.
818 
819      @discussion
820      In order for the hardware to access some memory, like a source image or a target buffer, it needs to be allocated first. The
821      supplied <code>vg_lite_buffer_t</code> structure needs to be initialized with the size (width and height) and format of the
822      requested buffer. If the stride is set to zero, this function will fill it in.
823 
824      This function will call the kernel to actually allocate the memory and the memory handle and logical and hardware addresses
825      will be filled in by the kernel.
826 
827      @param buffer
828      Pointer to the buffer that holds the size and format of the buffer being allocated.
829 
830      @result
831      Returns the status as defined by <code>vg_lite_error_t</code>.
832      */
833     vg_lite_error_t vg_lite_allocate(vg_lite_buffer_t *buffer);
834 
835     /*!
836      @abstract Free a buffer that was previously allocated by {@link vg_lite_allocate}.
837 
838      @discussion
839      Free any memory resources allocated by a previous call to {@link vg_lite_allocate}.
840 
841      @param buffer
842      Pointer to a buffer structure that was filled in by {@link vg_lite_allocate}.
843 
844      @result
845      Returns the status as defined by <code>vg_lite_error_t</code>.
846      */
847     vg_lite_error_t vg_lite_free(vg_lite_buffer_t *buffer);
848 
849     /*!
850      @abstract Upload the pixel data to the buffer object.
851 
852      @discussion
853      The function uploads the pixel data to the buffer object. According to the
854      buffer format, there are 3 planes' data at most (for YUV planars). Note that
855      the format of the data (pixel) to upload must be the same as described in
856      the buffer object. The input data memory pointers should be big enough to
857      hold all the data needed by the buffer.
858 
859      @param buffer
860      The image buffer object.
861 
862      @param data
863      Pixel data. For YUV format, it may be up to 3 pointers.
864 
865      @param stride
866      Stride for pixel data.
867 
868      @result
869      Any error status during uploading.
870      */
871     vg_lite_error_t vg_lite_buffer_upload(vg_lite_buffer_t  *buffer, uint8_t *data[3], uint32_t stride[3]);
872 
873     /*!
874      @abstract Map a buffer into hardware accessible address space.
875 
876      @discussion
877      If you want the use a frame buffer directly as an target buffer, you need to wrap a <code>vg_lite_buffer_t</code> structure
878      around it and call the kernel to map the supplied logical or physical address into hardware accessible memory.
879 
880      For example, if you know the logical address of the frame buffer, set the memory field of the vg_lite_buffer_t structure
881      with that address and call this function. If you know the physical address, set the memory field to <code>NULL</code> and
882      program the address field with the physical address.
883 
884      @param buffer
885      Pointer to the buffer that holds the size and format of the buffer being allocated. Either the memory or address field
886      needs to be set to a non-zero value to map either a logical or physical address into hardware accessible memory.
887 
888      @result
889      Returns the status as defined by <code>vg_lite_error_t</code>.
890      */
891     vg_lite_error_t vg_lite_map(vg_lite_buffer_t *buffer);
892 
893     /*!
894      @abstract Unmap a buffer that was previously mapped by {@link vg_lite_map}.
895 
896      @discussion
897      Free any memory resources allocated by a previous call to {@link vg_lite_map}.
898 
899      @param buffer
900      Pointer to a buffer structure that was filled in by {@link vg_lite_map}.
901 
902      @result
903      Returns the status as defined by <code>vg_lite_error_t</code>.
904      */
905     vg_lite_error_t vg_lite_unmap(vg_lite_buffer_t *buffer);
906 
907     /*!
908      @abstract Fill a (partial) buffer with a specified color.
909 
910      @discussion
911      Either an entire buffer or a partial rectangle of a buffer will be filled with a specific color.
912 
913      This function will wait until the hardware is complete, i.e. it is synchronous.
914 
915      @param target
916      Pointer to a <code>vg_lite_buffer_t</code> structure that describes the buffer to be filled.
917 
918      @param rectangle
919      Pointer to a rectangle that specifies the area to be filled. If <code>rectangle</code> is <code>NULL</code>, the entire target
920      buffer will be filled with the specified color.
921 
922      @param color
923      The color value to use for filling the buffer. If the buffer is in L8 format, the RGBA color will be converted into a
924      luminance value.
925 
926      @result
927      Returns the status as defined by <code>vg_lite_error_t</code>.
928      */
929     vg_lite_error_t vg_lite_clear(vg_lite_buffer_t *target,
930                                   vg_lite_rectangle_t *rectangle,
931                                   vg_lite_color_t color);
932 
933     /*!
934      @abstract Copy a source image to the the destination window with a specified matrix that can include translation, rotation,
935      scaling, and perspective correction.
936 
937      @discussion
938      A source image is copied to the target using the specified matrix. If the specified matrix is <code>NULL</code>, an identity
939      matrix is assumed, meaning the source will be copied directly on the target at 0,0 location.
940 
941      An optional blend mode can be specified that defines the blending of the source onto the target.
942 
943      Also, an optional mix color can be specified. The mix color will be multiplied by the source color. If you don't need a mix
944      color, set the <code>color</code> parameter to 0.
945 
946      Note that on hardware that doesn't support border scissoring (GC355) the blend mode will be forced to
947      <code>VG_LITE_BLEND_SRC_OVER</code> if rotation or perspective is involved.
948 
949      @param target
950      Pointer to a <code>vg_lite_buffer_t</code> structure that describes the target of the blit.
951 
952      @param source
953      Pointer to a <code>vg_lite_buffer_t</code> structure that describes the source of the blit.
954 
955      @param matrix
956      Pointer to a 3x3 matrix that defines the transformation matrix of source pixels into the target. If matrix is
957      <code>NULL</code>, an identity matrix is assumed.
958 
959      @param blend
960      The blending mode to be applied to each image pixel. If no blending is required, set this value to
961      <code>VG_LITE_BLEND_NONE</code> (0).
962 
963      @param color
964      If non-zero, this color value will be used as a mix color. The mix color gets multiplied with each source pixel before
965      blending happens.
966 
967      @param filter
968      The filter mode to be applied. If no filter mode is required, set this value to
969      <code>VG_LITE_FILTER_BI_LINEAR</code> (0x20000).
970 
971      @result
972      Returns the status as defined by <code>vg_lite_error_t</code>.
973      */
974     vg_lite_error_t vg_lite_blit(vg_lite_buffer_t *target,
975                                  vg_lite_buffer_t *source,
976                                  vg_lite_matrix_t *matrix,
977                                  vg_lite_blend_t blend,
978                                  vg_lite_color_t color,
979                                  vg_lite_filter_t filter);
980 
981     /* In additional to vg_lite_blit:
982     @brief
983     This API draws a porting of the image to the screen.
984 
985     @param
986     rect   The source rectangle to blit. rect[0]/[1]/[2]/[3] are x, y, width and height of the source rectangle. */
987     vg_lite_error_t vg_lite_blit_rect(vg_lite_buffer_t *target,
988         vg_lite_buffer_t *source,
989         uint32_t         *rect,
990         vg_lite_matrix_t *matrix,
991         vg_lite_blend_t   blend,
992         vg_lite_color_t   color,
993         vg_lite_filter_t  filter);
994 
995     /*!
996      @abstract Initialize a vglite context.
997 
998      @discussion
999      The {@link vg_lite_draw} function requires a draw context to be initialized. There is only one draw context per process, so
1000      this function has be called once in your application if any draw command will be used. If this would be the first context that
1001      accesses the hardware, the hardware will be turned on and initialized.
1002 
1003      The difference between a blit and draw context is that the draw context has a larger command buffer and allocates a
1004      tessellation buffer for the hardware. The size of the tessellation buffer can be specified, and that size will be aligned to
1005      the minimum required alignment of the hardware by the kernel. If you make the tessellation buffer smaller, less memory will
1006      be allocated, but a path might be sent down to the hardware multiple times because the hardware will walk the target with the
1007      provided tessellation window size, so performance might go down. It is good practice to set the tessellation buffer size to the
1008      most common path size. For example, if all you do is render up to 24-pt fonts, you can set the tessellation buffer to be
1009      24x24.
1010 
1011      @param tessellation_width
1012      The width of the tessellation window.
1013 
1014      @param tessellation_height
1015      The height of the tessellation window.
1016 
1017      @result
1018      Returns the status as defined by <code>vg_lite_error_t</code>.
1019      */
1020     vg_lite_error_t vg_lite_init(int32_t tessellation_width, int32_t tessellation_height);
1021 
1022     /*!
1023      @abstract Destroy a vglite context.
1024 
1025      @discussion
1026      Destroy a draw context that was previously initialized by {@link vg_lite_draw_init}.
1027 
1028      @result
1029      Returns the status as defined by <code>vg_lite_error_t</code>.
1030      */
1031     vg_lite_error_t vg_lite_close(void);
1032 
1033     /*!
1034      @abstract This api explicitly submits the command buffer to GPU and waits for it to complete.
1035 
1036      @param none.
1037 
1038      @result
1039      Returns the status as defined by <code>vg_lite_error_t</code>.
1040      */
1041     vg_lite_error_t vg_lite_finish(void);
1042 
1043     /*!
1044      @abstract This api explicitly submits the command buffer to GPU without waiting for it to complete.
1045 
1046      @param none.
1047 
1048      @result
1049      Returns the status as defined by <code>vg_lite_error_t</code>.
1050      */
1051     vg_lite_error_t vg_lite_flush(void);
1052 
1053     /*!
1054      @abstract Draw a path to a target buffer.
1055 
1056      @discussion
1057      The specified path will be transformed by the given matrix and drawn into the specified target buffer using the supplied color.
1058      Blending can be specified.
1059 
1060      @param target
1061      Pointer to a <code>vg_lite_buffer_t</code> structure that describes the target of the draw.
1062 
1063      @param path
1064      Pointer to a <code>vg_lite_path_t</code> structure that describes the path to draw.
1065 
1066      @param fill_rule
1067      Specified fill rule for the path.
1068 
1069      @param matrix
1070      Pointer to a 3x3 matrix that defines the transformation matrix of the path. If <code>matrix</code> is <code>NULL</code>, an
1071      identity matrix is assumed which is usually a bad idea since the path can be anything.
1072 
1073      @param blend
1074      The blending mode to be applied to each drawn pixel. If no blending is required, set this value to
1075      <code>VG_LITE_BLEND_NONE</code> (0).
1076 
1077      @param color
1078      The color applied to each pixel drawn by the path.
1079 
1080      @result
1081      Returns the status as defined by <code>vg_lite_error_t</code>.
1082      */
1083     vg_lite_error_t vg_lite_draw(vg_lite_buffer_t *target,
1084                                  vg_lite_path_t   *path,
1085                                  vg_lite_fill_t    fill_rule,
1086                                  vg_lite_matrix_t *matrix,
1087                                  vg_lite_blend_t   blend,
1088                                  vg_lite_color_t   color);
1089 
1090     /*!
1091      @abstract Set stroke path's attributes.
1092 
1093      @discussion
1094      This function use the input parameters to set stroke attributes.
1095 
1096      @param path
1097      Pointer to a <code>vg_lite_path_t</code> structure that describes the path.
1098 
1099      @param stroke_cap_style
1100      The end cap style defined by <code>vg_lite_cap_style_t</code>.
1101 
1102      @param stroke_join_style
1103      The line join style defined by <code>vg_lite_join_style_t</code>.
1104 
1105      @param stroke_line_width
1106      The line width of stroke path.A line width less than or equal to 0 prevents stroking from taking place.
1107 
1108      @param stroke_miter_limit
1109      When stroking using the Miter join style, the miter length (i.e., the length between the
1110      intersection points of the inner and outer perimeters of the two “fattened” lines) is compared
1111      to the product of the user-set miter limit and the line width. If the miter length exceeds this
1112      product, the Miter join is not drawn and a Bevel join is substituted.Miter limit values less
1113      than 1 are silently clamped to 1.
1114 
1115      @param stroke_dash_pattern
1116      The dash pattern consists of a sequence of lengths of alternating "on" and "off" dash
1117      segments. The first value of the dash array defines the length, in user coordinates, of the
1118      first "on" dash segment. The second value defines the length of the following "off"
1119      segment. Each subsequent pair of values defines one "on" and one "off" segment.If the dash
1120      pattern has an odd number of elements, the final element is ignored.
1121 
1122      @param stroke_dash_pattern_count
1123      The count of dash on/off segments.
1124 
1125      @param stroke_dash_phase
1126      The dash phase defines the starting point in the dash pattern that is associated with the
1127      start of the first segment of the path. For example, if the dash pattern is [10 20 30 40]
1128      and the dash phase is 35, the path will be stroked with an "on" segment of length 25
1129      (skipping the first "on" segment of length 10, the following "off" segment of length 20,
1130      and the first 5 units of the next "on" segment), followed by an "off" segment of length
1131      40. The pattern will then repeat from the beginning, with an “on” segment of length 10,
1132      an "off" segment of length 20, an "on" segment of length 30.
1133 
1134      @param stroke_color
1135      The color fill in stroke path.
1136 
1137      @result
1138      Returns the status as defined by <code>vg_lite_error_t</code>.
1139      */
1140     vg_lite_error_t vg_lite_set_stroke(vg_lite_path_t *path,
1141                                        vg_lite_cap_style_t stroke_cap_style,
1142                                        vg_lite_join_style_t stroke_join_style,
1143                                        vg_lite_float_t stroke_line_width,
1144                                        vg_lite_float_t stroke_miter_limit,
1145                                        vg_lite_float_t *stroke_dash_pattern,
1146                                        uint32_t stroke_dash_pattern_count,
1147                                        vg_lite_float_t stroke_dash_phase,
1148                                        vg_lite_color_t stroke_color);
1149     /*!
1150      @abstract Update stroke path.
1151 
1152      @discussion
1153      This function use the given path and stroke attributes given by function vg_lite_set_stroke
1154      to update stroke path's parameters and generate stroke path data.
1155 
1156      @param path
1157      Pointer to a <code>vg_lite_path_t</code> structure that describes the path.
1158 
1159      @result
1160      Returns the status as defined by <code>vg_lite_error_t</code>.
1161      */
1162     vg_lite_error_t vg_lite_update_stroke(vg_lite_path_t *path);
1163 
1164     /*!
1165      @abstract Set path type.
1166 
1167      @discussion
1168      This function set the path type.It can be VG_LITE_DRAW_FILL_PATH ,VG_LITE_DRAW_STROKE_PATH or
1169      VG_LITE_DRAW_FILL_PATH | VG_LITE_DRAW_STROKE_PATH.
1170 
1171      @param path
1172      Pointer to a <code>vg_lite_path_t</code> structure that describes the path.
1173 
1174      @param path_type
1175      Pointer to a <code>vg_lite_draw_path_type_t</code> structure that describes the path.
1176 
1177      @result
1178      Returns the status as defined by <code>vg_lite_error_t</code>.
1179      */
1180     vg_lite_error_t vg_lite_set_draw_path_type(vg_lite_path_t * path,vg_lite_draw_path_type_t path_type);
1181 
1182     /*!
1183      @abstract Get the value of register from register's address.
1184 
1185      @discussion
1186      This address will be the AHB Byte address of the register whose value you want to dump.
1187      Refer to the Vivante AHB Register Specification document for register descriptions.
1188      The valid range for VGLite cores is usually 0x0 to 0x1FF and 0xA00 to 0xA7F.
1189 
1190      @param address
1191      Address of register which is needed to get its value.
1192 
1193      @param result
1194      The register's value.
1195 
1196      */
1197     vg_lite_error_t vg_lite_get_register(uint32_t address, uint32_t *result);
1198 
1199     /*
1200      @abstract Get the VGLite driver information.
1201 
1202      @param info
1203      Pointer to vg_lite_info_t structure.
1204      */
1205     void vg_lite_get_info(vg_lite_info_t *info);
1206 
1207     /*
1208      @abstract Get the name of the VGLite Product.
1209 
1210      @param name
1211      Character array to store the name of the chip.
1212 
1213      @param chip_id
1214      Store the chip id.
1215 
1216      @param chip_rev
1217      Store the chip revision number.
1218 
1219      @return
1220      Length of the name string, including the ending '\0'.
1221      */
1222     uint32_t vg_lite_get_product_info(char *name, uint32_t *chip_id, uint32_t *chip_rev);
1223 
1224     /*!
1225      @abstract Queried whether the specified feature is available.
1226 
1227      @param feature
1228      Feature to be verified.
1229 
1230      @return
1231      The feature is supported (1) or not (0).
1232      */
1233     uint32_t vg_lite_query_feature(vg_lite_feature_t feature);
1234 
1235     /*!
1236      @abstract This api initializes a path object by given member values.
1237 
1238      @param path
1239      The path object.
1240 
1241      @param data_format
1242      The coordinate data format of the path. One of S8, S16, S32 and FP32.
1243 
1244      @param quality
1245      The rendering quality (AA level) of the path.
1246 
1247      @param path_length
1248      The memory length of the path data.
1249 
1250      @param path_data
1251      The path data.
1252 
1253      @param min_x
1254      The min x of the bounding box.
1255 
1256      @param min_y
1257      The min y of the bounding box.
1258 
1259      @param max_x
1260      The max x of the bounding box.
1261 
1262      @param max_y
1263      The max y of the bounding box.
1264 
1265      @result
1266      Returns the status as defined by <code>vg_lite_error_t</code>.
1267      */
1268     vg_lite_error_t vg_lite_init_path(vg_lite_path_t *path,
1269                            vg_lite_format_t data_format,
1270                            vg_lite_quality_t quality,
1271                            uint32_t path_length,
1272                            void *path_data,
1273                            vg_lite_float_t min_x, vg_lite_float_t min_y,
1274                            vg_lite_float_t max_x, vg_lite_float_t max_y);
1275 
1276      /*!
1277      @abstract This api initializes a path object which include arc command by given member values.
1278 
1279      @param path
1280      The path object.
1281 
1282      @param data_format
1283      The coordinate data format of the path. Should be FP32.
1284 
1285      @param quality
1286      The rendering quality (AA level) of the path.
1287 
1288      @param path_length
1289      The memory length of the path data.
1290 
1291      @param path_data
1292      The given path data which inlcude arc command.
1293 
1294      @param min_x
1295      The min x of the bounding box.
1296 
1297      @param min_y
1298      The min y of the bounding box.
1299 
1300      @param max_x
1301      The max x of the bounding box.
1302 
1303      @param max_y
1304      The max y of the bounding box.
1305 
1306      @result
1307      Returns the status as defined by <code>vg_lite_error_t</code>.
1308      */
1309     vg_lite_error_t vg_lite_init_arc_path(vg_lite_path_t * path,
1310                            vg_lite_format_t data_format,
1311                            vg_lite_quality_t quality,
1312                            uint32_t path_length,
1313                            void *   path_data,
1314                            vg_lite_float_t min_x, vg_lite_float_t min_y,
1315                            vg_lite_float_t max_x, vg_lite_float_t max_y);
1316 
1317     /*!
1318      @abstract This api clears the path member values.
1319 
1320      @discussion It frees the hw memory if path was ever uploaded.
1321 
1322      @param path
1323      The path object.
1324 
1325      @result
1326      Returns the status as defined by <code>vg_lite_error_t</code>.
1327      */
1328     vg_lite_error_t vg_lite_clear_path(vg_lite_path_t *path);
1329 
1330     /*!
1331      @abstract Calculate the path command buffer length (in bytes).
1332 
1333      @discussion The app should be response for allocating a buffer according to
1334      the buffer length calculated by this function. Then the buffer is used by
1335      the path as command buffer. The driver does not do allocation for the buffer.
1336 
1337      @param cmd
1338      The opcode array to construct the path.
1339 
1340      @param count
1341      The count of opcodes.
1342 
1343      @param format
1344      The data format of the coordinate (VG_LITE_S8, S16, S32, FP32)
1345 
1346      @result
1347      Return the actual length of the path command buffer.
1348      */
1349     int32_t vg_lite_path_calc_length(uint8_t           *cmd,
1350                                      uint32_t           count,
1351                                      vg_lite_format_t   format);
1352 
1353     /*!
1354      @abstract Assemble the command buffer for the path.
1355 
1356      @discussion The command buffer is allocated by the application and assigned
1357      to the path. The function make the final GPU command buffer for the path based
1358      on the input opcodes (cmd) and coordinates (data). Note that the Application
1359      must be responsible to alloate a big enough buffer for the path.
1360 
1361      @param path
1362      The path object.
1363 
1364      @param cmd
1365      The opcode array to construct the path.
1366 
1367      @param data
1368      The coordinate data array to construct the path.
1369 
1370      @param seg_count
1371      The count of the opcodes.
1372 
1373      */
1374     vg_lite_error_t vg_lite_path_append(vg_lite_path_t *path,
1375                              uint8_t        *cmd,
1376                              void           *data,
1377                              uint32_t        seg_count);
1378 
1379     /*!
1380      @abstract Upload a path to GPU memory.
1381 
1382      @discussion
1383      In normal cases, the VGLite driver will copy any path data into a command buffer structure during runtime. This does take some
1384      time if there are many paths to be rendered. Also, in an embedded system the path data wont change - so it makes sense to
1385      upload the path data into GPU memory in such a form the GPU can directly access it.
1386 
1387      This function will allocate a buffer that will contain the path data and the required command buffer header and footer data for
1388      the GPU to access the data directly.
1389 
1390      @param path
1391      Pointer to a <code>vg_lite_path_t</code> structure that contains the path to be uploaded. Some fields in this structure will be
1392      modified to point to a command buffer instead of the native path data.
1393 
1394      @result
1395      A pointer to a <code>vg_lite_buffer_t</code> structure that contains the command buffer and path data after uploading it to GPU
1396      memory. <code>NULL</code> is returned if there is an error.
1397      */
1398     vg_lite_error_t vg_lite_upload_path(vg_lite_path_t *path);
1399 
1400     /*!
1401      @abstract Set the current CLUT (Color Look Up Table) for index image to use.
1402 
1403      @discussion
1404      This is a global context state. Once it's set (Not NULL), when an indexed format image is rendered, the image color will
1405      be got from the CLUT by the image's pixels as indecies.
1406 
1407      @param count
1408      This is the count of the colors in the look up table.
1409      For index 1, up to 2 colors in the table;
1410      For index 2, up to 4 colors in the table;
1411      For index 4, up to 16 colors in the table;
1412      For index 8, up to 256 colros in the table.
1413      Driver is not responsible to check the validation of the CLUT.
1414 
1415      @param colors
1416      This pointer is directly programmed to the command buffer. So it won't take effect
1417      unless the command buffer is submitted. The color is in ARGB format with A staying at the high bits.
1418 
1419      @result
1420      Error code. Currently always returns VG_LITE_SUCCESS since it does not do any checks.
1421      */
1422     vg_lite_error_t vg_lite_set_CLUT(uint32_t count,
1423                                      uint32_t *colors);
1424 
1425     /*!
1426      @abstract Fill a path with an image pattern.
1427 
1428      @discussion
1429      The specified path will be transformed by the given matrix and filled by the tranformed image pattern.
1430 
1431      @param path
1432      Pointer to a <code>vg_lite_path_t</code> structure that describes the path to draw.
1433 
1434      @param fill_rule
1435      Specified fill rule for the path.
1436 
1437      @param matrix0
1438      Pointer to a 3x3 matrix that defines the transformation matrix of the path. If <code>matrix</code> is <code>NULL</code>, an
1439      identity matrix is assumed which is usually a bad idea since the path can be anything.
1440 
1441      @param source
1442      Pointer to a <code>vg_lite_buffer_t</code> structure that describes the source of the image pattern.
1443 
1444      @param matrix1
1445      Pointer to a 3x3 matrix that defines the transformation matrix of source pixels into the target. If matrix is
1446      <code>NULL</code>, an identity matrix is assumed.
1447 
1448      @param blend
1449      The blending mode to be applied to each drawn pixel. If no blending is required, set this value to
1450      <code>VG_LITE_BLEND_NONE</code> (0).
1451 
1452      @param pattern_mode
1453      The tiling mode that applied to the pixels out of the image after transformed.
1454 
1455      @param pattern_color
1456      The pattern_color applied by pattern_mode VG_LITE_PATTERN_COLOR. When pixels are out of the image after transformed,
1457      they are applied "pattern_color".
1458 
1459      @result
1460      Returns the status as defined by <code>vg_lite_error_t</code>.
1461      */
1462     vg_lite_error_t vg_lite_draw_pattern(vg_lite_buffer_t *target,
1463                                          vg_lite_path_t *path,
1464                                          vg_lite_fill_t fill_rule,
1465                                          vg_lite_matrix_t *matrix0,
1466                                          vg_lite_buffer_t *source,
1467                                          vg_lite_matrix_t *matrix1,
1468                                          vg_lite_blend_t blend,
1469                                          vg_lite_pattern_mode_t pattern_mode,
1470                                          vg_lite_color_t  pattern_color,
1471                                          vg_lite_filter_t filter);
1472 
1473     /*!
1474      @abstract Init the linear gradient object.
1475 
1476      @discussion
1477      This API initialize the grad object to its default settings. Since grad has
1478      an internal buffer object, this API will init the buffer object for rendering use.
1479 
1480      @param grad
1481      This is the vg_lite_linear_gradient_t object to be initialized.
1482 
1483      @result
1484      Error code, in case the buffer can't be created.
1485      */
1486     vg_lite_error_t vg_lite_init_grad(vg_lite_linear_gradient_t *grad);
1487 
1488     /*!
1489      @abstract Set the linear gradient members.
1490 
1491      @discussion
1492      This API sets the values for the members of the gradient definition.
1493 
1494      @param grad
1495      This is the vg_lite_linear_gradient_t object to be set.
1496 
1497      @param count
1498      This is the count of the colors in grad.
1499      The maxmum color stop count is defined by VLC_MAX_GRAD, which is currently 16.
1500 
1501      @param colors
1502      This is the color array for the gradient stops. The color is in ARGB8888 format
1503      with alpha at the higher byte.
1504 
1505      @result
1506      Error code. VG_LITE_INVALID_ARGUMENTS to indicate the parameters are wrong.
1507      */
1508     vg_lite_error_t vg_lite_set_grad(vg_lite_linear_gradient_t *grad,
1509                                      uint32_t count,
1510                                      uint32_t *colors,
1511                                      uint32_t *stops);
1512 
1513     /*!
1514      @abstract Set the radial gradient members.
1515 
1516      @discussion
1517      This API sets the values for the members of the radial gradient definition.
1518 
1519      @param grad
1520      This is the vg_lite_radial_gradient_t object to be set.
1521 
1522      @param count
1523      This is the count of the colors in grad.
1524      The maxmum color stop count is defined by MAX_COLOR_RAMP_STOPS, which is currently 256.
1525 
1526      @param vgColorRamp
1527      This is the stop for the radial gradient.The number of parameters is 5,and give the offset and
1528      color of the stop.Each stop is defined by a floating-point offset value and four floating-point values
1529      containing the sRGBA color and alpha value associated with each stop, in the form of a non-premultiplied
1530      (R, G, B, alpha) quad.And the range of all parameters in it is [0,1].
1531 
1532      @param radialGradient
1533      The radial gradient parameters are supplied as a vector of 5 floats in the order {cx,cy,fx,fy,r}.
1534      the range of all parameters in it is [0,1].The meaning of the parameters in it is:(cx,cy) is center point,
1535      (fx,fy) is focal point, and r is radius.
1536 
1537      @param SpreadMode
1538      The tiling mode that applied to the pixels out of the paint after transformed.
1539 
1540      @param colorRampPremultiplied
1541      The parameter controls whether color and alpha values are interpolated in premultiplied or non-premultiplied
1542      form.
1543 
1544      @result
1545      Error code. VG_LITE_INVALID_ARGUMENTS to indicate the parameters are wrong.
1546      */
1547     vg_lite_error_t vg_lite_set_rad_grad(vg_lite_radial_gradient_t *grad,
1548                                      uint32_t count,
1549                                      vg_lite_color_ramp_t *vgColorRamp,
1550                                      vg_lite_radial_gradient_parameter_t radialGradient,
1551                                      vg_lite_radial_gradient_spreadmode_t SpreadMode,
1552                                      uint8_t colorRampPremultiplied);
1553 
1554     /*!
1555      @abstract Set the linear gradient members.
1556 
1557      @discussion
1558      This API sets the values for the members of the linear gradient definition.
1559 
1560      @param grad
1561      This is the vg_lite_linear_gradient_ext_t object to be set.
1562 
1563      @param count
1564      This is the count of the colors in grad.
1565      The maxmum color stop count is defined by MAX_COLOR_RAMP_STOPS, which is currently 256.
1566 
1567      @param vg_color_ramp
1568      This is the stop for the linear gradient.The number of parameters is 5,and give the offset and
1569      color of the stop.Each stop is defined by a floating-point offset value and four floating-point values
1570      containing the sRGBA color and alpha value associated with each stop, in the form of a non-premultiplied
1571      (R, G, B, alpha) quad.And the range of all parameters in it is [0,1].
1572 
1573      @param linear_gradient
1574      Refer to the definition by <code>vg_lite_linear_gradient_parameter_t</code>.
1575 
1576      @param spread_mode
1577      The tiling mode that applied to the pixels out of the paint after transformed.Use tge same spread mode enumeration type as radial gradient.
1578 
1579      @param color_ramp_premultiplied
1580      The parameter controls whether color and alpha values are interpolated in premultiplied or non-premultiplied
1581      form.
1582 
1583      @result
1584      Error code. VG_LITE_INVALID_ARGUMENTS to indicate the parameters are wrong.
1585      */
1586     vg_lite_error_t vg_lite_set_linear_grad(vg_lite_linear_gradient_ext_t *grad,
1587                                             uint32_t count,
1588                                             vg_lite_color_ramp_t *vg_color_ramp,
1589                                             vg_lite_linear_gradient_parameter_t linear_gradient,
1590                                             vg_lite_radial_gradient_spreadmode_t spread_mode,
1591                                             uint8_t color_ramp_premultiplied);
1592 
1593     /*!
1594      @abstract Update or generate the corresponding image object to render with.
1595 
1596      @discussion
1597      The vg_lite_linear_gradient_ext_t object has an image buffer which is used to render
1598      the linear gradient paint. The image buffer will be create/updated by the corresponding
1599      grad parameters.
1600 
1601      @param grad
1602      This is the vg_lite_linear_gradient_ext_t object to be updated from.
1603 
1604      @result
1605      Returns the status as defined by <code>vg_lite_error_t</code>.
1606      */
1607     vg_lite_error_t vg_lite_update_linear_grad(vg_lite_linear_gradient_ext_t *grad);
1608 
1609     /*!
1610      @abstract Update or generate the corresponding image object to render with.
1611 
1612      @discussion
1613      The vg_lite_linear_gradient_t object has an image buffer which is used to render
1614      the gradient pattern. The image buffer will be create/updated by the corresponding
1615      grad parameters.
1616 
1617      @param grad
1618      This is the vg_lite_linear_gradient_t object to be upated from.
1619 
1620      @result
1621      Error code.
1622      */
1623     vg_lite_error_t vg_lite_update_grad(vg_lite_linear_gradient_t *grad);
1624 
1625     /*!
1626      @abstract Update or generate the corresponding image object to render with.
1627 
1628      @discussion
1629      The vg_lite_radial_gradient_t object has an image buffer which is used to render
1630      the radial gradient paint. The image buffer will be create/updated by the corresponding
1631      grad parameters.
1632 
1633      @param grad
1634      This is the vg_lite_radial_gradient_t object to be upated from.
1635 
1636      @result
1637      Error code.
1638      */
1639     vg_lite_error_t vg_lite_update_rad_grad(vg_lite_radial_gradient_t *grad);
1640 
1641     /*!
1642      @abstract Clear the gradient object.
1643 
1644      @discussion
1645      This will reset the grad members and free the image buffer's memory.
1646 
1647      @param grad
1648      This is the vg_lite_linear_gradient_t object to be cleared.
1649 
1650      @result
1651      Error code.
1652      */
1653     vg_lite_error_t vg_lite_clear_grad(vg_lite_linear_gradient_t *grad);
1654 
1655     /*!
1656      @abstract Clear the radial gradient object.
1657 
1658      @discussion
1659      This will reset the grad members and free the image buffer's memory.
1660 
1661      @param grad
1662      This is the vg_lite_radial_gradient_t object to be cleared.
1663 
1664      @result
1665      Error code.
1666      */
1667     vg_lite_error_t vg_lite_clear_rad_grad(vg_lite_radial_gradient_t *grad);
1668 
1669     /*!
1670      @abstract Clear the linear gradient object.
1671 
1672      @discussion
1673      This will reset the grad members and free the image buffer's memory.
1674 
1675      @param grad
1676      This is the vg_lite_linear_gradient_ext_t object to be cleared.
1677 
1678      @result
1679      Returns the status as defined by <code>vg_lite_error_t</code>.
1680      */
1681     vg_lite_error_t vg_lite_clear_linear_grad(vg_lite_linear_gradient_ext_t *grad);
1682 
1683     /*!
1684      @abstract Get the pointer to the grad object's matrix.
1685 
1686      @discussion
1687      This function get the pointer to the gradient object's matrix. Thus the app
1688      can manipulate the matrix to render the gradient path correctly.
1689 
1690      @param grad
1691      This is the vg_lite_linear_gradient_t object where to get the matrix.
1692 
1693      @result
1694      The pointer to the matrix.
1695      */
1696     vg_lite_matrix_t * vg_lite_get_grad_matrix(vg_lite_linear_gradient_t *grad);
1697 
1698     /*!
1699      @abstract Get the pointer to the grad object's matrix.
1700 
1701      @discussion
1702      This function get the pointer to the gradient object's matrix. Thus the app
1703      can manipulate the matrix to render the gradient path correctly.
1704 
1705      @param grad
1706      This is the vg_lite_linear_gradient_ext_t object where to get the matrix.
1707 
1708      @result
1709      The pointer to the matrix.
1710      */
1711      vg_lite_matrix_t * vg_lite_get_linear_grad_matrix(vg_lite_linear_gradient_ext_t *grad);
1712 
1713     /*!
1714      @abstract Get the pointer to the grad object's matrix.
1715 
1716      @discussion
1717      This function get the pointer to the radial gradient object's matrix. Thus the app
1718      can manipulate the matrix to render the radial gradient path correctly.
1719 
1720      @param grad
1721      This is the vg_lite_radial_gradient_t object where to get the matrix.
1722 
1723      @result
1724      The pointer to the matrix.
1725      */
1726     vg_lite_matrix_t * vg_lite_get_rad_grad_matrix(vg_lite_radial_gradient_t *grad);
1727 
1728     /*!
1729      @abstract Fill a path with an image pattern.
1730 
1731      @discussion
1732      The specified path will be transformed by the given matrix and filled by the tranformed image pattern.
1733 
1734      @param path
1735      Pointer to a <code>vg_lite_path_t</code> structure that describes the path to draw.
1736 
1737      @param fill_rule
1738      Specified fill rule for the path.
1739 
1740      @param matrix0
1741      Pointer to a 3x3 matrix that defines the transformation matrix of the path. If <code>matrix</code> is <code>NULL</code>, an
1742      identity matrix is assumed which is usually a bad idea since the path can be anything.
1743 
1744      @param grad
1745      Pointer to the gradient object that will be filled the path with.
1746 
1747      @param blend
1748      The blending mode to be applied to each drawn pixel. If no blending is required, set this value to
1749      <code>VG_LITE_BLEND_NONE</code> (0).
1750 
1751      @param pattern_mode
1752      The tiling mode that applied to the pixels out of the image after transformed.
1753 
1754      @param pattern_color
1755      The pattern_color applied by pattern_mode VG_LITE_PATTERN_COLOR. When pixels are out of the image after transformed,
1756      they are applied "pattern_color".
1757 
1758      @result
1759      Returns the status as defined by <code>vg_lite_error_t</code>.
1760      */
1761     vg_lite_error_t vg_lite_draw_gradient(vg_lite_buffer_t *target,
1762                                           vg_lite_path_t *path,
1763                                           vg_lite_fill_t fill_rule,
1764                                           vg_lite_matrix_t *matrix,
1765                                           vg_lite_linear_gradient_t *grad,
1766                                           vg_lite_blend_t blend);
1767 
1768     /*!
1769      @abstract Fill a path with a linear gradient.
1770 
1771      @discussion
1772      The specified path will be transformed by the given matrix and filled by the tranformed linear gradient.
1773 
1774      @param path
1775      Pointer to a <code>vg_lite_path_t</code> structure that describes the path to draw.
1776 
1777      @param fill_rule
1778      Specified fill rule for the path.
1779 
1780      @param path_matrix
1781      Pointer to a 3x3 matrix that defines the transformation matrix of the path. If <code>matrix</code> is <code>NULL</code>, an
1782      identity matrix is assumed which is usually a bad idea since the path can be anything.
1783 
1784      @param grad
1785      This is the vg_lite_linear_gradient_ext_t object to be set.
1786 
1787      @param paint_color
1788      Specifies the paint color vg_lite_color_t RGBA value to applied by VG_LITE_RADIAL_GRADIENT_SPREAD_FILL,which set by fuction
1789      vg_lite_set_linear_grad. When pixels are out of the image after transformed,this paint_color is applied to them,See enum
1790      vg_lite_radial_gradient_spreadmode_t.
1791 
1792      @param blend
1793      The blending mode to be applied to each drawn pixel. If no blending is required, set this value to
1794      <code>VG_LITE_BLEND_NONE</code> (0).
1795 
1796      @param filter
1797      Specified the filter mode vg_lite_filter_t enum value to be applied to each drawn pixel.
1798 
1799      @result
1800      Returns the status as defined by <code>vg_lite_error_t</code>.
1801      */
1802     vg_lite_error_t vg_lite_draw_linear_gradient(vg_lite_buffer_t * target,
1803                                      vg_lite_path_t * path,
1804                                      vg_lite_fill_t fill_rule,
1805                                      vg_lite_matrix_t * path_matrix,
1806                                      vg_lite_linear_gradient_ext_t *grad,
1807                                      vg_lite_color_t paint_color,
1808                                      vg_lite_blend_t blend,
1809                                      vg_lite_filter_t filter);
1810 
1811     /*!
1812      @abstract Fill a path with a radial gradient.
1813 
1814      @discussion
1815      The specified path will be transformed by the given matrix and filled by the tranformed radial gradient.
1816 
1817      @param path
1818      Pointer to a <code>vg_lite_path_t</code> structure that describes the path to draw.
1819 
1820      @param fill_rule
1821      Specified fill rule for the path.
1822 
1823      @param path_matrix
1824      Pointer to a 3x3 matrix that defines the transformation matrix of the path. If <code>matrix</code> is <code>NULL</code>, an
1825      identity matrix is assumed which is usually a bad idea since the path can be anything.
1826 
1827      @param grad
1828      This is the vg_lite_radial_gradient_t object to be set.
1829 
1830      @param paint_color
1831      Specifies the paint color vg_lite_color_t RGBA value to applied by VG_LITE_RADIAL_GRADIENT_SPREAD_FILL,which set by fuction
1832      vg_lite_set_rad_grad. When pixels are out of the image after transformed,this paint_color is applied to them,See enum
1833      vg_lite_radial_gradient_spreadmode_t.
1834 
1835      @param blend
1836      The blending mode to be applied to each drawn pixel. If no blending is required, set this value to
1837      <code>VG_LITE_BLEND_NONE</code> (0).
1838 
1839      @param filter
1840      Specified the filter mode vg_lite_filter_t enum value to be applied to each drawn pixel.
1841 
1842      @result
1843      Returns the status as defined by <code>vg_lite_error_t</code>.
1844      */
1845     vg_lite_error_t vg_lite_draw_radial_gradient(vg_lite_buffer_t * target,
1846                                      vg_lite_path_t * path,
1847                                      vg_lite_fill_t fill_rule,
1848                                      vg_lite_matrix_t * path_matrix,
1849                                      vg_lite_radial_gradient_t *grad,
1850                                      vg_lite_color_t  paint_color,
1851                                      vg_lite_blend_t blend,
1852                                      vg_lite_filter_t filter);
1853 
1854     /*!
1855      @abstract Load an identity matrix.
1856 
1857      @discussion
1858      Load an identity matrix into a matrix variable.
1859 
1860      @param matrix
1861      Pointer to a <code>vg_lite_matrix_t</code> structure that will be loaded with an identity matrix.
1862      */
1863     void vg_lite_identity(vg_lite_matrix_t *matrix);
1864 
1865     /*!
1866      @abstract Translate a matrix.
1867 
1868      @discussion
1869      Translate a matrix to a new position.
1870 
1871      @param x
1872      X location of the transformation.
1873 
1874      @param y
1875      Y location of the transformation.
1876 
1877      @param matrix
1878      Pointer to a <code>vg_lite_matrix_t</code> structure that will be translated.
1879      */
1880     void vg_lite_translate(vg_lite_float_t x, vg_lite_float_t y, vg_lite_matrix_t *matrix);
1881 
1882     /*!
1883      @abstract Scale a matrix.
1884 
1885      @discussion
1886      Scale a matrix in both x and y directions.
1887 
1888      @param scale_x
1889      Horizontal scale.
1890 
1891      @param scale_y
1892      Vertical scale.
1893 
1894      @param matrix
1895      Pointer to a <code>vg_lite_matrix_t</code> structure that will be scaled.
1896      */
1897     void vg_lite_scale(vg_lite_float_t scale_x, vg_lite_float_t scale_y, vg_lite_matrix_t *matrix);
1898 
1899     /*!
1900      @abstract Rotate a matrix.
1901 
1902      @discussion
1903      Rotate a matrix a certain number of degrees.
1904 
1905      @param degrees
1906      Number of degrees to rotate the matrix around. Positive numbers rotate counter clock wise.
1907 
1908      @param matrix
1909      Pointer to a <code>vg_lite_matrix_t</code> structure that will be rotated.
1910      */
1911     void vg_lite_rotate(vg_lite_float_t degrees, vg_lite_matrix_t *matrix);
1912 
1913     /*!
1914      @abstract Set the command buffer size.
1915 
1916      @discussion
1917      In the rt device, the memory was limited, need to set the command buffer
1918      size by the chip.
1919      @result
1920      Returns the status as defined by <code>vg_lite_error_t</code>.
1921      */
1922     vg_lite_error_t vg_lite_set_command_buffer_size(uint32_t size);
1923 
1924     /*!
1925      @abstract Set scissor used for render target's boundary.
1926 
1927      @discussion
1928       This function is used to set a scissor into render target so that the out region
1929       of scissor boundary is not drawn.
1930 
1931      @param x, y, width, height
1932       The scissor bounds which specifies the x, y, width, and height of the region.
1933 
1934      @result
1935       Returns the status as defined by <code>vg_lite_error_t</code>.*/
1936     vg_lite_error_t vg_lite_set_scissor(int32_t x, int32_t y, int32_t width, int32_t height);
1937 
1938     /*!
1939       @abstract Enable scissor.
1940 
1941       @result
1942       Returns the status as defined by <code>vg_lite_error_t</code>.*/
1943     vg_lite_error_t vg_lite_enable_scissor(void);
1944 
1945     /*!
1946       @abstract Disable scissor.
1947 
1948       @result
1949       Returns the status as defined by <code>vg_lite_error_t</code>.*/
1950     vg_lite_error_t vg_lite_disable_scissor(void);
1951 
1952     /*!
1953       @abstract query the remaining allocate contiguous video memory.
1954 
1955       @param size
1956       This is a pointer to remaining allocate contiguous video memory.
1957 
1958       @result
1959       Returns the status as defined by <code>vg_lite_error_t</code>.The result correctly returns VG_LITE_SUCCESS,
1960       return VG_LITE_NO_CONTEXT if not initialized.*/
1961     vg_lite_error_t vg_lite_mem_avail(uint32_t *size);
1962 
1963     /*!
1964       @abstract Enable premultiply.
1965 
1966       @result
1967       Returns the status as defined by <code>vg_lite_error_t</code>.*/
1968     vg_lite_error_t vg_lite_enable_premultiply(void);
1969 
1970     /*!
1971       @abstract Disable premultiply.
1972 
1973       @result
1974       Returns the status as defined by <code>vg_lite_error_t</code>.*/
1975     vg_lite_error_t vg_lite_disable_premultiply(void);
1976 
1977     /*!
1978      @abstract This api use to control dither function switch.Dither is turned off by default.
1979 
1980      @param enable
1981      0 means turn off the dither function. 1 means turn on the dither function.
1982 
1983      @result
1984      Returns the status as defined by <code>vg_lite_error_t</code>.
1985      */
1986     vg_lite_error_t vg_lite_set_dither(int enable);
1987 
1988     /*!
1989       @abstract use to set the colorkey.
1990 
1991       @param colorkey
1992       Defined by <code>vg_lite_color_key4_t</code>.
1993 
1994       @result
1995       Returns the status as defined by <code>vg_lite_error_t</code>.
1996       Possible return value in this function:
1997           VG_LITE_SUCCESS,the result correctly
1998           VG_LITE_NOT_SUPPORT, if not support colorkey.*/
1999     vg_lite_error_t vg_lite_set_color_key(vg_lite_color_key4_t colorkey);
2000 
2001 #endif /* VGLITE_VERSION_2_0 */
2002 
2003 
2004 /**************************** Capture ********************************************/
2005 #ifndef vgliteDUMP_PATH
2006 #   define vgliteDUMP_PATH                      "./"
2007 #endif
2008 
2009 #ifndef vgliteDUMP_KEY
2010 #   define vgliteDUMP_KEY                          "process"
2011 #endif
2012 
2013 #define DUMP_CAPTURE                            0
2014 
2015 #if DUMP_CAPTURE
2016 void _SetDumpFileInfo();
2017 
2018 vg_lite_error_t
2019     vglitefDump(
2020     char * String,
2021     ...
2022     );
2023 #  define vglitemDUMP               vglitefDump
2024 
2025 vg_lite_error_t
2026     vglitefDumpBuffer(
2027     char* Tag,
2028     unsigned int Physical,
2029     void * Logical,
2030     unsigned int Offset,
2031     size_t Bytes
2032     );
2033 #   define vglitemDUMP_BUFFER       vglitefDumpBuffer
2034 #else
__dummy_dump(char * Message,...)2035 inline static void __dummy_dump(
2036     char * Message,
2037     ...
2038     )
2039 {
2040 }
2041 #  define vglitemDUMP               __dummy_dump
2042 
2043 inline static void
__dummy_dump_buffer(char * Tag,unsigned int Physical,void * Logical,unsigned int Offset,size_t Bytes)2044     __dummy_dump_buffer(
2045     char* Tag,
2046     unsigned int Physical,
2047     void * Logical,
2048     unsigned int Offset,
2049     size_t Bytes
2050     )
2051 {
2052 }
2053 #   define vglitemDUMP_BUFFER       __dummy_dump_buffer
2054 #endif
2055 /**************************** Capture ********************************************/
2056 
2057 #ifdef __cplusplus
2058 }
2059 #endif
2060 #endif /* _vg_lite_h_ */
2061