vg_lite.h 82 KB

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