cairo.h 107 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153
  1. /* cairo - a vector graphics library with display and print output
  2. *
  3. * Copyright © 2002 University of Southern California
  4. * Copyright © 2005 Red Hat, Inc.
  5. *
  6. * This library is free software; you can redistribute it and/or
  7. * modify it either under the terms of the GNU Lesser General Public
  8. * License version 2.1 as published by the Free Software Foundation
  9. * (the "LGPL") or, at your option, under the terms of the Mozilla
  10. * Public License Version 1.1 (the "MPL"). If you do not alter this
  11. * notice, a recipient may use your version of this file under either
  12. * the MPL or the LGPL.
  13. *
  14. * You should have received a copy of the LGPL along with this library
  15. * in the file COPYING-LGPL-2.1; if not, write to the Free Software
  16. * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
  17. * You should have received a copy of the MPL along with this library
  18. * in the file COPYING-MPL-1.1
  19. *
  20. * The contents of this file are subject to the Mozilla Public License
  21. * Version 1.1 (the "License"); you may not use this file except in
  22. * compliance with the License. You may obtain a copy of the License at
  23. * http://www.mozilla.org/MPL/
  24. *
  25. * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
  26. * OF ANY KIND, either express or implied. See the LGPL or the MPL for
  27. * the specific language governing rights and limitations.
  28. *
  29. * The Original Code is the cairo graphics library.
  30. *
  31. * The Initial Developer of the Original Code is University of Southern
  32. * California.
  33. *
  34. * Contributor(s):
  35. * Carl D. Worth <cworth@cworth.org>
  36. */
  37. #ifndef CAIRO_H
  38. #define CAIRO_H
  39. #include "cairo-version.h"
  40. #include "cairo-features.h"
  41. #include "cairo-deprecated.h"
  42. #ifdef __cplusplus
  43. # define CAIRO_BEGIN_DECLS extern "C" {
  44. # define CAIRO_END_DECLS }
  45. #else
  46. # define CAIRO_BEGIN_DECLS
  47. # define CAIRO_END_DECLS
  48. #endif
  49. #ifndef cairo_public
  50. # if defined (_MSC_VER) && ! defined (CAIRO_WIN32_STATIC_BUILD)
  51. # define cairo_public __declspec(dllimport)
  52. # else
  53. # define cairo_public
  54. # endif
  55. #endif
  56. CAIRO_BEGIN_DECLS
  57. #define CAIRO_VERSION_ENCODE(major, minor, micro) ( \
  58. ((major) * 10000) \
  59. + ((minor) * 100) \
  60. + ((micro) * 1))
  61. #define CAIRO_VERSION CAIRO_VERSION_ENCODE( \
  62. CAIRO_VERSION_MAJOR, \
  63. CAIRO_VERSION_MINOR, \
  64. CAIRO_VERSION_MICRO)
  65. #define CAIRO_VERSION_STRINGIZE_(major, minor, micro) \
  66. #major"."#minor"."#micro
  67. #define CAIRO_VERSION_STRINGIZE(major, minor, micro) \
  68. CAIRO_VERSION_STRINGIZE_(major, minor, micro)
  69. #define CAIRO_VERSION_STRING CAIRO_VERSION_STRINGIZE( \
  70. CAIRO_VERSION_MAJOR, \
  71. CAIRO_VERSION_MINOR, \
  72. CAIRO_VERSION_MICRO)
  73. cairo_public int
  74. cairo_version (void);
  75. cairo_public const char*
  76. cairo_version_string (void);
  77. /**
  78. * cairo_bool_t:
  79. *
  80. * #cairo_bool_t is used for boolean values. Returns of type
  81. * #cairo_bool_t will always be either 0 or 1, but testing against
  82. * these values explicitly is not encouraged; just use the
  83. * value as a boolean condition.
  84. *
  85. * <informalexample><programlisting>
  86. * if (cairo_in_stroke (cr, x, y)) {
  87. * /<!-- -->* do something *<!-- -->/
  88. * }
  89. * </programlisting></informalexample>
  90. *
  91. * Since: 1.0
  92. **/
  93. typedef int cairo_bool_t;
  94. /**
  95. * cairo_t:
  96. *
  97. * A #cairo_t contains the current state of the rendering device,
  98. * including coordinates of yet to be drawn shapes.
  99. *
  100. * Cairo contexts, as #cairo_t objects are named, are central to
  101. * cairo and all drawing with cairo is always done to a #cairo_t
  102. * object.
  103. *
  104. * Memory management of #cairo_t is done with
  105. * cairo_reference() and cairo_destroy().
  106. *
  107. * Since: 1.0
  108. **/
  109. typedef struct _cairo cairo_t;
  110. /**
  111. * cairo_surface_t:
  112. *
  113. * A #cairo_surface_t represents an image, either as the destination
  114. * of a drawing operation or as source when drawing onto another
  115. * surface. To draw to a #cairo_surface_t, create a cairo context
  116. * with the surface as the target, using cairo_create().
  117. *
  118. * There are different subtypes of #cairo_surface_t for
  119. * different drawing backends; for example, cairo_image_surface_create()
  120. * creates a bitmap image in memory.
  121. * The type of a surface can be queried with cairo_surface_get_type().
  122. *
  123. * The initial contents of a surface after creation depend upon the manner
  124. * of its creation. If cairo creates the surface and backing storage for
  125. * the user, it will be initially cleared; for example,
  126. * cairo_image_surface_create() and cairo_surface_create_similar().
  127. * Alternatively, if the user passes in a reference to some backing storage
  128. * and asks cairo to wrap that in a #cairo_surface_t, then the contents are
  129. * not modified; for example, cairo_image_surface_create_for_data() and
  130. * cairo_xlib_surface_create().
  131. *
  132. * Memory management of #cairo_surface_t is done with
  133. * cairo_surface_reference() and cairo_surface_destroy().
  134. *
  135. * Since: 1.0
  136. **/
  137. typedef struct _cairo_surface cairo_surface_t;
  138. /**
  139. * cairo_device_t:
  140. *
  141. * A #cairo_device_t represents the driver interface for drawing
  142. * operations to a #cairo_surface_t. There are different subtypes of
  143. * #cairo_device_t for different drawing backends; for example,
  144. * cairo_egl_device_create() creates a device that wraps an EGL display and
  145. * context.
  146. *
  147. * The type of a device can be queried with cairo_device_get_type().
  148. *
  149. * Memory management of #cairo_device_t is done with
  150. * cairo_device_reference() and cairo_device_destroy().
  151. *
  152. * Since: 1.10
  153. **/
  154. typedef struct _cairo_device cairo_device_t;
  155. /**
  156. * cairo_matrix_t:
  157. * @xx: xx component of the affine transformation
  158. * @yx: yx component of the affine transformation
  159. * @xy: xy component of the affine transformation
  160. * @yy: yy component of the affine transformation
  161. * @x0: X translation component of the affine transformation
  162. * @y0: Y translation component of the affine transformation
  163. *
  164. * A #cairo_matrix_t holds an affine transformation, such as a scale,
  165. * rotation, shear, or a combination of those. The transformation of
  166. * a point (x, y) is given by:
  167. * <programlisting>
  168. * x_new = xx * x + xy * y + x0;
  169. * y_new = yx * x + yy * y + y0;
  170. * </programlisting>
  171. *
  172. * Since: 1.0
  173. **/
  174. typedef struct _cairo_matrix {
  175. double xx; double yx;
  176. double xy; double yy;
  177. double x0; double y0;
  178. } cairo_matrix_t;
  179. /**
  180. * cairo_pattern_t:
  181. *
  182. * A #cairo_pattern_t represents a source when drawing onto a
  183. * surface. There are different subtypes of #cairo_pattern_t,
  184. * for different types of sources; for example,
  185. * cairo_pattern_create_rgb() creates a pattern for a solid
  186. * opaque color.
  187. *
  188. * Other than various
  189. * <function>cairo_pattern_create_<emphasis>type</emphasis>()</function>
  190. * functions, some of the pattern types can be implicitly created using various
  191. * <function>cairo_set_source_<emphasis>type</emphasis>()</function> functions;
  192. * for example cairo_set_source_rgb().
  193. *
  194. * The type of a pattern can be queried with cairo_pattern_get_type().
  195. *
  196. * Memory management of #cairo_pattern_t is done with
  197. * cairo_pattern_reference() and cairo_pattern_destroy().
  198. *
  199. * Since: 1.0
  200. **/
  201. typedef struct _cairo_pattern cairo_pattern_t;
  202. /**
  203. * cairo_destroy_func_t:
  204. * @data: The data element being destroyed.
  205. *
  206. * #cairo_destroy_func_t the type of function which is called when a
  207. * data element is destroyed. It is passed the pointer to the data
  208. * element and should free any memory and resources allocated for it.
  209. *
  210. * Since: 1.0
  211. **/
  212. typedef void (*cairo_destroy_func_t) (void *data);
  213. /**
  214. * cairo_user_data_key_t:
  215. * @unused: not used; ignore.
  216. *
  217. * #cairo_user_data_key_t is used for attaching user data to cairo
  218. * data structures. The actual contents of the struct is never used,
  219. * and there is no need to initialize the object; only the unique
  220. * address of a #cairo_data_key_t object is used. Typically, you
  221. * would just use the address of a static #cairo_data_key_t object.
  222. *
  223. * Since: 1.0
  224. **/
  225. typedef struct _cairo_user_data_key {
  226. int unused;
  227. } cairo_user_data_key_t;
  228. /**
  229. * cairo_status_t:
  230. * @CAIRO_STATUS_SUCCESS: no error has occurred (Since 1.0)
  231. * @CAIRO_STATUS_NO_MEMORY: out of memory (Since 1.0)
  232. * @CAIRO_STATUS_INVALID_RESTORE: cairo_restore() called without matching cairo_save() (Since 1.0)
  233. * @CAIRO_STATUS_INVALID_POP_GROUP: no saved group to pop, i.e. cairo_pop_group() without matching cairo_push_group() (Since 1.0)
  234. * @CAIRO_STATUS_NO_CURRENT_POINT: no current point defined (Since 1.0)
  235. * @CAIRO_STATUS_INVALID_MATRIX: invalid matrix (not invertible) (Since 1.0)
  236. * @CAIRO_STATUS_INVALID_STATUS: invalid value for an input #cairo_status_t (Since 1.0)
  237. * @CAIRO_STATUS_NULL_POINTER: %NULL pointer (Since 1.0)
  238. * @CAIRO_STATUS_INVALID_STRING: input string not valid UTF-8 (Since 1.0)
  239. * @CAIRO_STATUS_INVALID_PATH_DATA: input path data not valid (Since 1.0)
  240. * @CAIRO_STATUS_READ_ERROR: error while reading from input stream (Since 1.0)
  241. * @CAIRO_STATUS_WRITE_ERROR: error while writing to output stream (Since 1.0)
  242. * @CAIRO_STATUS_SURFACE_FINISHED: target surface has been finished (Since 1.0)
  243. * @CAIRO_STATUS_SURFACE_TYPE_MISMATCH: the surface type is not appropriate for the operation (Since 1.0)
  244. * @CAIRO_STATUS_PATTERN_TYPE_MISMATCH: the pattern type is not appropriate for the operation (Since 1.0)
  245. * @CAIRO_STATUS_INVALID_CONTENT: invalid value for an input #cairo_content_t (Since 1.0)
  246. * @CAIRO_STATUS_INVALID_FORMAT: invalid value for an input #cairo_format_t (Since 1.0)
  247. * @CAIRO_STATUS_INVALID_VISUAL: invalid value for an input Visual* (Since 1.0)
  248. * @CAIRO_STATUS_FILE_NOT_FOUND: file not found (Since 1.0)
  249. * @CAIRO_STATUS_INVALID_DASH: invalid value for a dash setting (Since 1.0)
  250. * @CAIRO_STATUS_INVALID_DSC_COMMENT: invalid value for a DSC comment (Since 1.2)
  251. * @CAIRO_STATUS_INVALID_INDEX: invalid index passed to getter (Since 1.4)
  252. * @CAIRO_STATUS_CLIP_NOT_REPRESENTABLE: clip region not representable in desired format (Since 1.4)
  253. * @CAIRO_STATUS_TEMP_FILE_ERROR: error creating or writing to a temporary file (Since 1.6)
  254. * @CAIRO_STATUS_INVALID_STRIDE: invalid value for stride (Since 1.6)
  255. * @CAIRO_STATUS_FONT_TYPE_MISMATCH: the font type is not appropriate for the operation (Since 1.8)
  256. * @CAIRO_STATUS_USER_FONT_IMMUTABLE: the user-font is immutable (Since 1.8)
  257. * @CAIRO_STATUS_USER_FONT_ERROR: error occurred in a user-font callback function (Since 1.8)
  258. * @CAIRO_STATUS_NEGATIVE_COUNT: negative number used where it is not allowed (Since 1.8)
  259. * @CAIRO_STATUS_INVALID_CLUSTERS: input clusters do not represent the accompanying text and glyph array (Since 1.8)
  260. * @CAIRO_STATUS_INVALID_SLANT: invalid value for an input #cairo_font_slant_t (Since 1.8)
  261. * @CAIRO_STATUS_INVALID_WEIGHT: invalid value for an input #cairo_font_weight_t (Since 1.8)
  262. * @CAIRO_STATUS_INVALID_SIZE: invalid value (typically too big) for the size of the input (surface, pattern, etc.) (Since 1.10)
  263. * @CAIRO_STATUS_USER_FONT_NOT_IMPLEMENTED: user-font method not implemented (Since 1.10)
  264. * @CAIRO_STATUS_DEVICE_TYPE_MISMATCH: the device type is not appropriate for the operation (Since 1.10)
  265. * @CAIRO_STATUS_DEVICE_ERROR: an operation to the device caused an unspecified error (Since 1.10)
  266. * @CAIRO_STATUS_INVALID_MESH_CONSTRUCTION: a mesh pattern
  267. * construction operation was used outside of a
  268. * cairo_mesh_pattern_begin_patch()/cairo_mesh_pattern_end_patch()
  269. * pair (Since 1.12)
  270. * @CAIRO_STATUS_DEVICE_FINISHED: target device has been finished (Since 1.12)
  271. * @CAIRO_STATUS_JBIG2_GLOBAL_MISSING: %CAIRO_MIME_TYPE_JBIG2_GLOBAL_ID has been used on at least one image
  272. * but no image provided %CAIRO_MIME_TYPE_JBIG2_GLOBAL (Since 1.14)
  273. * @CAIRO_STATUS_LAST_STATUS: this is a special value indicating the number of
  274. * status values defined in this enumeration. When using this value, note
  275. * that the version of cairo at run-time may have additional status values
  276. * defined than the value of this symbol at compile-time. (Since 1.10)
  277. *
  278. * #cairo_status_t is used to indicate errors that can occur when
  279. * using Cairo. In some cases it is returned directly by functions.
  280. * but when using #cairo_t, the last error, if any, is stored in
  281. * the context and can be retrieved with cairo_status().
  282. *
  283. * New entries may be added in future versions. Use cairo_status_to_string()
  284. * to get a human-readable representation of an error message.
  285. *
  286. * Since: 1.0
  287. **/
  288. typedef enum _cairo_status {
  289. CAIRO_STATUS_SUCCESS = 0,
  290. CAIRO_STATUS_NO_MEMORY,
  291. CAIRO_STATUS_INVALID_RESTORE,
  292. CAIRO_STATUS_INVALID_POP_GROUP,
  293. CAIRO_STATUS_NO_CURRENT_POINT,
  294. CAIRO_STATUS_INVALID_MATRIX,
  295. CAIRO_STATUS_INVALID_STATUS,
  296. CAIRO_STATUS_NULL_POINTER,
  297. CAIRO_STATUS_INVALID_STRING,
  298. CAIRO_STATUS_INVALID_PATH_DATA,
  299. CAIRO_STATUS_READ_ERROR,
  300. CAIRO_STATUS_WRITE_ERROR,
  301. CAIRO_STATUS_SURFACE_FINISHED,
  302. CAIRO_STATUS_SURFACE_TYPE_MISMATCH,
  303. CAIRO_STATUS_PATTERN_TYPE_MISMATCH,
  304. CAIRO_STATUS_INVALID_CONTENT,
  305. CAIRO_STATUS_INVALID_FORMAT,
  306. CAIRO_STATUS_INVALID_VISUAL,
  307. CAIRO_STATUS_FILE_NOT_FOUND,
  308. CAIRO_STATUS_INVALID_DASH,
  309. CAIRO_STATUS_INVALID_DSC_COMMENT,
  310. CAIRO_STATUS_INVALID_INDEX,
  311. CAIRO_STATUS_CLIP_NOT_REPRESENTABLE,
  312. CAIRO_STATUS_TEMP_FILE_ERROR,
  313. CAIRO_STATUS_INVALID_STRIDE,
  314. CAIRO_STATUS_FONT_TYPE_MISMATCH,
  315. CAIRO_STATUS_USER_FONT_IMMUTABLE,
  316. CAIRO_STATUS_USER_FONT_ERROR,
  317. CAIRO_STATUS_NEGATIVE_COUNT,
  318. CAIRO_STATUS_INVALID_CLUSTERS,
  319. CAIRO_STATUS_INVALID_SLANT,
  320. CAIRO_STATUS_INVALID_WEIGHT,
  321. CAIRO_STATUS_INVALID_SIZE,
  322. CAIRO_STATUS_USER_FONT_NOT_IMPLEMENTED,
  323. CAIRO_STATUS_DEVICE_TYPE_MISMATCH,
  324. CAIRO_STATUS_DEVICE_ERROR,
  325. CAIRO_STATUS_INVALID_MESH_CONSTRUCTION,
  326. CAIRO_STATUS_DEVICE_FINISHED,
  327. CAIRO_STATUS_JBIG2_GLOBAL_MISSING,
  328. CAIRO_STATUS_LAST_STATUS
  329. } cairo_status_t;
  330. /**
  331. * cairo_content_t:
  332. * @CAIRO_CONTENT_COLOR: The surface will hold color content only. (Since 1.0)
  333. * @CAIRO_CONTENT_ALPHA: The surface will hold alpha content only. (Since 1.0)
  334. * @CAIRO_CONTENT_COLOR_ALPHA: The surface will hold color and alpha content. (Since 1.0)
  335. *
  336. * #cairo_content_t is used to describe the content that a surface will
  337. * contain, whether color information, alpha information (translucence
  338. * vs. opacity), or both.
  339. *
  340. * Note: The large values here are designed to keep #cairo_content_t
  341. * values distinct from #cairo_format_t values so that the
  342. * implementation can detect the error if users confuse the two types.
  343. *
  344. * Since: 1.0
  345. **/
  346. typedef enum _cairo_content {
  347. CAIRO_CONTENT_COLOR = 0x1000,
  348. CAIRO_CONTENT_ALPHA = 0x2000,
  349. CAIRO_CONTENT_COLOR_ALPHA = 0x3000
  350. } cairo_content_t;
  351. /**
  352. * cairo_format_t:
  353. * @CAIRO_FORMAT_INVALID: no such format exists or is supported.
  354. * @CAIRO_FORMAT_ARGB32: each pixel is a 32-bit quantity, with
  355. * alpha in the upper 8 bits, then red, then green, then blue.
  356. * The 32-bit quantities are stored native-endian. Pre-multiplied
  357. * alpha is used. (That is, 50% transparent red is 0x80800000,
  358. * not 0x80ff0000.) (Since 1.0)
  359. * @CAIRO_FORMAT_RGB24: each pixel is a 32-bit quantity, with
  360. * the upper 8 bits unused. Red, Green, and Blue are stored
  361. * in the remaining 24 bits in that order. (Since 1.0)
  362. * @CAIRO_FORMAT_A8: each pixel is a 8-bit quantity holding
  363. * an alpha value. (Since 1.0)
  364. * @CAIRO_FORMAT_A1: each pixel is a 1-bit quantity holding
  365. * an alpha value. Pixels are packed together into 32-bit
  366. * quantities. The ordering of the bits matches the
  367. * endianess of the platform. On a big-endian machine, the
  368. * first pixel is in the uppermost bit, on a little-endian
  369. * machine the first pixel is in the least-significant bit. (Since 1.0)
  370. * @CAIRO_FORMAT_RGB16_565: each pixel is a 16-bit quantity
  371. * with red in the upper 5 bits, then green in the middle
  372. * 6 bits, and blue in the lower 5 bits. (Since 1.2)
  373. * @CAIRO_FORMAT_RGB30: like RGB24 but with 10bpc. (Since 1.12)
  374. *
  375. * #cairo_format_t is used to identify the memory format of
  376. * image data.
  377. *
  378. * New entries may be added in future versions.
  379. *
  380. * Since: 1.0
  381. **/
  382. typedef enum _cairo_format {
  383. CAIRO_FORMAT_INVALID = -1,
  384. CAIRO_FORMAT_ARGB32 = 0,
  385. CAIRO_FORMAT_RGB24 = 1,
  386. CAIRO_FORMAT_A8 = 2,
  387. CAIRO_FORMAT_A1 = 3,
  388. CAIRO_FORMAT_RGB16_565 = 4,
  389. CAIRO_FORMAT_RGB30 = 5
  390. } cairo_format_t;
  391. /**
  392. * cairo_write_func_t:
  393. * @closure: the output closure
  394. * @data: the buffer containing the data to write
  395. * @length: the amount of data to write
  396. *
  397. * #cairo_write_func_t is the type of function which is called when a
  398. * backend needs to write data to an output stream. It is passed the
  399. * closure which was specified by the user at the time the write
  400. * function was registered, the data to write and the length of the
  401. * data in bytes. The write function should return
  402. * %CAIRO_STATUS_SUCCESS if all the data was successfully written,
  403. * %CAIRO_STATUS_WRITE_ERROR otherwise.
  404. *
  405. * Returns: the status code of the write operation
  406. *
  407. * Since: 1.0
  408. **/
  409. typedef cairo_status_t (*cairo_write_func_t) (void *closure,
  410. const unsigned char *data,
  411. unsigned int length);
  412. /**
  413. * cairo_read_func_t:
  414. * @closure: the input closure
  415. * @data: the buffer into which to read the data
  416. * @length: the amount of data to read
  417. *
  418. * #cairo_read_func_t is the type of function which is called when a
  419. * backend needs to read data from an input stream. It is passed the
  420. * closure which was specified by the user at the time the read
  421. * function was registered, the buffer to read the data into and the
  422. * length of the data in bytes. The read function should return
  423. * %CAIRO_STATUS_SUCCESS if all the data was successfully read,
  424. * %CAIRO_STATUS_READ_ERROR otherwise.
  425. *
  426. * Returns: the status code of the read operation
  427. *
  428. * Since: 1.0
  429. **/
  430. typedef cairo_status_t (*cairo_read_func_t) (void *closure,
  431. unsigned char *data,
  432. unsigned int length);
  433. /**
  434. * cairo_rectangle_int_t:
  435. * @x: X coordinate of the left side of the rectangle
  436. * @y: Y coordinate of the the top side of the rectangle
  437. * @width: width of the rectangle
  438. * @height: height of the rectangle
  439. *
  440. * A data structure for holding a rectangle with integer coordinates.
  441. *
  442. * Since: 1.10
  443. **/
  444. typedef struct _cairo_rectangle_int {
  445. int x, y;
  446. int width, height;
  447. } cairo_rectangle_int_t;
  448. /* Functions for manipulating state objects */
  449. cairo_public cairo_t *
  450. cairo_create (cairo_surface_t *target);
  451. cairo_public cairo_t *
  452. cairo_reference (cairo_t *cr);
  453. cairo_public void
  454. cairo_destroy (cairo_t *cr);
  455. cairo_public unsigned int
  456. cairo_get_reference_count (cairo_t *cr);
  457. cairo_public void *
  458. cairo_get_user_data (cairo_t *cr,
  459. const cairo_user_data_key_t *key);
  460. cairo_public cairo_status_t
  461. cairo_set_user_data (cairo_t *cr,
  462. const cairo_user_data_key_t *key,
  463. void *user_data,
  464. cairo_destroy_func_t destroy);
  465. cairo_public void
  466. cairo_save (cairo_t *cr);
  467. cairo_public void
  468. cairo_restore (cairo_t *cr);
  469. cairo_public void
  470. cairo_push_group (cairo_t *cr);
  471. cairo_public void
  472. cairo_push_group_with_content (cairo_t *cr, cairo_content_t content);
  473. cairo_public cairo_pattern_t *
  474. cairo_pop_group (cairo_t *cr);
  475. cairo_public void
  476. cairo_pop_group_to_source (cairo_t *cr);
  477. /* Modify state */
  478. /**
  479. * cairo_operator_t:
  480. * @CAIRO_OPERATOR_CLEAR: clear destination layer (bounded) (Since 1.0)
  481. * @CAIRO_OPERATOR_SOURCE: replace destination layer (bounded) (Since 1.0)
  482. * @CAIRO_OPERATOR_OVER: draw source layer on top of destination layer
  483. * (bounded) (Since 1.0)
  484. * @CAIRO_OPERATOR_IN: draw source where there was destination content
  485. * (unbounded) (Since 1.0)
  486. * @CAIRO_OPERATOR_OUT: draw source where there was no destination
  487. * content (unbounded) (Since 1.0)
  488. * @CAIRO_OPERATOR_ATOP: draw source on top of destination content and
  489. * only there (Since 1.0)
  490. * @CAIRO_OPERATOR_DEST: ignore the source (Since 1.0)
  491. * @CAIRO_OPERATOR_DEST_OVER: draw destination on top of source (Since 1.0)
  492. * @CAIRO_OPERATOR_DEST_IN: leave destination only where there was
  493. * source content (unbounded) (Since 1.0)
  494. * @CAIRO_OPERATOR_DEST_OUT: leave destination only where there was no
  495. * source content (Since 1.0)
  496. * @CAIRO_OPERATOR_DEST_ATOP: leave destination on top of source content
  497. * and only there (unbounded) (Since 1.0)
  498. * @CAIRO_OPERATOR_XOR: source and destination are shown where there is only
  499. * one of them (Since 1.0)
  500. * @CAIRO_OPERATOR_ADD: source and destination layers are accumulated (Since 1.0)
  501. * @CAIRO_OPERATOR_SATURATE: like over, but assuming source and dest are
  502. * disjoint geometries (Since 1.0)
  503. * @CAIRO_OPERATOR_MULTIPLY: source and destination layers are multiplied.
  504. * This causes the result to be at least as dark as the darker inputs. (Since 1.10)
  505. * @CAIRO_OPERATOR_SCREEN: source and destination are complemented and
  506. * multiplied. This causes the result to be at least as light as the lighter
  507. * inputs. (Since 1.10)
  508. * @CAIRO_OPERATOR_OVERLAY: multiplies or screens, depending on the
  509. * lightness of the destination color. (Since 1.10)
  510. * @CAIRO_OPERATOR_DARKEN: replaces the destination with the source if it
  511. * is darker, otherwise keeps the source. (Since 1.10)
  512. * @CAIRO_OPERATOR_LIGHTEN: replaces the destination with the source if it
  513. * is lighter, otherwise keeps the source. (Since 1.10)
  514. * @CAIRO_OPERATOR_COLOR_DODGE: brightens the destination color to reflect
  515. * the source color. (Since 1.10)
  516. * @CAIRO_OPERATOR_COLOR_BURN: darkens the destination color to reflect
  517. * the source color. (Since 1.10)
  518. * @CAIRO_OPERATOR_HARD_LIGHT: Multiplies or screens, dependent on source
  519. * color. (Since 1.10)
  520. * @CAIRO_OPERATOR_SOFT_LIGHT: Darkens or lightens, dependent on source
  521. * color. (Since 1.10)
  522. * @CAIRO_OPERATOR_DIFFERENCE: Takes the difference of the source and
  523. * destination color. (Since 1.10)
  524. * @CAIRO_OPERATOR_EXCLUSION: Produces an effect similar to difference, but
  525. * with lower contrast. (Since 1.10)
  526. * @CAIRO_OPERATOR_HSL_HUE: Creates a color with the hue of the source
  527. * and the saturation and luminosity of the target. (Since 1.10)
  528. * @CAIRO_OPERATOR_HSL_SATURATION: Creates a color with the saturation
  529. * of the source and the hue and luminosity of the target. Painting with
  530. * this mode onto a gray area produces no change. (Since 1.10)
  531. * @CAIRO_OPERATOR_HSL_COLOR: Creates a color with the hue and saturation
  532. * of the source and the luminosity of the target. This preserves the gray
  533. * levels of the target and is useful for coloring monochrome images or
  534. * tinting color images. (Since 1.10)
  535. * @CAIRO_OPERATOR_HSL_LUMINOSITY: Creates a color with the luminosity of
  536. * the source and the hue and saturation of the target. This produces an
  537. * inverse effect to @CAIRO_OPERATOR_HSL_COLOR. (Since 1.10)
  538. *
  539. * #cairo_operator_t is used to set the compositing operator for all cairo
  540. * drawing operations.
  541. *
  542. * The default operator is %CAIRO_OPERATOR_OVER.
  543. *
  544. * The operators marked as <firstterm>unbounded</firstterm> modify their
  545. * destination even outside of the mask layer (that is, their effect is not
  546. * bound by the mask layer). However, their effect can still be limited by
  547. * way of clipping.
  548. *
  549. * To keep things simple, the operator descriptions here
  550. * document the behavior for when both source and destination are either fully
  551. * transparent or fully opaque. The actual implementation works for
  552. * translucent layers too.
  553. * For a more detailed explanation of the effects of each operator, including
  554. * the mathematical definitions, see
  555. * <ulink url="http://cairographics.org/operators/">http://cairographics.org/operators/</ulink>.
  556. *
  557. * Since: 1.0
  558. **/
  559. typedef enum _cairo_operator {
  560. CAIRO_OPERATOR_CLEAR,
  561. CAIRO_OPERATOR_SOURCE,
  562. CAIRO_OPERATOR_OVER,
  563. CAIRO_OPERATOR_IN,
  564. CAIRO_OPERATOR_OUT,
  565. CAIRO_OPERATOR_ATOP,
  566. CAIRO_OPERATOR_DEST,
  567. CAIRO_OPERATOR_DEST_OVER,
  568. CAIRO_OPERATOR_DEST_IN,
  569. CAIRO_OPERATOR_DEST_OUT,
  570. CAIRO_OPERATOR_DEST_ATOP,
  571. CAIRO_OPERATOR_XOR,
  572. CAIRO_OPERATOR_ADD,
  573. CAIRO_OPERATOR_SATURATE,
  574. CAIRO_OPERATOR_MULTIPLY,
  575. CAIRO_OPERATOR_SCREEN,
  576. CAIRO_OPERATOR_OVERLAY,
  577. CAIRO_OPERATOR_DARKEN,
  578. CAIRO_OPERATOR_LIGHTEN,
  579. CAIRO_OPERATOR_COLOR_DODGE,
  580. CAIRO_OPERATOR_COLOR_BURN,
  581. CAIRO_OPERATOR_HARD_LIGHT,
  582. CAIRO_OPERATOR_SOFT_LIGHT,
  583. CAIRO_OPERATOR_DIFFERENCE,
  584. CAIRO_OPERATOR_EXCLUSION,
  585. CAIRO_OPERATOR_HSL_HUE,
  586. CAIRO_OPERATOR_HSL_SATURATION,
  587. CAIRO_OPERATOR_HSL_COLOR,
  588. CAIRO_OPERATOR_HSL_LUMINOSITY
  589. } cairo_operator_t;
  590. cairo_public void
  591. cairo_set_operator (cairo_t *cr, cairo_operator_t op);
  592. cairo_public void
  593. cairo_set_source (cairo_t *cr, cairo_pattern_t *source);
  594. cairo_public void
  595. cairo_set_source_rgb (cairo_t *cr, double red, double green, double blue);
  596. cairo_public void
  597. cairo_set_source_rgba (cairo_t *cr,
  598. double red, double green, double blue,
  599. double alpha);
  600. cairo_public void
  601. cairo_set_source_surface (cairo_t *cr,
  602. cairo_surface_t *surface,
  603. double x,
  604. double y);
  605. cairo_public void
  606. cairo_set_tolerance (cairo_t *cr, double tolerance);
  607. /**
  608. * cairo_antialias_t:
  609. * @CAIRO_ANTIALIAS_DEFAULT: Use the default antialiasing for
  610. * the subsystem and target device, since 1.0
  611. * @CAIRO_ANTIALIAS_NONE: Use a bilevel alpha mask, since 1.0
  612. * @CAIRO_ANTIALIAS_GRAY: Perform single-color antialiasing (using
  613. * shades of gray for black text on a white background, for example), since 1.0
  614. * @CAIRO_ANTIALIAS_SUBPIXEL: Perform antialiasing by taking
  615. * advantage of the order of subpixel elements on devices
  616. * such as LCD panels, since 1.0
  617. * @CAIRO_ANTIALIAS_FAST: Hint that the backend should perform some
  618. * antialiasing but prefer speed over quality, since 1.12
  619. * @CAIRO_ANTIALIAS_GOOD: The backend should balance quality against
  620. * performance, since 1.12
  621. * @CAIRO_ANTIALIAS_BEST: Hint that the backend should render at the highest
  622. * quality, sacrificing speed if necessary, since 1.12
  623. *
  624. * Specifies the type of antialiasing to do when rendering text or shapes.
  625. *
  626. * As it is not necessarily clear from the above what advantages a particular
  627. * antialias method provides, since 1.12, there is also a set of hints:
  628. * @CAIRO_ANTIALIAS_FAST: Allow the backend to degrade raster quality for speed
  629. * @CAIRO_ANTIALIAS_GOOD: A balance between speed and quality
  630. * @CAIRO_ANTIALIAS_BEST: A high-fidelity, but potentially slow, raster mode
  631. *
  632. * These make no guarantee on how the backend will perform its rasterisation
  633. * (if it even rasterises!), nor that they have any differing effect other
  634. * than to enable some form of antialiasing. In the case of glyph rendering,
  635. * @CAIRO_ANTIALIAS_FAST and @CAIRO_ANTIALIAS_GOOD will be mapped to
  636. * @CAIRO_ANTIALIAS_GRAY, with @CAIRO_ANTALIAS_BEST being equivalent to
  637. * @CAIRO_ANTIALIAS_SUBPIXEL.
  638. *
  639. * The interpretation of @CAIRO_ANTIALIAS_DEFAULT is left entirely up to
  640. * the backend, typically this will be similar to @CAIRO_ANTIALIAS_GOOD.
  641. *
  642. * Since: 1.0
  643. **/
  644. typedef enum _cairo_antialias {
  645. CAIRO_ANTIALIAS_DEFAULT,
  646. /* method */
  647. CAIRO_ANTIALIAS_NONE,
  648. CAIRO_ANTIALIAS_GRAY,
  649. CAIRO_ANTIALIAS_SUBPIXEL,
  650. /* hints */
  651. CAIRO_ANTIALIAS_FAST,
  652. CAIRO_ANTIALIAS_GOOD,
  653. CAIRO_ANTIALIAS_BEST
  654. } cairo_antialias_t;
  655. cairo_public void
  656. cairo_set_antialias (cairo_t *cr, cairo_antialias_t antialias);
  657. /**
  658. * cairo_fill_rule_t:
  659. * @CAIRO_FILL_RULE_WINDING: If the path crosses the ray from
  660. * left-to-right, counts +1. If the path crosses the ray
  661. * from right to left, counts -1. (Left and right are determined
  662. * from the perspective of looking along the ray from the starting
  663. * point.) If the total count is non-zero, the point will be filled. (Since 1.0)
  664. * @CAIRO_FILL_RULE_EVEN_ODD: Counts the total number of
  665. * intersections, without regard to the orientation of the contour. If
  666. * the total number of intersections is odd, the point will be
  667. * filled. (Since 1.0)
  668. *
  669. * #cairo_fill_rule_t is used to select how paths are filled. For both
  670. * fill rules, whether or not a point is included in the fill is
  671. * determined by taking a ray from that point to infinity and looking
  672. * at intersections with the path. The ray can be in any direction,
  673. * as long as it doesn't pass through the end point of a segment
  674. * or have a tricky intersection such as intersecting tangent to the path.
  675. * (Note that filling is not actually implemented in this way. This
  676. * is just a description of the rule that is applied.)
  677. *
  678. * The default fill rule is %CAIRO_FILL_RULE_WINDING.
  679. *
  680. * New entries may be added in future versions.
  681. *
  682. * Since: 1.0
  683. **/
  684. typedef enum _cairo_fill_rule {
  685. CAIRO_FILL_RULE_WINDING,
  686. CAIRO_FILL_RULE_EVEN_ODD
  687. } cairo_fill_rule_t;
  688. cairo_public void
  689. cairo_set_fill_rule (cairo_t *cr, cairo_fill_rule_t fill_rule);
  690. cairo_public void
  691. cairo_set_line_width (cairo_t *cr, double width);
  692. /**
  693. * cairo_line_cap_t:
  694. * @CAIRO_LINE_CAP_BUTT: start(stop) the line exactly at the start(end) point (Since 1.0)
  695. * @CAIRO_LINE_CAP_ROUND: use a round ending, the center of the circle is the end point (Since 1.0)
  696. * @CAIRO_LINE_CAP_SQUARE: use squared ending, the center of the square is the end point (Since 1.0)
  697. *
  698. * Specifies how to render the endpoints of the path when stroking.
  699. *
  700. * The default line cap style is %CAIRO_LINE_CAP_BUTT.
  701. *
  702. * Since: 1.0
  703. **/
  704. typedef enum _cairo_line_cap {
  705. CAIRO_LINE_CAP_BUTT,
  706. CAIRO_LINE_CAP_ROUND,
  707. CAIRO_LINE_CAP_SQUARE
  708. } cairo_line_cap_t;
  709. cairo_public void
  710. cairo_set_line_cap (cairo_t *cr, cairo_line_cap_t line_cap);
  711. /**
  712. * cairo_line_join_t:
  713. * @CAIRO_LINE_JOIN_MITER: use a sharp (angled) corner, see
  714. * cairo_set_miter_limit() (Since 1.0)
  715. * @CAIRO_LINE_JOIN_ROUND: use a rounded join, the center of the circle is the
  716. * joint point (Since 1.0)
  717. * @CAIRO_LINE_JOIN_BEVEL: use a cut-off join, the join is cut off at half
  718. * the line width from the joint point (Since 1.0)
  719. *
  720. * Specifies how to render the junction of two lines when stroking.
  721. *
  722. * The default line join style is %CAIRO_LINE_JOIN_MITER.
  723. *
  724. * Since: 1.0
  725. **/
  726. typedef enum _cairo_line_join {
  727. CAIRO_LINE_JOIN_MITER,
  728. CAIRO_LINE_JOIN_ROUND,
  729. CAIRO_LINE_JOIN_BEVEL
  730. } cairo_line_join_t;
  731. cairo_public void
  732. cairo_set_line_join (cairo_t *cr, cairo_line_join_t line_join);
  733. cairo_public void
  734. cairo_set_dash (cairo_t *cr,
  735. const double *dashes,
  736. int num_dashes,
  737. double offset);
  738. cairo_public void
  739. cairo_set_miter_limit (cairo_t *cr, double limit);
  740. cairo_public void
  741. cairo_translate (cairo_t *cr, double tx, double ty);
  742. cairo_public void
  743. cairo_scale (cairo_t *cr, double sx, double sy);
  744. cairo_public void
  745. cairo_rotate (cairo_t *cr, double angle);
  746. cairo_public void
  747. cairo_transform (cairo_t *cr,
  748. const cairo_matrix_t *matrix);
  749. cairo_public void
  750. cairo_set_matrix (cairo_t *cr,
  751. const cairo_matrix_t *matrix);
  752. cairo_public void
  753. cairo_identity_matrix (cairo_t *cr);
  754. cairo_public void
  755. cairo_user_to_device (cairo_t *cr, double *x, double *y);
  756. cairo_public void
  757. cairo_user_to_device_distance (cairo_t *cr, double *dx, double *dy);
  758. cairo_public void
  759. cairo_device_to_user (cairo_t *cr, double *x, double *y);
  760. cairo_public void
  761. cairo_device_to_user_distance (cairo_t *cr, double *dx, double *dy);
  762. /* Path creation functions */
  763. cairo_public void
  764. cairo_new_path (cairo_t *cr);
  765. cairo_public void
  766. cairo_move_to (cairo_t *cr, double x, double y);
  767. cairo_public void
  768. cairo_new_sub_path (cairo_t *cr);
  769. cairo_public void
  770. cairo_line_to (cairo_t *cr, double x, double y);
  771. cairo_public void
  772. cairo_curve_to (cairo_t *cr,
  773. double x1, double y1,
  774. double x2, double y2,
  775. double x3, double y3);
  776. cairo_public void
  777. cairo_arc (cairo_t *cr,
  778. double xc, double yc,
  779. double radius,
  780. double angle1, double angle2);
  781. cairo_public void
  782. cairo_arc_negative (cairo_t *cr,
  783. double xc, double yc,
  784. double radius,
  785. double angle1, double angle2);
  786. /* XXX: NYI
  787. cairo_public void
  788. cairo_arc_to (cairo_t *cr,
  789. double x1, double y1,
  790. double x2, double y2,
  791. double radius);
  792. */
  793. cairo_public void
  794. cairo_rel_move_to (cairo_t *cr, double dx, double dy);
  795. cairo_public void
  796. cairo_rel_line_to (cairo_t *cr, double dx, double dy);
  797. cairo_public void
  798. cairo_rel_curve_to (cairo_t *cr,
  799. double dx1, double dy1,
  800. double dx2, double dy2,
  801. double dx3, double dy3);
  802. cairo_public void
  803. cairo_rectangle (cairo_t *cr,
  804. double x, double y,
  805. double width, double height);
  806. /* XXX: NYI
  807. cairo_public void
  808. cairo_stroke_to_path (cairo_t *cr);
  809. */
  810. cairo_public void
  811. cairo_close_path (cairo_t *cr);
  812. cairo_public void
  813. cairo_path_extents (cairo_t *cr,
  814. double *x1, double *y1,
  815. double *x2, double *y2);
  816. /* Painting functions */
  817. cairo_public void
  818. cairo_paint (cairo_t *cr);
  819. cairo_public void
  820. cairo_paint_with_alpha (cairo_t *cr,
  821. double alpha);
  822. cairo_public void
  823. cairo_mask (cairo_t *cr,
  824. cairo_pattern_t *pattern);
  825. cairo_public void
  826. cairo_mask_surface (cairo_t *cr,
  827. cairo_surface_t *surface,
  828. double surface_x,
  829. double surface_y);
  830. cairo_public void
  831. cairo_stroke (cairo_t *cr);
  832. cairo_public void
  833. cairo_stroke_preserve (cairo_t *cr);
  834. cairo_public void
  835. cairo_fill (cairo_t *cr);
  836. cairo_public void
  837. cairo_fill_preserve (cairo_t *cr);
  838. cairo_public void
  839. cairo_copy_page (cairo_t *cr);
  840. cairo_public void
  841. cairo_show_page (cairo_t *cr);
  842. /* Insideness testing */
  843. cairo_public cairo_bool_t
  844. cairo_in_stroke (cairo_t *cr, double x, double y);
  845. cairo_public cairo_bool_t
  846. cairo_in_fill (cairo_t *cr, double x, double y);
  847. cairo_public cairo_bool_t
  848. cairo_in_clip (cairo_t *cr, double x, double y);
  849. /* Rectangular extents */
  850. cairo_public void
  851. cairo_stroke_extents (cairo_t *cr,
  852. double *x1, double *y1,
  853. double *x2, double *y2);
  854. cairo_public void
  855. cairo_fill_extents (cairo_t *cr,
  856. double *x1, double *y1,
  857. double *x2, double *y2);
  858. /* Clipping */
  859. cairo_public void
  860. cairo_reset_clip (cairo_t *cr);
  861. cairo_public void
  862. cairo_clip (cairo_t *cr);
  863. cairo_public void
  864. cairo_clip_preserve (cairo_t *cr);
  865. cairo_public void
  866. cairo_clip_extents (cairo_t *cr,
  867. double *x1, double *y1,
  868. double *x2, double *y2);
  869. /**
  870. * cairo_rectangle_t:
  871. * @x: X coordinate of the left side of the rectangle
  872. * @y: Y coordinate of the the top side of the rectangle
  873. * @width: width of the rectangle
  874. * @height: height of the rectangle
  875. *
  876. * A data structure for holding a rectangle.
  877. *
  878. * Since: 1.4
  879. **/
  880. typedef struct _cairo_rectangle {
  881. double x, y, width, height;
  882. } cairo_rectangle_t;
  883. /**
  884. * cairo_rectangle_list_t:
  885. * @status: Error status of the rectangle list
  886. * @rectangles: Array containing the rectangles
  887. * @num_rectangles: Number of rectangles in this list
  888. *
  889. * A data structure for holding a dynamically allocated
  890. * array of rectangles.
  891. *
  892. * Since: 1.4
  893. **/
  894. typedef struct _cairo_rectangle_list {
  895. cairo_status_t status;
  896. cairo_rectangle_t *rectangles;
  897. int num_rectangles;
  898. } cairo_rectangle_list_t;
  899. cairo_public cairo_rectangle_list_t *
  900. cairo_copy_clip_rectangle_list (cairo_t *cr);
  901. cairo_public void
  902. cairo_rectangle_list_destroy (cairo_rectangle_list_t *rectangle_list);
  903. /* Font/Text functions */
  904. /**
  905. * cairo_scaled_font_t:
  906. *
  907. * A #cairo_scaled_font_t is a font scaled to a particular size and device
  908. * resolution. A #cairo_scaled_font_t is most useful for low-level font
  909. * usage where a library or application wants to cache a reference
  910. * to a scaled font to speed up the computation of metrics.
  911. *
  912. * There are various types of scaled fonts, depending on the
  913. * <firstterm>font backend</firstterm> they use. The type of a
  914. * scaled font can be queried using cairo_scaled_font_get_type().
  915. *
  916. * Memory management of #cairo_scaled_font_t is done with
  917. * cairo_scaled_font_reference() and cairo_scaled_font_destroy().
  918. *
  919. * Since: 1.0
  920. **/
  921. typedef struct _cairo_scaled_font cairo_scaled_font_t;
  922. /**
  923. * cairo_font_face_t:
  924. *
  925. * A #cairo_font_face_t specifies all aspects of a font other
  926. * than the size or font matrix (a font matrix is used to distort
  927. * a font by sheering it or scaling it unequally in the two
  928. * directions) . A font face can be set on a #cairo_t by using
  929. * cairo_set_font_face(); the size and font matrix are set with
  930. * cairo_set_font_size() and cairo_set_font_matrix().
  931. *
  932. * There are various types of font faces, depending on the
  933. * <firstterm>font backend</firstterm> they use. The type of a
  934. * font face can be queried using cairo_font_face_get_type().
  935. *
  936. * Memory management of #cairo_font_face_t is done with
  937. * cairo_font_face_reference() and cairo_font_face_destroy().
  938. *
  939. * Since: 1.0
  940. **/
  941. typedef struct _cairo_font_face cairo_font_face_t;
  942. /**
  943. * cairo_glyph_t:
  944. * @index: glyph index in the font. The exact interpretation of the
  945. * glyph index depends on the font technology being used.
  946. * @x: the offset in the X direction between the origin used for
  947. * drawing or measuring the string and the origin of this glyph.
  948. * @y: the offset in the Y direction between the origin used for
  949. * drawing or measuring the string and the origin of this glyph.
  950. *
  951. * The #cairo_glyph_t structure holds information about a single glyph
  952. * when drawing or measuring text. A font is (in simple terms) a
  953. * collection of shapes used to draw text. A glyph is one of these
  954. * shapes. There can be multiple glyphs for a single character
  955. * (alternates to be used in different contexts, for example), or a
  956. * glyph can be a <firstterm>ligature</firstterm> of multiple
  957. * characters. Cairo doesn't expose any way of converting input text
  958. * into glyphs, so in order to use the Cairo interfaces that take
  959. * arrays of glyphs, you must directly access the appropriate
  960. * underlying font system.
  961. *
  962. * Note that the offsets given by @x and @y are not cumulative. When
  963. * drawing or measuring text, each glyph is individually positioned
  964. * with respect to the overall origin
  965. *
  966. * Since: 1.0
  967. **/
  968. typedef struct {
  969. unsigned long index;
  970. double x;
  971. double y;
  972. } cairo_glyph_t;
  973. cairo_public cairo_glyph_t *
  974. cairo_glyph_allocate (int num_glyphs);
  975. cairo_public void
  976. cairo_glyph_free (cairo_glyph_t *glyphs);
  977. /**
  978. * cairo_text_cluster_t:
  979. * @num_bytes: the number of bytes of UTF-8 text covered by cluster
  980. * @num_glyphs: the number of glyphs covered by cluster
  981. *
  982. * The #cairo_text_cluster_t structure holds information about a single
  983. * <firstterm>text cluster</firstterm>. A text cluster is a minimal
  984. * mapping of some glyphs corresponding to some UTF-8 text.
  985. *
  986. * For a cluster to be valid, both @num_bytes and @num_glyphs should
  987. * be non-negative, and at least one should be non-zero.
  988. * Note that clusters with zero glyphs are not as well supported as
  989. * normal clusters. For example, PDF rendering applications typically
  990. * ignore those clusters when PDF text is being selected.
  991. *
  992. * See cairo_show_text_glyphs() for how clusters are used in advanced
  993. * text operations.
  994. *
  995. * Since: 1.8
  996. **/
  997. typedef struct {
  998. int num_bytes;
  999. int num_glyphs;
  1000. } cairo_text_cluster_t;
  1001. cairo_public cairo_text_cluster_t *
  1002. cairo_text_cluster_allocate (int num_clusters);
  1003. cairo_public void
  1004. cairo_text_cluster_free (cairo_text_cluster_t *clusters);
  1005. /**
  1006. * cairo_text_cluster_flags_t:
  1007. * @CAIRO_TEXT_CLUSTER_FLAG_BACKWARD: The clusters in the cluster array
  1008. * map to glyphs in the glyph array from end to start. (Since 1.8)
  1009. *
  1010. * Specifies properties of a text cluster mapping.
  1011. *
  1012. * Since: 1.8
  1013. **/
  1014. typedef enum _cairo_text_cluster_flags {
  1015. CAIRO_TEXT_CLUSTER_FLAG_BACKWARD = 0x00000001
  1016. } cairo_text_cluster_flags_t;
  1017. /**
  1018. * cairo_text_extents_t:
  1019. * @x_bearing: the horizontal distance from the origin to the
  1020. * leftmost part of the glyphs as drawn. Positive if the
  1021. * glyphs lie entirely to the right of the origin.
  1022. * @y_bearing: the vertical distance from the origin to the
  1023. * topmost part of the glyphs as drawn. Positive only if the
  1024. * glyphs lie completely below the origin; will usually be
  1025. * negative.
  1026. * @width: width of the glyphs as drawn
  1027. * @height: height of the glyphs as drawn
  1028. * @x_advance:distance to advance in the X direction
  1029. * after drawing these glyphs
  1030. * @y_advance: distance to advance in the Y direction
  1031. * after drawing these glyphs. Will typically be zero except
  1032. * for vertical text layout as found in East-Asian languages.
  1033. *
  1034. * The #cairo_text_extents_t structure stores the extents of a single
  1035. * glyph or a string of glyphs in user-space coordinates. Because text
  1036. * extents are in user-space coordinates, they are mostly, but not
  1037. * entirely, independent of the current transformation matrix. If you call
  1038. * <literal>cairo_scale(cr, 2.0, 2.0)</literal>, text will
  1039. * be drawn twice as big, but the reported text extents will not be
  1040. * doubled. They will change slightly due to hinting (so you can't
  1041. * assume that metrics are independent of the transformation matrix),
  1042. * but otherwise will remain unchanged.
  1043. *
  1044. * Since: 1.0
  1045. **/
  1046. typedef struct {
  1047. double x_bearing;
  1048. double y_bearing;
  1049. double width;
  1050. double height;
  1051. double x_advance;
  1052. double y_advance;
  1053. } cairo_text_extents_t;
  1054. /**
  1055. * cairo_font_extents_t:
  1056. * @ascent: the distance that the font extends above the baseline.
  1057. * Note that this is not always exactly equal to the maximum
  1058. * of the extents of all the glyphs in the font, but rather
  1059. * is picked to express the font designer's intent as to
  1060. * how the font should align with elements above it.
  1061. * @descent: the distance that the font extends below the baseline.
  1062. * This value is positive for typical fonts that include
  1063. * portions below the baseline. Note that this is not always
  1064. * exactly equal to the maximum of the extents of all the
  1065. * glyphs in the font, but rather is picked to express the
  1066. * font designer's intent as to how the font should
  1067. * align with elements below it.
  1068. * @height: the recommended vertical distance between baselines when
  1069. * setting consecutive lines of text with the font. This
  1070. * is greater than @ascent+@descent by a
  1071. * quantity known as the <firstterm>line spacing</firstterm>
  1072. * or <firstterm>external leading</firstterm>. When space
  1073. * is at a premium, most fonts can be set with only
  1074. * a distance of @ascent+@descent between lines.
  1075. * @max_x_advance: the maximum distance in the X direction that
  1076. * the origin is advanced for any glyph in the font.
  1077. * @max_y_advance: the maximum distance in the Y direction that
  1078. * the origin is advanced for any glyph in the font.
  1079. * This will be zero for normal fonts used for horizontal
  1080. * writing. (The scripts of East Asia are sometimes written
  1081. * vertically.)
  1082. *
  1083. * The #cairo_font_extents_t structure stores metric information for
  1084. * a font. Values are given in the current user-space coordinate
  1085. * system.
  1086. *
  1087. * Because font metrics are in user-space coordinates, they are
  1088. * mostly, but not entirely, independent of the current transformation
  1089. * matrix. If you call <literal>cairo_scale(cr, 2.0, 2.0)</literal>,
  1090. * text will be drawn twice as big, but the reported text extents will
  1091. * not be doubled. They will change slightly due to hinting (so you
  1092. * can't assume that metrics are independent of the transformation
  1093. * matrix), but otherwise will remain unchanged.
  1094. *
  1095. * Since: 1.0
  1096. **/
  1097. typedef struct {
  1098. double ascent;
  1099. double descent;
  1100. double height;
  1101. double max_x_advance;
  1102. double max_y_advance;
  1103. } cairo_font_extents_t;
  1104. /**
  1105. * cairo_font_slant_t:
  1106. * @CAIRO_FONT_SLANT_NORMAL: Upright font style, since 1.0
  1107. * @CAIRO_FONT_SLANT_ITALIC: Italic font style, since 1.0
  1108. * @CAIRO_FONT_SLANT_OBLIQUE: Oblique font style, since 1.0
  1109. *
  1110. * Specifies variants of a font face based on their slant.
  1111. *
  1112. * Since: 1.0
  1113. **/
  1114. typedef enum _cairo_font_slant {
  1115. CAIRO_FONT_SLANT_NORMAL,
  1116. CAIRO_FONT_SLANT_ITALIC,
  1117. CAIRO_FONT_SLANT_OBLIQUE
  1118. } cairo_font_slant_t;
  1119. /**
  1120. * cairo_font_weight_t:
  1121. * @CAIRO_FONT_WEIGHT_NORMAL: Normal font weight, since 1.0
  1122. * @CAIRO_FONT_WEIGHT_BOLD: Bold font weight, since 1.0
  1123. *
  1124. * Specifies variants of a font face based on their weight.
  1125. *
  1126. * Since: 1.0
  1127. **/
  1128. typedef enum _cairo_font_weight {
  1129. CAIRO_FONT_WEIGHT_NORMAL,
  1130. CAIRO_FONT_WEIGHT_BOLD
  1131. } cairo_font_weight_t;
  1132. /**
  1133. * cairo_subpixel_order_t:
  1134. * @CAIRO_SUBPIXEL_ORDER_DEFAULT: Use the default subpixel order for
  1135. * for the target device, since 1.0
  1136. * @CAIRO_SUBPIXEL_ORDER_RGB: Subpixel elements are arranged horizontally
  1137. * with red at the left, since 1.0
  1138. * @CAIRO_SUBPIXEL_ORDER_BGR: Subpixel elements are arranged horizontally
  1139. * with blue at the left, since 1.0
  1140. * @CAIRO_SUBPIXEL_ORDER_VRGB: Subpixel elements are arranged vertically
  1141. * with red at the top, since 1.0
  1142. * @CAIRO_SUBPIXEL_ORDER_VBGR: Subpixel elements are arranged vertically
  1143. * with blue at the top, since 1.0
  1144. *
  1145. * The subpixel order specifies the order of color elements within
  1146. * each pixel on the display device when rendering with an
  1147. * antialiasing mode of %CAIRO_ANTIALIAS_SUBPIXEL.
  1148. *
  1149. * Since: 1.0
  1150. **/
  1151. typedef enum _cairo_subpixel_order {
  1152. CAIRO_SUBPIXEL_ORDER_DEFAULT,
  1153. CAIRO_SUBPIXEL_ORDER_RGB,
  1154. CAIRO_SUBPIXEL_ORDER_BGR,
  1155. CAIRO_SUBPIXEL_ORDER_VRGB,
  1156. CAIRO_SUBPIXEL_ORDER_VBGR
  1157. } cairo_subpixel_order_t;
  1158. /**
  1159. * cairo_hint_style_t:
  1160. * @CAIRO_HINT_STYLE_DEFAULT: Use the default hint style for
  1161. * font backend and target device, since 1.0
  1162. * @CAIRO_HINT_STYLE_NONE: Do not hint outlines, since 1.0
  1163. * @CAIRO_HINT_STYLE_SLIGHT: Hint outlines slightly to improve
  1164. * contrast while retaining good fidelity to the original
  1165. * shapes, since 1.0
  1166. * @CAIRO_HINT_STYLE_MEDIUM: Hint outlines with medium strength
  1167. * giving a compromise between fidelity to the original shapes
  1168. * and contrast, since 1.0
  1169. * @CAIRO_HINT_STYLE_FULL: Hint outlines to maximize contrast, since 1.0
  1170. *
  1171. * Specifies the type of hinting to do on font outlines. Hinting
  1172. * is the process of fitting outlines to the pixel grid in order
  1173. * to improve the appearance of the result. Since hinting outlines
  1174. * involves distorting them, it also reduces the faithfulness
  1175. * to the original outline shapes. Not all of the outline hinting
  1176. * styles are supported by all font backends.
  1177. *
  1178. * New entries may be added in future versions.
  1179. *
  1180. * Since: 1.0
  1181. **/
  1182. typedef enum _cairo_hint_style {
  1183. CAIRO_HINT_STYLE_DEFAULT,
  1184. CAIRO_HINT_STYLE_NONE,
  1185. CAIRO_HINT_STYLE_SLIGHT,
  1186. CAIRO_HINT_STYLE_MEDIUM,
  1187. CAIRO_HINT_STYLE_FULL
  1188. } cairo_hint_style_t;
  1189. /**
  1190. * cairo_hint_metrics_t:
  1191. * @CAIRO_HINT_METRICS_DEFAULT: Hint metrics in the default
  1192. * manner for the font backend and target device, since 1.0
  1193. * @CAIRO_HINT_METRICS_OFF: Do not hint font metrics, since 1.0
  1194. * @CAIRO_HINT_METRICS_ON: Hint font metrics, since 1.0
  1195. *
  1196. * Specifies whether to hint font metrics; hinting font metrics
  1197. * means quantizing them so that they are integer values in
  1198. * device space. Doing this improves the consistency of
  1199. * letter and line spacing, however it also means that text
  1200. * will be laid out differently at different zoom factors.
  1201. *
  1202. * Since: 1.0
  1203. **/
  1204. typedef enum _cairo_hint_metrics {
  1205. CAIRO_HINT_METRICS_DEFAULT,
  1206. CAIRO_HINT_METRICS_OFF,
  1207. CAIRO_HINT_METRICS_ON
  1208. } cairo_hint_metrics_t;
  1209. /**
  1210. * cairo_font_options_t:
  1211. *
  1212. * An opaque structure holding all options that are used when
  1213. * rendering fonts.
  1214. *
  1215. * Individual features of a #cairo_font_options_t can be set or
  1216. * accessed using functions named
  1217. * <function>cairo_font_options_set_<emphasis>feature_name</emphasis>()</function> and
  1218. * <function>cairo_font_options_get_<emphasis>feature_name</emphasis>()</function>, like
  1219. * cairo_font_options_set_antialias() and
  1220. * cairo_font_options_get_antialias().
  1221. *
  1222. * New features may be added to a #cairo_font_options_t in the
  1223. * future. For this reason, cairo_font_options_copy(),
  1224. * cairo_font_options_equal(), cairo_font_options_merge(), and
  1225. * cairo_font_options_hash() should be used to copy, check
  1226. * for equality, merge, or compute a hash value of
  1227. * #cairo_font_options_t objects.
  1228. *
  1229. * Since: 1.0
  1230. **/
  1231. typedef struct _cairo_font_options cairo_font_options_t;
  1232. cairo_public cairo_font_options_t *
  1233. cairo_font_options_create (void);
  1234. cairo_public cairo_font_options_t *
  1235. cairo_font_options_copy (const cairo_font_options_t *original);
  1236. cairo_public void
  1237. cairo_font_options_destroy (cairo_font_options_t *options);
  1238. cairo_public cairo_status_t
  1239. cairo_font_options_status (cairo_font_options_t *options);
  1240. cairo_public void
  1241. cairo_font_options_merge (cairo_font_options_t *options,
  1242. const cairo_font_options_t *other);
  1243. cairo_public cairo_bool_t
  1244. cairo_font_options_equal (const cairo_font_options_t *options,
  1245. const cairo_font_options_t *other);
  1246. cairo_public unsigned long
  1247. cairo_font_options_hash (const cairo_font_options_t *options);
  1248. cairo_public void
  1249. cairo_font_options_set_antialias (cairo_font_options_t *options,
  1250. cairo_antialias_t antialias);
  1251. cairo_public cairo_antialias_t
  1252. cairo_font_options_get_antialias (const cairo_font_options_t *options);
  1253. cairo_public void
  1254. cairo_font_options_set_subpixel_order (cairo_font_options_t *options,
  1255. cairo_subpixel_order_t subpixel_order);
  1256. cairo_public cairo_subpixel_order_t
  1257. cairo_font_options_get_subpixel_order (const cairo_font_options_t *options);
  1258. cairo_public void
  1259. cairo_font_options_set_hint_style (cairo_font_options_t *options,
  1260. cairo_hint_style_t hint_style);
  1261. cairo_public cairo_hint_style_t
  1262. cairo_font_options_get_hint_style (const cairo_font_options_t *options);
  1263. cairo_public void
  1264. cairo_font_options_set_hint_metrics (cairo_font_options_t *options,
  1265. cairo_hint_metrics_t hint_metrics);
  1266. cairo_public cairo_hint_metrics_t
  1267. cairo_font_options_get_hint_metrics (const cairo_font_options_t *options);
  1268. /* This interface is for dealing with text as text, not caring about the
  1269. font object inside the the cairo_t. */
  1270. cairo_public void
  1271. cairo_select_font_face (cairo_t *cr,
  1272. const char *family,
  1273. cairo_font_slant_t slant,
  1274. cairo_font_weight_t weight);
  1275. cairo_public void
  1276. cairo_set_font_size (cairo_t *cr, double size);
  1277. cairo_public void
  1278. cairo_set_font_matrix (cairo_t *cr,
  1279. const cairo_matrix_t *matrix);
  1280. cairo_public void
  1281. cairo_get_font_matrix (cairo_t *cr,
  1282. cairo_matrix_t *matrix);
  1283. cairo_public void
  1284. cairo_set_font_options (cairo_t *cr,
  1285. const cairo_font_options_t *options);
  1286. cairo_public void
  1287. cairo_get_font_options (cairo_t *cr,
  1288. cairo_font_options_t *options);
  1289. cairo_public void
  1290. cairo_set_font_face (cairo_t *cr, cairo_font_face_t *font_face);
  1291. cairo_public cairo_font_face_t *
  1292. cairo_get_font_face (cairo_t *cr);
  1293. cairo_public void
  1294. cairo_set_scaled_font (cairo_t *cr,
  1295. const cairo_scaled_font_t *scaled_font);
  1296. cairo_public cairo_scaled_font_t *
  1297. cairo_get_scaled_font (cairo_t *cr);
  1298. cairo_public void
  1299. cairo_show_text (cairo_t *cr, const char *utf8);
  1300. cairo_public void
  1301. cairo_show_glyphs (cairo_t *cr, const cairo_glyph_t *glyphs, int num_glyphs);
  1302. cairo_public void
  1303. cairo_show_text_glyphs (cairo_t *cr,
  1304. const char *utf8,
  1305. int utf8_len,
  1306. const cairo_glyph_t *glyphs,
  1307. int num_glyphs,
  1308. const cairo_text_cluster_t *clusters,
  1309. int num_clusters,
  1310. cairo_text_cluster_flags_t cluster_flags);
  1311. cairo_public void
  1312. cairo_text_path (cairo_t *cr, const char *utf8);
  1313. cairo_public void
  1314. cairo_glyph_path (cairo_t *cr, const cairo_glyph_t *glyphs, int num_glyphs);
  1315. cairo_public void
  1316. cairo_text_extents (cairo_t *cr,
  1317. const char *utf8,
  1318. cairo_text_extents_t *extents);
  1319. cairo_public void
  1320. cairo_glyph_extents (cairo_t *cr,
  1321. const cairo_glyph_t *glyphs,
  1322. int num_glyphs,
  1323. cairo_text_extents_t *extents);
  1324. cairo_public void
  1325. cairo_font_extents (cairo_t *cr,
  1326. cairo_font_extents_t *extents);
  1327. /* Generic identifier for a font style */
  1328. cairo_public cairo_font_face_t *
  1329. cairo_font_face_reference (cairo_font_face_t *font_face);
  1330. cairo_public void
  1331. cairo_font_face_destroy (cairo_font_face_t *font_face);
  1332. cairo_public unsigned int
  1333. cairo_font_face_get_reference_count (cairo_font_face_t *font_face);
  1334. cairo_public cairo_status_t
  1335. cairo_font_face_status (cairo_font_face_t *font_face);
  1336. /**
  1337. * cairo_font_type_t:
  1338. * @CAIRO_FONT_TYPE_TOY: The font was created using cairo's toy font api (Since: 1.2)
  1339. * @CAIRO_FONT_TYPE_FT: The font is of type FreeType (Since: 1.2)
  1340. * @CAIRO_FONT_TYPE_WIN32: The font is of type Win32 (Since: 1.2)
  1341. * @CAIRO_FONT_TYPE_QUARTZ: The font is of type Quartz (Since: 1.6, in 1.2 and
  1342. * 1.4 it was named CAIRO_FONT_TYPE_ATSUI)
  1343. * @CAIRO_FONT_TYPE_USER: The font was create using cairo's user font api (Since: 1.8)
  1344. *
  1345. * #cairo_font_type_t is used to describe the type of a given font
  1346. * face or scaled font. The font types are also known as "font
  1347. * backends" within cairo.
  1348. *
  1349. * The type of a font face is determined by the function used to
  1350. * create it, which will generally be of the form
  1351. * <function>cairo_<emphasis>type</emphasis>_font_face_create(<!-- -->)</function>.
  1352. * The font face type can be queried with cairo_font_face_get_type()
  1353. *
  1354. * The various #cairo_font_face_t functions can be used with a font face
  1355. * of any type.
  1356. *
  1357. * The type of a scaled font is determined by the type of the font
  1358. * face passed to cairo_scaled_font_create(). The scaled font type can
  1359. * be queried with cairo_scaled_font_get_type()
  1360. *
  1361. * The various #cairo_scaled_font_t functions can be used with scaled
  1362. * fonts of any type, but some font backends also provide
  1363. * type-specific functions that must only be called with a scaled font
  1364. * of the appropriate type. These functions have names that begin with
  1365. * <function>cairo_<emphasis>type</emphasis>_scaled_font(<!-- -->)</function>
  1366. * such as cairo_ft_scaled_font_lock_face().
  1367. *
  1368. * The behavior of calling a type-specific function with a scaled font
  1369. * of the wrong type is undefined.
  1370. *
  1371. * New entries may be added in future versions.
  1372. *
  1373. * Since: 1.2
  1374. **/
  1375. typedef enum _cairo_font_type {
  1376. CAIRO_FONT_TYPE_TOY,
  1377. CAIRO_FONT_TYPE_FT,
  1378. CAIRO_FONT_TYPE_WIN32,
  1379. CAIRO_FONT_TYPE_QUARTZ,
  1380. CAIRO_FONT_TYPE_USER
  1381. } cairo_font_type_t;
  1382. cairo_public cairo_font_type_t
  1383. cairo_font_face_get_type (cairo_font_face_t *font_face);
  1384. cairo_public void *
  1385. cairo_font_face_get_user_data (cairo_font_face_t *font_face,
  1386. const cairo_user_data_key_t *key);
  1387. cairo_public cairo_status_t
  1388. cairo_font_face_set_user_data (cairo_font_face_t *font_face,
  1389. const cairo_user_data_key_t *key,
  1390. void *user_data,
  1391. cairo_destroy_func_t destroy);
  1392. /* Portable interface to general font features. */
  1393. cairo_public cairo_scaled_font_t *
  1394. cairo_scaled_font_create (cairo_font_face_t *font_face,
  1395. const cairo_matrix_t *font_matrix,
  1396. const cairo_matrix_t *ctm,
  1397. const cairo_font_options_t *options);
  1398. cairo_public cairo_scaled_font_t *
  1399. cairo_scaled_font_reference (cairo_scaled_font_t *scaled_font);
  1400. cairo_public void
  1401. cairo_scaled_font_destroy (cairo_scaled_font_t *scaled_font);
  1402. cairo_public unsigned int
  1403. cairo_scaled_font_get_reference_count (cairo_scaled_font_t *scaled_font);
  1404. cairo_public cairo_status_t
  1405. cairo_scaled_font_status (cairo_scaled_font_t *scaled_font);
  1406. cairo_public cairo_font_type_t
  1407. cairo_scaled_font_get_type (cairo_scaled_font_t *scaled_font);
  1408. cairo_public void *
  1409. cairo_scaled_font_get_user_data (cairo_scaled_font_t *scaled_font,
  1410. const cairo_user_data_key_t *key);
  1411. cairo_public cairo_status_t
  1412. cairo_scaled_font_set_user_data (cairo_scaled_font_t *scaled_font,
  1413. const cairo_user_data_key_t *key,
  1414. void *user_data,
  1415. cairo_destroy_func_t destroy);
  1416. cairo_public void
  1417. cairo_scaled_font_extents (cairo_scaled_font_t *scaled_font,
  1418. cairo_font_extents_t *extents);
  1419. cairo_public void
  1420. cairo_scaled_font_text_extents (cairo_scaled_font_t *scaled_font,
  1421. const char *utf8,
  1422. cairo_text_extents_t *extents);
  1423. cairo_public void
  1424. cairo_scaled_font_glyph_extents (cairo_scaled_font_t *scaled_font,
  1425. const cairo_glyph_t *glyphs,
  1426. int num_glyphs,
  1427. cairo_text_extents_t *extents);
  1428. cairo_public cairo_status_t
  1429. cairo_scaled_font_text_to_glyphs (cairo_scaled_font_t *scaled_font,
  1430. double x,
  1431. double y,
  1432. const char *utf8,
  1433. int utf8_len,
  1434. cairo_glyph_t **glyphs,
  1435. int *num_glyphs,
  1436. cairo_text_cluster_t **clusters,
  1437. int *num_clusters,
  1438. cairo_text_cluster_flags_t *cluster_flags);
  1439. cairo_public cairo_font_face_t *
  1440. cairo_scaled_font_get_font_face (cairo_scaled_font_t *scaled_font);
  1441. cairo_public void
  1442. cairo_scaled_font_get_font_matrix (cairo_scaled_font_t *scaled_font,
  1443. cairo_matrix_t *font_matrix);
  1444. cairo_public void
  1445. cairo_scaled_font_get_ctm (cairo_scaled_font_t *scaled_font,
  1446. cairo_matrix_t *ctm);
  1447. cairo_public void
  1448. cairo_scaled_font_get_scale_matrix (cairo_scaled_font_t *scaled_font,
  1449. cairo_matrix_t *scale_matrix);
  1450. cairo_public void
  1451. cairo_scaled_font_get_font_options (cairo_scaled_font_t *scaled_font,
  1452. cairo_font_options_t *options);
  1453. /* Toy fonts */
  1454. cairo_public cairo_font_face_t *
  1455. cairo_toy_font_face_create (const char *family,
  1456. cairo_font_slant_t slant,
  1457. cairo_font_weight_t weight);
  1458. cairo_public const char *
  1459. cairo_toy_font_face_get_family (cairo_font_face_t *font_face);
  1460. cairo_public cairo_font_slant_t
  1461. cairo_toy_font_face_get_slant (cairo_font_face_t *font_face);
  1462. cairo_public cairo_font_weight_t
  1463. cairo_toy_font_face_get_weight (cairo_font_face_t *font_face);
  1464. /* User fonts */
  1465. cairo_public cairo_font_face_t *
  1466. cairo_user_font_face_create (void);
  1467. /* User-font method signatures */
  1468. /**
  1469. * cairo_user_scaled_font_init_func_t:
  1470. * @scaled_font: the scaled-font being created
  1471. * @cr: a cairo context, in font space
  1472. * @extents: font extents to fill in, in font space
  1473. *
  1474. * #cairo_user_scaled_font_init_func_t is the type of function which is
  1475. * called when a scaled-font needs to be created for a user font-face.
  1476. *
  1477. * The cairo context @cr is not used by the caller, but is prepared in font
  1478. * space, similar to what the cairo contexts passed to the render_glyph
  1479. * method will look like. The callback can use this context for extents
  1480. * computation for example. After the callback is called, @cr is checked
  1481. * for any error status.
  1482. *
  1483. * The @extents argument is where the user font sets the font extents for
  1484. * @scaled_font. It is in font space, which means that for most cases its
  1485. * ascent and descent members should add to 1.0. @extents is preset to
  1486. * hold a value of 1.0 for ascent, height, and max_x_advance, and 0.0 for
  1487. * descent and max_y_advance members.
  1488. *
  1489. * The callback is optional. If not set, default font extents as described
  1490. * in the previous paragraph will be used.
  1491. *
  1492. * Note that @scaled_font is not fully initialized at this
  1493. * point and trying to use it for text operations in the callback will result
  1494. * in deadlock.
  1495. *
  1496. * Returns: %CAIRO_STATUS_SUCCESS upon success, or an error status on error.
  1497. *
  1498. * Since: 1.8
  1499. **/
  1500. typedef cairo_status_t (*cairo_user_scaled_font_init_func_t) (cairo_scaled_font_t *scaled_font,
  1501. cairo_t *cr,
  1502. cairo_font_extents_t *extents);
  1503. /**
  1504. * cairo_user_scaled_font_render_glyph_func_t:
  1505. * @scaled_font: user scaled-font
  1506. * @glyph: glyph code to render
  1507. * @cr: cairo context to draw to, in font space
  1508. * @extents: glyph extents to fill in, in font space
  1509. *
  1510. * #cairo_user_scaled_font_render_glyph_func_t is the type of function which
  1511. * is called when a user scaled-font needs to render a glyph.
  1512. *
  1513. * The callback is mandatory, and expected to draw the glyph with code @glyph to
  1514. * the cairo context @cr. @cr is prepared such that the glyph drawing is done in
  1515. * font space. That is, the matrix set on @cr is the scale matrix of @scaled_font,
  1516. * The @extents argument is where the user font sets the font extents for
  1517. * @scaled_font. However, if user prefers to draw in user space, they can
  1518. * achieve that by changing the matrix on @cr. All cairo rendering operations
  1519. * to @cr are permitted, however, the result is undefined if any source other
  1520. * than the default source on @cr is used. That means, glyph bitmaps should
  1521. * be rendered using cairo_mask() instead of cairo_paint().
  1522. *
  1523. * Other non-default settings on @cr include a font size of 1.0 (given that
  1524. * it is set up to be in font space), and font options corresponding to
  1525. * @scaled_font.
  1526. *
  1527. * The @extents argument is preset to have <literal>x_bearing</literal>,
  1528. * <literal>width</literal>, and <literal>y_advance</literal> of zero,
  1529. * <literal>y_bearing</literal> set to <literal>-font_extents.ascent</literal>,
  1530. * <literal>height</literal> to <literal>font_extents.ascent+font_extents.descent</literal>,
  1531. * and <literal>x_advance</literal> to <literal>font_extents.max_x_advance</literal>.
  1532. * The only field user needs to set in majority of cases is
  1533. * <literal>x_advance</literal>.
  1534. * If the <literal>width</literal> field is zero upon the callback returning
  1535. * (which is its preset value), the glyph extents are automatically computed
  1536. * based on the drawings done to @cr. This is in most cases exactly what the
  1537. * desired behavior is. However, if for any reason the callback sets the
  1538. * extents, it must be ink extents, and include the extents of all drawing
  1539. * done to @cr in the callback.
  1540. *
  1541. * Returns: %CAIRO_STATUS_SUCCESS upon success, or
  1542. * %CAIRO_STATUS_USER_FONT_ERROR or any other error status on error.
  1543. *
  1544. * Since: 1.8
  1545. **/
  1546. typedef cairo_status_t (*cairo_user_scaled_font_render_glyph_func_t) (cairo_scaled_font_t *scaled_font,
  1547. unsigned long glyph,
  1548. cairo_t *cr,
  1549. cairo_text_extents_t *extents);
  1550. /**
  1551. * cairo_user_scaled_font_text_to_glyphs_func_t:
  1552. * @scaled_font: the scaled-font being created
  1553. * @utf8: a string of text encoded in UTF-8
  1554. * @utf8_len: length of @utf8 in bytes
  1555. * @glyphs: pointer to array of glyphs to fill, in font space
  1556. * @num_glyphs: pointer to number of glyphs
  1557. * @clusters: pointer to array of cluster mapping information to fill, or %NULL
  1558. * @num_clusters: pointer to number of clusters
  1559. * @cluster_flags: pointer to location to store cluster flags corresponding to the
  1560. * output @clusters
  1561. *
  1562. * #cairo_user_scaled_font_text_to_glyphs_func_t is the type of function which
  1563. * is called to convert input text to an array of glyphs. This is used by the
  1564. * cairo_show_text() operation.
  1565. *
  1566. * Using this callback the user-font has full control on glyphs and their
  1567. * positions. That means, it allows for features like ligatures and kerning,
  1568. * as well as complex <firstterm>shaping</firstterm> required for scripts like
  1569. * Arabic and Indic.
  1570. *
  1571. * The @num_glyphs argument is preset to the number of glyph entries available
  1572. * in the @glyphs buffer. If the @glyphs buffer is %NULL, the value of
  1573. * @num_glyphs will be zero. If the provided glyph array is too short for
  1574. * the conversion (or for convenience), a new glyph array may be allocated
  1575. * using cairo_glyph_allocate() and placed in @glyphs. Upon return,
  1576. * @num_glyphs should contain the number of generated glyphs. If the value
  1577. * @glyphs points at has changed after the call, the caller will free the
  1578. * allocated glyph array using cairo_glyph_free(). The caller will also free
  1579. * the original value of @glyphs, so the callback shouldn't do so.
  1580. * The callback should populate the glyph indices and positions (in font space)
  1581. * assuming that the text is to be shown at the origin.
  1582. *
  1583. * If @clusters is not %NULL, @num_clusters and @cluster_flags are also
  1584. * non-%NULL, and cluster mapping should be computed. The semantics of how
  1585. * cluster array allocation works is similar to the glyph array. That is,
  1586. * if @clusters initially points to a non-%NULL value, that array may be used
  1587. * as a cluster buffer, and @num_clusters points to the number of cluster
  1588. * entries available there. If the provided cluster array is too short for
  1589. * the conversion (or for convenience), a new cluster array may be allocated
  1590. * using cairo_text_cluster_allocate() and placed in @clusters. In this case,
  1591. * the original value of @clusters will still be freed by the caller. Upon
  1592. * return, @num_clusters should contain the number of generated clusters.
  1593. * If the value @clusters points at has changed after the call, the caller
  1594. * will free the allocated cluster array using cairo_text_cluster_free().
  1595. *
  1596. * The callback is optional. If @num_glyphs is negative upon
  1597. * the callback returning or if the return value
  1598. * is %CAIRO_STATUS_USER_FONT_NOT_IMPLEMENTED, the unicode_to_glyph callback
  1599. * is tried. See #cairo_user_scaled_font_unicode_to_glyph_func_t.
  1600. *
  1601. * Note: While cairo does not impose any limitation on glyph indices,
  1602. * some applications may assume that a glyph index fits in a 16-bit
  1603. * unsigned integer. As such, it is advised that user-fonts keep their
  1604. * glyphs in the 0 to 65535 range. Furthermore, some applications may
  1605. * assume that glyph 0 is a special glyph-not-found glyph. User-fonts
  1606. * are advised to use glyph 0 for such purposes and do not use that
  1607. * glyph value for other purposes.
  1608. *
  1609. * Returns: %CAIRO_STATUS_SUCCESS upon success,
  1610. * %CAIRO_STATUS_USER_FONT_NOT_IMPLEMENTED if fallback options should be tried,
  1611. * or %CAIRO_STATUS_USER_FONT_ERROR or any other error status on error.
  1612. *
  1613. * Since: 1.8
  1614. **/
  1615. typedef cairo_status_t (*cairo_user_scaled_font_text_to_glyphs_func_t) (cairo_scaled_font_t *scaled_font,
  1616. const char *utf8,
  1617. int utf8_len,
  1618. cairo_glyph_t **glyphs,
  1619. int *num_glyphs,
  1620. cairo_text_cluster_t **clusters,
  1621. int *num_clusters,
  1622. cairo_text_cluster_flags_t *cluster_flags);
  1623. /**
  1624. * cairo_user_scaled_font_unicode_to_glyph_func_t:
  1625. * @scaled_font: the scaled-font being created
  1626. * @unicode: input unicode character code-point
  1627. * @glyph_index: output glyph index
  1628. *
  1629. * #cairo_user_scaled_font_unicode_to_glyph_func_t is the type of function which
  1630. * is called to convert an input Unicode character to a single glyph.
  1631. * This is used by the cairo_show_text() operation.
  1632. *
  1633. * This callback is used to provide the same functionality as the
  1634. * text_to_glyphs callback does (see #cairo_user_scaled_font_text_to_glyphs_func_t)
  1635. * but has much less control on the output,
  1636. * in exchange for increased ease of use. The inherent assumption to using
  1637. * this callback is that each character maps to one glyph, and that the
  1638. * mapping is context independent. It also assumes that glyphs are positioned
  1639. * according to their advance width. These mean no ligatures, kerning, or
  1640. * complex scripts can be implemented using this callback.
  1641. *
  1642. * The callback is optional, and only used if text_to_glyphs callback is not
  1643. * set or fails to return glyphs. If this callback is not set or if it returns
  1644. * %CAIRO_STATUS_USER_FONT_NOT_IMPLEMENTED, an identity mapping from Unicode
  1645. * code-points to glyph indices is assumed.
  1646. *
  1647. * Note: While cairo does not impose any limitation on glyph indices,
  1648. * some applications may assume that a glyph index fits in a 16-bit
  1649. * unsigned integer. As such, it is advised that user-fonts keep their
  1650. * glyphs in the 0 to 65535 range. Furthermore, some applications may
  1651. * assume that glyph 0 is a special glyph-not-found glyph. User-fonts
  1652. * are advised to use glyph 0 for such purposes and do not use that
  1653. * glyph value for other purposes.
  1654. *
  1655. * Returns: %CAIRO_STATUS_SUCCESS upon success,
  1656. * %CAIRO_STATUS_USER_FONT_NOT_IMPLEMENTED if fallback options should be tried,
  1657. * or %CAIRO_STATUS_USER_FONT_ERROR or any other error status on error.
  1658. *
  1659. * Since: 1.8
  1660. **/
  1661. typedef cairo_status_t (*cairo_user_scaled_font_unicode_to_glyph_func_t) (cairo_scaled_font_t *scaled_font,
  1662. unsigned long unicode,
  1663. unsigned long *glyph_index);
  1664. /* User-font method setters */
  1665. cairo_public void
  1666. cairo_user_font_face_set_init_func (cairo_font_face_t *font_face,
  1667. cairo_user_scaled_font_init_func_t init_func);
  1668. cairo_public void
  1669. cairo_user_font_face_set_render_glyph_func (cairo_font_face_t *font_face,
  1670. cairo_user_scaled_font_render_glyph_func_t render_glyph_func);
  1671. cairo_public void
  1672. cairo_user_font_face_set_text_to_glyphs_func (cairo_font_face_t *font_face,
  1673. cairo_user_scaled_font_text_to_glyphs_func_t text_to_glyphs_func);
  1674. cairo_public void
  1675. cairo_user_font_face_set_unicode_to_glyph_func (cairo_font_face_t *font_face,
  1676. cairo_user_scaled_font_unicode_to_glyph_func_t unicode_to_glyph_func);
  1677. /* User-font method getters */
  1678. cairo_public cairo_user_scaled_font_init_func_t
  1679. cairo_user_font_face_get_init_func (cairo_font_face_t *font_face);
  1680. cairo_public cairo_user_scaled_font_render_glyph_func_t
  1681. cairo_user_font_face_get_render_glyph_func (cairo_font_face_t *font_face);
  1682. cairo_public cairo_user_scaled_font_text_to_glyphs_func_t
  1683. cairo_user_font_face_get_text_to_glyphs_func (cairo_font_face_t *font_face);
  1684. cairo_public cairo_user_scaled_font_unicode_to_glyph_func_t
  1685. cairo_user_font_face_get_unicode_to_glyph_func (cairo_font_face_t *font_face);
  1686. /* Query functions */
  1687. cairo_public cairo_operator_t
  1688. cairo_get_operator (cairo_t *cr);
  1689. cairo_public cairo_pattern_t *
  1690. cairo_get_source (cairo_t *cr);
  1691. cairo_public double
  1692. cairo_get_tolerance (cairo_t *cr);
  1693. cairo_public cairo_antialias_t
  1694. cairo_get_antialias (cairo_t *cr);
  1695. cairo_public cairo_bool_t
  1696. cairo_has_current_point (cairo_t *cr);
  1697. cairo_public void
  1698. cairo_get_current_point (cairo_t *cr, double *x, double *y);
  1699. cairo_public cairo_fill_rule_t
  1700. cairo_get_fill_rule (cairo_t *cr);
  1701. cairo_public double
  1702. cairo_get_line_width (cairo_t *cr);
  1703. cairo_public cairo_line_cap_t
  1704. cairo_get_line_cap (cairo_t *cr);
  1705. cairo_public cairo_line_join_t
  1706. cairo_get_line_join (cairo_t *cr);
  1707. cairo_public double
  1708. cairo_get_miter_limit (cairo_t *cr);
  1709. cairo_public int
  1710. cairo_get_dash_count (cairo_t *cr);
  1711. cairo_public void
  1712. cairo_get_dash (cairo_t *cr, double *dashes, double *offset);
  1713. cairo_public void
  1714. cairo_get_matrix (cairo_t *cr, cairo_matrix_t *matrix);
  1715. cairo_public cairo_surface_t *
  1716. cairo_get_target (cairo_t *cr);
  1717. cairo_public cairo_surface_t *
  1718. cairo_get_group_target (cairo_t *cr);
  1719. /**
  1720. * cairo_path_data_type_t:
  1721. * @CAIRO_PATH_MOVE_TO: A move-to operation, since 1.0
  1722. * @CAIRO_PATH_LINE_TO: A line-to operation, since 1.0
  1723. * @CAIRO_PATH_CURVE_TO: A curve-to operation, since 1.0
  1724. * @CAIRO_PATH_CLOSE_PATH: A close-path operation, since 1.0
  1725. *
  1726. * #cairo_path_data_t is used to describe the type of one portion
  1727. * of a path when represented as a #cairo_path_t.
  1728. * See #cairo_path_data_t for details.
  1729. *
  1730. * Since: 1.0
  1731. **/
  1732. typedef enum _cairo_path_data_type {
  1733. CAIRO_PATH_MOVE_TO,
  1734. CAIRO_PATH_LINE_TO,
  1735. CAIRO_PATH_CURVE_TO,
  1736. CAIRO_PATH_CLOSE_PATH
  1737. } cairo_path_data_type_t;
  1738. /**
  1739. * cairo_path_data_t:
  1740. *
  1741. * #cairo_path_data_t is used to represent the path data inside a
  1742. * #cairo_path_t.
  1743. *
  1744. * The data structure is designed to try to balance the demands of
  1745. * efficiency and ease-of-use. A path is represented as an array of
  1746. * #cairo_path_data_t, which is a union of headers and points.
  1747. *
  1748. * Each portion of the path is represented by one or more elements in
  1749. * the array, (one header followed by 0 or more points). The length
  1750. * value of the header is the number of array elements for the current
  1751. * portion including the header, (ie. length == 1 + # of points), and
  1752. * where the number of points for each element type is as follows:
  1753. *
  1754. * <programlisting>
  1755. * %CAIRO_PATH_MOVE_TO: 1 point
  1756. * %CAIRO_PATH_LINE_TO: 1 point
  1757. * %CAIRO_PATH_CURVE_TO: 3 points
  1758. * %CAIRO_PATH_CLOSE_PATH: 0 points
  1759. * </programlisting>
  1760. *
  1761. * The semantics and ordering of the coordinate values are consistent
  1762. * with cairo_move_to(), cairo_line_to(), cairo_curve_to(), and
  1763. * cairo_close_path().
  1764. *
  1765. * Here is sample code for iterating through a #cairo_path_t:
  1766. *
  1767. * <informalexample><programlisting>
  1768. * int i;
  1769. * cairo_path_t *path;
  1770. * cairo_path_data_t *data;
  1771. * &nbsp;
  1772. * path = cairo_copy_path (cr);
  1773. * &nbsp;
  1774. * for (i=0; i < path->num_data; i += path->data[i].header.length) {
  1775. * data = &amp;path->data[i];
  1776. * switch (data->header.type) {
  1777. * case CAIRO_PATH_MOVE_TO:
  1778. * do_move_to_things (data[1].point.x, data[1].point.y);
  1779. * break;
  1780. * case CAIRO_PATH_LINE_TO:
  1781. * do_line_to_things (data[1].point.x, data[1].point.y);
  1782. * break;
  1783. * case CAIRO_PATH_CURVE_TO:
  1784. * do_curve_to_things (data[1].point.x, data[1].point.y,
  1785. * data[2].point.x, data[2].point.y,
  1786. * data[3].point.x, data[3].point.y);
  1787. * break;
  1788. * case CAIRO_PATH_CLOSE_PATH:
  1789. * do_close_path_things ();
  1790. * break;
  1791. * }
  1792. * }
  1793. * cairo_path_destroy (path);
  1794. * </programlisting></informalexample>
  1795. *
  1796. * As of cairo 1.4, cairo does not mind if there are more elements in
  1797. * a portion of the path than needed. Such elements can be used by
  1798. * users of the cairo API to hold extra values in the path data
  1799. * structure. For this reason, it is recommended that applications
  1800. * always use <literal>data->header.length</literal> to
  1801. * iterate over the path data, instead of hardcoding the number of
  1802. * elements for each element type.
  1803. *
  1804. * Since: 1.0
  1805. **/
  1806. typedef union _cairo_path_data_t cairo_path_data_t;
  1807. union _cairo_path_data_t {
  1808. struct {
  1809. cairo_path_data_type_t type;
  1810. int length;
  1811. } header;
  1812. struct {
  1813. double x, y;
  1814. } point;
  1815. };
  1816. /**
  1817. * cairo_path_t:
  1818. * @status: the current error status
  1819. * @data: the elements in the path
  1820. * @num_data: the number of elements in the data array
  1821. *
  1822. * A data structure for holding a path. This data structure serves as
  1823. * the return value for cairo_copy_path() and
  1824. * cairo_copy_path_flat() as well the input value for
  1825. * cairo_append_path().
  1826. *
  1827. * See #cairo_path_data_t for hints on how to iterate over the
  1828. * actual data within the path.
  1829. *
  1830. * The num_data member gives the number of elements in the data
  1831. * array. This number is larger than the number of independent path
  1832. * portions (defined in #cairo_path_data_type_t), since the data
  1833. * includes both headers and coordinates for each portion.
  1834. *
  1835. * Since: 1.0
  1836. **/
  1837. typedef struct cairo_path {
  1838. cairo_status_t status;
  1839. cairo_path_data_t *data;
  1840. int num_data;
  1841. } cairo_path_t;
  1842. cairo_public cairo_path_t *
  1843. cairo_copy_path (cairo_t *cr);
  1844. cairo_public cairo_path_t *
  1845. cairo_copy_path_flat (cairo_t *cr);
  1846. cairo_public void
  1847. cairo_append_path (cairo_t *cr,
  1848. const cairo_path_t *path);
  1849. cairo_public void
  1850. cairo_path_destroy (cairo_path_t *path);
  1851. /* Error status queries */
  1852. cairo_public cairo_status_t
  1853. cairo_status (cairo_t *cr);
  1854. cairo_public const char *
  1855. cairo_status_to_string (cairo_status_t status);
  1856. /* Backend device manipulation */
  1857. cairo_public cairo_device_t *
  1858. cairo_device_reference (cairo_device_t *device);
  1859. /**
  1860. * cairo_device_type_t:
  1861. * @CAIRO_DEVICE_TYPE_DRM: The device is of type Direct Render Manager, since 1.10
  1862. * @CAIRO_DEVICE_TYPE_GL: The device is of type OpenGL, since 1.10
  1863. * @CAIRO_DEVICE_TYPE_SCRIPT: The device is of type script, since 1.10
  1864. * @CAIRO_DEVICE_TYPE_XCB: The device is of type xcb, since 1.10
  1865. * @CAIRO_DEVICE_TYPE_XLIB: The device is of type xlib, since 1.10
  1866. * @CAIRO_DEVICE_TYPE_XML: The device is of type XML, since 1.10
  1867. * @CAIRO_DEVICE_TYPE_COGL: The device is of type cogl, since 1.12
  1868. * @CAIRO_DEVICE_TYPE_WIN32: The device is of type win32, since 1.12
  1869. * @CAIRO_DEVICE_TYPE_INVALID: The device is invalid, since 1.10
  1870. *
  1871. * #cairo_device_type_t is used to describe the type of a given
  1872. * device. The devices types are also known as "backends" within cairo.
  1873. *
  1874. * The device type can be queried with cairo_device_get_type()
  1875. *
  1876. * The various #cairo_device_t functions can be used with devices of
  1877. * any type, but some backends also provide type-specific functions
  1878. * that must only be called with a device of the appropriate
  1879. * type. These functions have names that begin with
  1880. * <literal>cairo_<emphasis>type</emphasis>_device</literal> such as
  1881. * cairo_xcb_device_debug_cap_xrender_version().
  1882. *
  1883. * The behavior of calling a type-specific function with a device of
  1884. * the wrong type is undefined.
  1885. *
  1886. * New entries may be added in future versions.
  1887. *
  1888. * Since: 1.10
  1889. **/
  1890. typedef enum _cairo_device_type {
  1891. CAIRO_DEVICE_TYPE_DRM,
  1892. CAIRO_DEVICE_TYPE_GL,
  1893. CAIRO_DEVICE_TYPE_SCRIPT,
  1894. CAIRO_DEVICE_TYPE_XCB,
  1895. CAIRO_DEVICE_TYPE_XLIB,
  1896. CAIRO_DEVICE_TYPE_XML,
  1897. CAIRO_DEVICE_TYPE_COGL,
  1898. CAIRO_DEVICE_TYPE_WIN32,
  1899. CAIRO_DEVICE_TYPE_INVALID = -1
  1900. } cairo_device_type_t;
  1901. cairo_public cairo_device_type_t
  1902. cairo_device_get_type (cairo_device_t *device);
  1903. cairo_public cairo_status_t
  1904. cairo_device_status (cairo_device_t *device);
  1905. cairo_public cairo_status_t
  1906. cairo_device_acquire (cairo_device_t *device);
  1907. cairo_public void
  1908. cairo_device_release (cairo_device_t *device);
  1909. cairo_public void
  1910. cairo_device_flush (cairo_device_t *device);
  1911. cairo_public void
  1912. cairo_device_finish (cairo_device_t *device);
  1913. cairo_public void
  1914. cairo_device_destroy (cairo_device_t *device);
  1915. cairo_public unsigned int
  1916. cairo_device_get_reference_count (cairo_device_t *device);
  1917. cairo_public void *
  1918. cairo_device_get_user_data (cairo_device_t *device,
  1919. const cairo_user_data_key_t *key);
  1920. cairo_public cairo_status_t
  1921. cairo_device_set_user_data (cairo_device_t *device,
  1922. const cairo_user_data_key_t *key,
  1923. void *user_data,
  1924. cairo_destroy_func_t destroy);
  1925. /* Surface manipulation */
  1926. cairo_public cairo_surface_t *
  1927. cairo_surface_create_similar (cairo_surface_t *other,
  1928. cairo_content_t content,
  1929. int width,
  1930. int height);
  1931. cairo_public cairo_surface_t *
  1932. cairo_surface_create_similar_image (cairo_surface_t *other,
  1933. cairo_format_t format,
  1934. int width,
  1935. int height);
  1936. cairo_public cairo_surface_t *
  1937. cairo_surface_map_to_image (cairo_surface_t *surface,
  1938. const cairo_rectangle_int_t *extents);
  1939. cairo_public void
  1940. cairo_surface_unmap_image (cairo_surface_t *surface,
  1941. cairo_surface_t *image);
  1942. cairo_public cairo_surface_t *
  1943. cairo_surface_create_for_rectangle (cairo_surface_t *target,
  1944. double x,
  1945. double y,
  1946. double width,
  1947. double height);
  1948. /**
  1949. * cairo_surface_observer_mode_t:
  1950. * @CAIRO_SURFACE_OBSERVER_NORMAL: no recording is done
  1951. * @CAIRO_SURFACE_OBSERVER_RECORD_OPERATIONS: operations are recorded
  1952. *
  1953. * Whether operations should be recorded.
  1954. *
  1955. * Since: 1.12
  1956. **/
  1957. typedef enum {
  1958. CAIRO_SURFACE_OBSERVER_NORMAL = 0,
  1959. CAIRO_SURFACE_OBSERVER_RECORD_OPERATIONS = 0x1
  1960. } cairo_surface_observer_mode_t;
  1961. cairo_public cairo_surface_t *
  1962. cairo_surface_create_observer (cairo_surface_t *target,
  1963. cairo_surface_observer_mode_t mode);
  1964. typedef void (*cairo_surface_observer_callback_t) (cairo_surface_t *observer,
  1965. cairo_surface_t *target,
  1966. void *data);
  1967. cairo_public cairo_status_t
  1968. cairo_surface_observer_add_paint_callback (cairo_surface_t *abstract_surface,
  1969. cairo_surface_observer_callback_t func,
  1970. void *data);
  1971. cairo_public cairo_status_t
  1972. cairo_surface_observer_add_mask_callback (cairo_surface_t *abstract_surface,
  1973. cairo_surface_observer_callback_t func,
  1974. void *data);
  1975. cairo_public cairo_status_t
  1976. cairo_surface_observer_add_fill_callback (cairo_surface_t *abstract_surface,
  1977. cairo_surface_observer_callback_t func,
  1978. void *data);
  1979. cairo_public cairo_status_t
  1980. cairo_surface_observer_add_stroke_callback (cairo_surface_t *abstract_surface,
  1981. cairo_surface_observer_callback_t func,
  1982. void *data);
  1983. cairo_public cairo_status_t
  1984. cairo_surface_observer_add_glyphs_callback (cairo_surface_t *abstract_surface,
  1985. cairo_surface_observer_callback_t func,
  1986. void *data);
  1987. cairo_public cairo_status_t
  1988. cairo_surface_observer_add_flush_callback (cairo_surface_t *abstract_surface,
  1989. cairo_surface_observer_callback_t func,
  1990. void *data);
  1991. cairo_public cairo_status_t
  1992. cairo_surface_observer_add_finish_callback (cairo_surface_t *abstract_surface,
  1993. cairo_surface_observer_callback_t func,
  1994. void *data);
  1995. cairo_public cairo_status_t
  1996. cairo_surface_observer_print (cairo_surface_t *surface,
  1997. cairo_write_func_t write_func,
  1998. void *closure);
  1999. cairo_public double
  2000. cairo_surface_observer_elapsed (cairo_surface_t *surface);
  2001. cairo_public cairo_status_t
  2002. cairo_device_observer_print (cairo_device_t *device,
  2003. cairo_write_func_t write_func,
  2004. void *closure);
  2005. cairo_public double
  2006. cairo_device_observer_elapsed (cairo_device_t *device);
  2007. cairo_public double
  2008. cairo_device_observer_paint_elapsed (cairo_device_t *device);
  2009. cairo_public double
  2010. cairo_device_observer_mask_elapsed (cairo_device_t *device);
  2011. cairo_public double
  2012. cairo_device_observer_fill_elapsed (cairo_device_t *device);
  2013. cairo_public double
  2014. cairo_device_observer_stroke_elapsed (cairo_device_t *device);
  2015. cairo_public double
  2016. cairo_device_observer_glyphs_elapsed (cairo_device_t *device);
  2017. cairo_public cairo_surface_t *
  2018. cairo_surface_reference (cairo_surface_t *surface);
  2019. cairo_public void
  2020. cairo_surface_finish (cairo_surface_t *surface);
  2021. cairo_public void
  2022. cairo_surface_destroy (cairo_surface_t *surface);
  2023. cairo_public cairo_device_t *
  2024. cairo_surface_get_device (cairo_surface_t *surface);
  2025. cairo_public unsigned int
  2026. cairo_surface_get_reference_count (cairo_surface_t *surface);
  2027. cairo_public cairo_status_t
  2028. cairo_surface_status (cairo_surface_t *surface);
  2029. /**
  2030. * cairo_surface_type_t:
  2031. * @CAIRO_SURFACE_TYPE_IMAGE: The surface is of type image, since 1.2
  2032. * @CAIRO_SURFACE_TYPE_PDF: The surface is of type pdf, since 1.2
  2033. * @CAIRO_SURFACE_TYPE_PS: The surface is of type ps, since 1.2
  2034. * @CAIRO_SURFACE_TYPE_XLIB: The surface is of type xlib, since 1.2
  2035. * @CAIRO_SURFACE_TYPE_XCB: The surface is of type xcb, since 1.2
  2036. * @CAIRO_SURFACE_TYPE_GLITZ: The surface is of type glitz, since 1.2
  2037. * @CAIRO_SURFACE_TYPE_QUARTZ: The surface is of type quartz, since 1.2
  2038. * @CAIRO_SURFACE_TYPE_WIN32: The surface is of type win32, since 1.2
  2039. * @CAIRO_SURFACE_TYPE_BEOS: The surface is of type beos, since 1.2
  2040. * @CAIRO_SURFACE_TYPE_DIRECTFB: The surface is of type directfb, since 1.2
  2041. * @CAIRO_SURFACE_TYPE_SVG: The surface is of type svg, since 1.2
  2042. * @CAIRO_SURFACE_TYPE_OS2: The surface is of type os2, since 1.4
  2043. * @CAIRO_SURFACE_TYPE_WIN32_PRINTING: The surface is a win32 printing surface, since 1.6
  2044. * @CAIRO_SURFACE_TYPE_QUARTZ_IMAGE: The surface is of type quartz_image, since 1.6
  2045. * @CAIRO_SURFACE_TYPE_SCRIPT: The surface is of type script, since 1.10
  2046. * @CAIRO_SURFACE_TYPE_QT: The surface is of type Qt, since 1.10
  2047. * @CAIRO_SURFACE_TYPE_RECORDING: The surface is of type recording, since 1.10
  2048. * @CAIRO_SURFACE_TYPE_VG: The surface is a OpenVG surface, since 1.10
  2049. * @CAIRO_SURFACE_TYPE_GL: The surface is of type OpenGL, since 1.10
  2050. * @CAIRO_SURFACE_TYPE_DRM: The surface is of type Direct Render Manager, since 1.10
  2051. * @CAIRO_SURFACE_TYPE_TEE: The surface is of type 'tee' (a multiplexing surface), since 1.10
  2052. * @CAIRO_SURFACE_TYPE_XML: The surface is of type XML (for debugging), since 1.10
  2053. * @CAIRO_SURFACE_TYPE_SKIA: The surface is of type Skia, since 1.10
  2054. * @CAIRO_SURFACE_TYPE_SUBSURFACE: The surface is a subsurface created with
  2055. * cairo_surface_create_for_rectangle(), since 1.10
  2056. * @CAIRO_SURFACE_TYPE_COGL: This surface is of type Cogl, since 1.12
  2057. *
  2058. * #cairo_surface_type_t is used to describe the type of a given
  2059. * surface. The surface types are also known as "backends" or "surface
  2060. * backends" within cairo.
  2061. *
  2062. * The type of a surface is determined by the function used to create
  2063. * it, which will generally be of the form
  2064. * <function>cairo_<emphasis>type</emphasis>_surface_create(<!-- -->)</function>,
  2065. * (though see cairo_surface_create_similar() as well).
  2066. *
  2067. * The surface type can be queried with cairo_surface_get_type()
  2068. *
  2069. * The various #cairo_surface_t functions can be used with surfaces of
  2070. * any type, but some backends also provide type-specific functions
  2071. * that must only be called with a surface of the appropriate
  2072. * type. These functions have names that begin with
  2073. * <literal>cairo_<emphasis>type</emphasis>_surface</literal> such as cairo_image_surface_get_width().
  2074. *
  2075. * The behavior of calling a type-specific function with a surface of
  2076. * the wrong type is undefined.
  2077. *
  2078. * New entries may be added in future versions.
  2079. *
  2080. * Since: 1.2
  2081. **/
  2082. typedef enum _cairo_surface_type {
  2083. CAIRO_SURFACE_TYPE_IMAGE,
  2084. CAIRO_SURFACE_TYPE_PDF,
  2085. CAIRO_SURFACE_TYPE_PS,
  2086. CAIRO_SURFACE_TYPE_XLIB,
  2087. CAIRO_SURFACE_TYPE_XCB,
  2088. CAIRO_SURFACE_TYPE_GLITZ,
  2089. CAIRO_SURFACE_TYPE_QUARTZ,
  2090. CAIRO_SURFACE_TYPE_WIN32,
  2091. CAIRO_SURFACE_TYPE_BEOS,
  2092. CAIRO_SURFACE_TYPE_DIRECTFB,
  2093. CAIRO_SURFACE_TYPE_SVG,
  2094. CAIRO_SURFACE_TYPE_OS2,
  2095. CAIRO_SURFACE_TYPE_WIN32_PRINTING,
  2096. CAIRO_SURFACE_TYPE_QUARTZ_IMAGE,
  2097. CAIRO_SURFACE_TYPE_SCRIPT,
  2098. CAIRO_SURFACE_TYPE_QT,
  2099. CAIRO_SURFACE_TYPE_RECORDING,
  2100. CAIRO_SURFACE_TYPE_VG,
  2101. CAIRO_SURFACE_TYPE_GL,
  2102. CAIRO_SURFACE_TYPE_DRM,
  2103. CAIRO_SURFACE_TYPE_TEE,
  2104. CAIRO_SURFACE_TYPE_XML,
  2105. CAIRO_SURFACE_TYPE_SKIA,
  2106. CAIRO_SURFACE_TYPE_SUBSURFACE,
  2107. CAIRO_SURFACE_TYPE_COGL
  2108. } cairo_surface_type_t;
  2109. cairo_public cairo_surface_type_t
  2110. cairo_surface_get_type (cairo_surface_t *surface);
  2111. cairo_public cairo_content_t
  2112. cairo_surface_get_content (cairo_surface_t *surface);
  2113. #if CAIRO_HAS_PNG_FUNCTIONS
  2114. cairo_public cairo_status_t
  2115. cairo_surface_write_to_png (cairo_surface_t *surface,
  2116. const char *filename);
  2117. cairo_public cairo_status_t
  2118. cairo_surface_write_to_png_stream (cairo_surface_t *surface,
  2119. cairo_write_func_t write_func,
  2120. void *closure);
  2121. #endif
  2122. cairo_public void *
  2123. cairo_surface_get_user_data (cairo_surface_t *surface,
  2124. const cairo_user_data_key_t *key);
  2125. cairo_public cairo_status_t
  2126. cairo_surface_set_user_data (cairo_surface_t *surface,
  2127. const cairo_user_data_key_t *key,
  2128. void *user_data,
  2129. cairo_destroy_func_t destroy);
  2130. #define CAIRO_MIME_TYPE_JPEG "image/jpeg"
  2131. #define CAIRO_MIME_TYPE_PNG "image/png"
  2132. #define CAIRO_MIME_TYPE_JP2 "image/jp2"
  2133. #define CAIRO_MIME_TYPE_URI "text/x-uri"
  2134. #define CAIRO_MIME_TYPE_UNIQUE_ID "application/x-cairo.uuid"
  2135. #define CAIRO_MIME_TYPE_JBIG2 "application/x-cairo.jbig2"
  2136. #define CAIRO_MIME_TYPE_JBIG2_GLOBAL "application/x-cairo.jbig2-global"
  2137. #define CAIRO_MIME_TYPE_JBIG2_GLOBAL_ID "application/x-cairo.jbig2-global-id"
  2138. cairo_public void
  2139. cairo_surface_get_mime_data (cairo_surface_t *surface,
  2140. const char *mime_type,
  2141. const unsigned char **data,
  2142. unsigned long *length);
  2143. cairo_public cairo_status_t
  2144. cairo_surface_set_mime_data (cairo_surface_t *surface,
  2145. const char *mime_type,
  2146. const unsigned char *data,
  2147. unsigned long length,
  2148. cairo_destroy_func_t destroy,
  2149. void *closure);
  2150. cairo_public cairo_bool_t
  2151. cairo_surface_supports_mime_type (cairo_surface_t *surface,
  2152. const char *mime_type);
  2153. cairo_public void
  2154. cairo_surface_get_font_options (cairo_surface_t *surface,
  2155. cairo_font_options_t *options);
  2156. cairo_public void
  2157. cairo_surface_flush (cairo_surface_t *surface);
  2158. cairo_public void
  2159. cairo_surface_mark_dirty (cairo_surface_t *surface);
  2160. cairo_public void
  2161. cairo_surface_mark_dirty_rectangle (cairo_surface_t *surface,
  2162. int x,
  2163. int y,
  2164. int width,
  2165. int height);
  2166. cairo_public void
  2167. cairo_surface_set_device_scale (cairo_surface_t *surface,
  2168. double x_scale,
  2169. double y_scale);
  2170. cairo_public void
  2171. cairo_surface_get_device_scale (cairo_surface_t *surface,
  2172. double *x_scale,
  2173. double *y_scale);
  2174. cairo_public void
  2175. cairo_surface_set_device_offset (cairo_surface_t *surface,
  2176. double x_offset,
  2177. double y_offset);
  2178. cairo_public void
  2179. cairo_surface_get_device_offset (cairo_surface_t *surface,
  2180. double *x_offset,
  2181. double *y_offset);
  2182. cairo_public void
  2183. cairo_surface_set_fallback_resolution (cairo_surface_t *surface,
  2184. double x_pixels_per_inch,
  2185. double y_pixels_per_inch);
  2186. cairo_public void
  2187. cairo_surface_get_fallback_resolution (cairo_surface_t *surface,
  2188. double *x_pixels_per_inch,
  2189. double *y_pixels_per_inch);
  2190. cairo_public void
  2191. cairo_surface_copy_page (cairo_surface_t *surface);
  2192. cairo_public void
  2193. cairo_surface_show_page (cairo_surface_t *surface);
  2194. cairo_public cairo_bool_t
  2195. cairo_surface_has_show_text_glyphs (cairo_surface_t *surface);
  2196. /* Image-surface functions */
  2197. cairo_public cairo_surface_t *
  2198. cairo_image_surface_create (cairo_format_t format,
  2199. int width,
  2200. int height);
  2201. cairo_public int
  2202. cairo_format_stride_for_width (cairo_format_t format,
  2203. int width);
  2204. cairo_public cairo_surface_t *
  2205. cairo_image_surface_create_for_data (unsigned char *data,
  2206. cairo_format_t format,
  2207. int width,
  2208. int height,
  2209. int stride);
  2210. cairo_public unsigned char *
  2211. cairo_image_surface_get_data (cairo_surface_t *surface);
  2212. cairo_public cairo_format_t
  2213. cairo_image_surface_get_format (cairo_surface_t *surface);
  2214. cairo_public int
  2215. cairo_image_surface_get_width (cairo_surface_t *surface);
  2216. cairo_public int
  2217. cairo_image_surface_get_height (cairo_surface_t *surface);
  2218. cairo_public int
  2219. cairo_image_surface_get_stride (cairo_surface_t *surface);
  2220. #if CAIRO_HAS_PNG_FUNCTIONS
  2221. cairo_public cairo_surface_t *
  2222. cairo_image_surface_create_from_png (const char *filename);
  2223. cairo_public cairo_surface_t *
  2224. cairo_image_surface_create_from_png_stream (cairo_read_func_t read_func,
  2225. void *closure);
  2226. #endif
  2227. /* Recording-surface functions */
  2228. cairo_public cairo_surface_t *
  2229. cairo_recording_surface_create (cairo_content_t content,
  2230. const cairo_rectangle_t *extents);
  2231. cairo_public void
  2232. cairo_recording_surface_ink_extents (cairo_surface_t *surface,
  2233. double *x0,
  2234. double *y0,
  2235. double *width,
  2236. double *height);
  2237. cairo_public cairo_bool_t
  2238. cairo_recording_surface_get_extents (cairo_surface_t *surface,
  2239. cairo_rectangle_t *extents);
  2240. /* raster-source pattern (callback) functions */
  2241. /**
  2242. * cairo_raster_source_acquire_func_t:
  2243. * @pattern: the pattern being rendered from
  2244. * @callback_data: the user data supplied during creation
  2245. * @target: the rendering target surface
  2246. * @extents: rectangular region of interest in pixels in sample space
  2247. *
  2248. * #cairo_raster_source_acquire_func_t is the type of function which is
  2249. * called when a pattern is being rendered from. It should create a surface
  2250. * that provides the pixel data for the region of interest as defined by
  2251. * extents, though the surface itself does not have to be limited to that
  2252. * area. For convenience the surface should probably be of image type,
  2253. * created with cairo_surface_create_similar_image() for the target (which
  2254. * enables the number of copies to be reduced during transfer to the
  2255. * device). Another option, might be to return a similar surface to the
  2256. * target for explicit handling by the application of a set of cached sources
  2257. * on the device. The region of sample data provided should be defined using
  2258. * cairo_surface_set_device_offset() to specify the top-left corner of the
  2259. * sample data (along with width and height of the surface).
  2260. *
  2261. * Returns: a #cairo_surface_t
  2262. *
  2263. * Since: 1.12
  2264. **/
  2265. typedef cairo_surface_t *
  2266. (*cairo_raster_source_acquire_func_t) (cairo_pattern_t *pattern,
  2267. void *callback_data,
  2268. cairo_surface_t *target,
  2269. const cairo_rectangle_int_t *extents);
  2270. /**
  2271. * cairo_raster_source_release_func_t:
  2272. * @pattern: the pattern being rendered from
  2273. * @callback_data: the user data supplied during creation
  2274. * @surface: the surface created during acquire
  2275. *
  2276. * #cairo_raster_source_release_func_t is the type of function which is
  2277. * called when the pixel data is no longer being access by the pattern
  2278. * for the rendering operation. Typically this function will simply
  2279. * destroy the surface created during acquire.
  2280. *
  2281. * Since: 1.12
  2282. **/
  2283. typedef void
  2284. (*cairo_raster_source_release_func_t) (cairo_pattern_t *pattern,
  2285. void *callback_data,
  2286. cairo_surface_t *surface);
  2287. /**
  2288. * cairo_raster_source_snapshot_func_t:
  2289. * @pattern: the pattern being rendered from
  2290. * @callback_data: the user data supplied during creation
  2291. *
  2292. * #cairo_raster_source_snapshot_func_t is the type of function which is
  2293. * called when the pixel data needs to be preserved for later use
  2294. * during printing. This pattern will be accessed again later, and it
  2295. * is expected to provide the pixel data that was current at the time
  2296. * of snapshotting.
  2297. *
  2298. * Return value: CAIRO_STATUS_SUCCESS on success, or one of the
  2299. * #cairo_status_t error codes for failure.
  2300. *
  2301. * Since: 1.12
  2302. **/
  2303. typedef cairo_status_t
  2304. (*cairo_raster_source_snapshot_func_t) (cairo_pattern_t *pattern,
  2305. void *callback_data);
  2306. /**
  2307. * cairo_raster_source_copy_func_t:
  2308. * @pattern: the #cairo_pattern_t that was copied to
  2309. * @callback_data: the user data supplied during creation
  2310. * @other: the #cairo_pattern_t being used as the source for the copy
  2311. *
  2312. * #cairo_raster_source_copy_func_t is the type of function which is
  2313. * called when the pattern gets copied as a normal part of rendering.
  2314. *
  2315. * Return value: CAIRO_STATUS_SUCCESS on success, or one of the
  2316. * #cairo_status_t error codes for failure.
  2317. *
  2318. * Since: 1.12
  2319. **/
  2320. typedef cairo_status_t
  2321. (*cairo_raster_source_copy_func_t) (cairo_pattern_t *pattern,
  2322. void *callback_data,
  2323. const cairo_pattern_t *other);
  2324. /**
  2325. * cairo_raster_source_finish_func_t:
  2326. * @pattern: the pattern being rendered from
  2327. * @callback_data: the user data supplied during creation
  2328. *
  2329. * #cairo_raster_source_finish_func_t is the type of function which is
  2330. * called when the pattern (or a copy thereof) is no longer required.
  2331. *
  2332. * Since: 1.12
  2333. **/
  2334. typedef void
  2335. (*cairo_raster_source_finish_func_t) (cairo_pattern_t *pattern,
  2336. void *callback_data);
  2337. cairo_public cairo_pattern_t *
  2338. cairo_pattern_create_raster_source (void *user_data,
  2339. cairo_content_t content,
  2340. int width, int height);
  2341. cairo_public void
  2342. cairo_raster_source_pattern_set_callback_data (cairo_pattern_t *pattern,
  2343. void *data);
  2344. cairo_public void *
  2345. cairo_raster_source_pattern_get_callback_data (cairo_pattern_t *pattern);
  2346. cairo_public void
  2347. cairo_raster_source_pattern_set_acquire (cairo_pattern_t *pattern,
  2348. cairo_raster_source_acquire_func_t acquire,
  2349. cairo_raster_source_release_func_t release);
  2350. cairo_public void
  2351. cairo_raster_source_pattern_get_acquire (cairo_pattern_t *pattern,
  2352. cairo_raster_source_acquire_func_t *acquire,
  2353. cairo_raster_source_release_func_t *release);
  2354. cairo_public void
  2355. cairo_raster_source_pattern_set_snapshot (cairo_pattern_t *pattern,
  2356. cairo_raster_source_snapshot_func_t snapshot);
  2357. cairo_public cairo_raster_source_snapshot_func_t
  2358. cairo_raster_source_pattern_get_snapshot (cairo_pattern_t *pattern);
  2359. cairo_public void
  2360. cairo_raster_source_pattern_set_copy (cairo_pattern_t *pattern,
  2361. cairo_raster_source_copy_func_t copy);
  2362. cairo_public cairo_raster_source_copy_func_t
  2363. cairo_raster_source_pattern_get_copy (cairo_pattern_t *pattern);
  2364. cairo_public void
  2365. cairo_raster_source_pattern_set_finish (cairo_pattern_t *pattern,
  2366. cairo_raster_source_finish_func_t finish);
  2367. cairo_public cairo_raster_source_finish_func_t
  2368. cairo_raster_source_pattern_get_finish (cairo_pattern_t *pattern);
  2369. /* Pattern creation functions */
  2370. cairo_public cairo_pattern_t *
  2371. cairo_pattern_create_rgb (double red, double green, double blue);
  2372. cairo_public cairo_pattern_t *
  2373. cairo_pattern_create_rgba (double red, double green, double blue,
  2374. double alpha);
  2375. cairo_public cairo_pattern_t *
  2376. cairo_pattern_create_for_surface (cairo_surface_t *surface);
  2377. cairo_public cairo_pattern_t *
  2378. cairo_pattern_create_linear (double x0, double y0,
  2379. double x1, double y1);
  2380. cairo_public cairo_pattern_t *
  2381. cairo_pattern_create_radial (double cx0, double cy0, double radius0,
  2382. double cx1, double cy1, double radius1);
  2383. cairo_public cairo_pattern_t *
  2384. cairo_pattern_create_mesh (void);
  2385. cairo_public cairo_pattern_t *
  2386. cairo_pattern_reference (cairo_pattern_t *pattern);
  2387. cairo_public void
  2388. cairo_pattern_destroy (cairo_pattern_t *pattern);
  2389. cairo_public unsigned int
  2390. cairo_pattern_get_reference_count (cairo_pattern_t *pattern);
  2391. cairo_public cairo_status_t
  2392. cairo_pattern_status (cairo_pattern_t *pattern);
  2393. cairo_public void *
  2394. cairo_pattern_get_user_data (cairo_pattern_t *pattern,
  2395. const cairo_user_data_key_t *key);
  2396. cairo_public cairo_status_t
  2397. cairo_pattern_set_user_data (cairo_pattern_t *pattern,
  2398. const cairo_user_data_key_t *key,
  2399. void *user_data,
  2400. cairo_destroy_func_t destroy);
  2401. /**
  2402. * cairo_pattern_type_t:
  2403. * @CAIRO_PATTERN_TYPE_SOLID: The pattern is a solid (uniform)
  2404. * color. It may be opaque or translucent, since 1.2.
  2405. * @CAIRO_PATTERN_TYPE_SURFACE: The pattern is a based on a surface (an image), since 1.2.
  2406. * @CAIRO_PATTERN_TYPE_LINEAR: The pattern is a linear gradient, since 1.2.
  2407. * @CAIRO_PATTERN_TYPE_RADIAL: The pattern is a radial gradient, since 1.2.
  2408. * @CAIRO_PATTERN_TYPE_MESH: The pattern is a mesh, since 1.12.
  2409. * @CAIRO_PATTERN_TYPE_RASTER_SOURCE: The pattern is a user pattern providing raster data, since 1.12.
  2410. *
  2411. * #cairo_pattern_type_t is used to describe the type of a given pattern.
  2412. *
  2413. * The type of a pattern is determined by the function used to create
  2414. * it. The cairo_pattern_create_rgb() and cairo_pattern_create_rgba()
  2415. * functions create SOLID patterns. The remaining
  2416. * cairo_pattern_create<!-- --> functions map to pattern types in obvious
  2417. * ways.
  2418. *
  2419. * The pattern type can be queried with cairo_pattern_get_type()
  2420. *
  2421. * Most #cairo_pattern_t functions can be called with a pattern of any
  2422. * type, (though trying to change the extend or filter for a solid
  2423. * pattern will have no effect). A notable exception is
  2424. * cairo_pattern_add_color_stop_rgb() and
  2425. * cairo_pattern_add_color_stop_rgba() which must only be called with
  2426. * gradient patterns (either LINEAR or RADIAL). Otherwise the pattern
  2427. * will be shutdown and put into an error state.
  2428. *
  2429. * New entries may be added in future versions.
  2430. *
  2431. * Since: 1.2
  2432. **/
  2433. typedef enum _cairo_pattern_type {
  2434. CAIRO_PATTERN_TYPE_SOLID,
  2435. CAIRO_PATTERN_TYPE_SURFACE,
  2436. CAIRO_PATTERN_TYPE_LINEAR,
  2437. CAIRO_PATTERN_TYPE_RADIAL,
  2438. CAIRO_PATTERN_TYPE_MESH,
  2439. CAIRO_PATTERN_TYPE_RASTER_SOURCE
  2440. } cairo_pattern_type_t;
  2441. cairo_public cairo_pattern_type_t
  2442. cairo_pattern_get_type (cairo_pattern_t *pattern);
  2443. cairo_public void
  2444. cairo_pattern_add_color_stop_rgb (cairo_pattern_t *pattern,
  2445. double offset,
  2446. double red, double green, double blue);
  2447. cairo_public void
  2448. cairo_pattern_add_color_stop_rgba (cairo_pattern_t *pattern,
  2449. double offset,
  2450. double red, double green, double blue,
  2451. double alpha);
  2452. cairo_public void
  2453. cairo_mesh_pattern_begin_patch (cairo_pattern_t *pattern);
  2454. cairo_public void
  2455. cairo_mesh_pattern_end_patch (cairo_pattern_t *pattern);
  2456. cairo_public void
  2457. cairo_mesh_pattern_curve_to (cairo_pattern_t *pattern,
  2458. double x1, double y1,
  2459. double x2, double y2,
  2460. double x3, double y3);
  2461. cairo_public void
  2462. cairo_mesh_pattern_line_to (cairo_pattern_t *pattern,
  2463. double x, double y);
  2464. cairo_public void
  2465. cairo_mesh_pattern_move_to (cairo_pattern_t *pattern,
  2466. double x, double y);
  2467. cairo_public void
  2468. cairo_mesh_pattern_set_control_point (cairo_pattern_t *pattern,
  2469. unsigned int point_num,
  2470. double x, double y);
  2471. cairo_public void
  2472. cairo_mesh_pattern_set_corner_color_rgb (cairo_pattern_t *pattern,
  2473. unsigned int corner_num,
  2474. double red, double green, double blue);
  2475. cairo_public void
  2476. cairo_mesh_pattern_set_corner_color_rgba (cairo_pattern_t *pattern,
  2477. unsigned int corner_num,
  2478. double red, double green, double blue,
  2479. double alpha);
  2480. cairo_public void
  2481. cairo_pattern_set_matrix (cairo_pattern_t *pattern,
  2482. const cairo_matrix_t *matrix);
  2483. cairo_public void
  2484. cairo_pattern_get_matrix (cairo_pattern_t *pattern,
  2485. cairo_matrix_t *matrix);
  2486. /**
  2487. * cairo_extend_t:
  2488. * @CAIRO_EXTEND_NONE: pixels outside of the source pattern
  2489. * are fully transparent (Since 1.0)
  2490. * @CAIRO_EXTEND_REPEAT: the pattern is tiled by repeating (Since 1.0)
  2491. * @CAIRO_EXTEND_REFLECT: the pattern is tiled by reflecting
  2492. * at the edges (Since 1.0; but only implemented for surface patterns since 1.6)
  2493. * @CAIRO_EXTEND_PAD: pixels outside of the pattern copy
  2494. * the closest pixel from the source (Since 1.2; but only
  2495. * implemented for surface patterns since 1.6)
  2496. *
  2497. * #cairo_extend_t is used to describe how pattern color/alpha will be
  2498. * determined for areas "outside" the pattern's natural area, (for
  2499. * example, outside the surface bounds or outside the gradient
  2500. * geometry).
  2501. *
  2502. * Mesh patterns are not affected by the extend mode.
  2503. *
  2504. * The default extend mode is %CAIRO_EXTEND_NONE for surface patterns
  2505. * and %CAIRO_EXTEND_PAD for gradient patterns.
  2506. *
  2507. * New entries may be added in future versions.
  2508. *
  2509. * Since: 1.0
  2510. **/
  2511. typedef enum _cairo_extend {
  2512. CAIRO_EXTEND_NONE,
  2513. CAIRO_EXTEND_REPEAT,
  2514. CAIRO_EXTEND_REFLECT,
  2515. CAIRO_EXTEND_PAD
  2516. } cairo_extend_t;
  2517. cairo_public void
  2518. cairo_pattern_set_extend (cairo_pattern_t *pattern, cairo_extend_t extend);
  2519. cairo_public cairo_extend_t
  2520. cairo_pattern_get_extend (cairo_pattern_t *pattern);
  2521. /**
  2522. * cairo_filter_t:
  2523. * @CAIRO_FILTER_FAST: A high-performance filter, with quality similar
  2524. * to %CAIRO_FILTER_NEAREST (Since 1.0)
  2525. * @CAIRO_FILTER_GOOD: A reasonable-performance filter, with quality
  2526. * similar to %CAIRO_FILTER_BILINEAR (Since 1.0)
  2527. * @CAIRO_FILTER_BEST: The highest-quality available, performance may
  2528. * not be suitable for interactive use. (Since 1.0)
  2529. * @CAIRO_FILTER_NEAREST: Nearest-neighbor filtering (Since 1.0)
  2530. * @CAIRO_FILTER_BILINEAR: Linear interpolation in two dimensions (Since 1.0)
  2531. * @CAIRO_FILTER_GAUSSIAN: This filter value is currently
  2532. * unimplemented, and should not be used in current code. (Since 1.0)
  2533. *
  2534. * #cairo_filter_t is used to indicate what filtering should be
  2535. * applied when reading pixel values from patterns. See
  2536. * cairo_pattern_set_filter() for indicating the desired filter to be
  2537. * used with a particular pattern.
  2538. *
  2539. * Since: 1.0
  2540. **/
  2541. typedef enum _cairo_filter {
  2542. CAIRO_FILTER_FAST,
  2543. CAIRO_FILTER_GOOD,
  2544. CAIRO_FILTER_BEST,
  2545. CAIRO_FILTER_NEAREST,
  2546. CAIRO_FILTER_BILINEAR,
  2547. CAIRO_FILTER_GAUSSIAN
  2548. } cairo_filter_t;
  2549. cairo_public void
  2550. cairo_pattern_set_filter (cairo_pattern_t *pattern, cairo_filter_t filter);
  2551. cairo_public cairo_filter_t
  2552. cairo_pattern_get_filter (cairo_pattern_t *pattern);
  2553. cairo_public cairo_status_t
  2554. cairo_pattern_get_rgba (cairo_pattern_t *pattern,
  2555. double *red, double *green,
  2556. double *blue, double *alpha);
  2557. cairo_public cairo_status_t
  2558. cairo_pattern_get_surface (cairo_pattern_t *pattern,
  2559. cairo_surface_t **surface);
  2560. cairo_public cairo_status_t
  2561. cairo_pattern_get_color_stop_rgba (cairo_pattern_t *pattern,
  2562. int index, double *offset,
  2563. double *red, double *green,
  2564. double *blue, double *alpha);
  2565. cairo_public cairo_status_t
  2566. cairo_pattern_get_color_stop_count (cairo_pattern_t *pattern,
  2567. int *count);
  2568. cairo_public cairo_status_t
  2569. cairo_pattern_get_linear_points (cairo_pattern_t *pattern,
  2570. double *x0, double *y0,
  2571. double *x1, double *y1);
  2572. cairo_public cairo_status_t
  2573. cairo_pattern_get_radial_circles (cairo_pattern_t *pattern,
  2574. double *x0, double *y0, double *r0,
  2575. double *x1, double *y1, double *r1);
  2576. cairo_public cairo_status_t
  2577. cairo_mesh_pattern_get_patch_count (cairo_pattern_t *pattern,
  2578. unsigned int *count);
  2579. cairo_public cairo_path_t *
  2580. cairo_mesh_pattern_get_path (cairo_pattern_t *pattern,
  2581. unsigned int patch_num);
  2582. cairo_public cairo_status_t
  2583. cairo_mesh_pattern_get_corner_color_rgba (cairo_pattern_t *pattern,
  2584. unsigned int patch_num,
  2585. unsigned int corner_num,
  2586. double *red, double *green,
  2587. double *blue, double *alpha);
  2588. cairo_public cairo_status_t
  2589. cairo_mesh_pattern_get_control_point (cairo_pattern_t *pattern,
  2590. unsigned int patch_num,
  2591. unsigned int point_num,
  2592. double *x, double *y);
  2593. /* Matrix functions */
  2594. cairo_public void
  2595. cairo_matrix_init (cairo_matrix_t *matrix,
  2596. double xx, double yx,
  2597. double xy, double yy,
  2598. double x0, double y0);
  2599. cairo_public void
  2600. cairo_matrix_init_identity (cairo_matrix_t *matrix);
  2601. cairo_public void
  2602. cairo_matrix_init_translate (cairo_matrix_t *matrix,
  2603. double tx, double ty);
  2604. cairo_public void
  2605. cairo_matrix_init_scale (cairo_matrix_t *matrix,
  2606. double sx, double sy);
  2607. cairo_public void
  2608. cairo_matrix_init_rotate (cairo_matrix_t *matrix,
  2609. double radians);
  2610. cairo_public void
  2611. cairo_matrix_translate (cairo_matrix_t *matrix, double tx, double ty);
  2612. cairo_public void
  2613. cairo_matrix_scale (cairo_matrix_t *matrix, double sx, double sy);
  2614. cairo_public void
  2615. cairo_matrix_rotate (cairo_matrix_t *matrix, double radians);
  2616. cairo_public cairo_status_t
  2617. cairo_matrix_invert (cairo_matrix_t *matrix);
  2618. cairo_public void
  2619. cairo_matrix_multiply (cairo_matrix_t *result,
  2620. const cairo_matrix_t *a,
  2621. const cairo_matrix_t *b);
  2622. cairo_public void
  2623. cairo_matrix_transform_distance (const cairo_matrix_t *matrix,
  2624. double *dx, double *dy);
  2625. cairo_public void
  2626. cairo_matrix_transform_point (const cairo_matrix_t *matrix,
  2627. double *x, double *y);
  2628. /* Region functions */
  2629. /**
  2630. * cairo_region_t:
  2631. *
  2632. * A #cairo_region_t represents a set of integer-aligned rectangles.
  2633. *
  2634. * It allows set-theoretical operations like cairo_region_union() and
  2635. * cairo_region_intersect() to be performed on them.
  2636. *
  2637. * Memory management of #cairo_region_t is done with
  2638. * cairo_region_reference() and cairo_region_destroy().
  2639. *
  2640. * Since: 1.10
  2641. **/
  2642. typedef struct _cairo_region cairo_region_t;
  2643. /**
  2644. * cairo_region_overlap_t:
  2645. * @CAIRO_REGION_OVERLAP_IN: The contents are entirely inside the region. (Since 1.10)
  2646. * @CAIRO_REGION_OVERLAP_OUT: The contents are entirely outside the region. (Since 1.10)
  2647. * @CAIRO_REGION_OVERLAP_PART: The contents are partially inside and
  2648. * partially outside the region. (Since 1.10)
  2649. *
  2650. * Used as the return value for cairo_region_contains_rectangle().
  2651. *
  2652. * Since: 1.10
  2653. **/
  2654. typedef enum _cairo_region_overlap {
  2655. CAIRO_REGION_OVERLAP_IN, /* completely inside region */
  2656. CAIRO_REGION_OVERLAP_OUT, /* completely outside region */
  2657. CAIRO_REGION_OVERLAP_PART /* partly inside region */
  2658. } cairo_region_overlap_t;
  2659. cairo_public cairo_region_t *
  2660. cairo_region_create (void);
  2661. cairo_public cairo_region_t *
  2662. cairo_region_create_rectangle (const cairo_rectangle_int_t *rectangle);
  2663. cairo_public cairo_region_t *
  2664. cairo_region_create_rectangles (const cairo_rectangle_int_t *rects,
  2665. int count);
  2666. cairo_public cairo_region_t *
  2667. cairo_region_copy (const cairo_region_t *original);
  2668. cairo_public cairo_region_t *
  2669. cairo_region_reference (cairo_region_t *region);
  2670. cairo_public void
  2671. cairo_region_destroy (cairo_region_t *region);
  2672. cairo_public cairo_bool_t
  2673. cairo_region_equal (const cairo_region_t *a, const cairo_region_t *b);
  2674. cairo_public cairo_status_t
  2675. cairo_region_status (const cairo_region_t *region);
  2676. cairo_public void
  2677. cairo_region_get_extents (const cairo_region_t *region,
  2678. cairo_rectangle_int_t *extents);
  2679. cairo_public int
  2680. cairo_region_num_rectangles (const cairo_region_t *region);
  2681. cairo_public void
  2682. cairo_region_get_rectangle (const cairo_region_t *region,
  2683. int nth,
  2684. cairo_rectangle_int_t *rectangle);
  2685. cairo_public cairo_bool_t
  2686. cairo_region_is_empty (const cairo_region_t *region);
  2687. cairo_public cairo_region_overlap_t
  2688. cairo_region_contains_rectangle (const cairo_region_t *region,
  2689. const cairo_rectangle_int_t *rectangle);
  2690. cairo_public cairo_bool_t
  2691. cairo_region_contains_point (const cairo_region_t *region, int x, int y);
  2692. cairo_public void
  2693. cairo_region_translate (cairo_region_t *region, int dx, int dy);
  2694. cairo_public cairo_status_t
  2695. cairo_region_subtract (cairo_region_t *dst, const cairo_region_t *other);
  2696. cairo_public cairo_status_t
  2697. cairo_region_subtract_rectangle (cairo_region_t *dst,
  2698. const cairo_rectangle_int_t *rectangle);
  2699. cairo_public cairo_status_t
  2700. cairo_region_intersect (cairo_region_t *dst, const cairo_region_t *other);
  2701. cairo_public cairo_status_t
  2702. cairo_region_intersect_rectangle (cairo_region_t *dst,
  2703. const cairo_rectangle_int_t *rectangle);
  2704. cairo_public cairo_status_t
  2705. cairo_region_union (cairo_region_t *dst, const cairo_region_t *other);
  2706. cairo_public cairo_status_t
  2707. cairo_region_union_rectangle (cairo_region_t *dst,
  2708. const cairo_rectangle_int_t *rectangle);
  2709. cairo_public cairo_status_t
  2710. cairo_region_xor (cairo_region_t *dst, const cairo_region_t *other);
  2711. cairo_public cairo_status_t
  2712. cairo_region_xor_rectangle (cairo_region_t *dst,
  2713. const cairo_rectangle_int_t *rectangle);
  2714. /* Functions to be used while debugging (not intended for use in production code) */
  2715. cairo_public void
  2716. cairo_debug_reset_static_data (void);
  2717. CAIRO_END_DECLS
  2718. #endif /* CAIRO_H */