vg_lite.h 76 KB

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