vg_lite.h 103 KB

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