File: | root/firefox-clang/gfx/cairo/cairo/src/cairo.c |
Warning: | line 3814, column 5 Value stored to 'status' is never read |
Press '?' to see keyboard shortcuts
Keyboard shortcuts:
1 | /* -*- Mode: c; c-basic-offset: 4; indent-tabs-mode: t; tab-width: 8; -*- */ |
2 | /* cairo - a vector graphics library with display and print output |
3 | * |
4 | * Copyright © 2002 University of Southern California |
5 | * Copyright © 2005 Red Hat, Inc. |
6 | * Copyright © 2011 Intel Corporation |
7 | * |
8 | * This library is free software; you can redistribute it and/or |
9 | * modify it either under the terms of the GNU Lesser General Public |
10 | * License version 2.1 as published by the Free Software Foundation |
11 | * (the "LGPL") or, at your option, under the terms of the Mozilla |
12 | * Public License Version 1.1 (the "MPL"). If you do not alter this |
13 | * notice, a recipient may use your version of this file under either |
14 | * the MPL or the LGPL. |
15 | * |
16 | * You should have received a copy of the LGPL along with this library |
17 | * in the file COPYING-LGPL-2.1; if not, write to the Free Software |
18 | * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA |
19 | * You should have received a copy of the MPL along with this library |
20 | * in the file COPYING-MPL-1.1 |
21 | * |
22 | * The contents of this file are subject to the Mozilla Public License |
23 | * Version 1.1 (the "License"); you may not use this file except in |
24 | * compliance with the License. You may obtain a copy of the License at |
25 | * http://www.mozilla.org/MPL/ |
26 | * |
27 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY |
28 | * OF ANY KIND, either express or implied. See the LGPL or the MPL for |
29 | * the specific language governing rights and limitations. |
30 | * |
31 | * The Original Code is the cairo graphics library. |
32 | * |
33 | * The Initial Developer of the Original Code is University of Southern |
34 | * California. |
35 | * |
36 | * Contributor(s): |
37 | * Carl D. Worth <cworth@cworth.org> |
38 | * Chris Wilson <chris@chris-wilson.co.uk> |
39 | */ |
40 | |
41 | #include "cairoint.h" |
42 | #include "cairo-private.h" |
43 | |
44 | #include "cairo-backend-private.h" |
45 | #include "cairo-error-private.h" |
46 | #include "cairo-path-private.h" |
47 | #include "cairo-pattern-private.h" |
48 | #include "cairo-surface-private.h" |
49 | #include "cairo-surface-backend-private.h" |
50 | |
51 | #include <assert.h> |
52 | |
53 | /** |
54 | * SECTION:cairo |
55 | * @Title: cairo_t |
56 | * @Short_Description: The cairo drawing context |
57 | * @See_Also: #cairo_surface_t |
58 | * |
59 | * #cairo_t is the main object used when drawing with cairo. To |
60 | * draw with cairo, you create a #cairo_t, set the target surface, |
61 | * and drawing options for the #cairo_t, create shapes with |
62 | * functions like cairo_move_to() and cairo_line_to(), and then |
63 | * draw shapes with cairo_stroke() or cairo_fill(). |
64 | * |
65 | * #cairo_t<!-- -->'s can be pushed to a stack via cairo_save(). |
66 | * They may then safely be changed, without losing the current state. |
67 | * Use cairo_restore() to restore to the saved state. |
68 | **/ |
69 | |
70 | /** |
71 | * SECTION:cairo-text |
72 | * @Title: text |
73 | * @Short_Description: Rendering text and glyphs |
74 | * @See_Also: #cairo_font_face_t, #cairo_scaled_font_t, cairo_text_path(), |
75 | * cairo_glyph_path() |
76 | * |
77 | * The functions with <emphasis>text</emphasis> in their name form cairo's |
78 | * <firstterm>toy</firstterm> text API. The toy API takes UTF-8 encoded |
79 | * text and is limited in its functionality to rendering simple |
80 | * left-to-right text with no advanced features. That means for example |
81 | * that most complex scripts like Hebrew, Arabic, and Indic scripts are |
82 | * out of question. No kerning or correct positioning of diacritical marks |
83 | * either. The font selection is pretty limited too and doesn't handle the |
84 | * case that the selected font does not cover the characters in the text. |
85 | * This set of functions are really that, a toy text API, for testing and |
86 | * demonstration purposes. Any serious application should avoid them. |
87 | * |
88 | * The functions with <emphasis>glyphs</emphasis> in their name form cairo's |
89 | * <firstterm>low-level</firstterm> text API. The low-level API relies on |
90 | * the user to convert text to a set of glyph indexes and positions. This |
91 | * is a very hard problem and is best handled by external libraries, like |
92 | * the pangocairo that is part of the Pango text layout and rendering library. |
93 | * Pango is available from <ulink |
94 | * url="http://www.pango.org/">http://www.pango.org/</ulink>. |
95 | **/ |
96 | |
97 | /** |
98 | * SECTION:cairo-transforms |
99 | * @Title: Transformations |
100 | * @Short_Description: Manipulating the current transformation matrix |
101 | * @See_Also: #cairo_matrix_t |
102 | * |
103 | * The current transformation matrix, <firstterm>ctm</firstterm>, is a |
104 | * two-dimensional affine transformation that maps all coordinates and other |
105 | * drawing instruments from the <firstterm>user space</firstterm> into the |
106 | * surface's canonical coordinate system, also known as the <firstterm>device |
107 | * space</firstterm>. |
108 | **/ |
109 | |
110 | /** |
111 | * SECTION:cairo-tag |
112 | * @Title: Tags and Links |
113 | * @Short_Description: Hyperlinks and document structure |
114 | * @See_Also: #cairo_pdf_surface_t |
115 | * |
116 | * The tag functions provide the ability to specify hyperlinks and |
117 | * document logical structure on supported backends. The following tags are supported: |
118 | * * [Link][link] - Create a hyperlink |
119 | * * [Destinations][dest] - Create a hyperlink destination |
120 | * * [Document Structure Tags][doc-struct] - Create PDF Document Structure |
121 | * |
122 | * # Link Tags # {#link} |
123 | * A hyperlink is specified by enclosing the hyperlink text with the %CAIRO_TAG_LINK tag. |
124 | * |
125 | * For example: |
126 | * <informalexample><programlisting> |
127 | * cairo_tag_begin (cr, CAIRO_TAG_LINK, "uri='https://cairographics.org'"); |
128 | * cairo_move_to (cr, 50, 50); |
129 | * cairo_show_text (cr, "This is a link to the cairo website."); |
130 | * cairo_tag_end (cr, CAIRO_TAG_LINK); |
131 | * </programlisting></informalexample> |
132 | * |
133 | * The PDF backend uses one or more rectangles to define the clickable |
134 | * area of the link. By default cairo will use the extents of the |
135 | * drawing operations enclosed by the begin/end link tags to define the |
136 | * clickable area. In some cases, such as a link split across two |
137 | * lines, the default rectangle is undesirable. |
138 | * |
139 | * @rect: [optional] The "rect" attribute allows the application to |
140 | * specify one or more rectangles that form the clickable region. The |
141 | * value of this attribute is an array of floats. Each rectangle is |
142 | * specified by four elements in the array: x, y, width, height. The |
143 | * array size must be a multiple of four. |
144 | * |
145 | * An example of creating a link with user specified clickable region: |
146 | * <informalexample><programlisting> |
147 | * struct text { |
148 | * const char *s; |
149 | * double x, y; |
150 | * }; |
151 | * const struct text text1 = { "This link is split", 450, 70 }; |
152 | * const struct text text2 = { "across two lines", 50, 70 }; |
153 | * cairo_text_extents_t text1_extents; |
154 | * cairo_text_extents_t text2_extents; |
155 | * char attribs[100]; |
156 | * |
157 | * cairo_text_extents (cr, text1.s, &text1_extents); |
158 | * cairo_text_extents (cr, text2.s, &text2_extents); |
159 | * sprintf (attribs, |
160 | * "rect=[%f %f %f %f %f %f %f %f] uri='https://cairographics.org'", |
161 | * text1_extents.x_bearing + text1.x, |
162 | * text1_extents.y_bearing + text1.y, |
163 | * text1_extents.width, |
164 | * text1_extents.height, |
165 | * text2_extents.x_bearing + text2.x, |
166 | * text2_extents.y_bearing + text2.y, |
167 | * text2_extents.width, |
168 | * text2_extents.height); |
169 | * |
170 | * cairo_tag_begin (cr, CAIRO_TAG_LINK, attribs); |
171 | * cairo_move_to (cr, text1.x, text1.y); |
172 | * cairo_show_text (cr, text1.s); |
173 | * cairo_move_to (cr, text2.x, text2.y); |
174 | * cairo_show_text (cr, text2.s); |
175 | * cairo_tag_end (cr, CAIRO_TAG_LINK); |
176 | * </programlisting></informalexample> |
177 | * |
178 | * There are three types of links. Each type has its own attributes as detailed below. |
179 | * * [Internal Links][internal-link] - A link to a location in the same document |
180 | * * [URI Links][uri-link] - A link to a Uniform resource identifier |
181 | * * [File Links][file-link] - A link to a location in another document |
182 | * |
183 | * ## Internal Links ## {#internal-link} |
184 | * An internal link is a link to a location in the same document. The destination |
185 | * is specified with either: |
186 | * |
187 | * @dest: a UTF-8 string specifying the destination in the PDF file to link |
188 | * to. Destinations are created with the %CAIRO_TAG_DEST tag. |
189 | * |
190 | * or the two attributes: |
191 | * |
192 | * @page: An integer specifying the page number in the PDF file to link to. |
193 | * |
194 | * @pos: [optional] An array of two floats specifying the x,y position |
195 | * on the page. |
196 | * |
197 | * An example of the link attributes to link to a page and x,y position: |
198 | * <programlisting> |
199 | * "page=3 pos=[3.1 6.2]" |
200 | * </programlisting> |
201 | * |
202 | * ## URI Links ## {#uri-link} |
203 | * A URI link is a link to a Uniform Resource Identifier ([RFC 2396](http://tools.ietf.org/html/rfc2396)). |
204 | * |
205 | * A URI is specified with the following attribute: |
206 | * |
207 | * @uri: An ASCII string specifying the URI. |
208 | * |
209 | * An example of the link attributes to the cairo website: |
210 | * <programlisting> |
211 | * "uri='https://cairographics.org'" |
212 | * </programlisting> |
213 | * |
214 | * ## File Links ## {#file-link} |
215 | * A file link is a link a location in another PDF file. |
216 | * |
217 | * The file attribute (required) specifies the name of the PDF file: |
218 | * |
219 | * @file: File name of PDF file to link to. |
220 | * |
221 | * The position is specified by either: |
222 | * |
223 | * @dest: a UTF-8 string specifying the named destination in the PDF file. |
224 | * |
225 | * or |
226 | * |
227 | * @page: An integer specifying the page number in the PDF file. |
228 | * |
229 | * @pos: [optional] An array of two floats specifying the x,y |
230 | * position on the page. Position coordinates in external files are in PDF |
231 | * coordinates (0,0 at bottom left). |
232 | * |
233 | * An example of the link attributes to PDF file: |
234 | * <programlisting> |
235 | * "file='document.pdf' page=16 pos=[25 40]" |
236 | * </programlisting> |
237 | * |
238 | * # Destination Tags # {#dest} |
239 | * |
240 | * A destination is specified by enclosing the destination drawing |
241 | * operations with the %CAIRO_TAG_DEST tag. |
242 | * |
243 | * @name: [required] A UTF-8 string specifying the name of this destination. |
244 | * |
245 | * @x: [optional] A float specifying the x coordinate of destination |
246 | * position on this page. If not specified the default |
247 | * x coordinate is the left side of the extents of the |
248 | * operations enclosed by the %CAIRO_TAG_DEST begin/end tags. If |
249 | * no operations are enclosed, the x coordidate is 0. |
250 | * |
251 | * @y: [optional] A float specifying the y coordinate of destination |
252 | * position on this page. If not specified the default |
253 | * y coordinate is the top of the extents of the |
254 | * operations enclosed by the %CAIRO_TAG_DEST begin/end tags. If |
255 | * no operations are enclosed, the y coordidate is 0. |
256 | * |
257 | * @internal: A boolean that if true, the destination name may be |
258 | * omitted from PDF where possible. In this case, links |
259 | * refer directly to the page and position instead of via |
260 | * the named destination table. Note that if this |
261 | * destination is referenced by another PDF (see [File Links][file-link]), |
262 | * this attribute must be false. Default is false. |
263 | * |
264 | * <informalexample><programlisting> |
265 | * /* Create a hyperlink */ |
266 | * cairo_tag_begin (cr, CAIRO_TAG_LINK, "dest='mydest' internal"); |
267 | * cairo_move_to (cr, 50, 50); |
268 | * cairo_show_text (cr, "This is a hyperlink."); |
269 | * cairo_tag_end (cr, CAIRO_TAG_LINK); |
270 | * |
271 | * /* Create a destination */ |
272 | * cairo_tag_begin (cr, CAIRO_TAG_DEST, "name='mydest'"); |
273 | * cairo_move_to (cr, 50, 250); |
274 | * cairo_show_text (cr, "This paragraph is the destination of the above link."); |
275 | * cairo_tag_end (cr, CAIRO_TAG_DEST); |
276 | * </programlisting></informalexample> |
277 | * |
278 | * # Document Structure (PDF) # {#doc-struct} |
279 | * |
280 | * The document structure tags provide a means of specifying structural information |
281 | * such as headers, paragraphs, tables, and figures. The inclusion of structural information facilitates: |
282 | * * Extraction of text and graphics for copy and paste |
283 | * * Reflow of text and graphics in the viewer |
284 | * * Processing text eg searching and indexing |
285 | * * Conversion to other formats |
286 | * * Accessability support |
287 | * |
288 | * The list of structure types is specified in section 14.8.4 of the |
289 | * [PDF Reference](http://www.adobe.com/content/dam/Adobe/en/devnet/acrobat/pdfs/PDF32000_2008.pdf). |
290 | * |
291 | * Note the PDF "Link" structure tag is the same as the cairo %CAIRO_TAG_LINK tag. |
292 | * |
293 | * The following example creates a document structure for a document containing two section, each with |
294 | * a header and a paragraph. |
295 | * |
296 | * <informalexample><programlisting> |
297 | * cairo_tag_begin (cr, "Document", NULL); |
298 | * |
299 | * cairo_tag_begin (cr, "Sect", NULL); |
300 | * cairo_tag_begin (cr, "H1", NULL); |
301 | * cairo_show_text (cr, "Heading 1"); |
302 | * cairo_tag_end (cr, "H1"); |
303 | * |
304 | * cairo_tag_begin (cr, "P", NULL); |
305 | * cairo_show_text (cr, "Paragraph 1"); |
306 | * cairo_tag_end (cr, "P"); |
307 | * cairo_tag_end (cr, "Sect"); |
308 | * |
309 | * cairo_tag_begin (cr, "Sect", NULL); |
310 | * cairo_tag_begin (cr, "H1", NULL); |
311 | * cairo_show_text (cr, "Heading 2"); |
312 | * cairo_tag_end (cr, "H1"); |
313 | * |
314 | * cairo_tag_begin (cr, "P", NULL); |
315 | * cairo_show_text (cr, "Paragraph 2"); |
316 | * cairo_tag_end (cr, "P"); |
317 | * cairo_tag_end (cr, "Sect"); |
318 | * |
319 | * cairo_tag_end (cr, "Document"); |
320 | * </programlisting></informalexample> |
321 | * |
322 | **/ |
323 | |
324 | #define DEFINE_NIL_CONTEXT(status){ {((cairo_atomic_int_t) -1)}, status, { 0, 0, 0, ((void*)0) } , ((void*)0) } \ |
325 | { \ |
326 | CAIRO_REFERENCE_COUNT_INVALID{((cairo_atomic_int_t) -1)}, /* ref_count */ \ |
327 | status, /* status */ \ |
328 | { 0, 0, 0, NULL((void*)0) }, /* user_data */ \ |
329 | NULL((void*)0) \ |
330 | } |
331 | |
332 | static const cairo_t _cairo_nil[] = { |
333 | DEFINE_NIL_CONTEXT (CAIRO_STATUS_NO_MEMORY){ {((cairo_atomic_int_t) -1)}, CAIRO_STATUS_NO_MEMORY, { 0, 0 , 0, ((void*)0) }, ((void*)0) }, |
334 | DEFINE_NIL_CONTEXT (CAIRO_STATUS_INVALID_RESTORE){ {((cairo_atomic_int_t) -1)}, CAIRO_STATUS_INVALID_RESTORE, { 0, 0, 0, ((void*)0) }, ((void*)0) }, |
335 | DEFINE_NIL_CONTEXT (CAIRO_STATUS_INVALID_POP_GROUP){ {((cairo_atomic_int_t) -1)}, CAIRO_STATUS_INVALID_POP_GROUP , { 0, 0, 0, ((void*)0) }, ((void*)0) }, |
336 | DEFINE_NIL_CONTEXT (CAIRO_STATUS_NO_CURRENT_POINT){ {((cairo_atomic_int_t) -1)}, CAIRO_STATUS_NO_CURRENT_POINT, { 0, 0, 0, ((void*)0) }, ((void*)0) }, |
337 | DEFINE_NIL_CONTEXT (CAIRO_STATUS_INVALID_MATRIX){ {((cairo_atomic_int_t) -1)}, CAIRO_STATUS_INVALID_MATRIX, { 0, 0, 0, ((void*)0) }, ((void*)0) }, |
338 | DEFINE_NIL_CONTEXT (CAIRO_STATUS_INVALID_STATUS){ {((cairo_atomic_int_t) -1)}, CAIRO_STATUS_INVALID_STATUS, { 0, 0, 0, ((void*)0) }, ((void*)0) }, |
339 | DEFINE_NIL_CONTEXT (CAIRO_STATUS_NULL_POINTER){ {((cairo_atomic_int_t) -1)}, CAIRO_STATUS_NULL_POINTER, { 0 , 0, 0, ((void*)0) }, ((void*)0) }, |
340 | DEFINE_NIL_CONTEXT (CAIRO_STATUS_INVALID_STRING){ {((cairo_atomic_int_t) -1)}, CAIRO_STATUS_INVALID_STRING, { 0, 0, 0, ((void*)0) }, ((void*)0) }, |
341 | DEFINE_NIL_CONTEXT (CAIRO_STATUS_INVALID_PATH_DATA){ {((cairo_atomic_int_t) -1)}, CAIRO_STATUS_INVALID_PATH_DATA , { 0, 0, 0, ((void*)0) }, ((void*)0) }, |
342 | DEFINE_NIL_CONTEXT (CAIRO_STATUS_READ_ERROR){ {((cairo_atomic_int_t) -1)}, CAIRO_STATUS_READ_ERROR, { 0, 0 , 0, ((void*)0) }, ((void*)0) }, |
343 | DEFINE_NIL_CONTEXT (CAIRO_STATUS_WRITE_ERROR){ {((cairo_atomic_int_t) -1)}, CAIRO_STATUS_WRITE_ERROR, { 0, 0, 0, ((void*)0) }, ((void*)0) }, |
344 | DEFINE_NIL_CONTEXT (CAIRO_STATUS_SURFACE_FINISHED){ {((cairo_atomic_int_t) -1)}, CAIRO_STATUS_SURFACE_FINISHED, { 0, 0, 0, ((void*)0) }, ((void*)0) }, |
345 | DEFINE_NIL_CONTEXT (CAIRO_STATUS_SURFACE_TYPE_MISMATCH){ {((cairo_atomic_int_t) -1)}, CAIRO_STATUS_SURFACE_TYPE_MISMATCH , { 0, 0, 0, ((void*)0) }, ((void*)0) }, |
346 | DEFINE_NIL_CONTEXT (CAIRO_STATUS_PATTERN_TYPE_MISMATCH){ {((cairo_atomic_int_t) -1)}, CAIRO_STATUS_PATTERN_TYPE_MISMATCH , { 0, 0, 0, ((void*)0) }, ((void*)0) }, |
347 | DEFINE_NIL_CONTEXT (CAIRO_STATUS_INVALID_CONTENT){ {((cairo_atomic_int_t) -1)}, CAIRO_STATUS_INVALID_CONTENT, { 0, 0, 0, ((void*)0) }, ((void*)0) }, |
348 | DEFINE_NIL_CONTEXT (CAIRO_STATUS_INVALID_FORMAT){ {((cairo_atomic_int_t) -1)}, CAIRO_STATUS_INVALID_FORMAT, { 0, 0, 0, ((void*)0) }, ((void*)0) }, |
349 | DEFINE_NIL_CONTEXT (CAIRO_STATUS_INVALID_VISUAL){ {((cairo_atomic_int_t) -1)}, CAIRO_STATUS_INVALID_VISUAL, { 0, 0, 0, ((void*)0) }, ((void*)0) }, |
350 | DEFINE_NIL_CONTEXT (CAIRO_STATUS_FILE_NOT_FOUND){ {((cairo_atomic_int_t) -1)}, CAIRO_STATUS_FILE_NOT_FOUND, { 0, 0, 0, ((void*)0) }, ((void*)0) }, |
351 | DEFINE_NIL_CONTEXT (CAIRO_STATUS_INVALID_DASH){ {((cairo_atomic_int_t) -1)}, CAIRO_STATUS_INVALID_DASH, { 0 , 0, 0, ((void*)0) }, ((void*)0) }, |
352 | DEFINE_NIL_CONTEXT (CAIRO_STATUS_INVALID_DSC_COMMENT){ {((cairo_atomic_int_t) -1)}, CAIRO_STATUS_INVALID_DSC_COMMENT , { 0, 0, 0, ((void*)0) }, ((void*)0) }, |
353 | DEFINE_NIL_CONTEXT (CAIRO_STATUS_INVALID_INDEX){ {((cairo_atomic_int_t) -1)}, CAIRO_STATUS_INVALID_INDEX, { 0 , 0, 0, ((void*)0) }, ((void*)0) }, |
354 | DEFINE_NIL_CONTEXT (CAIRO_STATUS_CLIP_NOT_REPRESENTABLE){ {((cairo_atomic_int_t) -1)}, CAIRO_STATUS_CLIP_NOT_REPRESENTABLE , { 0, 0, 0, ((void*)0) }, ((void*)0) }, |
355 | DEFINE_NIL_CONTEXT (CAIRO_STATUS_TEMP_FILE_ERROR){ {((cairo_atomic_int_t) -1)}, CAIRO_STATUS_TEMP_FILE_ERROR, { 0, 0, 0, ((void*)0) }, ((void*)0) }, |
356 | DEFINE_NIL_CONTEXT (CAIRO_STATUS_INVALID_STRIDE){ {((cairo_atomic_int_t) -1)}, CAIRO_STATUS_INVALID_STRIDE, { 0, 0, 0, ((void*)0) }, ((void*)0) }, |
357 | DEFINE_NIL_CONTEXT (CAIRO_STATUS_FONT_TYPE_MISMATCH){ {((cairo_atomic_int_t) -1)}, CAIRO_STATUS_FONT_TYPE_MISMATCH , { 0, 0, 0, ((void*)0) }, ((void*)0) }, |
358 | DEFINE_NIL_CONTEXT (CAIRO_STATUS_USER_FONT_IMMUTABLE){ {((cairo_atomic_int_t) -1)}, CAIRO_STATUS_USER_FONT_IMMUTABLE , { 0, 0, 0, ((void*)0) }, ((void*)0) }, |
359 | DEFINE_NIL_CONTEXT (CAIRO_STATUS_USER_FONT_ERROR){ {((cairo_atomic_int_t) -1)}, CAIRO_STATUS_USER_FONT_ERROR, { 0, 0, 0, ((void*)0) }, ((void*)0) }, |
360 | DEFINE_NIL_CONTEXT (CAIRO_STATUS_NEGATIVE_COUNT){ {((cairo_atomic_int_t) -1)}, CAIRO_STATUS_NEGATIVE_COUNT, { 0, 0, 0, ((void*)0) }, ((void*)0) }, |
361 | DEFINE_NIL_CONTEXT (CAIRO_STATUS_INVALID_CLUSTERS){ {((cairo_atomic_int_t) -1)}, CAIRO_STATUS_INVALID_CLUSTERS, { 0, 0, 0, ((void*)0) }, ((void*)0) }, |
362 | DEFINE_NIL_CONTEXT (CAIRO_STATUS_INVALID_SLANT){ {((cairo_atomic_int_t) -1)}, CAIRO_STATUS_INVALID_SLANT, { 0 , 0, 0, ((void*)0) }, ((void*)0) }, |
363 | DEFINE_NIL_CONTEXT (CAIRO_STATUS_INVALID_WEIGHT){ {((cairo_atomic_int_t) -1)}, CAIRO_STATUS_INVALID_WEIGHT, { 0, 0, 0, ((void*)0) }, ((void*)0) }, |
364 | DEFINE_NIL_CONTEXT (CAIRO_STATUS_INVALID_SIZE){ {((cairo_atomic_int_t) -1)}, CAIRO_STATUS_INVALID_SIZE, { 0 , 0, 0, ((void*)0) }, ((void*)0) }, |
365 | DEFINE_NIL_CONTEXT (CAIRO_STATUS_USER_FONT_NOT_IMPLEMENTED){ {((cairo_atomic_int_t) -1)}, CAIRO_STATUS_USER_FONT_NOT_IMPLEMENTED , { 0, 0, 0, ((void*)0) }, ((void*)0) }, |
366 | DEFINE_NIL_CONTEXT (CAIRO_STATUS_DEVICE_TYPE_MISMATCH){ {((cairo_atomic_int_t) -1)}, CAIRO_STATUS_DEVICE_TYPE_MISMATCH , { 0, 0, 0, ((void*)0) }, ((void*)0) }, |
367 | DEFINE_NIL_CONTEXT (CAIRO_STATUS_DEVICE_ERROR){ {((cairo_atomic_int_t) -1)}, CAIRO_STATUS_DEVICE_ERROR, { 0 , 0, 0, ((void*)0) }, ((void*)0) }, |
368 | DEFINE_NIL_CONTEXT (CAIRO_STATUS_INVALID_MESH_CONSTRUCTION){ {((cairo_atomic_int_t) -1)}, CAIRO_STATUS_INVALID_MESH_CONSTRUCTION , { 0, 0, 0, ((void*)0) }, ((void*)0) }, |
369 | DEFINE_NIL_CONTEXT (CAIRO_STATUS_DEVICE_FINISHED){ {((cairo_atomic_int_t) -1)}, CAIRO_STATUS_DEVICE_FINISHED, { 0, 0, 0, ((void*)0) }, ((void*)0) }, |
370 | DEFINE_NIL_CONTEXT (CAIRO_STATUS_JBIG2_GLOBAL_MISSING){ {((cairo_atomic_int_t) -1)}, CAIRO_STATUS_JBIG2_GLOBAL_MISSING , { 0, 0, 0, ((void*)0) }, ((void*)0) }, |
371 | DEFINE_NIL_CONTEXT (CAIRO_STATUS_PNG_ERROR){ {((cairo_atomic_int_t) -1)}, CAIRO_STATUS_PNG_ERROR, { 0, 0 , 0, ((void*)0) }, ((void*)0) }, |
372 | DEFINE_NIL_CONTEXT (CAIRO_STATUS_FREETYPE_ERROR){ {((cairo_atomic_int_t) -1)}, CAIRO_STATUS_FREETYPE_ERROR, { 0, 0, 0, ((void*)0) }, ((void*)0) }, |
373 | DEFINE_NIL_CONTEXT (CAIRO_STATUS_WIN32_GDI_ERROR){ {((cairo_atomic_int_t) -1)}, CAIRO_STATUS_WIN32_GDI_ERROR, { 0, 0, 0, ((void*)0) }, ((void*)0) }, |
374 | DEFINE_NIL_CONTEXT (CAIRO_STATUS_TAG_ERROR){ {((cairo_atomic_int_t) -1)}, CAIRO_STATUS_TAG_ERROR, { 0, 0 , 0, ((void*)0) }, ((void*)0) }, |
375 | DEFINE_NIL_CONTEXT (CAIRO_STATUS_DWRITE_ERROR){ {((cairo_atomic_int_t) -1)}, CAIRO_STATUS_DWRITE_ERROR, { 0 , 0, 0, ((void*)0) }, ((void*)0) }, |
376 | DEFINE_NIL_CONTEXT (CAIRO_STATUS_SVG_FONT_ERROR){ {((cairo_atomic_int_t) -1)}, CAIRO_STATUS_SVG_FONT_ERROR, { 0, 0, 0, ((void*)0) }, ((void*)0) } |
377 | }; |
378 | COMPILE_TIME_ASSERT (ARRAY_LENGTH (_cairo_nil) == CAIRO_STATUS_LAST_STATUS - 1)typedef int compile_time_assertion_at_line_378_failed [(((int ) (sizeof (_cairo_nil) / sizeof (_cairo_nil[0]))) == CAIRO_STATUS_LAST_STATUS - 1)?1:-1]; |
379 | |
380 | /** |
381 | * _cairo_set_error: |
382 | * @cr: a cairo context |
383 | * @status: a status value indicating an error |
384 | * |
385 | * Atomically sets cr->status to @status and calls _cairo_error; |
386 | * Does nothing if status is %CAIRO_STATUS_SUCCESS. |
387 | * |
388 | * All assignments of an error status to cr->status should happen |
389 | * through _cairo_set_error(). Note that due to the nature of the atomic |
390 | * operation, it is not safe to call this function on the nil objects. |
391 | * |
392 | * The purpose of this function is to allow the user to set a |
393 | * breakpoint in _cairo_error() to generate a stack trace for when the |
394 | * user causes cairo to detect an error. |
395 | **/ |
396 | static void |
397 | _cairo_set_error (cairo_t *cr, cairo_status_t status) |
398 | { |
399 | /* Don't overwrite an existing error. This preserves the first |
400 | * error, which is the most significant. */ |
401 | _cairo_status_set_error (&cr->status, _cairo_error (status))do { int ret__; ((void) sizeof ((_cairo_error (status) < CAIRO_STATUS_LAST_STATUS ) ? 1 : 0), __extension__ ({ if (_cairo_error (status) < CAIRO_STATUS_LAST_STATUS ) ; else __assert_fail ("_cairo_error (status) < CAIRO_STATUS_LAST_STATUS" , "/root/firefox-clang/gfx/cairo/cairo/src/cairo.c", 401, __extension__ __PRETTY_FUNCTION__); })); ((void) sizeof ((sizeof(*&cr-> status) == sizeof(cairo_atomic_int_t)) ? 1 : 0), __extension__ ({ if (sizeof(*&cr->status) == sizeof(cairo_atomic_int_t )) ; else __assert_fail ("sizeof(*&cr->status) == sizeof(cairo_atomic_int_t)" , "/root/firefox-clang/gfx/cairo/cairo/src/cairo.c", 401, __extension__ __PRETTY_FUNCTION__); })); ret__ = _cairo_atomic_int_cmpxchg_impl ((cairo_atomic_int_t *) &cr->status, CAIRO_STATUS_SUCCESS , _cairo_error (status)); (void) ret__; } while (0); |
402 | } |
403 | |
404 | cairo_t * |
405 | _cairo_create_in_error (cairo_status_t status) |
406 | { |
407 | cairo_t *cr; |
408 | |
409 | assert (status != CAIRO_STATUS_SUCCESS)((void) sizeof ((status != CAIRO_STATUS_SUCCESS) ? 1 : 0), __extension__ ({ if (status != CAIRO_STATUS_SUCCESS) ; else __assert_fail ( "status != CAIRO_STATUS_SUCCESS", "/root/firefox-clang/gfx/cairo/cairo/src/cairo.c" , 409, __extension__ __PRETTY_FUNCTION__); })); |
410 | |
411 | cr = (cairo_t *) &_cairo_nil[status - CAIRO_STATUS_NO_MEMORY]; |
412 | assert (status == cr->status)((void) sizeof ((status == cr->status) ? 1 : 0), __extension__ ({ if (status == cr->status) ; else __assert_fail ("status == cr->status" , "/root/firefox-clang/gfx/cairo/cairo/src/cairo.c", 412, __extension__ __PRETTY_FUNCTION__); })); |
413 | |
414 | return cr; |
415 | } |
416 | |
417 | /** |
418 | * cairo_create: |
419 | * @target: target surface for the context |
420 | * |
421 | * Creates a new #cairo_t with all graphics state parameters set to |
422 | * default values and with @target as a target surface. The target |
423 | * surface should be constructed with a backend-specific function such |
424 | * as cairo_image_surface_create() (or any other |
425 | * <function>cairo_<emphasis>backend</emphasis>_surface_create(<!-- -->)</function> |
426 | * variant). |
427 | * |
428 | * This function references @target, so you can immediately |
429 | * call cairo_surface_destroy() on it if you don't need to |
430 | * maintain a separate reference to it. |
431 | * |
432 | * Return value: a newly allocated #cairo_t with a reference |
433 | * count of 1. The initial reference count should be released |
434 | * with cairo_destroy() when you are done using the #cairo_t. |
435 | * This function never returns %NULL. If memory cannot be |
436 | * allocated, a special #cairo_t object will be returned on |
437 | * which cairo_status() returns %CAIRO_STATUS_NO_MEMORY. If |
438 | * you attempt to target a surface which does not support |
439 | * writing (such as #cairo_mime_surface_t) then a |
440 | * %CAIRO_STATUS_WRITE_ERROR will be raised. You can use this |
441 | * object normally, but no drawing will be done. |
442 | * |
443 | * Since: 1.0 |
444 | **/ |
445 | cairo_t * |
446 | cairo_create_moz_cairo_create (cairo_surface_t *target) |
447 | { |
448 | if (unlikely (target == NULL)(__builtin_expect (!!(target == ((void*)0)), 0))) |
449 | return _cairo_create_in_error (_cairo_error (CAIRO_STATUS_NULL_POINTER)); |
450 | if (unlikely (target->status)(__builtin_expect (!!(target->status), 0))) |
451 | return _cairo_create_in_error (target->status); |
452 | if (unlikely (target->finished)(__builtin_expect (!!(target->finished), 0))) |
453 | return _cairo_create_in_error (_cairo_error (CAIRO_STATUS_SURFACE_FINISHED)); |
454 | |
455 | if (target->backend->create_context == NULL((void*)0)) |
456 | return _cairo_create_in_error (_cairo_error (CAIRO_STATUS_WRITE_ERROR)); |
457 | |
458 | return target->backend->create_context (target); |
459 | |
460 | } |
461 | |
462 | void |
463 | _cairo_init (cairo_t *cr, |
464 | const cairo_backend_t *backend) |
465 | { |
466 | CAIRO_REFERENCE_COUNT_INIT (&cr->ref_count, 1)((&cr->ref_count)->ref_count = (1)); |
467 | cr->status = CAIRO_STATUS_SUCCESS; |
468 | _cairo_user_data_array_init (&cr->user_data); |
469 | |
470 | cr->backend = backend; |
471 | } |
472 | |
473 | /** |
474 | * cairo_reference: |
475 | * @cr: a #cairo_t |
476 | * |
477 | * Increases the reference count on @cr by one. This prevents |
478 | * @cr from being destroyed until a matching call to cairo_destroy() |
479 | * is made. |
480 | * |
481 | * Use cairo_get_reference_count() to get the number of references to |
482 | * a #cairo_t. |
483 | * |
484 | * Return value: the referenced #cairo_t. |
485 | * |
486 | * Since: 1.0 |
487 | **/ |
488 | cairo_t * |
489 | cairo_reference_moz_cairo_reference (cairo_t *cr) |
490 | { |
491 | if (cr == NULL((void*)0) || CAIRO_REFERENCE_COUNT_IS_INVALID (&cr->ref_count)(_cairo_atomic_int_get (&(&cr->ref_count)->ref_count ) == ((cairo_atomic_int_t) -1))) |
492 | return cr; |
493 | |
494 | assert (CAIRO_REFERENCE_COUNT_HAS_REFERENCE (&cr->ref_count))((void) sizeof (((_cairo_atomic_int_get (&(&cr->ref_count )->ref_count) > 0)) ? 1 : 0), __extension__ ({ if ((_cairo_atomic_int_get (&(&cr->ref_count)->ref_count) > 0)) ; else __assert_fail ("CAIRO_REFERENCE_COUNT_HAS_REFERENCE (&cr->ref_count)" , "/root/firefox-clang/gfx/cairo/cairo/src/cairo.c", 494, __extension__ __PRETTY_FUNCTION__); })); |
495 | |
496 | _cairo_reference_count_inc (&cr->ref_count)((void) __atomic_fetch_add(&(&cr->ref_count)->ref_count , 1, 5)); |
497 | |
498 | return cr; |
499 | } |
500 | |
501 | void |
502 | _cairo_fini (cairo_t *cr) |
503 | { |
504 | _cairo_user_data_array_fini (&cr->user_data); |
505 | } |
506 | |
507 | /** |
508 | * cairo_destroy: |
509 | * @cr: a #cairo_t |
510 | * |
511 | * Decreases the reference count on @cr by one. If the result |
512 | * is zero, then @cr and all associated resources are freed. |
513 | * See cairo_reference(). |
514 | * |
515 | * Since: 1.0 |
516 | **/ |
517 | void |
518 | cairo_destroy_moz_cairo_destroy (cairo_t *cr) |
519 | { |
520 | if (cr == NULL((void*)0) || CAIRO_REFERENCE_COUNT_IS_INVALID (&cr->ref_count)(_cairo_atomic_int_get (&(&cr->ref_count)->ref_count ) == ((cairo_atomic_int_t) -1))) |
521 | return; |
522 | |
523 | assert (CAIRO_REFERENCE_COUNT_HAS_REFERENCE (&cr->ref_count))((void) sizeof (((_cairo_atomic_int_get (&(&cr->ref_count )->ref_count) > 0)) ? 1 : 0), __extension__ ({ if ((_cairo_atomic_int_get (&(&cr->ref_count)->ref_count) > 0)) ; else __assert_fail ("CAIRO_REFERENCE_COUNT_HAS_REFERENCE (&cr->ref_count)" , "/root/firefox-clang/gfx/cairo/cairo/src/cairo.c", 523, __extension__ __PRETTY_FUNCTION__); })); |
524 | |
525 | if (! _cairo_reference_count_dec_and_test (&cr->ref_count)(__atomic_fetch_sub(&(&cr->ref_count)->ref_count , 1, 5) == 1)) |
526 | return; |
527 | |
528 | cr->backend->destroy (cr); |
529 | } |
530 | |
531 | /** |
532 | * cairo_get_user_data: |
533 | * @cr: a #cairo_t |
534 | * @key: the address of the #cairo_user_data_key_t the user data was |
535 | * attached to |
536 | * |
537 | * Return user data previously attached to @cr using the specified |
538 | * key. If no user data has been attached with the given key this |
539 | * function returns %NULL. |
540 | * |
541 | * Return value: the user data previously attached or %NULL. |
542 | * |
543 | * Since: 1.4 |
544 | **/ |
545 | void * |
546 | cairo_get_user_data_moz_cairo_get_user_data (cairo_t *cr, |
547 | const cairo_user_data_key_t *key) |
548 | { |
549 | return _cairo_user_data_array_get_data (&cr->user_data, key); |
550 | } |
551 | |
552 | /** |
553 | * cairo_set_user_data: |
554 | * @cr: a #cairo_t |
555 | * @key: the address of a #cairo_user_data_key_t to attach the user data to |
556 | * @user_data: the user data to attach to the #cairo_t |
557 | * @destroy: a #cairo_destroy_func_t which will be called when the |
558 | * #cairo_t is destroyed or when new user data is attached using the |
559 | * same key. |
560 | * |
561 | * Attach user data to @cr. To remove user data from a surface, |
562 | * call this function with the key that was used to set it and %NULL |
563 | * for @data. |
564 | * |
565 | * Return value: %CAIRO_STATUS_SUCCESS or %CAIRO_STATUS_NO_MEMORY if a |
566 | * slot could not be allocated for the user data. |
567 | * |
568 | * Since: 1.4 |
569 | **/ |
570 | cairo_status_t |
571 | cairo_set_user_data_moz_cairo_set_user_data (cairo_t *cr, |
572 | const cairo_user_data_key_t *key, |
573 | void *user_data, |
574 | cairo_destroy_func_t destroy) |
575 | { |
576 | if (CAIRO_REFERENCE_COUNT_IS_INVALID (&cr->ref_count)(_cairo_atomic_int_get (&(&cr->ref_count)->ref_count ) == ((cairo_atomic_int_t) -1))) |
577 | return cr->status; |
578 | |
579 | return _cairo_user_data_array_set_data (&cr->user_data, |
580 | key, user_data, destroy); |
581 | } |
582 | |
583 | /** |
584 | * cairo_get_reference_count: |
585 | * @cr: a #cairo_t |
586 | * |
587 | * Returns the current reference count of @cr. |
588 | * |
589 | * Return value: the current reference count of @cr. If the |
590 | * object is a nil object, 0 will be returned. |
591 | * |
592 | * Since: 1.4 |
593 | **/ |
594 | unsigned int |
595 | cairo_get_reference_count_moz_cairo_get_reference_count (cairo_t *cr) |
596 | { |
597 | if (cr == NULL((void*)0) || CAIRO_REFERENCE_COUNT_IS_INVALID (&cr->ref_count)(_cairo_atomic_int_get (&(&cr->ref_count)->ref_count ) == ((cairo_atomic_int_t) -1))) |
598 | return 0; |
599 | |
600 | return CAIRO_REFERENCE_COUNT_GET_VALUE (&cr->ref_count)_cairo_atomic_int_get (&(&cr->ref_count)->ref_count ); |
601 | } |
602 | |
603 | /** |
604 | * cairo_save: |
605 | * @cr: a #cairo_t |
606 | * |
607 | * Makes a copy of the current state of @cr and saves it |
608 | * on an internal stack of saved states for @cr. When |
609 | * cairo_restore() is called, @cr will be restored to |
610 | * the saved state. Multiple calls to cairo_save() and |
611 | * cairo_restore() can be nested; each call to cairo_restore() |
612 | * restores the state from the matching paired cairo_save(). |
613 | * |
614 | * It isn't necessary to clear all saved states before |
615 | * a #cairo_t is freed. If the reference count of a #cairo_t |
616 | * drops to zero in response to a call to cairo_destroy(), |
617 | * any saved states will be freed along with the #cairo_t. |
618 | * |
619 | * Since: 1.0 |
620 | **/ |
621 | void |
622 | cairo_save_moz_cairo_save (cairo_t *cr) |
623 | { |
624 | cairo_status_t status; |
625 | |
626 | if (unlikely (cr->status)(__builtin_expect (!!(cr->status), 0))) |
627 | return; |
628 | |
629 | status = cr->backend->save (cr); |
630 | if (unlikely (status)(__builtin_expect (!!(status), 0))) |
631 | _cairo_set_error (cr, status); |
632 | } |
633 | |
634 | /** |
635 | * cairo_restore: |
636 | * @cr: a #cairo_t |
637 | * |
638 | * Restores @cr to the state saved by a preceding call to |
639 | * cairo_save() and removes that state from the stack of |
640 | * saved states. |
641 | * |
642 | * Since: 1.0 |
643 | **/ |
644 | void |
645 | cairo_restore_moz_cairo_restore (cairo_t *cr) |
646 | { |
647 | cairo_status_t status; |
648 | |
649 | if (unlikely (cr->status)(__builtin_expect (!!(cr->status), 0))) |
650 | return; |
651 | |
652 | status = cr->backend->restore (cr); |
653 | if (unlikely (status)(__builtin_expect (!!(status), 0))) |
654 | _cairo_set_error (cr, status); |
655 | } |
656 | |
657 | /** |
658 | * cairo_push_group: |
659 | * @cr: a cairo context |
660 | * |
661 | * Temporarily redirects drawing to an intermediate surface known as a |
662 | * group. The redirection lasts until the group is completed by a call |
663 | * to cairo_pop_group() or cairo_pop_group_to_source(). These calls |
664 | * provide the result of any drawing to the group as a pattern, |
665 | * (either as an explicit object, or set as the source pattern). |
666 | * |
667 | * This group functionality can be convenient for performing |
668 | * intermediate compositing. One common use of a group is to render |
669 | * objects as opaque within the group, (so that they occlude each |
670 | * other), and then blend the result with translucence onto the |
671 | * destination. |
672 | * |
673 | * Groups can be nested arbitrarily deep by making balanced calls to |
674 | * cairo_push_group()/cairo_pop_group(). Each call pushes/pops the new |
675 | * target group onto/from a stack. |
676 | * |
677 | * The cairo_push_group() function calls cairo_save() so that any |
678 | * changes to the graphics state will not be visible outside the |
679 | * group, (the pop_group functions call cairo_restore()). |
680 | * |
681 | * By default the intermediate group will have a content type of |
682 | * %CAIRO_CONTENT_COLOR_ALPHA. Other content types can be chosen for |
683 | * the group by using cairo_push_group_with_content() instead. |
684 | * |
685 | * As an example, here is how one might fill and stroke a path with |
686 | * translucence, but without any portion of the fill being visible |
687 | * under the stroke: |
688 | * |
689 | * <informalexample><programlisting> |
690 | * cairo_push_group (cr); |
691 | * cairo_set_source (cr, fill_pattern); |
692 | * cairo_fill_preserve (cr); |
693 | * cairo_set_source (cr, stroke_pattern); |
694 | * cairo_stroke (cr); |
695 | * cairo_pop_group_to_source (cr); |
696 | * cairo_paint_with_alpha (cr, alpha); |
697 | * </programlisting></informalexample> |
698 | * |
699 | * Since: 1.2 |
700 | **/ |
701 | void |
702 | cairo_push_group_moz_cairo_push_group (cairo_t *cr) |
703 | { |
704 | cairo_push_group_with_content_moz_cairo_push_group_with_content (cr, CAIRO_CONTENT_COLOR_ALPHA); |
705 | } |
706 | |
707 | /** |
708 | * cairo_push_group_with_content: |
709 | * @cr: a cairo context |
710 | * @content: a #cairo_content_t indicating the type of group that |
711 | * will be created |
712 | * |
713 | * Temporarily redirects drawing to an intermediate surface known as a |
714 | * group. The redirection lasts until the group is completed by a call |
715 | * to cairo_pop_group() or cairo_pop_group_to_source(). These calls |
716 | * provide the result of any drawing to the group as a pattern, |
717 | * (either as an explicit object, or set as the source pattern). |
718 | * |
719 | * The group will have a content type of @content. The ability to |
720 | * control this content type is the only distinction between this |
721 | * function and cairo_push_group() which you should see for a more |
722 | * detailed description of group rendering. |
723 | * |
724 | * Since: 1.2 |
725 | **/ |
726 | void |
727 | cairo_push_group_with_content_moz_cairo_push_group_with_content (cairo_t *cr, cairo_content_t content) |
728 | { |
729 | cairo_status_t status; |
730 | |
731 | if (unlikely (cr->status)(__builtin_expect (!!(cr->status), 0))) |
732 | return; |
733 | |
734 | status = cr->backend->push_group (cr, content); |
735 | if (unlikely (status)(__builtin_expect (!!(status), 0))) |
736 | _cairo_set_error (cr, status); |
737 | } |
738 | |
739 | /** |
740 | * cairo_pop_group: |
741 | * @cr: a cairo context |
742 | * |
743 | * Terminates the redirection begun by a call to cairo_push_group() or |
744 | * cairo_push_group_with_content() and returns a new pattern |
745 | * containing the results of all drawing operations performed to the |
746 | * group. |
747 | * |
748 | * The cairo_pop_group() function calls cairo_restore(), (balancing a |
749 | * call to cairo_save() by the push_group function), so that any |
750 | * changes to the graphics state will not be visible outside the |
751 | * group. |
752 | * |
753 | * Return value: a newly created (surface) pattern containing the |
754 | * results of all drawing operations performed to the group. The |
755 | * caller owns the returned object and should call |
756 | * cairo_pattern_destroy() when finished with it. |
757 | * |
758 | * Since: 1.2 |
759 | **/ |
760 | cairo_pattern_t * |
761 | cairo_pop_group_moz_cairo_pop_group (cairo_t *cr) |
762 | { |
763 | cairo_pattern_t *group_pattern; |
764 | |
765 | if (unlikely (cr->status)(__builtin_expect (!!(cr->status), 0))) |
766 | return _cairo_pattern_create_in_error (cr->status); |
767 | |
768 | group_pattern = cr->backend->pop_group (cr); |
769 | if (unlikely (group_pattern->status)(__builtin_expect (!!(group_pattern->status), 0))) |
770 | _cairo_set_error (cr, group_pattern->status); |
771 | |
772 | return group_pattern; |
773 | } |
774 | |
775 | /** |
776 | * cairo_pop_group_to_source: |
777 | * @cr: a cairo context |
778 | * |
779 | * Terminates the redirection begun by a call to cairo_push_group() or |
780 | * cairo_push_group_with_content() and installs the resulting pattern |
781 | * as the source pattern in the given cairo context. |
782 | * |
783 | * The behavior of this function is equivalent to the sequence of |
784 | * operations: |
785 | * |
786 | * <informalexample><programlisting> |
787 | * cairo_pattern_t *group = cairo_pop_group (cr); |
788 | * cairo_set_source (cr, group); |
789 | * cairo_pattern_destroy (group); |
790 | * </programlisting></informalexample> |
791 | * |
792 | * but is more convenient as their is no need for a variable to store |
793 | * the short-lived pointer to the pattern. |
794 | * |
795 | * The cairo_pop_group() function calls cairo_restore(), (balancing a |
796 | * call to cairo_save() by the push_group function), so that any |
797 | * changes to the graphics state will not be visible outside the |
798 | * group. |
799 | * |
800 | * Since: 1.2 |
801 | **/ |
802 | void |
803 | cairo_pop_group_to_source_moz_cairo_pop_group_to_source (cairo_t *cr) |
804 | { |
805 | cairo_pattern_t *group_pattern; |
806 | |
807 | group_pattern = cairo_pop_group_moz_cairo_pop_group (cr); |
808 | cairo_set_source_moz_cairo_set_source (cr, group_pattern); |
809 | cairo_pattern_destroy_moz_cairo_pattern_destroy (group_pattern); |
810 | } |
811 | |
812 | /** |
813 | * cairo_set_operator: |
814 | * @cr: a #cairo_t |
815 | * @op: a compositing operator, specified as a #cairo_operator_t |
816 | * |
817 | * Sets the compositing operator to be used for all drawing |
818 | * operations. See #cairo_operator_t for details on the semantics of |
819 | * each available compositing operator. |
820 | * |
821 | * The default operator is %CAIRO_OPERATOR_OVER. |
822 | * |
823 | * Since: 1.0 |
824 | **/ |
825 | void |
826 | cairo_set_operator_moz_cairo_set_operator (cairo_t *cr, cairo_operator_t op) |
827 | { |
828 | cairo_status_t status; |
829 | |
830 | if (unlikely (cr->status)(__builtin_expect (!!(cr->status), 0))) |
831 | return; |
832 | |
833 | status = cr->backend->set_operator (cr, op); |
834 | if (unlikely (status)(__builtin_expect (!!(status), 0))) |
835 | _cairo_set_error (cr, status); |
836 | } |
837 | |
838 | |
839 | #if 0 |
840 | /* |
841 | * cairo_set_opacity: |
842 | * @cr: a #cairo_t |
843 | * @opacity: the level of opacity to use when compositing |
844 | * |
845 | * Sets the compositing opacity to be used for all drawing |
846 | * operations. The effect is to fade out the operations |
847 | * using the alpha value. |
848 | * |
849 | * The default opacity is 1. |
850 | */ |
851 | void |
852 | cairo_set_opacity (cairo_t *cr, double opacity) |
853 | { |
854 | cairo_status_t status; |
855 | |
856 | if (unlikely (cr->status)(__builtin_expect (!!(cr->status), 0))) |
857 | return; |
858 | |
859 | status = cr->backend->set_opacity (cr, opacity); |
860 | if (unlikely (status)(__builtin_expect (!!(status), 0))) |
861 | _cairo_set_error (cr, status); |
862 | } |
863 | #endif |
864 | |
865 | /** |
866 | * cairo_set_source_rgb: |
867 | * @cr: a cairo context |
868 | * @red: red component of color |
869 | * @green: green component of color |
870 | * @blue: blue component of color |
871 | * |
872 | * Sets the source pattern within @cr to an opaque color. This opaque |
873 | * color will then be used for any subsequent drawing operation until |
874 | * a new source pattern is set. |
875 | * |
876 | * The color components are floating point numbers in the range 0 to |
877 | * 1. If the values passed in are outside that range, they will be |
878 | * clamped. |
879 | * |
880 | * The default source pattern is opaque black, (that is, it is |
881 | * equivalent to cairo_set_source_rgb(cr, 0.0, 0.0, 0.0)). |
882 | * |
883 | * Since: 1.0 |
884 | **/ |
885 | void |
886 | cairo_set_source_rgb_moz_cairo_set_source_rgb (cairo_t *cr, double red, double green, double blue) |
887 | { |
888 | cairo_status_t status; |
889 | |
890 | if (unlikely (cr->status)(__builtin_expect (!!(cr->status), 0))) |
891 | return; |
892 | |
893 | status = cr->backend->set_source_rgba (cr, red, green, blue, 1.); |
894 | if (unlikely (status)(__builtin_expect (!!(status), 0))) |
895 | _cairo_set_error (cr, status); |
896 | } |
897 | |
898 | /** |
899 | * cairo_set_source_rgba: |
900 | * @cr: a cairo context |
901 | * @red: red component of color |
902 | * @green: green component of color |
903 | * @blue: blue component of color |
904 | * @alpha: alpha component of color |
905 | * |
906 | * Sets the source pattern within @cr to a translucent color. This |
907 | * color will then be used for any subsequent drawing operation until |
908 | * a new source pattern is set. |
909 | * |
910 | * The color and alpha components are floating point numbers in the |
911 | * range 0 to 1. If the values passed in are outside that range, they |
912 | * will be clamped. |
913 | * |
914 | * Note that the color and alpha values are not premultiplied. |
915 | * |
916 | * The default source pattern is opaque black, (that is, it is |
917 | * equivalent to cairo_set_source_rgba(cr, 0.0, 0.0, 0.0, 1.0)). |
918 | * |
919 | * Since: 1.0 |
920 | **/ |
921 | void |
922 | cairo_set_source_rgba_moz_cairo_set_source_rgba (cairo_t *cr, |
923 | double red, double green, double blue, |
924 | double alpha) |
925 | { |
926 | cairo_status_t status; |
927 | |
928 | if (unlikely (cr->status)(__builtin_expect (!!(cr->status), 0))) |
929 | return; |
930 | |
931 | status = cr->backend->set_source_rgba (cr, red, green, blue, alpha); |
932 | if (unlikely (status)(__builtin_expect (!!(status), 0))) |
933 | _cairo_set_error (cr, status); |
934 | } |
935 | |
936 | /** |
937 | * cairo_set_source_surface: |
938 | * @cr: a cairo context |
939 | * @surface: a surface to be used to set the source pattern |
940 | * @x: User-space X coordinate for surface origin |
941 | * @y: User-space Y coordinate for surface origin |
942 | * |
943 | * This is a convenience function for creating a pattern from @surface |
944 | * and setting it as the source in @cr with cairo_set_source(). |
945 | * |
946 | * The @x and @y parameters give the user-space coordinate at which |
947 | * the surface origin should appear. (The surface origin is its |
948 | * upper-left corner before any transformation has been applied.) The |
949 | * @x and @y parameters are negated and then set as translation values |
950 | * in the pattern matrix. |
951 | * |
952 | * Other than the initial translation pattern matrix, as described |
953 | * above, all other pattern attributes, (such as its extend mode), are |
954 | * set to the default values as in cairo_pattern_create_for_surface(). |
955 | * The resulting pattern can be queried with cairo_get_source() so |
956 | * that these attributes can be modified if desired, (eg. to create a |
957 | * repeating pattern with cairo_pattern_set_extend()). |
958 | * |
959 | * Since: 1.0 |
960 | **/ |
961 | void |
962 | cairo_set_source_surface_moz_cairo_set_source_surface (cairo_t *cr, |
963 | cairo_surface_t *surface, |
964 | double x, |
965 | double y) |
966 | { |
967 | cairo_status_t status; |
968 | |
969 | if (unlikely (cr->status)(__builtin_expect (!!(cr->status), 0))) |
970 | return; |
971 | |
972 | if (unlikely (surface == NULL)(__builtin_expect (!!(surface == ((void*)0)), 0))) { |
973 | _cairo_set_error (cr, CAIRO_STATUS_NULL_POINTER); |
974 | return; |
975 | } |
976 | |
977 | status = cr->backend->set_source_surface (cr, surface, x, y); |
978 | if (unlikely (status)(__builtin_expect (!!(status), 0))) |
979 | _cairo_set_error (cr, status); |
980 | } |
981 | |
982 | /** |
983 | * cairo_set_source: |
984 | * @cr: a cairo context |
985 | * @source: a #cairo_pattern_t to be used as the source for |
986 | * subsequent drawing operations. |
987 | * |
988 | * Sets the source pattern within @cr to @source. This pattern |
989 | * will then be used for any subsequent drawing operation until a new |
990 | * source pattern is set. |
991 | * |
992 | * Note: The pattern's transformation matrix will be locked to the |
993 | * user space in effect at the time of cairo_set_source(). This means |
994 | * that further modifications of the current transformation matrix |
995 | * will not affect the source pattern. See cairo_pattern_set_matrix(). |
996 | * |
997 | * The default source pattern is a solid pattern that is opaque black, |
998 | * (that is, it is equivalent to cairo_set_source_rgb(cr, 0.0, 0.0, |
999 | * 0.0)). |
1000 | * |
1001 | * Since: 1.0 |
1002 | **/ |
1003 | void |
1004 | cairo_set_source_moz_cairo_set_source (cairo_t *cr, cairo_pattern_t *source) |
1005 | { |
1006 | cairo_status_t status; |
1007 | |
1008 | if (unlikely (cr->status)(__builtin_expect (!!(cr->status), 0))) |
1009 | return; |
1010 | |
1011 | if (unlikely (source == NULL)(__builtin_expect (!!(source == ((void*)0)), 0))) { |
1012 | _cairo_set_error (cr, CAIRO_STATUS_NULL_POINTER); |
1013 | return; |
1014 | } |
1015 | |
1016 | if (unlikely (source->status)(__builtin_expect (!!(source->status), 0))) { |
1017 | _cairo_set_error (cr, source->status); |
1018 | return; |
1019 | } |
1020 | |
1021 | status = cr->backend->set_source (cr, source); |
1022 | if (unlikely (status)(__builtin_expect (!!(status), 0))) |
1023 | _cairo_set_error (cr, status); |
1024 | } |
1025 | |
1026 | /** |
1027 | * cairo_get_source: |
1028 | * @cr: a cairo context |
1029 | * |
1030 | * Gets the current source pattern for @cr. |
1031 | * |
1032 | * Return value: the current source pattern. This object is owned by |
1033 | * cairo. To keep a reference to it, you must call |
1034 | * cairo_pattern_reference(). |
1035 | * |
1036 | * Since: 1.0 |
1037 | **/ |
1038 | cairo_pattern_t * |
1039 | cairo_get_source_moz_cairo_get_source (cairo_t *cr) |
1040 | { |
1041 | if (unlikely (cr->status)(__builtin_expect (!!(cr->status), 0))) |
1042 | return _cairo_pattern_create_in_error (cr->status); |
1043 | |
1044 | return cr->backend->get_source (cr); |
1045 | } |
1046 | |
1047 | /** |
1048 | * cairo_set_tolerance: |
1049 | * @cr: a #cairo_t |
1050 | * @tolerance: the tolerance, in device units (typically pixels) |
1051 | * |
1052 | * Sets the tolerance used when converting paths into trapezoids. |
1053 | * Curved segments of the path will be subdivided until the maximum |
1054 | * deviation between the original path and the polygonal approximation |
1055 | * is less than @tolerance. The default value is 0.1. A larger |
1056 | * value will give better performance, a smaller value, better |
1057 | * appearance. (Reducing the value from the default value of 0.1 |
1058 | * is unlikely to improve appearance significantly.) The accuracy of paths |
1059 | * within Cairo is limited by the precision of its internal arithmetic, and |
1060 | * the prescribed @tolerance is restricted to the smallest |
1061 | * representable internal value. |
1062 | * |
1063 | * Since: 1.0 |
1064 | **/ |
1065 | void |
1066 | cairo_set_tolerance_moz_cairo_set_tolerance (cairo_t *cr, double tolerance) |
1067 | { |
1068 | cairo_status_t status; |
1069 | |
1070 | if (unlikely (cr->status)(__builtin_expect (!!(cr->status), 0))) |
1071 | return; |
1072 | |
1073 | status = cr->backend->set_tolerance (cr, tolerance); |
1074 | if (unlikely (status)(__builtin_expect (!!(status), 0))) |
1075 | _cairo_set_error (cr, status); |
1076 | } |
1077 | |
1078 | /** |
1079 | * cairo_set_antialias: |
1080 | * @cr: a #cairo_t |
1081 | * @antialias: the new antialiasing mode |
1082 | * |
1083 | * Set the antialiasing mode of the rasterizer used for drawing shapes. |
1084 | * This value is a hint, and a particular backend may or may not support |
1085 | * a particular value. At the current time, no backend supports |
1086 | * %CAIRO_ANTIALIAS_SUBPIXEL when drawing shapes. |
1087 | * |
1088 | * Note that this option does not affect text rendering, instead see |
1089 | * cairo_font_options_set_antialias(). |
1090 | * |
1091 | * Since: 1.0 |
1092 | **/ |
1093 | void |
1094 | cairo_set_antialias_moz_cairo_set_antialias (cairo_t *cr, cairo_antialias_t antialias) |
1095 | { |
1096 | cairo_status_t status; |
1097 | |
1098 | if (unlikely (cr->status)(__builtin_expect (!!(cr->status), 0))) |
1099 | return; |
1100 | |
1101 | status = cr->backend->set_antialias (cr, antialias); |
1102 | if (unlikely (status)(__builtin_expect (!!(status), 0))) |
1103 | _cairo_set_error (cr, status); |
1104 | } |
1105 | |
1106 | /** |
1107 | * cairo_set_fill_rule: |
1108 | * @cr: a #cairo_t |
1109 | * @fill_rule: a fill rule, specified as a #cairo_fill_rule_t |
1110 | * |
1111 | * Set the current fill rule within the cairo context. The fill rule |
1112 | * is used to determine which regions are inside or outside a complex |
1113 | * (potentially self-intersecting) path. The current fill rule affects |
1114 | * both cairo_fill() and cairo_clip(). See #cairo_fill_rule_t for details |
1115 | * on the semantics of each available fill rule. |
1116 | * |
1117 | * The default fill rule is %CAIRO_FILL_RULE_WINDING. |
1118 | * |
1119 | * Since: 1.0 |
1120 | **/ |
1121 | void |
1122 | cairo_set_fill_rule_moz_cairo_set_fill_rule (cairo_t *cr, cairo_fill_rule_t fill_rule) |
1123 | { |
1124 | cairo_status_t status; |
1125 | |
1126 | if (unlikely (cr->status)(__builtin_expect (!!(cr->status), 0))) |
1127 | return; |
1128 | |
1129 | status = cr->backend->set_fill_rule (cr, fill_rule); |
1130 | if (unlikely (status)(__builtin_expect (!!(status), 0))) |
1131 | _cairo_set_error (cr, status); |
1132 | } |
1133 | |
1134 | /** |
1135 | * cairo_set_line_width: |
1136 | * @cr: a #cairo_t |
1137 | * @width: a line width |
1138 | * |
1139 | * Sets the current line width within the cairo context. The line |
1140 | * width value specifies the diameter of a pen that is circular in |
1141 | * user space, (though device-space pen may be an ellipse in general |
1142 | * due to scaling/shear/rotation of the CTM). |
1143 | * |
1144 | * Note: When the description above refers to user space and CTM it |
1145 | * refers to the user space and CTM in effect at the time of the |
1146 | * stroking operation, not the user space and CTM in effect at the |
1147 | * time of the call to cairo_set_line_width(). The simplest usage |
1148 | * makes both of these spaces identical. That is, if there is no |
1149 | * change to the CTM between a call to cairo_set_line_width() and the |
1150 | * stroking operation, then one can just pass user-space values to |
1151 | * cairo_set_line_width() and ignore this note. |
1152 | * |
1153 | * As with the other stroke parameters, the current line width is |
1154 | * examined by cairo_stroke(), and cairo_stroke_extents(), but does not have |
1155 | * any effect during path construction. |
1156 | * |
1157 | * The default line width value is 2.0. |
1158 | * |
1159 | * Since: 1.0 |
1160 | **/ |
1161 | void |
1162 | cairo_set_line_width_moz_cairo_set_line_width (cairo_t *cr, double width) |
1163 | { |
1164 | cairo_status_t status; |
1165 | |
1166 | if (unlikely (cr->status)(__builtin_expect (!!(cr->status), 0))) |
1167 | return; |
1168 | |
1169 | if (width < 0.) |
1170 | width = 0.; |
1171 | |
1172 | status = cr->backend->set_line_width (cr, width); |
1173 | if (unlikely (status)(__builtin_expect (!!(status), 0))) |
1174 | _cairo_set_error (cr, status); |
1175 | } |
1176 | |
1177 | /** |
1178 | * cairo_set_hairline: |
1179 | * @cr: a #cairo_t |
1180 | * @set_hairline: whether or not to set hairline mode |
1181 | * |
1182 | * Sets lines within the cairo context to be hairlines. |
1183 | * Hairlines are logically zero-width lines that are drawn at the |
1184 | * thinnest renderable width possible in the current context. |
1185 | * |
1186 | * On surfaces with native hairline support, the native hairline |
1187 | * functionality will be used. Surfaces that support hairlines include: |
1188 | * - pdf/ps: Encoded as 0-width line. |
1189 | * - win32_printing: Rendered with PS_COSMETIC pen. |
1190 | * - svg: Encoded as 1px non-scaling-stroke. |
1191 | * - script: Encoded with set-hairline function. |
1192 | * |
1193 | * Cairo will always render hairlines at 1 device unit wide, even if |
1194 | * an anisotropic scaling was applied to the stroke width. In the wild, |
1195 | * handling of this situation is not well-defined. Some PDF, PS, and SVG |
1196 | * renderers match Cairo's output, but some very popular implementations |
1197 | * (Acrobat, Chrome, rsvg) will scale the hairline unevenly. |
1198 | * As such, best practice is to reset any anisotropic scaling before calling |
1199 | * cairo_stroke(). See https://cairographics.org/cookbook/ellipses/ |
1200 | * for an example. |
1201 | * |
1202 | * Since: 1.18 |
1203 | **/ |
1204 | void |
1205 | cairo_set_hairline (cairo_t *cr, cairo_bool_t set_hairline) |
1206 | { |
1207 | cairo_status_t status; |
1208 | |
1209 | if (unlikely (cr->status)(__builtin_expect (!!(cr->status), 0))) |
1210 | return; |
1211 | |
1212 | status = cr->backend->set_hairline (cr, set_hairline); |
1213 | if (unlikely (status)(__builtin_expect (!!(status), 0))) |
1214 | _cairo_set_error (cr, status); |
1215 | } |
1216 | |
1217 | /** |
1218 | * cairo_set_line_cap: |
1219 | * @cr: a cairo context |
1220 | * @line_cap: a line cap style |
1221 | * |
1222 | * Sets the current line cap style within the cairo context. See |
1223 | * #cairo_line_cap_t for details about how the available line cap |
1224 | * styles are drawn. |
1225 | * |
1226 | * As with the other stroke parameters, the current line cap style is |
1227 | * examined by cairo_stroke(), and cairo_stroke_extents(), but does not have |
1228 | * any effect during path construction. |
1229 | * |
1230 | * The default line cap style is %CAIRO_LINE_CAP_BUTT. |
1231 | * |
1232 | * Since: 1.0 |
1233 | **/ |
1234 | void |
1235 | cairo_set_line_cap_moz_cairo_set_line_cap (cairo_t *cr, cairo_line_cap_t line_cap) |
1236 | { |
1237 | cairo_status_t status; |
1238 | |
1239 | if (unlikely (cr->status)(__builtin_expect (!!(cr->status), 0))) |
1240 | return; |
1241 | |
1242 | status = cr->backend->set_line_cap (cr, line_cap); |
1243 | if (unlikely (status)(__builtin_expect (!!(status), 0))) |
1244 | _cairo_set_error (cr, status); |
1245 | } |
1246 | |
1247 | /** |
1248 | * cairo_set_line_join: |
1249 | * @cr: a cairo context |
1250 | * @line_join: a line join style |
1251 | * |
1252 | * Sets the current line join style within the cairo context. See |
1253 | * #cairo_line_join_t for details about how the available line join |
1254 | * styles are drawn. |
1255 | * |
1256 | * As with the other stroke parameters, the current line join style is |
1257 | * examined by cairo_stroke(), and cairo_stroke_extents(), but does not have |
1258 | * any effect during path construction. |
1259 | * |
1260 | * The default line join style is %CAIRO_LINE_JOIN_MITER. |
1261 | * |
1262 | * Since: 1.0 |
1263 | **/ |
1264 | void |
1265 | cairo_set_line_join_moz_cairo_set_line_join (cairo_t *cr, cairo_line_join_t line_join) |
1266 | { |
1267 | cairo_status_t status; |
1268 | |
1269 | if (unlikely (cr->status)(__builtin_expect (!!(cr->status), 0))) |
1270 | return; |
1271 | |
1272 | status = cr->backend->set_line_join (cr, line_join); |
1273 | if (unlikely (status)(__builtin_expect (!!(status), 0))) |
1274 | _cairo_set_error (cr, status); |
1275 | } |
1276 | |
1277 | /** |
1278 | * cairo_set_dash: |
1279 | * @cr: a cairo context |
1280 | * @dashes: an array specifying alternate lengths of on and off stroke portions |
1281 | * @num_dashes: the length of the dashes array |
1282 | * @offset: an offset into the dash pattern at which the stroke should start |
1283 | * |
1284 | * Sets the dash pattern to be used by cairo_stroke(). A dash pattern |
1285 | * is specified by @dashes, an array of positive values. Each value |
1286 | * provides the length of alternate "on" and "off" portions of the |
1287 | * stroke. The @offset specifies an offset into the pattern at which |
1288 | * the stroke begins. |
1289 | * |
1290 | * Each "on" segment will have caps applied as if the segment were a |
1291 | * separate sub-path. In particular, it is valid to use an "on" length |
1292 | * of 0.0 with %CAIRO_LINE_CAP_ROUND or %CAIRO_LINE_CAP_SQUARE in order |
1293 | * to distributed dots or squares along a path. |
1294 | * |
1295 | * Note: The length values are in user-space units as evaluated at the |
1296 | * time of stroking. This is not necessarily the same as the user |
1297 | * space at the time of cairo_set_dash(). |
1298 | * |
1299 | * If @num_dashes is 0 dashing is disabled. |
1300 | * |
1301 | * If @num_dashes is 1 a symmetric pattern is assumed with alternating |
1302 | * on and off portions of the size specified by the single value in |
1303 | * @dashes. |
1304 | * |
1305 | * If any value in @dashes is negative, or if all values are 0, then |
1306 | * @cr will be put into an error state with a status of |
1307 | * %CAIRO_STATUS_INVALID_DASH. |
1308 | * |
1309 | * Since: 1.0 |
1310 | **/ |
1311 | void |
1312 | cairo_set_dash_moz_cairo_set_dash (cairo_t *cr, |
1313 | const double *dashes, |
1314 | int num_dashes, |
1315 | double offset) |
1316 | { |
1317 | cairo_status_t status; |
1318 | |
1319 | if (unlikely (cr->status)(__builtin_expect (!!(cr->status), 0))) |
1320 | return; |
1321 | |
1322 | status = cr->backend->set_dash (cr, dashes, num_dashes, offset); |
1323 | if (unlikely (status)(__builtin_expect (!!(status), 0))) |
1324 | _cairo_set_error (cr, status); |
1325 | } |
1326 | |
1327 | /** |
1328 | * cairo_get_dash_count: |
1329 | * @cr: a #cairo_t |
1330 | * |
1331 | * This function returns the length of the dash array in @cr (0 if dashing |
1332 | * is not currently in effect). |
1333 | * |
1334 | * See also cairo_set_dash() and cairo_get_dash(). |
1335 | * |
1336 | * Return value: the length of the dash array, or 0 if no dash array set. |
1337 | * |
1338 | * Since: 1.4 |
1339 | **/ |
1340 | int |
1341 | cairo_get_dash_count_moz_cairo_get_dash_count (cairo_t *cr) |
1342 | { |
1343 | int num_dashes; |
1344 | |
1345 | if (unlikely (cr->status)(__builtin_expect (!!(cr->status), 0))) |
1346 | return 0; |
1347 | |
1348 | cr->backend->get_dash (cr, NULL((void*)0), &num_dashes, NULL((void*)0)); |
1349 | |
1350 | return num_dashes; |
1351 | } |
1352 | |
1353 | /** |
1354 | * cairo_get_dash: |
1355 | * @cr: a #cairo_t |
1356 | * @dashes: return value for the dash array, or %NULL |
1357 | * @offset: return value for the current dash offset, or %NULL |
1358 | * |
1359 | * Gets the current dash array. If not %NULL, @dashes should be big |
1360 | * enough to hold at least the number of values returned by |
1361 | * cairo_get_dash_count(). |
1362 | * |
1363 | * Since: 1.4 |
1364 | **/ |
1365 | void |
1366 | cairo_get_dash_moz_cairo_get_dash (cairo_t *cr, |
1367 | double *dashes, |
1368 | double *offset) |
1369 | { |
1370 | if (unlikely (cr->status)(__builtin_expect (!!(cr->status), 0))) |
1371 | return; |
1372 | |
1373 | cr->backend->get_dash (cr, dashes, NULL((void*)0), offset); |
1374 | } |
1375 | |
1376 | /** |
1377 | * cairo_set_miter_limit: |
1378 | * @cr: a cairo context |
1379 | * @limit: miter limit to set |
1380 | * |
1381 | * Sets the current miter limit within the cairo context. |
1382 | * |
1383 | * If the current line join style is set to %CAIRO_LINE_JOIN_MITER |
1384 | * (see cairo_set_line_join()), the miter limit is used to determine |
1385 | * whether the lines should be joined with a bevel instead of a miter. |
1386 | * Cairo divides the length of the miter by the line width. |
1387 | * If the result is greater than the miter limit, the style is |
1388 | * converted to a bevel. |
1389 | * |
1390 | * As with the other stroke parameters, the current line miter limit is |
1391 | * examined by cairo_stroke(), and cairo_stroke_extents(), but does not have |
1392 | * any effect during path construction. |
1393 | * |
1394 | * The default miter limit value is 10.0, which will convert joins |
1395 | * with interior angles less than 11 degrees to bevels instead of |
1396 | * miters. For reference, a miter limit of 2.0 makes the miter cutoff |
1397 | * at 60 degrees, and a miter limit of 1.414 makes the cutoff at 90 |
1398 | * degrees. |
1399 | * |
1400 | * A miter limit for a desired angle can be computed as: miter limit = |
1401 | * 1/sin(angle/2) |
1402 | * |
1403 | * Since: 1.0 |
1404 | **/ |
1405 | void |
1406 | cairo_set_miter_limit_moz_cairo_set_miter_limit (cairo_t *cr, double limit) |
1407 | { |
1408 | cairo_status_t status; |
1409 | |
1410 | if (unlikely (cr->status)(__builtin_expect (!!(cr->status), 0))) |
1411 | return; |
1412 | |
1413 | status = cr->backend->set_miter_limit (cr, limit); |
1414 | if (unlikely (status)(__builtin_expect (!!(status), 0))) |
1415 | _cairo_set_error (cr, status); |
1416 | } |
1417 | |
1418 | /** |
1419 | * cairo_translate: |
1420 | * @cr: a cairo context |
1421 | * @tx: amount to translate in the X direction |
1422 | * @ty: amount to translate in the Y direction |
1423 | * |
1424 | * Modifies the current transformation matrix (CTM) by translating the |
1425 | * user-space origin by (@tx, @ty). This offset is interpreted as a |
1426 | * user-space coordinate according to the CTM in place before the new |
1427 | * call to cairo_translate(). In other words, the translation of the |
1428 | * user-space origin takes place after any existing transformation. |
1429 | * |
1430 | * Since: 1.0 |
1431 | **/ |
1432 | void |
1433 | cairo_translate_moz_cairo_translate (cairo_t *cr, double tx, double ty) |
1434 | { |
1435 | cairo_status_t status; |
1436 | |
1437 | if (unlikely (cr->status)(__builtin_expect (!!(cr->status), 0))) |
1438 | return; |
1439 | |
1440 | status = cr->backend->translate (cr, tx, ty); |
1441 | if (unlikely (status)(__builtin_expect (!!(status), 0))) |
1442 | _cairo_set_error (cr, status); |
1443 | } |
1444 | |
1445 | /** |
1446 | * cairo_scale: |
1447 | * @cr: a cairo context |
1448 | * @sx: scale factor for the X dimension |
1449 | * @sy: scale factor for the Y dimension |
1450 | * |
1451 | * Modifies the current transformation matrix (CTM) by scaling the X |
1452 | * and Y user-space axes by @sx and @sy respectively. The scaling of |
1453 | * the axes takes place after any existing transformation of user |
1454 | * space. |
1455 | * |
1456 | * Since: 1.0 |
1457 | **/ |
1458 | void |
1459 | cairo_scale_moz_cairo_scale (cairo_t *cr, double sx, double sy) |
1460 | { |
1461 | cairo_status_t status; |
1462 | |
1463 | if (unlikely (cr->status)(__builtin_expect (!!(cr->status), 0))) |
1464 | return; |
1465 | |
1466 | status = cr->backend->scale (cr, sx, sy); |
1467 | if (unlikely (status)(__builtin_expect (!!(status), 0))) |
1468 | _cairo_set_error (cr, status); |
1469 | } |
1470 | |
1471 | /** |
1472 | * cairo_rotate: |
1473 | * @cr: a cairo context |
1474 | * @angle: angle (in radians) by which the user-space axes will be |
1475 | * rotated |
1476 | * |
1477 | * Modifies the current transformation matrix (CTM) by rotating the |
1478 | * user-space axes by @angle radians. The rotation of the axes takes |
1479 | * places after any existing transformation of user space. The |
1480 | * rotation direction for positive angles is from the positive X axis |
1481 | * toward the positive Y axis. |
1482 | * |
1483 | * Since: 1.0 |
1484 | **/ |
1485 | void |
1486 | cairo_rotate_moz_cairo_rotate (cairo_t *cr, double angle) |
1487 | { |
1488 | cairo_status_t status; |
1489 | |
1490 | if (unlikely (cr->status)(__builtin_expect (!!(cr->status), 0))) |
1491 | return; |
1492 | |
1493 | status = cr->backend->rotate (cr, angle); |
1494 | if (unlikely (status)(__builtin_expect (!!(status), 0))) |
1495 | _cairo_set_error (cr, status); |
1496 | } |
1497 | |
1498 | /** |
1499 | * cairo_transform: |
1500 | * @cr: a cairo context |
1501 | * @matrix: a transformation to be applied to the user-space axes |
1502 | * |
1503 | * Modifies the current transformation matrix (CTM) by applying |
1504 | * @matrix as an additional transformation. The new transformation of |
1505 | * user space takes place after any existing transformation. |
1506 | * |
1507 | * Since: 1.0 |
1508 | **/ |
1509 | void |
1510 | cairo_transform_moz_cairo_transform (cairo_t *cr, |
1511 | const cairo_matrix_t *matrix) |
1512 | { |
1513 | cairo_status_t status; |
1514 | |
1515 | if (unlikely (cr->status)(__builtin_expect (!!(cr->status), 0))) |
1516 | return; |
1517 | |
1518 | status = cr->backend->transform (cr, matrix); |
1519 | if (unlikely (status)(__builtin_expect (!!(status), 0))) |
1520 | _cairo_set_error (cr, status); |
1521 | } |
1522 | |
1523 | /** |
1524 | * cairo_set_matrix: |
1525 | * @cr: a cairo context |
1526 | * @matrix: a transformation matrix from user space to device space |
1527 | * |
1528 | * Modifies the current transformation matrix (CTM) by setting it |
1529 | * equal to @matrix. |
1530 | * |
1531 | * Since: 1.0 |
1532 | **/ |
1533 | void |
1534 | cairo_set_matrix_moz_cairo_set_matrix (cairo_t *cr, |
1535 | const cairo_matrix_t *matrix) |
1536 | { |
1537 | cairo_status_t status; |
1538 | |
1539 | if (unlikely (cr->status)(__builtin_expect (!!(cr->status), 0))) |
1540 | return; |
1541 | |
1542 | status = cr->backend->set_matrix (cr, matrix); |
1543 | if (unlikely (status)(__builtin_expect (!!(status), 0))) |
1544 | _cairo_set_error (cr, status); |
1545 | } |
1546 | |
1547 | /** |
1548 | * cairo_identity_matrix: |
1549 | * @cr: a cairo context |
1550 | * |
1551 | * Resets the current transformation matrix (CTM) by setting it equal |
1552 | * to the identity matrix. That is, the user-space and device-space |
1553 | * axes will be aligned and one user-space unit will transform to one |
1554 | * device-space unit. |
1555 | * |
1556 | * Since: 1.0 |
1557 | **/ |
1558 | void |
1559 | cairo_identity_matrix_moz_cairo_identity_matrix (cairo_t *cr) |
1560 | { |
1561 | cairo_status_t status; |
1562 | |
1563 | if (unlikely (cr->status)(__builtin_expect (!!(cr->status), 0))) |
1564 | return; |
1565 | |
1566 | status = cr->backend->set_identity_matrix (cr); |
1567 | if (unlikely (status)(__builtin_expect (!!(status), 0))) |
1568 | _cairo_set_error (cr, status); |
1569 | } |
1570 | |
1571 | /** |
1572 | * cairo_user_to_device: |
1573 | * @cr: a cairo context |
1574 | * @x: X value of coordinate (in/out parameter) |
1575 | * @y: Y value of coordinate (in/out parameter) |
1576 | * |
1577 | * Transform a coordinate from user space to device space by |
1578 | * multiplying the given point by the current transformation matrix |
1579 | * (CTM). |
1580 | * |
1581 | * Since: 1.0 |
1582 | **/ |
1583 | void |
1584 | cairo_user_to_device_moz_cairo_user_to_device (cairo_t *cr, double *x, double *y) |
1585 | { |
1586 | if (unlikely (cr->status)(__builtin_expect (!!(cr->status), 0))) |
1587 | return; |
1588 | |
1589 | cr->backend->user_to_device (cr, x, y); |
1590 | } |
1591 | |
1592 | /** |
1593 | * cairo_user_to_device_distance: |
1594 | * @cr: a cairo context |
1595 | * @dx: X component of a distance vector (in/out parameter) |
1596 | * @dy: Y component of a distance vector (in/out parameter) |
1597 | * |
1598 | * Transform a distance vector from user space to device space. This |
1599 | * function is similar to cairo_user_to_device() except that the |
1600 | * translation components of the CTM will be ignored when transforming |
1601 | * (@dx,@dy). |
1602 | * |
1603 | * Since: 1.0 |
1604 | **/ |
1605 | void |
1606 | cairo_user_to_device_distance_moz_cairo_user_to_device_distance (cairo_t *cr, double *dx, double *dy) |
1607 | { |
1608 | if (unlikely (cr->status)(__builtin_expect (!!(cr->status), 0))) |
1609 | return; |
1610 | |
1611 | cr->backend->user_to_device_distance (cr, dx, dy); |
1612 | } |
1613 | |
1614 | /** |
1615 | * cairo_device_to_user: |
1616 | * @cr: a cairo |
1617 | * @x: X value of coordinate (in/out parameter) |
1618 | * @y: Y value of coordinate (in/out parameter) |
1619 | * |
1620 | * Transform a coordinate from device space to user space by |
1621 | * multiplying the given point by the inverse of the current |
1622 | * transformation matrix (CTM). |
1623 | * |
1624 | * Since: 1.0 |
1625 | **/ |
1626 | void |
1627 | cairo_device_to_user_moz_cairo_device_to_user (cairo_t *cr, double *x, double *y) |
1628 | { |
1629 | if (unlikely (cr->status)(__builtin_expect (!!(cr->status), 0))) |
1630 | return; |
1631 | |
1632 | cr->backend->device_to_user (cr, x, y); |
1633 | } |
1634 | |
1635 | /** |
1636 | * cairo_device_to_user_distance: |
1637 | * @cr: a cairo context |
1638 | * @dx: X component of a distance vector (in/out parameter) |
1639 | * @dy: Y component of a distance vector (in/out parameter) |
1640 | * |
1641 | * Transform a distance vector from device space to user space. This |
1642 | * function is similar to cairo_device_to_user() except that the |
1643 | * translation components of the inverse CTM will be ignored when |
1644 | * transforming (@dx,@dy). |
1645 | * |
1646 | * Since: 1.0 |
1647 | **/ |
1648 | void |
1649 | cairo_device_to_user_distance_moz_cairo_device_to_user_distance (cairo_t *cr, double *dx, double *dy) |
1650 | { |
1651 | if (unlikely (cr->status)(__builtin_expect (!!(cr->status), 0))) |
1652 | return; |
1653 | |
1654 | cr->backend->device_to_user_distance (cr, dx, dy); |
1655 | } |
1656 | |
1657 | /** |
1658 | * cairo_new_path: |
1659 | * @cr: a cairo context |
1660 | * |
1661 | * Clears the current path. After this call there will be no path and |
1662 | * no current point. |
1663 | * |
1664 | * Since: 1.0 |
1665 | **/ |
1666 | void |
1667 | cairo_new_path_moz_cairo_new_path (cairo_t *cr) |
1668 | { |
1669 | cairo_status_t status; |
1670 | |
1671 | if (unlikely (cr->status)(__builtin_expect (!!(cr->status), 0))) |
1672 | return; |
1673 | |
1674 | status = cr->backend->new_path (cr); |
1675 | if (unlikely (status)(__builtin_expect (!!(status), 0))) |
1676 | _cairo_set_error (cr, status); |
1677 | } |
1678 | |
1679 | /** |
1680 | * cairo_new_sub_path: |
1681 | * @cr: a cairo context |
1682 | * |
1683 | * Begin a new sub-path. Note that the existing path is not |
1684 | * affected. After this call there will be no current point. |
1685 | * |
1686 | * In many cases, this call is not needed since new sub-paths are |
1687 | * frequently started with cairo_move_to(). |
1688 | * |
1689 | * A call to cairo_new_sub_path() is particularly useful when |
1690 | * beginning a new sub-path with one of the cairo_arc() calls. This |
1691 | * makes things easier as it is no longer necessary to manually |
1692 | * compute the arc's initial coordinates for a call to |
1693 | * cairo_move_to(). |
1694 | * |
1695 | * Since: 1.2 |
1696 | **/ |
1697 | void |
1698 | cairo_new_sub_path_moz_cairo_new_sub_path (cairo_t *cr) |
1699 | { |
1700 | cairo_status_t status; |
1701 | |
1702 | if (unlikely (cr->status)(__builtin_expect (!!(cr->status), 0))) |
1703 | return; |
1704 | |
1705 | status = cr->backend->new_sub_path (cr); |
1706 | if (unlikely (status)(__builtin_expect (!!(status), 0))) |
1707 | _cairo_set_error (cr, status); |
1708 | } |
1709 | |
1710 | /** |
1711 | * cairo_move_to: |
1712 | * @cr: a cairo context |
1713 | * @x: the X coordinate of the new position |
1714 | * @y: the Y coordinate of the new position |
1715 | * |
1716 | * Begin a new sub-path. After this call the current point will be (@x, |
1717 | * @y). |
1718 | * |
1719 | * Since: 1.0 |
1720 | **/ |
1721 | void |
1722 | cairo_move_to_moz_cairo_move_to (cairo_t *cr, double x, double y) |
1723 | { |
1724 | cairo_status_t status; |
1725 | |
1726 | if (unlikely (cr->status)(__builtin_expect (!!(cr->status), 0))) |
1727 | return; |
1728 | |
1729 | status = cr->backend->move_to (cr, x, y); |
1730 | if (unlikely (status)(__builtin_expect (!!(status), 0))) |
1731 | _cairo_set_error (cr, status); |
1732 | } |
1733 | |
1734 | /** |
1735 | * cairo_line_to: |
1736 | * @cr: a cairo context |
1737 | * @x: the X coordinate of the end of the new line |
1738 | * @y: the Y coordinate of the end of the new line |
1739 | * |
1740 | * Adds a line to the path from the current point to position (@x, @y) |
1741 | * in user-space coordinates. After this call the current point |
1742 | * will be (@x, @y). |
1743 | * |
1744 | * If there is no current point before the call to cairo_line_to() |
1745 | * this function will behave as cairo_move_to(@cr, @x, @y). |
1746 | * |
1747 | * Since: 1.0 |
1748 | **/ |
1749 | void |
1750 | cairo_line_to_moz_cairo_line_to (cairo_t *cr, double x, double y) |
1751 | { |
1752 | cairo_status_t status; |
1753 | |
1754 | if (unlikely (cr->status)(__builtin_expect (!!(cr->status), 0))) |
1755 | return; |
1756 | |
1757 | status = cr->backend->line_to (cr, x, y); |
1758 | if (unlikely (status)(__builtin_expect (!!(status), 0))) |
1759 | _cairo_set_error (cr, status); |
1760 | } |
1761 | |
1762 | /** |
1763 | * cairo_curve_to: |
1764 | * @cr: a cairo context |
1765 | * @x1: the X coordinate of the first control point |
1766 | * @y1: the Y coordinate of the first control point |
1767 | * @x2: the X coordinate of the second control point |
1768 | * @y2: the Y coordinate of the second control point |
1769 | * @x3: the X coordinate of the end of the curve |
1770 | * @y3: the Y coordinate of the end of the curve |
1771 | * |
1772 | * Adds a cubic Bézier spline to the path from the current point to |
1773 | * position (@x3, @y3) in user-space coordinates, using (@x1, @y1) and |
1774 | * (@x2, @y2) as the control points. After this call the current point |
1775 | * will be (@x3, @y3). |
1776 | * |
1777 | * If there is no current point before the call to cairo_curve_to() |
1778 | * this function will behave as if preceded by a call to |
1779 | * cairo_move_to(@cr, @x1, @y1). |
1780 | * |
1781 | * Since: 1.0 |
1782 | **/ |
1783 | void |
1784 | cairo_curve_to_moz_cairo_curve_to (cairo_t *cr, |
1785 | double x1, double y1, |
1786 | double x2, double y2, |
1787 | double x3, double y3) |
1788 | { |
1789 | cairo_status_t status; |
1790 | |
1791 | if (unlikely (cr->status)(__builtin_expect (!!(cr->status), 0))) |
1792 | return; |
1793 | |
1794 | status = cr->backend->curve_to (cr, |
1795 | x1, y1, |
1796 | x2, y2, |
1797 | x3, y3); |
1798 | if (unlikely (status)(__builtin_expect (!!(status), 0))) |
1799 | _cairo_set_error (cr, status); |
1800 | } |
1801 | |
1802 | /** |
1803 | * cairo_arc: |
1804 | * @cr: a cairo context |
1805 | * @xc: X position of the center of the arc |
1806 | * @yc: Y position of the center of the arc |
1807 | * @radius: the radius of the arc |
1808 | * @angle1: the start angle, in radians |
1809 | * @angle2: the end angle, in radians |
1810 | * |
1811 | * Adds a circular arc of the given @radius to the current path. The |
1812 | * arc is centered at (@xc, @yc), begins at @angle1 and proceeds in |
1813 | * the direction of increasing angles to end at @angle2. If @angle2 is |
1814 | * less than @angle1 it will be progressively increased by |
1815 | * <literal>2*M_PI</literal> until it is greater than @angle1. |
1816 | * |
1817 | * If there is a current point, an initial line segment will be added |
1818 | * to the path to connect the current point to the beginning of the |
1819 | * arc. If this initial line is undesired, it can be avoided by |
1820 | * calling cairo_new_sub_path() before calling cairo_arc(). |
1821 | * |
1822 | * Angles are measured in radians. An angle of 0.0 is in the direction |
1823 | * of the positive X axis (in user space). An angle of |
1824 | * <literal>M_PI/2.0</literal> radians (90 degrees) is in the |
1825 | * direction of the positive Y axis (in user space). Angles increase |
1826 | * in the direction from the positive X axis toward the positive Y |
1827 | * axis. So with the default transformation matrix, angles increase in |
1828 | * a clockwise direction. |
1829 | * |
1830 | * (To convert from degrees to radians, use <literal>degrees * (M_PI / |
1831 | * 180.)</literal>.) |
1832 | * |
1833 | * This function gives the arc in the direction of increasing angles; |
1834 | * see cairo_arc_negative() to get the arc in the direction of |
1835 | * decreasing angles. |
1836 | * |
1837 | * The arc is circular in user space. To achieve an elliptical arc, |
1838 | * you can scale the current transformation matrix by different |
1839 | * amounts in the X and Y directions. For example, to draw an ellipse |
1840 | * in the box given by @x, @y, @width, @height: |
1841 | * |
1842 | * <informalexample><programlisting> |
1843 | * cairo_save (cr); |
1844 | * cairo_translate (cr, x + width / 2., y + height / 2.); |
1845 | * cairo_scale (cr, width / 2., height / 2.); |
1846 | * cairo_arc (cr, 0., 0., 1., 0., 2 * M_PI); |
1847 | * cairo_restore (cr); |
1848 | * </programlisting></informalexample> |
1849 | * |
1850 | * Since: 1.0 |
1851 | **/ |
1852 | void |
1853 | cairo_arc_moz_cairo_arc (cairo_t *cr, |
1854 | double xc, double yc, |
1855 | double radius, |
1856 | double angle1, double angle2) |
1857 | { |
1858 | cairo_status_t status; |
1859 | |
1860 | if (unlikely (cr->status)(__builtin_expect (!!(cr->status), 0))) |
1861 | return; |
1862 | |
1863 | if (angle2 < angle1) { |
1864 | /* increase angle2 by multiples of full circle until it |
1865 | * satisfies angle2 >= angle1 */ |
1866 | angle2 = fmod (angle2 - angle1, 2 * M_PI3.14159265358979323846); |
1867 | if (angle2 < 0) |
1868 | angle2 += 2 * M_PI3.14159265358979323846; |
1869 | angle2 += angle1; |
1870 | } |
1871 | |
1872 | status = cr->backend->arc (cr, xc, yc, radius, angle1, angle2, TRUE1); |
1873 | if (unlikely (status)(__builtin_expect (!!(status), 0))) |
1874 | _cairo_set_error (cr, status); |
1875 | } |
1876 | |
1877 | /** |
1878 | * cairo_arc_negative: |
1879 | * @cr: a cairo context |
1880 | * @xc: X position of the center of the arc |
1881 | * @yc: Y position of the center of the arc |
1882 | * @radius: the radius of the arc |
1883 | * @angle1: the start angle, in radians |
1884 | * @angle2: the end angle, in radians |
1885 | * |
1886 | * Adds a circular arc of the given @radius to the current path. The |
1887 | * arc is centered at (@xc, @yc), begins at @angle1 and proceeds in |
1888 | * the direction of decreasing angles to end at @angle2. If @angle2 is |
1889 | * greater than @angle1 it will be progressively decreased by |
1890 | * <literal>2*M_PI</literal> until it is less than @angle1. |
1891 | * |
1892 | * See cairo_arc() for more details. This function differs only in the |
1893 | * direction of the arc between the two angles. |
1894 | * |
1895 | * Since: 1.0 |
1896 | **/ |
1897 | void |
1898 | cairo_arc_negative_moz_cairo_arc_negative (cairo_t *cr, |
1899 | double xc, double yc, |
1900 | double radius, |
1901 | double angle1, double angle2) |
1902 | { |
1903 | cairo_status_t status; |
1904 | |
1905 | if (unlikely (cr->status)(__builtin_expect (!!(cr->status), 0))) |
1906 | return; |
1907 | |
1908 | if (angle2 > angle1) { |
1909 | /* decrease angle2 by multiples of full circle until it |
1910 | * satisfies angle2 <= angle1 */ |
1911 | angle2 = fmod (angle2 - angle1, 2 * M_PI3.14159265358979323846); |
1912 | if (angle2 > 0) |
1913 | angle2 -= 2 * M_PI3.14159265358979323846; |
1914 | angle2 += angle1; |
1915 | } |
1916 | |
1917 | status = cr->backend->arc (cr, xc, yc, radius, angle1, angle2, FALSE0); |
1918 | if (unlikely (status)(__builtin_expect (!!(status), 0))) |
1919 | _cairo_set_error (cr, status); |
1920 | } |
1921 | |
1922 | /* XXX: NYI |
1923 | void |
1924 | cairo_arc_to (cairo_t *cr, |
1925 | double x1, double y1, |
1926 | double x2, double y2, |
1927 | double radius) |
1928 | { |
1929 | cairo_status_t status; |
1930 | |
1931 | if (unlikely (cr->status)) |
1932 | return; |
1933 | |
1934 | status = cr->backend->arc_to (cr, x1, y1, x2, y2, radius); |
1935 | if (unlikely (status)) |
1936 | _cairo_set_error (cr, status); |
1937 | } |
1938 | |
1939 | void |
1940 | cairo_rel_arc_to (cairo_t *cr, |
1941 | double dx1, double dy1, |
1942 | double dx2, double dy2, |
1943 | double radius) |
1944 | { |
1945 | cairo_status_t status; |
1946 | |
1947 | if (unlikely (cr->status)) |
1948 | return; |
1949 | |
1950 | status = cr->backend->rel_arc_to (cr, dx1, dy1, dx2, dy2, radius); |
1951 | if (unlikely (status)) |
1952 | _cairo_set_error (cr, status); |
1953 | } |
1954 | */ |
1955 | |
1956 | /** |
1957 | * cairo_rel_move_to: |
1958 | * @cr: a cairo context |
1959 | * @dx: the X offset |
1960 | * @dy: the Y offset |
1961 | * |
1962 | * Begin a new sub-path. After this call the current point will offset |
1963 | * by (@x, @y). |
1964 | * |
1965 | * Given a current point of (x, y), cairo_rel_move_to(@cr, @dx, @dy) |
1966 | * is logically equivalent to cairo_move_to(@cr, x + @dx, y + @dy). |
1967 | * |
1968 | * It is an error to call this function with no current point. Doing |
1969 | * so will cause @cr to shutdown with a status of |
1970 | * %CAIRO_STATUS_NO_CURRENT_POINT. |
1971 | * |
1972 | * Since: 1.0 |
1973 | **/ |
1974 | void |
1975 | cairo_rel_move_to_moz_cairo_rel_move_to (cairo_t *cr, double dx, double dy) |
1976 | { |
1977 | cairo_status_t status; |
1978 | |
1979 | if (unlikely (cr->status)(__builtin_expect (!!(cr->status), 0))) |
1980 | return; |
1981 | |
1982 | status = cr->backend->rel_move_to (cr, dx, dy); |
1983 | if (unlikely (status)(__builtin_expect (!!(status), 0))) |
1984 | _cairo_set_error (cr, status); |
1985 | } |
1986 | |
1987 | /** |
1988 | * cairo_rel_line_to: |
1989 | * @cr: a cairo context |
1990 | * @dx: the X offset to the end of the new line |
1991 | * @dy: the Y offset to the end of the new line |
1992 | * |
1993 | * Relative-coordinate version of cairo_line_to(). Adds a line to the |
1994 | * path from the current point to a point that is offset from the |
1995 | * current point by (@dx, @dy) in user space. After this call the |
1996 | * current point will be offset by (@dx, @dy). |
1997 | * |
1998 | * Given a current point of (x, y), cairo_rel_line_to(@cr, @dx, @dy) |
1999 | * is logically equivalent to cairo_line_to(@cr, x + @dx, y + @dy). |
2000 | * |
2001 | * It is an error to call this function with no current point. Doing |
2002 | * so will cause @cr to shutdown with a status of |
2003 | * %CAIRO_STATUS_NO_CURRENT_POINT. |
2004 | * |
2005 | * Since: 1.0 |
2006 | **/ |
2007 | void |
2008 | cairo_rel_line_to_moz_cairo_rel_line_to (cairo_t *cr, double dx, double dy) |
2009 | { |
2010 | cairo_status_t status; |
2011 | |
2012 | if (unlikely (cr->status)(__builtin_expect (!!(cr->status), 0))) |
2013 | return; |
2014 | |
2015 | status = cr->backend->rel_line_to (cr, dx, dy); |
2016 | if (unlikely (status)(__builtin_expect (!!(status), 0))) |
2017 | _cairo_set_error (cr, status); |
2018 | } |
2019 | |
2020 | /** |
2021 | * cairo_rel_curve_to: |
2022 | * @cr: a cairo context |
2023 | * @dx1: the X offset to the first control point |
2024 | * @dy1: the Y offset to the first control point |
2025 | * @dx2: the X offset to the second control point |
2026 | * @dy2: the Y offset to the second control point |
2027 | * @dx3: the X offset to the end of the curve |
2028 | * @dy3: the Y offset to the end of the curve |
2029 | * |
2030 | * Relative-coordinate version of cairo_curve_to(). All offsets are |
2031 | * relative to the current point. Adds a cubic Bézier spline to the |
2032 | * path from the current point to a point offset from the current |
2033 | * point by (@dx3, @dy3), using points offset by (@dx1, @dy1) and |
2034 | * (@dx2, @dy2) as the control points. After this call the current |
2035 | * point will be offset by (@dx3, @dy3). |
2036 | * |
2037 | * Given a current point of (x, y), cairo_rel_curve_to(@cr, @dx1, |
2038 | * @dy1, @dx2, @dy2, @dx3, @dy3) is logically equivalent to |
2039 | * cairo_curve_to(@cr, x+@dx1, y+@dy1, x+@dx2, y+@dy2, x+@dx3, y+@dy3). |
2040 | * |
2041 | * It is an error to call this function with no current point. Doing |
2042 | * so will cause @cr to shutdown with a status of |
2043 | * %CAIRO_STATUS_NO_CURRENT_POINT. |
2044 | * |
2045 | * Since: 1.0 |
2046 | **/ |
2047 | void |
2048 | cairo_rel_curve_to_moz_cairo_rel_curve_to (cairo_t *cr, |
2049 | double dx1, double dy1, |
2050 | double dx2, double dy2, |
2051 | double dx3, double dy3) |
2052 | { |
2053 | cairo_status_t status; |
2054 | |
2055 | if (unlikely (cr->status)(__builtin_expect (!!(cr->status), 0))) |
2056 | return; |
2057 | |
2058 | status = cr->backend->rel_curve_to (cr, |
2059 | dx1, dy1, |
2060 | dx2, dy2, |
2061 | dx3, dy3); |
2062 | if (unlikely (status)(__builtin_expect (!!(status), 0))) |
2063 | _cairo_set_error (cr, status); |
2064 | } |
2065 | |
2066 | /** |
2067 | * cairo_rectangle: |
2068 | * @cr: a cairo context |
2069 | * @x: the X coordinate of the top left corner of the rectangle |
2070 | * @y: the Y coordinate to the top left corner of the rectangle |
2071 | * @width: the width of the rectangle |
2072 | * @height: the height of the rectangle |
2073 | * |
2074 | * Adds a closed sub-path rectangle of the given size to the current |
2075 | * path at position (@x, @y) in user-space coordinates. |
2076 | * |
2077 | * This function is logically equivalent to: |
2078 | * <informalexample><programlisting> |
2079 | * cairo_move_to (cr, x, y); |
2080 | * cairo_rel_line_to (cr, width, 0); |
2081 | * cairo_rel_line_to (cr, 0, height); |
2082 | * cairo_rel_line_to (cr, -width, 0); |
2083 | * cairo_close_path (cr); |
2084 | * </programlisting></informalexample> |
2085 | * |
2086 | * Since: 1.0 |
2087 | **/ |
2088 | void |
2089 | cairo_rectangle_moz_cairo_rectangle (cairo_t *cr, |
2090 | double x, double y, |
2091 | double width, double height) |
2092 | { |
2093 | cairo_status_t status; |
2094 | |
2095 | if (unlikely (cr->status)(__builtin_expect (!!(cr->status), 0))) |
2096 | return; |
2097 | |
2098 | status = cr->backend->rectangle (cr, x, y, width, height); |
2099 | if (unlikely (status)(__builtin_expect (!!(status), 0))) |
2100 | _cairo_set_error (cr, status); |
2101 | } |
2102 | |
2103 | #if 0 |
2104 | /* XXX: NYI */ |
2105 | void |
2106 | cairo_stroke_to_path_moz_cairo_stroke_to_path (cairo_t *cr) |
2107 | { |
2108 | cairo_status_t status; |
2109 | |
2110 | if (unlikely (cr->status)(__builtin_expect (!!(cr->status), 0))) |
2111 | return; |
2112 | |
2113 | /* The code in _cairo_recording_surface_get_path has a poorman's stroke_to_path */ |
2114 | |
2115 | status = _cairo_gstate_stroke_path (cr->gstate); |
2116 | if (unlikely (status)(__builtin_expect (!!(status), 0))) |
2117 | _cairo_set_error (cr, status); |
2118 | } |
2119 | #endif |
2120 | |
2121 | /** |
2122 | * cairo_close_path: |
2123 | * @cr: a cairo context |
2124 | * |
2125 | * Adds a line segment to the path from the current point to the |
2126 | * beginning of the current sub-path, (the most recent point passed to |
2127 | * cairo_move_to()), and closes this sub-path. After this call the |
2128 | * current point will be at the joined endpoint of the sub-path. |
2129 | * |
2130 | * The behavior of cairo_close_path() is distinct from simply calling |
2131 | * cairo_line_to() with the equivalent coordinate in the case of |
2132 | * stroking. When a closed sub-path is stroked, there are no caps on |
2133 | * the ends of the sub-path. Instead, there is a line join connecting |
2134 | * the final and initial segments of the sub-path. |
2135 | * |
2136 | * If there is no current point before the call to cairo_close_path(), |
2137 | * this function will have no effect. |
2138 | * |
2139 | * Note: As of cairo version 1.2.4 any call to cairo_close_path() will |
2140 | * place an explicit MOVE_TO element into the path immediately after |
2141 | * the CLOSE_PATH element, (which can be seen in cairo_copy_path() for |
2142 | * example). This can simplify path processing in some cases as it may |
2143 | * not be necessary to save the "last move_to point" during processing |
2144 | * as the MOVE_TO immediately after the CLOSE_PATH will provide that |
2145 | * point. |
2146 | * |
2147 | * Since: 1.0 |
2148 | **/ |
2149 | void |
2150 | cairo_close_path_moz_cairo_close_path (cairo_t *cr) |
2151 | { |
2152 | cairo_status_t status; |
2153 | |
2154 | if (unlikely (cr->status)(__builtin_expect (!!(cr->status), 0))) |
2155 | return; |
2156 | |
2157 | status = cr->backend->close_path (cr); |
2158 | if (unlikely (status)(__builtin_expect (!!(status), 0))) |
2159 | _cairo_set_error (cr, status); |
2160 | } |
2161 | |
2162 | /** |
2163 | * cairo_path_extents: |
2164 | * @cr: a cairo context |
2165 | * @x1: left of the resulting extents |
2166 | * @y1: top of the resulting extents |
2167 | * @x2: right of the resulting extents |
2168 | * @y2: bottom of the resulting extents |
2169 | * |
2170 | * Computes a bounding box in user-space coordinates covering the |
2171 | * points on the current path. If the current path is empty, returns |
2172 | * an empty rectangle ((0,0), (0,0)). Stroke parameters, fill rule, |
2173 | * surface dimensions and clipping are not taken into account. |
2174 | * |
2175 | * Contrast with cairo_fill_extents() and cairo_stroke_extents() which |
2176 | * return the extents of only the area that would be "inked" by |
2177 | * the corresponding drawing operations. |
2178 | * |
2179 | * The result of cairo_path_extents() is defined as equivalent to the |
2180 | * limit of cairo_stroke_extents() with %CAIRO_LINE_CAP_ROUND as the |
2181 | * line width approaches 0.0, (but never reaching the empty-rectangle |
2182 | * returned by cairo_stroke_extents() for a line width of 0.0). |
2183 | * |
2184 | * Specifically, this means that zero-area sub-paths such as |
2185 | * cairo_move_to();cairo_line_to() segments, (even degenerate cases |
2186 | * where the coordinates to both calls are identical), will be |
2187 | * considered as contributing to the extents. However, a lone |
2188 | * cairo_move_to() will not contribute to the results of |
2189 | * cairo_path_extents(). |
2190 | * |
2191 | * Since: 1.6 |
2192 | **/ |
2193 | void |
2194 | cairo_path_extents_moz_cairo_path_extents (cairo_t *cr, |
2195 | double *x1, double *y1, double *x2, double *y2) |
2196 | { |
2197 | if (unlikely (cr->status)(__builtin_expect (!!(cr->status), 0))) { |
2198 | if (x1) |
2199 | *x1 = 0.0; |
2200 | if (y1) |
2201 | *y1 = 0.0; |
2202 | if (x2) |
2203 | *x2 = 0.0; |
2204 | if (y2) |
2205 | *y2 = 0.0; |
2206 | |
2207 | return; |
2208 | } |
2209 | |
2210 | cr->backend->path_extents (cr, x1, y1, x2, y2); |
2211 | } |
2212 | |
2213 | /** |
2214 | * cairo_paint: |
2215 | * @cr: a cairo context |
2216 | * |
2217 | * A drawing operator that paints the current source everywhere within |
2218 | * the current clip region. |
2219 | * |
2220 | * Since: 1.0 |
2221 | **/ |
2222 | void |
2223 | cairo_paint_moz_cairo_paint (cairo_t *cr) |
2224 | { |
2225 | cairo_status_t status; |
2226 | |
2227 | if (unlikely (cr->status)(__builtin_expect (!!(cr->status), 0))) |
2228 | return; |
2229 | |
2230 | status = cr->backend->paint (cr); |
2231 | if (unlikely (status)(__builtin_expect (!!(status), 0))) |
2232 | _cairo_set_error (cr, status); |
2233 | } |
2234 | |
2235 | /** |
2236 | * cairo_paint_with_alpha: |
2237 | * @cr: a cairo context |
2238 | * @alpha: alpha value, between 0 (transparent) and 1 (opaque) |
2239 | * |
2240 | * A drawing operator that paints the current source everywhere within |
2241 | * the current clip region using a mask of constant alpha value |
2242 | * @alpha. The effect is similar to cairo_paint(), but the drawing |
2243 | * is faded out using the alpha value. |
2244 | * |
2245 | * Since: 1.0 |
2246 | **/ |
2247 | void |
2248 | cairo_paint_with_alpha_moz_cairo_paint_with_alpha (cairo_t *cr, |
2249 | double alpha) |
2250 | { |
2251 | cairo_status_t status; |
2252 | |
2253 | if (unlikely (cr->status)(__builtin_expect (!!(cr->status), 0))) |
2254 | return; |
2255 | |
2256 | status = cr->backend->paint_with_alpha (cr, alpha); |
2257 | if (unlikely (status)(__builtin_expect (!!(status), 0))) |
2258 | _cairo_set_error (cr, status); |
2259 | } |
2260 | |
2261 | /** |
2262 | * cairo_mask: |
2263 | * @cr: a cairo context |
2264 | * @pattern: a #cairo_pattern_t |
2265 | * |
2266 | * A drawing operator that paints the current source |
2267 | * using the alpha channel of @pattern as a mask. (Opaque |
2268 | * areas of @pattern are painted with the source, transparent |
2269 | * areas are not painted.) |
2270 | * |
2271 | * Since: 1.0 |
2272 | **/ |
2273 | void |
2274 | cairo_mask_moz_cairo_mask (cairo_t *cr, |
2275 | cairo_pattern_t *pattern) |
2276 | { |
2277 | cairo_status_t status; |
2278 | |
2279 | if (unlikely (cr->status)(__builtin_expect (!!(cr->status), 0))) |
2280 | return; |
2281 | |
2282 | if (unlikely (pattern == NULL)(__builtin_expect (!!(pattern == ((void*)0)), 0))) { |
2283 | _cairo_set_error (cr, CAIRO_STATUS_NULL_POINTER); |
2284 | return; |
2285 | } |
2286 | |
2287 | if (unlikely (pattern->status)(__builtin_expect (!!(pattern->status), 0))) { |
2288 | _cairo_set_error (cr, pattern->status); |
2289 | return; |
2290 | } |
2291 | |
2292 | status = cr->backend->mask (cr, pattern); |
2293 | if (unlikely (status)(__builtin_expect (!!(status), 0))) |
2294 | _cairo_set_error (cr, status); |
2295 | } |
2296 | |
2297 | /** |
2298 | * cairo_mask_surface: |
2299 | * @cr: a cairo context |
2300 | * @surface: a #cairo_surface_t |
2301 | * @surface_x: X coordinate at which to place the origin of @surface |
2302 | * @surface_y: Y coordinate at which to place the origin of @surface |
2303 | * |
2304 | * A drawing operator that paints the current source |
2305 | * using the alpha channel of @surface as a mask. (Opaque |
2306 | * areas of @surface are painted with the source, transparent |
2307 | * areas are not painted.) |
2308 | * |
2309 | * Since: 1.0 |
2310 | **/ |
2311 | void |
2312 | cairo_mask_surface_moz_cairo_mask_surface (cairo_t *cr, |
2313 | cairo_surface_t *surface, |
2314 | double surface_x, |
2315 | double surface_y) |
2316 | { |
2317 | cairo_pattern_t *pattern; |
2318 | cairo_matrix_t matrix; |
2319 | |
2320 | if (unlikely (cr->status)(__builtin_expect (!!(cr->status), 0))) |
2321 | return; |
2322 | |
2323 | pattern = cairo_pattern_create_for_surface_moz_cairo_pattern_create_for_surface (surface); |
2324 | |
2325 | cairo_matrix_init_translate_moz_cairo_matrix_init_translate (&matrix, - surface_x, - surface_y); |
2326 | cairo_pattern_set_matrix_moz_cairo_pattern_set_matrix (pattern, &matrix); |
2327 | |
2328 | cairo_mask_moz_cairo_mask (cr, pattern); |
2329 | |
2330 | cairo_pattern_destroy_moz_cairo_pattern_destroy (pattern); |
2331 | } |
2332 | |
2333 | /** |
2334 | * cairo_stroke: |
2335 | * @cr: a cairo context |
2336 | * |
2337 | * A drawing operator that strokes the current path according to the |
2338 | * current line width, line join, line cap, and dash settings. After |
2339 | * cairo_stroke(), the current path will be cleared from the cairo |
2340 | * context. See cairo_set_line_width(), cairo_set_line_join(), |
2341 | * cairo_set_line_cap(), cairo_set_dash(), and |
2342 | * cairo_stroke_preserve(). |
2343 | * |
2344 | * Note: Degenerate segments and sub-paths are treated specially and |
2345 | * provide a useful result. These can result in two different |
2346 | * situations: |
2347 | * |
2348 | * 1. Zero-length "on" segments set in cairo_set_dash(). If the cap |
2349 | * style is %CAIRO_LINE_CAP_ROUND or %CAIRO_LINE_CAP_SQUARE then these |
2350 | * segments will be drawn as circular dots or squares respectively. In |
2351 | * the case of %CAIRO_LINE_CAP_SQUARE, the orientation of the squares |
2352 | * is determined by the direction of the underlying path. |
2353 | * |
2354 | * 2. A sub-path created by cairo_move_to() followed by either a |
2355 | * cairo_close_path() or one or more calls to cairo_line_to() to the |
2356 | * same coordinate as the cairo_move_to(). If the cap style is |
2357 | * %CAIRO_LINE_CAP_ROUND then these sub-paths will be drawn as circular |
2358 | * dots. Note that in the case of %CAIRO_LINE_CAP_SQUARE a degenerate |
2359 | * sub-path will not be drawn at all, (since the correct orientation |
2360 | * is indeterminate). |
2361 | * |
2362 | * In no case will a cap style of %CAIRO_LINE_CAP_BUTT cause anything |
2363 | * to be drawn in the case of either degenerate segments or sub-paths. |
2364 | * |
2365 | * Since: 1.0 |
2366 | **/ |
2367 | void |
2368 | cairo_stroke_moz_cairo_stroke (cairo_t *cr) |
2369 | { |
2370 | cairo_status_t status; |
2371 | |
2372 | if (unlikely (cr->status)(__builtin_expect (!!(cr->status), 0))) |
2373 | return; |
2374 | |
2375 | status = cr->backend->stroke (cr); |
2376 | if (unlikely (status)(__builtin_expect (!!(status), 0))) |
2377 | _cairo_set_error (cr, status); |
2378 | } |
2379 | |
2380 | /** |
2381 | * cairo_stroke_preserve: |
2382 | * @cr: a cairo context |
2383 | * |
2384 | * A drawing operator that strokes the current path according to the |
2385 | * current line width, line join, line cap, and dash settings. Unlike |
2386 | * cairo_stroke(), cairo_stroke_preserve() preserves the path within the |
2387 | * cairo context. |
2388 | * |
2389 | * See cairo_set_line_width(), cairo_set_line_join(), |
2390 | * cairo_set_line_cap(), cairo_set_dash(), and |
2391 | * cairo_stroke_preserve(). |
2392 | * |
2393 | * Since: 1.0 |
2394 | **/ |
2395 | void |
2396 | cairo_stroke_preserve_moz_cairo_stroke_preserve (cairo_t *cr) |
2397 | { |
2398 | cairo_status_t status; |
2399 | |
2400 | if (unlikely (cr->status)(__builtin_expect (!!(cr->status), 0))) |
2401 | return; |
2402 | |
2403 | status = cr->backend->stroke_preserve (cr); |
2404 | if (unlikely (status)(__builtin_expect (!!(status), 0))) |
2405 | _cairo_set_error (cr, status); |
2406 | } |
2407 | |
2408 | /** |
2409 | * cairo_fill: |
2410 | * @cr: a cairo context |
2411 | * |
2412 | * A drawing operator that fills the current path according to the |
2413 | * current fill rule, (each sub-path is implicitly closed before being |
2414 | * filled). After cairo_fill(), the current path will be cleared from |
2415 | * the cairo context. See cairo_set_fill_rule() and |
2416 | * cairo_fill_preserve(). |
2417 | * |
2418 | * Since: 1.0 |
2419 | **/ |
2420 | void |
2421 | cairo_fill_moz_cairo_fill (cairo_t *cr) |
2422 | { |
2423 | cairo_status_t status; |
2424 | |
2425 | if (unlikely (cr->status)(__builtin_expect (!!(cr->status), 0))) |
2426 | return; |
2427 | |
2428 | status = cr->backend->fill (cr); |
2429 | if (unlikely (status)(__builtin_expect (!!(status), 0))) |
2430 | _cairo_set_error (cr, status); |
2431 | } |
2432 | |
2433 | /** |
2434 | * cairo_fill_preserve: |
2435 | * @cr: a cairo context |
2436 | * |
2437 | * A drawing operator that fills the current path according to the |
2438 | * current fill rule, (each sub-path is implicitly closed before being |
2439 | * filled). Unlike cairo_fill(), cairo_fill_preserve() preserves the |
2440 | * path within the cairo context. |
2441 | * |
2442 | * See cairo_set_fill_rule() and cairo_fill(). |
2443 | * |
2444 | * Since: 1.0 |
2445 | **/ |
2446 | void |
2447 | cairo_fill_preserve_moz_cairo_fill_preserve (cairo_t *cr) |
2448 | { |
2449 | cairo_status_t status; |
2450 | |
2451 | if (unlikely (cr->status)(__builtin_expect (!!(cr->status), 0))) |
2452 | return; |
2453 | |
2454 | status = cr->backend->fill_preserve (cr); |
2455 | if (unlikely (status)(__builtin_expect (!!(status), 0))) |
2456 | _cairo_set_error (cr, status); |
2457 | } |
2458 | |
2459 | /** |
2460 | * cairo_copy_page: |
2461 | * @cr: a cairo context |
2462 | * |
2463 | * Emits the current page for backends that support multiple pages, but |
2464 | * doesn't clear it, so, the contents of the current page will be retained |
2465 | * for the next page too. Use cairo_show_page() if you want to get an |
2466 | * empty page after the emission. |
2467 | * |
2468 | * This is a convenience function that simply calls |
2469 | * cairo_surface_copy_page() on @cr's target. |
2470 | * |
2471 | * Since: 1.0 |
2472 | **/ |
2473 | void |
2474 | cairo_copy_page_moz_cairo_copy_page (cairo_t *cr) |
2475 | { |
2476 | cairo_status_t status; |
2477 | |
2478 | if (unlikely (cr->status)(__builtin_expect (!!(cr->status), 0))) |
2479 | return; |
2480 | |
2481 | status = cr->backend->copy_page (cr); |
2482 | if (unlikely (status)(__builtin_expect (!!(status), 0))) |
2483 | _cairo_set_error (cr, status); |
2484 | } |
2485 | |
2486 | /** |
2487 | * cairo_show_page: |
2488 | * @cr: a cairo context |
2489 | * |
2490 | * Emits and clears the current page for backends that support multiple |
2491 | * pages. Use cairo_copy_page() if you don't want to clear the page. |
2492 | * |
2493 | * This is a convenience function that simply calls |
2494 | * cairo_surface_show_page() on @cr's target. |
2495 | * |
2496 | * Since: 1.0 |
2497 | **/ |
2498 | void |
2499 | cairo_show_page_moz_cairo_show_page (cairo_t *cr) |
2500 | { |
2501 | cairo_status_t status; |
2502 | |
2503 | if (unlikely (cr->status)(__builtin_expect (!!(cr->status), 0))) |
2504 | return; |
2505 | |
2506 | status = cr->backend->show_page (cr); |
2507 | if (unlikely (status)(__builtin_expect (!!(status), 0))) |
2508 | _cairo_set_error (cr, status); |
2509 | } |
2510 | |
2511 | /** |
2512 | * cairo_in_stroke: |
2513 | * @cr: a cairo context |
2514 | * @x: X coordinate of the point to test |
2515 | * @y: Y coordinate of the point to test |
2516 | * |
2517 | * Tests whether the given point is inside the area that would be |
2518 | * affected by a cairo_stroke() operation given the current path and |
2519 | * stroking parameters. Surface dimensions and clipping are not taken |
2520 | * into account. |
2521 | * |
2522 | * See cairo_stroke(), cairo_set_line_width(), cairo_set_line_join(), |
2523 | * cairo_set_line_cap(), cairo_set_dash(), and |
2524 | * cairo_stroke_preserve(). |
2525 | * |
2526 | * Return value: A non-zero value if the point is inside, or zero if |
2527 | * outside. |
2528 | * |
2529 | * Since: 1.0 |
2530 | **/ |
2531 | cairo_bool_t |
2532 | cairo_in_stroke_moz_cairo_in_stroke (cairo_t *cr, double x, double y) |
2533 | { |
2534 | cairo_status_t status; |
2535 | cairo_bool_t inside = FALSE0; |
2536 | |
2537 | if (unlikely (cr->status)(__builtin_expect (!!(cr->status), 0))) |
2538 | return FALSE0; |
2539 | |
2540 | status = cr->backend->in_stroke (cr, x, y, &inside); |
2541 | if (unlikely (status)(__builtin_expect (!!(status), 0))) |
2542 | _cairo_set_error (cr, status); |
2543 | |
2544 | return inside; |
2545 | } |
2546 | |
2547 | /** |
2548 | * cairo_in_fill: |
2549 | * @cr: a cairo context |
2550 | * @x: X coordinate of the point to test |
2551 | * @y: Y coordinate of the point to test |
2552 | * |
2553 | * Tests whether the given point is inside the area that would be |
2554 | * affected by a cairo_fill() operation given the current path and |
2555 | * filling parameters. Surface dimensions and clipping are not taken |
2556 | * into account. |
2557 | * |
2558 | * See cairo_fill(), cairo_set_fill_rule() and cairo_fill_preserve(). |
2559 | * |
2560 | * Return value: A non-zero value if the point is inside, or zero if |
2561 | * outside. |
2562 | * |
2563 | * Since: 1.0 |
2564 | **/ |
2565 | cairo_bool_t |
2566 | cairo_in_fill_moz_cairo_in_fill (cairo_t *cr, double x, double y) |
2567 | { |
2568 | cairo_status_t status; |
2569 | cairo_bool_t inside = FALSE0; |
2570 | |
2571 | if (unlikely (cr->status)(__builtin_expect (!!(cr->status), 0))) |
2572 | return FALSE0; |
2573 | |
2574 | status = cr->backend->in_fill (cr, x, y, &inside); |
2575 | if (unlikely (status)(__builtin_expect (!!(status), 0))) |
2576 | _cairo_set_error (cr, status); |
2577 | |
2578 | return inside; |
2579 | } |
2580 | |
2581 | /** |
2582 | * cairo_stroke_extents: |
2583 | * @cr: a cairo context |
2584 | * @x1: left of the resulting extents |
2585 | * @y1: top of the resulting extents |
2586 | * @x2: right of the resulting extents |
2587 | * @y2: bottom of the resulting extents |
2588 | * |
2589 | * Computes a bounding box in user coordinates covering the area that |
2590 | * would be affected, (the "inked" area), by a cairo_stroke() |
2591 | * operation given the current path and stroke parameters. |
2592 | * If the current path is empty, returns an empty rectangle ((0,0), (0,0)). |
2593 | * Surface dimensions and clipping are not taken into account. |
2594 | * |
2595 | * Note that if the line width is set to exactly zero, then |
2596 | * cairo_stroke_extents() will return an empty rectangle. Contrast with |
2597 | * cairo_path_extents() which can be used to compute the non-empty |
2598 | * bounds as the line width approaches zero. |
2599 | * |
2600 | * Note that cairo_stroke_extents() must necessarily do more work to |
2601 | * compute the precise inked areas in light of the stroke parameters, |
2602 | * so cairo_path_extents() may be more desirable for sake of |
2603 | * performance if non-inked path extents are desired. |
2604 | * |
2605 | * See cairo_stroke(), cairo_set_line_width(), cairo_set_line_join(), |
2606 | * cairo_set_line_cap(), cairo_set_dash(), and |
2607 | * cairo_stroke_preserve(). |
2608 | * |
2609 | * Since: 1.0 |
2610 | **/ |
2611 | void |
2612 | cairo_stroke_extents_moz_cairo_stroke_extents (cairo_t *cr, |
2613 | double *x1, double *y1, double *x2, double *y2) |
2614 | { |
2615 | cairo_status_t status; |
2616 | |
2617 | if (unlikely (cr->status)(__builtin_expect (!!(cr->status), 0))) { |
2618 | if (x1) |
2619 | *x1 = 0.0; |
2620 | if (y1) |
2621 | *y1 = 0.0; |
2622 | if (x2) |
2623 | *x2 = 0.0; |
2624 | if (y2) |
2625 | *y2 = 0.0; |
2626 | |
2627 | return; |
2628 | } |
2629 | |
2630 | status = cr->backend->stroke_extents (cr, x1, y1, x2, y2); |
2631 | if (unlikely (status)(__builtin_expect (!!(status), 0))) |
2632 | _cairo_set_error (cr, status); |
2633 | } |
2634 | |
2635 | /** |
2636 | * cairo_fill_extents: |
2637 | * @cr: a cairo context |
2638 | * @x1: left of the resulting extents |
2639 | * @y1: top of the resulting extents |
2640 | * @x2: right of the resulting extents |
2641 | * @y2: bottom of the resulting extents |
2642 | * |
2643 | * Computes a bounding box in user coordinates covering the area that |
2644 | * would be affected, (the "inked" area), by a cairo_fill() operation |
2645 | * given the current path and fill parameters. If the current path is |
2646 | * empty, returns an empty rectangle ((0,0), (0,0)). Surface |
2647 | * dimensions and clipping are not taken into account. |
2648 | * |
2649 | * Contrast with cairo_path_extents(), which is similar, but returns |
2650 | * non-zero extents for some paths with no inked area, (such as a |
2651 | * simple line segment). |
2652 | * |
2653 | * Note that cairo_fill_extents() must necessarily do more work to |
2654 | * compute the precise inked areas in light of the fill rule, so |
2655 | * cairo_path_extents() may be more desirable for sake of performance |
2656 | * if the non-inked path extents are desired. |
2657 | * |
2658 | * See cairo_fill(), cairo_set_fill_rule() and cairo_fill_preserve(). |
2659 | * |
2660 | * Since: 1.0 |
2661 | **/ |
2662 | void |
2663 | cairo_fill_extents_moz_cairo_fill_extents (cairo_t *cr, |
2664 | double *x1, double *y1, double *x2, double *y2) |
2665 | { |
2666 | cairo_status_t status; |
2667 | |
2668 | if (unlikely (cr->status)(__builtin_expect (!!(cr->status), 0))) { |
2669 | if (x1) |
2670 | *x1 = 0.0; |
2671 | if (y1) |
2672 | *y1 = 0.0; |
2673 | if (x2) |
2674 | *x2 = 0.0; |
2675 | if (y2) |
2676 | *y2 = 0.0; |
2677 | |
2678 | return; |
2679 | } |
2680 | |
2681 | status = cr->backend->fill_extents (cr, x1, y1, x2, y2); |
2682 | if (unlikely (status)(__builtin_expect (!!(status), 0))) |
2683 | _cairo_set_error (cr, status); |
2684 | } |
2685 | |
2686 | /** |
2687 | * cairo_clip: |
2688 | * @cr: a cairo context |
2689 | * |
2690 | * Establishes a new clip region by intersecting the current clip |
2691 | * region with the current path as it would be filled by cairo_fill() |
2692 | * and according to the current fill rule (see cairo_set_fill_rule()). |
2693 | * |
2694 | * After cairo_clip(), the current path will be cleared from the cairo |
2695 | * context. |
2696 | * |
2697 | * The current clip region affects all drawing operations by |
2698 | * effectively masking out any changes to the surface that are outside |
2699 | * the current clip region. |
2700 | * |
2701 | * Calling cairo_clip() can only make the clip region smaller, never |
2702 | * larger. But the current clip is part of the graphics state, so a |
2703 | * temporary restriction of the clip region can be achieved by |
2704 | * calling cairo_clip() within a cairo_save()/cairo_restore() |
2705 | * pair. The only other means of increasing the size of the clip |
2706 | * region is cairo_reset_clip(). |
2707 | * |
2708 | * Since: 1.0 |
2709 | **/ |
2710 | void |
2711 | cairo_clip_moz_cairo_clip (cairo_t *cr) |
2712 | { |
2713 | cairo_status_t status; |
2714 | |
2715 | if (unlikely (cr->status)(__builtin_expect (!!(cr->status), 0))) |
2716 | return; |
2717 | |
2718 | status = cr->backend->clip (cr); |
2719 | if (unlikely (status)(__builtin_expect (!!(status), 0))) |
2720 | _cairo_set_error (cr, status); |
2721 | } |
2722 | |
2723 | /** |
2724 | * cairo_clip_preserve: |
2725 | * @cr: a cairo context |
2726 | * |
2727 | * Establishes a new clip region by intersecting the current clip |
2728 | * region with the current path as it would be filled by cairo_fill() |
2729 | * and according to the current fill rule (see cairo_set_fill_rule()). |
2730 | * |
2731 | * Unlike cairo_clip(), cairo_clip_preserve() preserves the path within |
2732 | * the cairo context. |
2733 | * |
2734 | * The current clip region affects all drawing operations by |
2735 | * effectively masking out any changes to the surface that are outside |
2736 | * the current clip region. |
2737 | * |
2738 | * Calling cairo_clip_preserve() can only make the clip region smaller, never |
2739 | * larger. But the current clip is part of the graphics state, so a |
2740 | * temporary restriction of the clip region can be achieved by |
2741 | * calling cairo_clip_preserve() within a cairo_save()/cairo_restore() |
2742 | * pair. The only other means of increasing the size of the clip |
2743 | * region is cairo_reset_clip(). |
2744 | * |
2745 | * Since: 1.0 |
2746 | **/ |
2747 | void |
2748 | cairo_clip_preserve_moz_cairo_clip_preserve (cairo_t *cr) |
2749 | { |
2750 | cairo_status_t status; |
2751 | |
2752 | if (unlikely (cr->status)(__builtin_expect (!!(cr->status), 0))) |
2753 | return; |
2754 | |
2755 | status = cr->backend->clip_preserve (cr); |
2756 | if (unlikely (status)(__builtin_expect (!!(status), 0))) |
2757 | _cairo_set_error (cr, status); |
2758 | } |
2759 | |
2760 | /** |
2761 | * cairo_reset_clip: |
2762 | * @cr: a cairo context |
2763 | * |
2764 | * Reset the current clip region to its original, unrestricted |
2765 | * state. That is, set the clip region to an infinitely large shape |
2766 | * containing the target surface. Equivalently, if infinity is too |
2767 | * hard to grasp, one can imagine the clip region being reset to the |
2768 | * exact bounds of the target surface. |
2769 | * |
2770 | * Note that code meant to be reusable should not call |
2771 | * cairo_reset_clip() as it will cause results unexpected by |
2772 | * higher-level code which calls cairo_clip(). Consider using |
2773 | * cairo_save() and cairo_restore() around cairo_clip() as a more |
2774 | * robust means of temporarily restricting the clip region. |
2775 | * |
2776 | * Since: 1.0 |
2777 | **/ |
2778 | void |
2779 | cairo_reset_clip_moz_cairo_reset_clip (cairo_t *cr) |
2780 | { |
2781 | cairo_status_t status; |
2782 | |
2783 | if (unlikely (cr->status)(__builtin_expect (!!(cr->status), 0))) |
2784 | return; |
2785 | |
2786 | status = cr->backend->reset_clip (cr); |
2787 | if (unlikely (status)(__builtin_expect (!!(status), 0))) |
2788 | _cairo_set_error (cr, status); |
2789 | } |
2790 | |
2791 | /** |
2792 | * cairo_clip_extents: |
2793 | * @cr: a cairo context |
2794 | * @x1: left of the resulting extents |
2795 | * @y1: top of the resulting extents |
2796 | * @x2: right of the resulting extents |
2797 | * @y2: bottom of the resulting extents |
2798 | * |
2799 | * Computes a bounding box in user coordinates covering the area inside the |
2800 | * current clip. |
2801 | * |
2802 | * Since: 1.4 |
2803 | **/ |
2804 | void |
2805 | cairo_clip_extents_moz_cairo_clip_extents (cairo_t *cr, |
2806 | double *x1, double *y1, |
2807 | double *x2, double *y2) |
2808 | { |
2809 | cairo_status_t status; |
2810 | |
2811 | if (x1) |
2812 | *x1 = 0.0; |
2813 | if (y1) |
2814 | *y1 = 0.0; |
2815 | if (x2) |
2816 | *x2 = 0.0; |
2817 | if (y2) |
2818 | *y2 = 0.0; |
2819 | |
2820 | if (unlikely (cr->status)(__builtin_expect (!!(cr->status), 0))) |
2821 | return; |
2822 | |
2823 | status = cr->backend->clip_extents (cr, x1, y1, x2, y2); |
2824 | if (unlikely (status)(__builtin_expect (!!(status), 0))) |
2825 | _cairo_set_error (cr, status); |
2826 | } |
2827 | |
2828 | /** |
2829 | * cairo_in_clip: |
2830 | * @cr: a cairo context |
2831 | * @x: X coordinate of the point to test |
2832 | * @y: Y coordinate of the point to test |
2833 | * |
2834 | * Tests whether the given point is inside the area that would be |
2835 | * visible through the current clip, i.e. the area that would be filled by |
2836 | * a cairo_paint() operation. |
2837 | * |
2838 | * See cairo_clip(), and cairo_clip_preserve(). |
2839 | * |
2840 | * Return value: A non-zero value if the point is inside, or zero if |
2841 | * outside. |
2842 | * |
2843 | * Since: 1.10 |
2844 | **/ |
2845 | cairo_bool_t |
2846 | cairo_in_clip_moz_cairo_in_clip (cairo_t *cr, double x, double y) |
2847 | { |
2848 | cairo_status_t status; |
2849 | cairo_bool_t inside = FALSE0; |
2850 | |
2851 | if (unlikely (cr->status)(__builtin_expect (!!(cr->status), 0))) |
2852 | return FALSE0; |
2853 | |
2854 | status = cr->backend->in_clip (cr, x, y, &inside); |
2855 | if (unlikely (status)(__builtin_expect (!!(status), 0))) |
2856 | _cairo_set_error (cr, status); |
2857 | |
2858 | return inside; |
2859 | } |
2860 | |
2861 | /** |
2862 | * cairo_copy_clip_rectangle_list: |
2863 | * @cr: a cairo context |
2864 | * |
2865 | * Gets the current clip region as a list of rectangles in user coordinates. |
2866 | * Never returns %NULL. |
2867 | * |
2868 | * The status in the list may be %CAIRO_STATUS_CLIP_NOT_REPRESENTABLE to |
2869 | * indicate that the clip region cannot be represented as a list of |
2870 | * user-space rectangles. The status may have other values to indicate |
2871 | * other errors. |
2872 | * |
2873 | * Returns: the current clip region as a list of rectangles in user coordinates, |
2874 | * which should be destroyed using cairo_rectangle_list_destroy(). |
2875 | * |
2876 | * Since: 1.4 |
2877 | **/ |
2878 | cairo_rectangle_list_t * |
2879 | cairo_copy_clip_rectangle_list_moz_cairo_copy_clip_rectangle_list (cairo_t *cr) |
2880 | { |
2881 | if (unlikely (cr->status)(__builtin_expect (!!(cr->status), 0))) |
2882 | return _cairo_rectangle_list_create_in_error (cr->status); |
2883 | |
2884 | return cr->backend->clip_copy_rectangle_list (cr); |
2885 | } |
2886 | |
2887 | /** |
2888 | * CAIRO_TAG_DEST: |
2889 | * |
2890 | * Create a destination for a hyperlink. Destination tag attributes |
2891 | * are detailed at [Destinations][dest]. |
2892 | * |
2893 | * Since: 1.16 |
2894 | **/ |
2895 | |
2896 | /** |
2897 | * CAIRO_TAG_LINK: |
2898 | * |
2899 | * Create hyperlink. Link tag attributes are detailed at |
2900 | * [Links][link]. |
2901 | * |
2902 | * Since: 1.16 |
2903 | **/ |
2904 | |
2905 | /** |
2906 | * CAIRO_TAG_CONTENT: |
2907 | * |
2908 | * Create a content tag. |
2909 | * |
2910 | * Since: 1.18 |
2911 | **/ |
2912 | |
2913 | /** |
2914 | * CAIRO_TAG_CONTENT_REF: |
2915 | * |
2916 | * Create a content reference tag. |
2917 | * |
2918 | * Since: 1.18 |
2919 | **/ |
2920 | |
2921 | /** |
2922 | * cairo_tag_begin: |
2923 | * @cr: a cairo context |
2924 | * @tag_name: tag name |
2925 | * @attributes: tag attributes |
2926 | * |
2927 | * Marks the beginning of the @tag_name structure. Call |
2928 | * cairo_tag_end() with the same @tag_name to mark the end of the |
2929 | * structure. |
2930 | * |
2931 | * The attributes string is of the form "key1=value2 key2=value2 ...". |
2932 | * Values may be boolean (true/false or 1/0), integer, float, string, |
2933 | * or an array. |
2934 | * |
2935 | * String values are enclosed in single quotes |
2936 | * ('). Single quotes and backslashes inside the string should be |
2937 | * escaped with a backslash. |
2938 | * |
2939 | * Boolean values may be set to true by only |
2940 | * specifying the key. eg the attribute string "key" is the equivalent |
2941 | * to "key=true". |
2942 | * |
2943 | * Arrays are enclosed in '[]'. eg "rect=[1.2 4.3 2.0 3.0]". |
2944 | * |
2945 | * If no attributes are required, @attributes can be an empty string or NULL. |
2946 | * |
2947 | * See [Tags and Links Description][cairo-Tags-and-Links.description] |
2948 | * for the list of tags and attributes. |
2949 | * |
2950 | * Invalid nesting of tags or invalid attributes will cause @cr to |
2951 | * shutdown with a status of %CAIRO_STATUS_TAG_ERROR. |
2952 | * |
2953 | * See cairo_tag_end(). |
2954 | * |
2955 | * Since: 1.16 |
2956 | **/ |
2957 | void |
2958 | cairo_tag_begin (cairo_t *cr, const char *tag_name, const char *attributes) |
2959 | { |
2960 | cairo_status_t status; |
2961 | |
2962 | if (unlikely (cr->status)(__builtin_expect (!!(cr->status), 0))) |
2963 | return; |
2964 | |
2965 | status = cr->backend->tag_begin (cr, tag_name, attributes); |
2966 | if (unlikely (status)(__builtin_expect (!!(status), 0))) |
2967 | _cairo_set_error (cr, status); |
2968 | } |
2969 | |
2970 | /** |
2971 | * cairo_tag_end: |
2972 | * @cr: a cairo context |
2973 | * @tag_name: tag name |
2974 | * |
2975 | * Marks the end of the @tag_name structure. |
2976 | * |
2977 | * Invalid nesting of tags will cause @cr to shutdown with a status of |
2978 | * %CAIRO_STATUS_TAG_ERROR. |
2979 | * |
2980 | * See cairo_tag_begin(). |
2981 | * |
2982 | * Since: 1.16 |
2983 | **/ |
2984 | cairo_publicextern __attribute__((visibility("hidden"))) void |
2985 | cairo_tag_end (cairo_t *cr, const char *tag_name) |
2986 | { |
2987 | cairo_status_t status; |
2988 | |
2989 | if (unlikely (cr->status)(__builtin_expect (!!(cr->status), 0))) |
2990 | return; |
2991 | |
2992 | status = cr->backend->tag_end (cr, tag_name); |
2993 | if (unlikely (status)(__builtin_expect (!!(status), 0))) |
2994 | _cairo_set_error (cr, status); |
2995 | } |
2996 | |
2997 | /** |
2998 | * cairo_select_font_face: |
2999 | * @cr: a #cairo_t |
3000 | * @family: a font family name, encoded in UTF-8 |
3001 | * @slant: the slant for the font |
3002 | * @weight: the weight for the font |
3003 | * |
3004 | * Note: The cairo_select_font_face() function call is part of what |
3005 | * the cairo designers call the "toy" text API. It is convenient for |
3006 | * short demos and simple programs, but it is not expected to be |
3007 | * adequate for serious text-using applications. |
3008 | * |
3009 | * Selects a family and style of font from a simplified description as |
3010 | * a family name, slant and weight. Cairo provides no operation to |
3011 | * list available family names on the system (this is a "toy", |
3012 | * remember), but the standard CSS2 generic family names, ("serif", |
3013 | * "sans-serif", "cursive", "fantasy", "monospace"), are likely to |
3014 | * work as expected. |
3015 | * |
3016 | * If @family starts with the string "@cairo:", or if no native font |
3017 | * backends are compiled in, cairo will use an internal font family. |
3018 | * The internal font family recognizes many modifiers in the @family |
3019 | * string, most notably, it recognizes the string "monospace". That is, |
3020 | * the family name "@cairo:monospace" will use the monospace version of |
3021 | * the internal font family. |
3022 | * |
3023 | * For "real" font selection, see the font-backend-specific |
3024 | * font_face_create functions for the font backend you are using. (For |
3025 | * example, if you are using the freetype-based cairo-ft font backend, |
3026 | * see cairo_ft_font_face_create_for_ft_face() or |
3027 | * cairo_ft_font_face_create_for_pattern().) The resulting font face |
3028 | * could then be used with cairo_scaled_font_create() and |
3029 | * cairo_set_scaled_font(). |
3030 | * |
3031 | * Similarly, when using the "real" font support, you can call |
3032 | * directly into the underlying font system, (such as fontconfig or |
3033 | * freetype), for operations such as listing available fonts, etc. |
3034 | * |
3035 | * It is expected that most applications will need to use a more |
3036 | * comprehensive font handling and text layout library, (for example, |
3037 | * pango), in conjunction with cairo. |
3038 | * |
3039 | * If text is drawn without a call to cairo_select_font_face(), (nor |
3040 | * cairo_set_font_face() nor cairo_set_scaled_font()), the default |
3041 | * family is platform-specific, but is essentially "sans-serif". |
3042 | * Default slant is %CAIRO_FONT_SLANT_NORMAL, and default weight is |
3043 | * %CAIRO_FONT_WEIGHT_NORMAL. |
3044 | * |
3045 | * This function is equivalent to a call to cairo_toy_font_face_create() |
3046 | * followed by cairo_set_font_face(). |
3047 | * |
3048 | * Since: 1.0 |
3049 | **/ |
3050 | void |
3051 | cairo_select_font_face_moz_cairo_select_font_face (cairo_t *cr, |
3052 | const char *family, |
3053 | cairo_font_slant_t slant, |
3054 | cairo_font_weight_t weight) |
3055 | { |
3056 | cairo_font_face_t *font_face; |
3057 | cairo_status_t status; |
3058 | |
3059 | if (unlikely (cr->status)(__builtin_expect (!!(cr->status), 0))) |
3060 | return; |
3061 | |
3062 | font_face = cairo_toy_font_face_create_moz_cairo_toy_font_face_create (family, slant, weight); |
3063 | if (unlikely (font_face->status)(__builtin_expect (!!(font_face->status), 0))) { |
3064 | _cairo_set_error (cr, font_face->status); |
3065 | return; |
3066 | } |
3067 | |
3068 | status = cr->backend->set_font_face (cr, font_face); |
3069 | cairo_font_face_destroy_moz_cairo_font_face_destroy (font_face); |
3070 | |
3071 | if (unlikely (status)(__builtin_expect (!!(status), 0))) |
3072 | _cairo_set_error (cr, status); |
3073 | } |
3074 | |
3075 | /** |
3076 | * cairo_font_extents: |
3077 | * @cr: a #cairo_t |
3078 | * @extents: a #cairo_font_extents_t object into which the results |
3079 | * will be stored. |
3080 | * |
3081 | * Gets the font extents for the currently selected font. |
3082 | * |
3083 | * Since: 1.0 |
3084 | **/ |
3085 | void |
3086 | cairo_font_extents_moz_cairo_font_extents (cairo_t *cr, |
3087 | cairo_font_extents_t *extents) |
3088 | { |
3089 | cairo_status_t status; |
3090 | |
3091 | extents->ascent = 0.0; |
3092 | extents->descent = 0.0; |
3093 | extents->height = 0.0; |
3094 | extents->max_x_advance = 0.0; |
3095 | extents->max_y_advance = 0.0; |
3096 | |
3097 | if (unlikely (cr->status)(__builtin_expect (!!(cr->status), 0))) |
3098 | return; |
3099 | |
3100 | status = cr->backend->font_extents (cr, extents); |
3101 | if (unlikely (status)(__builtin_expect (!!(status), 0))) |
3102 | _cairo_set_error (cr, status); |
3103 | } |
3104 | |
3105 | /** |
3106 | * cairo_set_font_face: |
3107 | * @cr: a #cairo_t |
3108 | * @font_face: a #cairo_font_face_t, or %NULL to restore to the default font |
3109 | * |
3110 | * Replaces the current #cairo_font_face_t object in the #cairo_t with |
3111 | * @font_face. The replaced font face in the #cairo_t will be |
3112 | * destroyed if there are no other references to it. |
3113 | * |
3114 | * Since: 1.0 |
3115 | **/ |
3116 | void |
3117 | cairo_set_font_face_moz_cairo_set_font_face (cairo_t *cr, |
3118 | cairo_font_face_t *font_face) |
3119 | { |
3120 | cairo_status_t status; |
3121 | |
3122 | if (unlikely (cr->status)(__builtin_expect (!!(cr->status), 0))) |
3123 | return; |
3124 | |
3125 | status = cr->backend->set_font_face (cr, font_face); |
3126 | if (unlikely (status)(__builtin_expect (!!(status), 0))) |
3127 | _cairo_set_error (cr, status); |
3128 | } |
3129 | |
3130 | /** |
3131 | * cairo_get_font_face: |
3132 | * @cr: a #cairo_t |
3133 | * |
3134 | * Gets the current font face for a #cairo_t. |
3135 | * |
3136 | * Return value: the current font face. This object is owned by |
3137 | * cairo. To keep a reference to it, you must call |
3138 | * cairo_font_face_reference(). |
3139 | * |
3140 | * This function never returns %NULL. If memory cannot be allocated, a |
3141 | * special "nil" #cairo_font_face_t object will be returned on which |
3142 | * cairo_font_face_status() returns %CAIRO_STATUS_NO_MEMORY. Using |
3143 | * this nil object will cause its error state to propagate to other |
3144 | * objects it is passed to, (for example, calling |
3145 | * cairo_set_font_face() with a nil font will trigger an error that |
3146 | * will shutdown the #cairo_t object). |
3147 | * |
3148 | * Since: 1.0 |
3149 | **/ |
3150 | cairo_font_face_t * |
3151 | cairo_get_font_face_moz_cairo_get_font_face (cairo_t *cr) |
3152 | { |
3153 | if (unlikely (cr->status)(__builtin_expect (!!(cr->status), 0))) |
3154 | return (cairo_font_face_t*) &_cairo_font_face_nil; |
3155 | |
3156 | return cr->backend->get_font_face (cr); |
3157 | } |
3158 | |
3159 | /** |
3160 | * cairo_set_font_size: |
3161 | * @cr: a #cairo_t |
3162 | * @size: the new font size, in user space units |
3163 | * |
3164 | * Sets the current font matrix to a scale by a factor of @size, replacing |
3165 | * any font matrix previously set with cairo_set_font_size() or |
3166 | * cairo_set_font_matrix(). This results in a font size of @size user space |
3167 | * units. (More precisely, this matrix will result in the font's |
3168 | * em-square being a @size by @size square in user space.) |
3169 | * |
3170 | * If text is drawn without a call to cairo_set_font_size(), (nor |
3171 | * cairo_set_font_matrix() nor cairo_set_scaled_font()), the default |
3172 | * font size is 10.0. |
3173 | * |
3174 | * Since: 1.0 |
3175 | **/ |
3176 | void |
3177 | cairo_set_font_size_moz_cairo_set_font_size (cairo_t *cr, double size) |
3178 | { |
3179 | cairo_status_t status; |
3180 | |
3181 | if (unlikely (cr->status)(__builtin_expect (!!(cr->status), 0))) |
3182 | return; |
3183 | |
3184 | status = cr->backend->set_font_size (cr, size); |
3185 | if (unlikely (status)(__builtin_expect (!!(status), 0))) |
3186 | _cairo_set_error (cr, status); |
3187 | } |
3188 | |
3189 | /** |
3190 | * cairo_set_font_matrix: |
3191 | * @cr: a #cairo_t |
3192 | * @matrix: a #cairo_matrix_t describing a transform to be applied to |
3193 | * the current font. |
3194 | * |
3195 | * Sets the current font matrix to @matrix. The font matrix gives a |
3196 | * transformation from the design space of the font (in this space, |
3197 | * the em-square is 1 unit by 1 unit) to user space. Normally, a |
3198 | * simple scale is used (see cairo_set_font_size()), but a more |
3199 | * complex font matrix can be used to shear the font |
3200 | * or stretch it unequally along the two axes |
3201 | * |
3202 | * Since: 1.0 |
3203 | **/ |
3204 | void |
3205 | cairo_set_font_matrix_moz_cairo_set_font_matrix (cairo_t *cr, |
3206 | const cairo_matrix_t *matrix) |
3207 | { |
3208 | cairo_status_t status; |
3209 | |
3210 | if (unlikely (cr->status)(__builtin_expect (!!(cr->status), 0))) |
3211 | return; |
3212 | |
3213 | status = cr->backend->set_font_matrix (cr, matrix); |
3214 | if (unlikely (status)(__builtin_expect (!!(status), 0))) |
3215 | _cairo_set_error (cr, status); |
3216 | } |
3217 | |
3218 | /** |
3219 | * cairo_get_font_matrix: |
3220 | * @cr: a #cairo_t |
3221 | * @matrix: return value for the matrix |
3222 | * |
3223 | * Stores the current font matrix into @matrix. See |
3224 | * cairo_set_font_matrix(). |
3225 | * |
3226 | * Since: 1.0 |
3227 | **/ |
3228 | void |
3229 | cairo_get_font_matrix_moz_cairo_get_font_matrix (cairo_t *cr, cairo_matrix_t *matrix) |
3230 | { |
3231 | if (unlikely (cr->status)(__builtin_expect (!!(cr->status), 0))) { |
3232 | cairo_matrix_init_identity_moz_cairo_matrix_init_identity (matrix); |
3233 | return; |
3234 | } |
3235 | |
3236 | cr->backend->get_font_matrix (cr, matrix); |
3237 | } |
3238 | |
3239 | /** |
3240 | * cairo_set_font_options: |
3241 | * @cr: a #cairo_t |
3242 | * @options: font options to use |
3243 | * |
3244 | * Sets a set of custom font rendering options for the #cairo_t. |
3245 | * Rendering options are derived by merging these options with the |
3246 | * options derived from underlying surface; if the value in @options |
3247 | * has a default value (like %CAIRO_ANTIALIAS_DEFAULT), then the value |
3248 | * from the surface is used. |
3249 | * |
3250 | * Since: 1.0 |
3251 | **/ |
3252 | void |
3253 | cairo_set_font_options_moz_cairo_set_font_options (cairo_t *cr, |
3254 | const cairo_font_options_t *options) |
3255 | { |
3256 | cairo_status_t status; |
3257 | |
3258 | if (unlikely (cr->status)(__builtin_expect (!!(cr->status), 0))) |
3259 | return; |
3260 | |
3261 | status = cairo_font_options_status_moz_cairo_font_options_status ((cairo_font_options_t *) options); |
3262 | if (unlikely (status)(__builtin_expect (!!(status), 0))) { |
3263 | _cairo_set_error (cr, status); |
3264 | return; |
3265 | } |
3266 | |
3267 | status = cr->backend->set_font_options (cr, options); |
3268 | if (unlikely (status)(__builtin_expect (!!(status), 0))) |
3269 | _cairo_set_error (cr, status); |
3270 | } |
3271 | |
3272 | /** |
3273 | * cairo_get_font_options: |
3274 | * @cr: a #cairo_t |
3275 | * @options: a #cairo_font_options_t object into which to store |
3276 | * the retrieved options. All existing values are overwritten |
3277 | * |
3278 | * Retrieves font rendering options set via #cairo_set_font_options. |
3279 | * Note that the returned options do not include any options derived |
3280 | * from the underlying surface; they are literally the options |
3281 | * passed to cairo_set_font_options(). |
3282 | * |
3283 | * Since: 1.0 |
3284 | **/ |
3285 | void |
3286 | cairo_get_font_options_moz_cairo_get_font_options (cairo_t *cr, |
3287 | cairo_font_options_t *options) |
3288 | { |
3289 | /* check that we aren't trying to overwrite the nil object */ |
3290 | if (cairo_font_options_status_moz_cairo_font_options_status (options)) |
3291 | return; |
3292 | |
3293 | if (unlikely (cr->status)(__builtin_expect (!!(cr->status), 0))) { |
3294 | _cairo_font_options_init_default (options); |
3295 | return; |
3296 | } |
3297 | |
3298 | cr->backend->get_font_options (cr, options); |
3299 | } |
3300 | |
3301 | /** |
3302 | * cairo_set_scaled_font: |
3303 | * @cr: a #cairo_t |
3304 | * @scaled_font: a #cairo_scaled_font_t |
3305 | * |
3306 | * Replaces the current font face, font matrix, and font options in |
3307 | * the #cairo_t with those of the #cairo_scaled_font_t. Except for |
3308 | * some translation, the current CTM of the #cairo_t should be the |
3309 | * same as that of the #cairo_scaled_font_t, which can be accessed |
3310 | * using cairo_scaled_font_get_ctm(). |
3311 | * |
3312 | * Since: 1.2 |
3313 | **/ |
3314 | void |
3315 | cairo_set_scaled_font_moz_cairo_set_scaled_font (cairo_t *cr, |
3316 | const cairo_scaled_font_t *scaled_font) |
3317 | { |
3318 | cairo_status_t status; |
3319 | |
3320 | if (unlikely (cr->status)(__builtin_expect (!!(cr->status), 0))) |
3321 | return; |
3322 | |
3323 | if (scaled_font == NULL((void*)0)) { |
3324 | _cairo_set_error (cr, _cairo_error (CAIRO_STATUS_NULL_POINTER)); |
3325 | return; |
3326 | } |
3327 | |
3328 | status = scaled_font->status; |
3329 | if (unlikely (status)(__builtin_expect (!!(status), 0))) { |
3330 | _cairo_set_error (cr, status); |
3331 | return; |
3332 | } |
3333 | |
3334 | status = cr->backend->set_scaled_font (cr, (cairo_scaled_font_t *) scaled_font); |
3335 | if (unlikely (status)(__builtin_expect (!!(status), 0))) |
3336 | _cairo_set_error (cr, status); |
3337 | } |
3338 | |
3339 | /** |
3340 | * cairo_get_scaled_font: |
3341 | * @cr: a #cairo_t |
3342 | * |
3343 | * Gets the current scaled font for a #cairo_t. |
3344 | * |
3345 | * Return value: the current scaled font. This object is owned by |
3346 | * cairo. To keep a reference to it, you must call |
3347 | * cairo_scaled_font_reference(). |
3348 | * |
3349 | * This function never returns %NULL. If memory cannot be allocated, a |
3350 | * special "nil" #cairo_scaled_font_t object will be returned on which |
3351 | * cairo_scaled_font_status() returns %CAIRO_STATUS_NO_MEMORY. Using |
3352 | * this nil object will cause its error state to propagate to other |
3353 | * objects it is passed to, (for example, calling |
3354 | * cairo_set_scaled_font() with a nil font will trigger an error that |
3355 | * will shutdown the #cairo_t object). |
3356 | * |
3357 | * Since: 1.4 |
3358 | **/ |
3359 | cairo_scaled_font_t * |
3360 | cairo_get_scaled_font_moz_cairo_get_scaled_font (cairo_t *cr) |
3361 | { |
3362 | if (unlikely (cr->status)(__builtin_expect (!!(cr->status), 0))) |
3363 | return _cairo_scaled_font_create_in_error (cr->status); |
3364 | |
3365 | return cr->backend->get_scaled_font (cr); |
3366 | } |
3367 | |
3368 | /** |
3369 | * cairo_text_extents: |
3370 | * @cr: a #cairo_t |
3371 | * @utf8: a NUL-terminated string of text encoded in UTF-8, or %NULL |
3372 | * @extents: a #cairo_text_extents_t object into which the results |
3373 | * will be stored |
3374 | * |
3375 | * Gets the extents for a string of text. The extents describe a |
3376 | * user-space rectangle that encloses the "inked" portion of the text, |
3377 | * (as it would be drawn by cairo_show_text()). Additionally, the |
3378 | * x_advance and y_advance values indicate the amount by which the |
3379 | * current point would be advanced by cairo_show_text(). |
3380 | * |
3381 | * Note that whitespace characters do not directly contribute to the |
3382 | * size of the rectangle (extents.width and extents.height). They do |
3383 | * contribute indirectly by changing the position of non-whitespace |
3384 | * characters. In particular, trailing whitespace characters are |
3385 | * likely to not affect the size of the rectangle, though they will |
3386 | * affect the x_advance and y_advance values. |
3387 | * |
3388 | * Since: 1.0 |
3389 | **/ |
3390 | void |
3391 | cairo_text_extents_moz_cairo_text_extents (cairo_t *cr, |
3392 | const char *utf8, |
3393 | cairo_text_extents_t *extents) |
3394 | { |
3395 | cairo_status_t status; |
3396 | cairo_scaled_font_t *scaled_font; |
3397 | cairo_glyph_t *glyphs = NULL((void*)0); |
3398 | int num_glyphs = 0; |
3399 | double x, y; |
3400 | |
3401 | extents->x_bearing = 0.0; |
3402 | extents->y_bearing = 0.0; |
3403 | extents->width = 0.0; |
3404 | extents->height = 0.0; |
3405 | extents->x_advance = 0.0; |
3406 | extents->y_advance = 0.0; |
3407 | |
3408 | if (unlikely (cr->status)(__builtin_expect (!!(cr->status), 0))) |
3409 | return; |
3410 | |
3411 | if (utf8 == NULL((void*)0)) |
3412 | return; |
3413 | |
3414 | scaled_font = cairo_get_scaled_font_moz_cairo_get_scaled_font (cr); |
3415 | if (unlikely (scaled_font->status)(__builtin_expect (!!(scaled_font->status), 0))) { |
3416 | _cairo_set_error (cr, scaled_font->status); |
3417 | return; |
3418 | } |
3419 | |
3420 | cairo_get_current_point_moz_cairo_get_current_point (cr, &x, &y); |
3421 | status = cairo_scaled_font_text_to_glyphs_moz_cairo_scaled_font_text_to_glyphs (scaled_font, |
3422 | x, y, |
3423 | utf8, -1, |
3424 | &glyphs, &num_glyphs, |
3425 | NULL((void*)0), NULL((void*)0), NULL((void*)0)); |
3426 | |
3427 | if (likely (status == CAIRO_STATUS_SUCCESS)(__builtin_expect (!!(status == CAIRO_STATUS_SUCCESS), 1))) { |
3428 | status = cr->backend->glyph_extents (cr, |
3429 | glyphs, num_glyphs, |
3430 | extents); |
3431 | } |
3432 | cairo_glyph_free_moz_cairo_glyph_free (glyphs); |
3433 | |
3434 | if (unlikely (status)(__builtin_expect (!!(status), 0))) |
3435 | _cairo_set_error (cr, status); |
3436 | } |
3437 | |
3438 | /** |
3439 | * cairo_glyph_extents: |
3440 | * @cr: a #cairo_t |
3441 | * @glyphs: an array of #cairo_glyph_t objects |
3442 | * @num_glyphs: the number of elements in @glyphs |
3443 | * @extents: a #cairo_text_extents_t object into which the results |
3444 | * will be stored |
3445 | * |
3446 | * Gets the extents for an array of glyphs. The extents describe a |
3447 | * user-space rectangle that encloses the "inked" portion of the |
3448 | * glyphs, (as they would be drawn by cairo_show_glyphs()). |
3449 | * Additionally, the x_advance and y_advance values indicate the |
3450 | * amount by which the current point would be advanced by |
3451 | * cairo_show_glyphs(). |
3452 | * |
3453 | * Note that whitespace glyphs do not contribute to the size of the |
3454 | * rectangle (extents.width and extents.height). |
3455 | * |
3456 | * Since: 1.0 |
3457 | **/ |
3458 | void |
3459 | cairo_glyph_extents_moz_cairo_glyph_extents (cairo_t *cr, |
3460 | const cairo_glyph_t *glyphs, |
3461 | int num_glyphs, |
3462 | cairo_text_extents_t *extents) |
3463 | { |
3464 | cairo_status_t status; |
3465 | |
3466 | extents->x_bearing = 0.0; |
3467 | extents->y_bearing = 0.0; |
3468 | extents->width = 0.0; |
3469 | extents->height = 0.0; |
3470 | extents->x_advance = 0.0; |
3471 | extents->y_advance = 0.0; |
3472 | |
3473 | if (unlikely (cr->status)(__builtin_expect (!!(cr->status), 0))) |
3474 | return; |
3475 | |
3476 | if (num_glyphs == 0) |
3477 | return; |
3478 | |
3479 | if (unlikely (num_glyphs < 0)(__builtin_expect (!!(num_glyphs < 0), 0))) { |
3480 | _cairo_set_error (cr, CAIRO_STATUS_NEGATIVE_COUNT); |
3481 | return; |
3482 | } |
3483 | |
3484 | if (unlikely (glyphs == NULL)(__builtin_expect (!!(glyphs == ((void*)0)), 0))) { |
3485 | _cairo_set_error (cr, CAIRO_STATUS_NULL_POINTER); |
3486 | return; |
3487 | } |
3488 | |
3489 | status = cr->backend->glyph_extents (cr, glyphs, num_glyphs, extents); |
3490 | if (unlikely (status)(__builtin_expect (!!(status), 0))) |
3491 | _cairo_set_error (cr, status); |
3492 | } |
3493 | |
3494 | /** |
3495 | * cairo_show_text: |
3496 | * @cr: a cairo context |
3497 | * @utf8: a NUL-terminated string of text encoded in UTF-8, or %NULL |
3498 | * |
3499 | * A drawing operator that generates the shape from a string of UTF-8 |
3500 | * characters, rendered according to the current font_face, font_size |
3501 | * (font_matrix), and font_options. |
3502 | * |
3503 | * This function first computes a set of glyphs for the string of |
3504 | * text. The first glyph is placed so that its origin is at the |
3505 | * current point. The origin of each subsequent glyph is offset from |
3506 | * that of the previous glyph by the advance values of the previous |
3507 | * glyph. |
3508 | * |
3509 | * After this call the current point is moved to the origin of where |
3510 | * the next glyph would be placed in this same progression. That is, |
3511 | * the current point will be at the origin of the final glyph offset |
3512 | * by its advance values. This allows for easy display of a single |
3513 | * logical string with multiple calls to cairo_show_text(). |
3514 | * |
3515 | * Note: The cairo_show_text() function call is part of what the cairo |
3516 | * designers call the "toy" text API. It is convenient for short demos |
3517 | * and simple programs, but it is not expected to be adequate for |
3518 | * serious text-using applications. See cairo_show_glyphs() for the |
3519 | * "real" text display API in cairo. |
3520 | * |
3521 | * Since: 1.0 |
3522 | **/ |
3523 | void |
3524 | cairo_show_text_moz_cairo_show_text (cairo_t *cr, const char *utf8) |
3525 | { |
3526 | cairo_text_extents_t extents; |
3527 | cairo_status_t status; |
3528 | cairo_glyph_t *glyphs, *last_glyph; |
3529 | cairo_text_cluster_t *clusters; |
3530 | int utf8_len, num_glyphs, num_clusters; |
3531 | cairo_text_cluster_flags_t cluster_flags; |
3532 | double x, y; |
3533 | cairo_bool_t has_show_text_glyphs; |
3534 | cairo_glyph_t stack_glyphs[CAIRO_STACK_ARRAY_LENGTH (cairo_glyph_t)((512 * sizeof (int)) / sizeof(cairo_glyph_t))]; |
3535 | cairo_text_cluster_t stack_clusters[CAIRO_STACK_ARRAY_LENGTH (cairo_text_cluster_t)((512 * sizeof (int)) / sizeof(cairo_text_cluster_t))]; |
3536 | cairo_scaled_font_t *scaled_font; |
3537 | cairo_glyph_text_info_t info, *i; |
3538 | |
3539 | if (unlikely (cr->status)(__builtin_expect (!!(cr->status), 0))) |
3540 | return; |
3541 | |
3542 | if (utf8 == NULL((void*)0)) |
3543 | return; |
3544 | |
3545 | scaled_font = cairo_get_scaled_font_moz_cairo_get_scaled_font (cr); |
3546 | if (unlikely (scaled_font->status)(__builtin_expect (!!(scaled_font->status), 0))) { |
3547 | _cairo_set_error (cr, scaled_font->status); |
3548 | return; |
3549 | } |
3550 | |
3551 | utf8_len = strlen (utf8); |
3552 | |
3553 | has_show_text_glyphs = |
3554 | cairo_surface_has_show_text_glyphs_moz_cairo_surface_has_show_text_glyphs (cairo_get_target_moz_cairo_get_target (cr)); |
3555 | |
3556 | glyphs = stack_glyphs; |
3557 | num_glyphs = ARRAY_LENGTH (stack_glyphs)((int) (sizeof (stack_glyphs) / sizeof (stack_glyphs[0]))); |
3558 | |
3559 | if (has_show_text_glyphs) { |
3560 | clusters = stack_clusters; |
3561 | num_clusters = ARRAY_LENGTH (stack_clusters)((int) (sizeof (stack_clusters) / sizeof (stack_clusters[0])) ); |
3562 | } else { |
3563 | clusters = NULL((void*)0); |
3564 | num_clusters = 0; |
3565 | } |
3566 | |
3567 | cairo_get_current_point_moz_cairo_get_current_point (cr, &x, &y); |
3568 | status = cairo_scaled_font_text_to_glyphs_moz_cairo_scaled_font_text_to_glyphs (scaled_font, |
3569 | x, y, |
3570 | utf8, utf8_len, |
3571 | &glyphs, &num_glyphs, |
3572 | has_show_text_glyphs ? &clusters : NULL((void*)0), &num_clusters, |
3573 | &cluster_flags); |
3574 | if (unlikely (status)(__builtin_expect (!!(status), 0))) |
3575 | goto BAIL; |
3576 | |
3577 | if (num_glyphs == 0) |
3578 | return; |
3579 | |
3580 | i = NULL((void*)0); |
3581 | if (has_show_text_glyphs) { |
3582 | info.utf8 = utf8; |
3583 | info.utf8_len = utf8_len; |
3584 | info.clusters = clusters; |
3585 | info.num_clusters = num_clusters; |
3586 | info.cluster_flags = cluster_flags; |
3587 | i = &info; |
3588 | } |
3589 | |
3590 | status = cr->backend->glyphs (cr, glyphs, num_glyphs, i); |
3591 | if (unlikely (status)(__builtin_expect (!!(status), 0))) |
3592 | goto BAIL; |
3593 | |
3594 | last_glyph = &glyphs[num_glyphs - 1]; |
3595 | status = cr->backend->glyph_extents (cr, last_glyph, 1, &extents); |
3596 | if (unlikely (status)(__builtin_expect (!!(status), 0))) |
3597 | goto BAIL; |
3598 | |
3599 | x = last_glyph->x + extents.x_advance; |
3600 | y = last_glyph->y + extents.y_advance; |
3601 | cr->backend->move_to (cr, x, y); |
3602 | |
3603 | BAIL: |
3604 | if (glyphs != stack_glyphs) |
3605 | cairo_glyph_free_moz_cairo_glyph_free (glyphs); |
3606 | if (clusters != stack_clusters) |
3607 | cairo_text_cluster_free_moz_cairo_text_cluster_free (clusters); |
3608 | |
3609 | if (unlikely (status)(__builtin_expect (!!(status), 0))) |
3610 | _cairo_set_error (cr, status); |
3611 | } |
3612 | |
3613 | /** |
3614 | * cairo_show_glyphs: |
3615 | * @cr: a cairo context |
3616 | * @glyphs: array of glyphs to show |
3617 | * @num_glyphs: number of glyphs to show |
3618 | * |
3619 | * A drawing operator that generates the shape from an array of glyphs, |
3620 | * rendered according to the current font face, font size |
3621 | * (font matrix), and font options. |
3622 | * |
3623 | * Since: 1.0 |
3624 | **/ |
3625 | void |
3626 | cairo_show_glyphs_moz_cairo_show_glyphs (cairo_t *cr, const cairo_glyph_t *glyphs, int num_glyphs) |
3627 | { |
3628 | cairo_status_t status; |
3629 | |
3630 | if (unlikely (cr->status)(__builtin_expect (!!(cr->status), 0))) |
3631 | return; |
3632 | |
3633 | if (num_glyphs == 0) |
3634 | return; |
3635 | |
3636 | if (num_glyphs < 0) { |
3637 | _cairo_set_error (cr, CAIRO_STATUS_NEGATIVE_COUNT); |
3638 | return; |
3639 | } |
3640 | |
3641 | if (glyphs == NULL((void*)0)) { |
3642 | _cairo_set_error (cr, CAIRO_STATUS_NULL_POINTER); |
3643 | return; |
3644 | } |
3645 | |
3646 | status = cr->backend->glyphs (cr, glyphs, num_glyphs, NULL((void*)0)); |
3647 | if (unlikely (status)(__builtin_expect (!!(status), 0))) |
3648 | _cairo_set_error (cr, status); |
3649 | } |
3650 | |
3651 | /** |
3652 | * cairo_show_text_glyphs: |
3653 | * @cr: a cairo context |
3654 | * @utf8: a string of text encoded in UTF-8 |
3655 | * @utf8_len: length of @utf8 in bytes, or -1 if it is NUL-terminated |
3656 | * @glyphs: array of glyphs to show |
3657 | * @num_glyphs: number of glyphs to show |
3658 | * @clusters: array of cluster mapping information |
3659 | * @num_clusters: number of clusters in the mapping |
3660 | * @cluster_flags: cluster mapping flags |
3661 | * |
3662 | * This operation has rendering effects similar to cairo_show_glyphs() |
3663 | * but, if the target surface supports it, uses the provided text and |
3664 | * cluster mapping to embed the text for the glyphs shown in the output. |
3665 | * If the target does not support the extended attributes, this function |
3666 | * acts like the basic cairo_show_glyphs() as if it had been passed |
3667 | * @glyphs and @num_glyphs. |
3668 | * |
3669 | * The mapping between @utf8 and @glyphs is provided by an array of |
3670 | * <firstterm>clusters</firstterm>. Each cluster covers a number of |
3671 | * text bytes and glyphs, and neighboring clusters cover neighboring |
3672 | * areas of @utf8 and @glyphs. The clusters should collectively cover @utf8 |
3673 | * and @glyphs in entirety. |
3674 | * |
3675 | * The first cluster always covers bytes from the beginning of @utf8. |
3676 | * If @cluster_flags do not have the %CAIRO_TEXT_CLUSTER_FLAG_BACKWARD |
3677 | * set, the first cluster also covers the beginning |
3678 | * of @glyphs, otherwise it covers the end of the @glyphs array and |
3679 | * following clusters move backward. |
3680 | * |
3681 | * See #cairo_text_cluster_t for constraints on valid clusters. |
3682 | * |
3683 | * Since: 1.8 |
3684 | **/ |
3685 | void |
3686 | cairo_show_text_glyphs_moz_cairo_show_text_glyphs (cairo_t *cr, |
3687 | const char *utf8, |
3688 | int utf8_len, |
3689 | const cairo_glyph_t *glyphs, |
3690 | int num_glyphs, |
3691 | const cairo_text_cluster_t *clusters, |
3692 | int num_clusters, |
3693 | cairo_text_cluster_flags_t cluster_flags) |
3694 | { |
3695 | cairo_status_t status; |
3696 | |
3697 | if (unlikely (cr->status)(__builtin_expect (!!(cr->status), 0))) |
3698 | return; |
3699 | |
3700 | /* A slew of sanity checks */ |
3701 | |
3702 | /* Special case for NULL and -1 */ |
3703 | if (utf8 == NULL((void*)0) && utf8_len == -1) |
3704 | utf8_len = 0; |
3705 | |
3706 | /* No NULLs for non-zeros */ |
3707 | if ((num_glyphs && glyphs == NULL((void*)0)) || |
3708 | (utf8_len && utf8 == NULL((void*)0)) || |
3709 | (num_clusters && clusters == NULL((void*)0))) { |
3710 | _cairo_set_error (cr, CAIRO_STATUS_NULL_POINTER); |
3711 | return; |
3712 | } |
3713 | |
3714 | /* A -1 for utf8_len means NUL-terminated */ |
3715 | if (utf8_len == -1) |
3716 | utf8_len = strlen (utf8); |
3717 | |
3718 | /* Apart from that, no negatives */ |
3719 | if (num_glyphs < 0 || utf8_len < 0 || num_clusters < 0) { |
3720 | _cairo_set_error (cr, CAIRO_STATUS_NEGATIVE_COUNT); |
3721 | return; |
3722 | } |
3723 | |
3724 | if (num_glyphs == 0 && utf8_len == 0) |
3725 | return; |
3726 | |
3727 | if (utf8) { |
3728 | /* Make sure clusters cover the entire glyphs and utf8 arrays, |
3729 | * and that cluster boundaries are UTF-8 boundaries. */ |
3730 | status = _cairo_validate_text_clusters (utf8, utf8_len, |
3731 | glyphs, num_glyphs, |
3732 | clusters, num_clusters, cluster_flags); |
3733 | if (status == CAIRO_STATUS_INVALID_CLUSTERS) { |
3734 | /* Either got invalid UTF-8 text, or cluster mapping is bad. |
3735 | * Differentiate those. */ |
3736 | |
3737 | cairo_status_t status2; |
3738 | |
3739 | status2 = _cairo_utf8_to_ucs4 (utf8, utf8_len, NULL((void*)0), NULL((void*)0)); |
3740 | if (status2) |
3741 | status = status2; |
3742 | } else { |
3743 | cairo_glyph_text_info_t info; |
3744 | |
3745 | info.utf8 = utf8; |
3746 | info.utf8_len = utf8_len; |
3747 | info.clusters = clusters; |
3748 | info.num_clusters = num_clusters; |
3749 | info.cluster_flags = cluster_flags; |
3750 | |
3751 | status = cr->backend->glyphs (cr, glyphs, num_glyphs, &info); |
3752 | } |
3753 | } else { |
3754 | status = cr->backend->glyphs (cr, glyphs, num_glyphs, NULL((void*)0)); |
3755 | } |
3756 | if (unlikely (status)(__builtin_expect (!!(status), 0))) |
3757 | _cairo_set_error (cr, status); |
3758 | } |
3759 | |
3760 | /** |
3761 | * cairo_text_path: |
3762 | * @cr: a cairo context |
3763 | * @utf8: a NUL-terminated string of text encoded in UTF-8, or %NULL |
3764 | * |
3765 | * Adds closed paths for text to the current path. The generated |
3766 | * path if filled, achieves an effect similar to that of |
3767 | * cairo_show_text(). |
3768 | * |
3769 | * Text conversion and positioning is done similar to cairo_show_text(). |
3770 | * |
3771 | * Like cairo_show_text(), After this call the current point is |
3772 | * moved to the origin of where the next glyph would be placed in |
3773 | * this same progression. That is, the current point will be at |
3774 | * the origin of the final glyph offset by its advance values. |
3775 | * This allows for chaining multiple calls to to cairo_text_path() |
3776 | * without having to set current point in between. |
3777 | * |
3778 | * Note: The cairo_text_path() function call is part of what the cairo |
3779 | * designers call the "toy" text API. It is convenient for short demos |
3780 | * and simple programs, but it is not expected to be adequate for |
3781 | * serious text-using applications. See cairo_glyph_path() for the |
3782 | * "real" text path API in cairo. |
3783 | * |
3784 | * Since: 1.0 |
3785 | **/ |
3786 | void |
3787 | cairo_text_path_moz_cairo_text_path (cairo_t *cr, const char *utf8) |
3788 | { |
3789 | cairo_status_t status; |
3790 | cairo_text_extents_t extents; |
3791 | cairo_glyph_t stack_glyphs[CAIRO_STACK_ARRAY_LENGTH (cairo_glyph_t)((512 * sizeof (int)) / sizeof(cairo_glyph_t))]; |
3792 | cairo_glyph_t *glyphs, *last_glyph; |
3793 | cairo_scaled_font_t *scaled_font; |
3794 | int num_glyphs; |
3795 | double x, y; |
3796 | |
3797 | if (unlikely (cr->status)(__builtin_expect (!!(cr->status), 0))) |
3798 | return; |
3799 | |
3800 | if (utf8 == NULL((void*)0)) |
3801 | return; |
3802 | |
3803 | |
3804 | glyphs = stack_glyphs; |
3805 | num_glyphs = ARRAY_LENGTH (stack_glyphs)((int) (sizeof (stack_glyphs) / sizeof (stack_glyphs[0]))); |
3806 | |
3807 | scaled_font = cairo_get_scaled_font_moz_cairo_get_scaled_font (cr); |
3808 | if (unlikely (scaled_font->status)(__builtin_expect (!!(scaled_font->status), 0))) { |
3809 | _cairo_set_error (cr, scaled_font->status); |
3810 | return; |
3811 | } |
3812 | |
3813 | cairo_get_current_point_moz_cairo_get_current_point (cr, &x, &y); |
3814 | status = cairo_scaled_font_text_to_glyphs_moz_cairo_scaled_font_text_to_glyphs (scaled_font, |
Value stored to 'status' is never read | |
3815 | x, y, |
3816 | utf8, -1, |
3817 | &glyphs, &num_glyphs, |
3818 | NULL((void*)0), NULL((void*)0), NULL((void*)0)); |
3819 | |
3820 | if (num_glyphs == 0) |
3821 | return; |
3822 | |
3823 | status = cr->backend->glyph_path (cr, glyphs, num_glyphs); |
3824 | |
3825 | if (unlikely (status)(__builtin_expect (!!(status), 0))) |
3826 | goto BAIL; |
3827 | |
3828 | last_glyph = &glyphs[num_glyphs - 1]; |
3829 | status = cr->backend->glyph_extents (cr, last_glyph, 1, &extents); |
3830 | |
3831 | if (unlikely (status)(__builtin_expect (!!(status), 0))) |
3832 | goto BAIL; |
3833 | |
3834 | x = last_glyph->x + extents.x_advance; |
3835 | y = last_glyph->y + extents.y_advance; |
3836 | cr->backend->move_to (cr, x, y); |
3837 | |
3838 | BAIL: |
3839 | if (glyphs != stack_glyphs) |
3840 | cairo_glyph_free_moz_cairo_glyph_free (glyphs); |
3841 | |
3842 | if (unlikely (status)(__builtin_expect (!!(status), 0))) |
3843 | _cairo_set_error (cr, status); |
3844 | } |
3845 | |
3846 | /** |
3847 | * cairo_glyph_path: |
3848 | * @cr: a cairo context |
3849 | * @glyphs: array of glyphs to show |
3850 | * @num_glyphs: number of glyphs to show |
3851 | * |
3852 | * Adds closed paths for the glyphs to the current path. The generated |
3853 | * path if filled, achieves an effect similar to that of |
3854 | * cairo_show_glyphs(). |
3855 | * |
3856 | * Since: 1.0 |
3857 | **/ |
3858 | void |
3859 | cairo_glyph_path_moz_cairo_glyph_path (cairo_t *cr, const cairo_glyph_t *glyphs, int num_glyphs) |
3860 | { |
3861 | cairo_status_t status; |
3862 | |
3863 | if (unlikely (cr->status)(__builtin_expect (!!(cr->status), 0))) |
3864 | return; |
3865 | |
3866 | if (num_glyphs == 0) |
3867 | return; |
3868 | |
3869 | if (unlikely (num_glyphs < 0)(__builtin_expect (!!(num_glyphs < 0), 0))) { |
3870 | _cairo_set_error (cr, CAIRO_STATUS_NEGATIVE_COUNT); |
3871 | return; |
3872 | } |
3873 | |
3874 | if (unlikely (glyphs == NULL)(__builtin_expect (!!(glyphs == ((void*)0)), 0))) { |
3875 | _cairo_set_error (cr, CAIRO_STATUS_NULL_POINTER); |
3876 | return; |
3877 | } |
3878 | |
3879 | status = cr->backend->glyph_path (cr, glyphs, num_glyphs); |
3880 | if (unlikely (status)(__builtin_expect (!!(status), 0))) |
3881 | _cairo_set_error (cr, status); |
3882 | } |
3883 | |
3884 | /** |
3885 | * cairo_get_operator: |
3886 | * @cr: a cairo context |
3887 | * |
3888 | * Gets the current compositing operator for a cairo context. |
3889 | * |
3890 | * Return value: the current compositing operator. |
3891 | * |
3892 | * Since: 1.0 |
3893 | **/ |
3894 | cairo_operator_t |
3895 | cairo_get_operator_moz_cairo_get_operator (cairo_t *cr) |
3896 | { |
3897 | if (unlikely (cr->status)(__builtin_expect (!!(cr->status), 0))) |
3898 | return CAIRO_GSTATE_OPERATOR_DEFAULTCAIRO_OPERATOR_OVER; |
3899 | |
3900 | return cr->backend->get_operator (cr); |
3901 | } |
3902 | |
3903 | #if 0 |
3904 | /* |
3905 | * cairo_get_opacity: |
3906 | * @cr: a cairo context |
3907 | * |
3908 | * Gets the current compositing opacity for a cairo context. |
3909 | * |
3910 | * Return value: the current compositing opacity. |
3911 | * |
3912 | * Since: TBD |
3913 | **/ |
3914 | double |
3915 | cairo_get_opacity (cairo_t *cr) |
3916 | { |
3917 | if (unlikely (cr->status)(__builtin_expect (!!(cr->status), 0))) |
3918 | return 1.; |
3919 | |
3920 | return cr->backend->get_opacity (cr); |
3921 | } |
3922 | #endif |
3923 | |
3924 | /** |
3925 | * cairo_get_tolerance: |
3926 | * @cr: a cairo context |
3927 | * |
3928 | * Gets the current tolerance value, as set by cairo_set_tolerance(). |
3929 | * |
3930 | * Return value: the current tolerance value. |
3931 | * |
3932 | * Since: 1.0 |
3933 | **/ |
3934 | double |
3935 | cairo_get_tolerance_moz_cairo_get_tolerance (cairo_t *cr) |
3936 | { |
3937 | if (unlikely (cr->status)(__builtin_expect (!!(cr->status), 0))) |
3938 | return CAIRO_GSTATE_TOLERANCE_DEFAULT0.1; |
3939 | |
3940 | return cr->backend->get_tolerance (cr); |
3941 | } |
3942 | |
3943 | /** |
3944 | * cairo_get_antialias: |
3945 | * @cr: a cairo context |
3946 | * |
3947 | * Gets the current shape antialiasing mode, as set by |
3948 | * cairo_set_antialias(). |
3949 | * |
3950 | * Return value: the current shape antialiasing mode. |
3951 | * |
3952 | * Since: 1.0 |
3953 | **/ |
3954 | cairo_antialias_t |
3955 | cairo_get_antialias_moz_cairo_get_antialias (cairo_t *cr) |
3956 | { |
3957 | if (unlikely (cr->status)(__builtin_expect (!!(cr->status), 0))) |
3958 | return CAIRO_ANTIALIAS_DEFAULT; |
3959 | |
3960 | return cr->backend->get_antialias (cr); |
3961 | } |
3962 | |
3963 | /** |
3964 | * cairo_has_current_point: |
3965 | * @cr: a cairo context |
3966 | * |
3967 | * Returns whether a current point is defined on the current path. |
3968 | * See cairo_get_current_point() for details on the current point. |
3969 | * |
3970 | * Return value: whether a current point is defined. |
3971 | * |
3972 | * Since: 1.6 |
3973 | **/ |
3974 | cairo_bool_t |
3975 | cairo_has_current_point_moz_cairo_has_current_point (cairo_t *cr) |
3976 | { |
3977 | if (unlikely (cr->status)(__builtin_expect (!!(cr->status), 0))) |
3978 | return FALSE0; |
3979 | |
3980 | return cr->backend->has_current_point (cr); |
3981 | } |
3982 | |
3983 | /** |
3984 | * cairo_get_current_point: |
3985 | * @cr: a cairo context |
3986 | * @x: return value for X coordinate of the current point |
3987 | * @y: return value for Y coordinate of the current point |
3988 | * |
3989 | * Gets the current point of the current path, which is |
3990 | * conceptually the final point reached by the path so far. |
3991 | * |
3992 | * The current point is returned in the user-space coordinate |
3993 | * system. If there is no defined current point or if @cr is in an |
3994 | * error status, @x and @y will both be set to 0.0. It is possible to |
3995 | * check this in advance with cairo_has_current_point(). |
3996 | * |
3997 | * Most path construction functions alter the current point. See the |
3998 | * following for details on how they affect the current point: |
3999 | * cairo_new_path(), cairo_new_sub_path(), |
4000 | * cairo_append_path(), cairo_close_path(), |
4001 | * cairo_move_to(), cairo_line_to(), cairo_curve_to(), |
4002 | * cairo_rel_move_to(), cairo_rel_line_to(), cairo_rel_curve_to(), |
4003 | * cairo_arc(), cairo_arc_negative(), cairo_rectangle(), |
4004 | * cairo_text_path(), cairo_glyph_path(). |
4005 | * |
4006 | * Some functions use and alter the current point but do not |
4007 | * otherwise change current path: |
4008 | * cairo_show_text(). |
4009 | * |
4010 | * Some functions unset the current path and as a result, current point: |
4011 | * cairo_fill(), cairo_stroke(). |
4012 | * |
4013 | * Since: 1.0 |
4014 | **/ |
4015 | void |
4016 | cairo_get_current_point_moz_cairo_get_current_point (cairo_t *cr, double *x_ret, double *y_ret) |
4017 | { |
4018 | double x, y; |
4019 | |
4020 | x = y = 0; |
4021 | if (cr->status == CAIRO_STATUS_SUCCESS && |
4022 | cr->backend->has_current_point (cr)) |
4023 | { |
4024 | cr->backend->get_current_point (cr, &x, &y); |
4025 | } |
4026 | |
4027 | if (x_ret) |
4028 | *x_ret = x; |
4029 | if (y_ret) |
4030 | *y_ret = y; |
4031 | } |
4032 | |
4033 | /** |
4034 | * cairo_get_fill_rule: |
4035 | * @cr: a cairo context |
4036 | * |
4037 | * Gets the current fill rule, as set by cairo_set_fill_rule(). |
4038 | * |
4039 | * Return value: the current fill rule. |
4040 | * |
4041 | * Since: 1.0 |
4042 | **/ |
4043 | cairo_fill_rule_t |
4044 | cairo_get_fill_rule_moz_cairo_get_fill_rule (cairo_t *cr) |
4045 | { |
4046 | if (unlikely (cr->status)(__builtin_expect (!!(cr->status), 0))) |
4047 | return CAIRO_GSTATE_FILL_RULE_DEFAULTCAIRO_FILL_RULE_WINDING; |
4048 | |
4049 | return cr->backend->get_fill_rule (cr); |
4050 | } |
4051 | |
4052 | /** |
4053 | * cairo_get_line_width: |
4054 | * @cr: a cairo context |
4055 | * |
4056 | * This function returns the current line width value exactly as set by |
4057 | * cairo_set_line_width(). Note that the value is unchanged even if |
4058 | * the CTM has changed between the calls to cairo_set_line_width() and |
4059 | * cairo_get_line_width(). |
4060 | * |
4061 | * Return value: the current line width. |
4062 | * |
4063 | * Since: 1.0 |
4064 | **/ |
4065 | double |
4066 | cairo_get_line_width_moz_cairo_get_line_width (cairo_t *cr) |
4067 | { |
4068 | if (unlikely (cr->status)(__builtin_expect (!!(cr->status), 0))) |
4069 | return CAIRO_GSTATE_LINE_WIDTH_DEFAULT2.0; |
4070 | |
4071 | return cr->backend->get_line_width (cr); |
4072 | } |
4073 | |
4074 | /** |
4075 | * cairo_get_hairline: |
4076 | * @cr: a cairo context |
4077 | * |
4078 | * Returns whether or not hairline mode is set, as set by cairo_set_hairline(). |
4079 | * |
4080 | * Return value: whether hairline mode is set. |
4081 | * |
4082 | * Since: 1.18 |
4083 | **/ |
4084 | cairo_bool_t |
4085 | cairo_get_hairline (cairo_t *cr) |
4086 | { |
4087 | if (unlikely (cr->status)(__builtin_expect (!!(cr->status), 0))) |
4088 | return FALSE0; |
4089 | |
4090 | return cr->backend->get_hairline (cr); |
4091 | } |
4092 | |
4093 | /** |
4094 | * cairo_get_line_cap: |
4095 | * @cr: a cairo context |
4096 | * |
4097 | * Gets the current line cap style, as set by cairo_set_line_cap(). |
4098 | * |
4099 | * Return value: the current line cap style. |
4100 | * |
4101 | * Since: 1.0 |
4102 | **/ |
4103 | cairo_line_cap_t |
4104 | cairo_get_line_cap_moz_cairo_get_line_cap (cairo_t *cr) |
4105 | { |
4106 | if (unlikely (cr->status)(__builtin_expect (!!(cr->status), 0))) |
4107 | return CAIRO_GSTATE_LINE_CAP_DEFAULTCAIRO_LINE_CAP_BUTT; |
4108 | |
4109 | return cr->backend->get_line_cap (cr); |
4110 | } |
4111 | |
4112 | /** |
4113 | * cairo_get_line_join: |
4114 | * @cr: a cairo context |
4115 | * |
4116 | * Gets the current line join style, as set by cairo_set_line_join(). |
4117 | * |
4118 | * Return value: the current line join style. |
4119 | * |
4120 | * Since: 1.0 |
4121 | **/ |
4122 | cairo_line_join_t |
4123 | cairo_get_line_join_moz_cairo_get_line_join (cairo_t *cr) |
4124 | { |
4125 | if (unlikely (cr->status)(__builtin_expect (!!(cr->status), 0))) |
4126 | return CAIRO_GSTATE_LINE_JOIN_DEFAULTCAIRO_LINE_JOIN_MITER; |
4127 | |
4128 | return cr->backend->get_line_join (cr); |
4129 | } |
4130 | |
4131 | /** |
4132 | * cairo_get_miter_limit: |
4133 | * @cr: a cairo context |
4134 | * |
4135 | * Gets the current miter limit, as set by cairo_set_miter_limit(). |
4136 | * |
4137 | * Return value: the current miter limit. |
4138 | * |
4139 | * Since: 1.0 |
4140 | **/ |
4141 | double |
4142 | cairo_get_miter_limit_moz_cairo_get_miter_limit (cairo_t *cr) |
4143 | { |
4144 | if (unlikely (cr->status)(__builtin_expect (!!(cr->status), 0))) |
4145 | return CAIRO_GSTATE_MITER_LIMIT_DEFAULT10.0; |
4146 | |
4147 | return cr->backend->get_miter_limit (cr); |
4148 | } |
4149 | |
4150 | /** |
4151 | * cairo_get_matrix: |
4152 | * @cr: a cairo context |
4153 | * @matrix: return value for the matrix |
4154 | * |
4155 | * Stores the current transformation matrix (CTM) into @matrix. |
4156 | * |
4157 | * Since: 1.0 |
4158 | **/ |
4159 | void |
4160 | cairo_get_matrix_moz_cairo_get_matrix (cairo_t *cr, cairo_matrix_t *matrix) |
4161 | { |
4162 | if (unlikely (cr->status)(__builtin_expect (!!(cr->status), 0))) { |
4163 | cairo_matrix_init_identity_moz_cairo_matrix_init_identity (matrix); |
4164 | return; |
4165 | } |
4166 | |
4167 | cr->backend->get_matrix (cr, matrix); |
4168 | } |
4169 | |
4170 | /** |
4171 | * cairo_get_target: |
4172 | * @cr: a cairo context |
4173 | * |
4174 | * Gets the target surface for the cairo context as passed to |
4175 | * cairo_create(). |
4176 | * |
4177 | * This function will always return a valid pointer, but the result |
4178 | * can be a "nil" surface if @cr is already in an error state, |
4179 | * (ie. cairo_status() <literal>!=</literal> %CAIRO_STATUS_SUCCESS). |
4180 | * A nil surface is indicated by cairo_surface_status() |
4181 | * <literal>!=</literal> %CAIRO_STATUS_SUCCESS. |
4182 | * |
4183 | * Return value: the target surface. This object is owned by cairo. To |
4184 | * keep a reference to it, you must call cairo_surface_reference(). |
4185 | * |
4186 | * Since: 1.0 |
4187 | **/ |
4188 | cairo_surface_t * |
4189 | cairo_get_target_moz_cairo_get_target (cairo_t *cr) |
4190 | { |
4191 | if (unlikely (cr->status)(__builtin_expect (!!(cr->status), 0))) |
4192 | return _cairo_surface_create_in_error (cr->status); |
4193 | |
4194 | return cr->backend->get_original_target (cr); |
4195 | } |
4196 | |
4197 | /** |
4198 | * cairo_get_group_target: |
4199 | * @cr: a cairo context |
4200 | * |
4201 | * Gets the current destination surface for the context. This is either |
4202 | * the original target surface as passed to cairo_create() or the target |
4203 | * surface for the current group as started by the most recent call to |
4204 | * cairo_push_group() or cairo_push_group_with_content(). |
4205 | * |
4206 | * This function will always return a valid pointer, but the result |
4207 | * can be a "nil" surface if @cr is already in an error state, |
4208 | * (ie. cairo_status() <literal>!=</literal> %CAIRO_STATUS_SUCCESS). |
4209 | * A nil surface is indicated by cairo_surface_status() |
4210 | * <literal>!=</literal> %CAIRO_STATUS_SUCCESS. |
4211 | * |
4212 | * Return value: the target surface. This object is owned by cairo. To |
4213 | * keep a reference to it, you must call cairo_surface_reference(). |
4214 | * |
4215 | * Since: 1.2 |
4216 | **/ |
4217 | cairo_surface_t * |
4218 | cairo_get_group_target_moz_cairo_get_group_target (cairo_t *cr) |
4219 | { |
4220 | if (unlikely (cr->status)(__builtin_expect (!!(cr->status), 0))) |
4221 | return _cairo_surface_create_in_error (cr->status); |
4222 | |
4223 | return cr->backend->get_current_target (cr); |
4224 | } |
4225 | |
4226 | /** |
4227 | * cairo_copy_path: |
4228 | * @cr: a cairo context |
4229 | * |
4230 | * Creates a copy of the current path and returns it to the user as a |
4231 | * #cairo_path_t. See #cairo_path_data_t for hints on how to iterate |
4232 | * over the returned data structure. |
4233 | * |
4234 | * This function will always return a valid pointer, but the result |
4235 | * will have no data (<literal>data==%NULL</literal> and |
4236 | * <literal>num_data==0</literal>), if either of the following |
4237 | * conditions hold: |
4238 | * |
4239 | * <orderedlist> |
4240 | * <listitem>If there is insufficient memory to copy the path. In this |
4241 | * case <literal>path->status</literal> will be set to |
4242 | * %CAIRO_STATUS_NO_MEMORY.</listitem> |
4243 | * <listitem>If @cr is already in an error state. In this case |
4244 | * <literal>path->status</literal> will contain the same status that |
4245 | * would be returned by cairo_status().</listitem> |
4246 | * </orderedlist> |
4247 | * |
4248 | * Return value: the copy of the current path. The caller owns the |
4249 | * returned object and should call cairo_path_destroy() when finished |
4250 | * with it. |
4251 | * |
4252 | * Since: 1.0 |
4253 | **/ |
4254 | cairo_path_t * |
4255 | cairo_copy_path_moz_cairo_copy_path (cairo_t *cr) |
4256 | { |
4257 | if (unlikely (cr->status)(__builtin_expect (!!(cr->status), 0))) |
4258 | return _cairo_path_create_in_error (cr->status); |
4259 | |
4260 | return cr->backend->copy_path (cr); |
4261 | } |
4262 | |
4263 | /** |
4264 | * cairo_copy_path_flat: |
4265 | * @cr: a cairo context |
4266 | * |
4267 | * Gets a flattened copy of the current path and returns it to the |
4268 | * user as a #cairo_path_t. See #cairo_path_data_t for hints on |
4269 | * how to iterate over the returned data structure. |
4270 | * |
4271 | * This function is like cairo_copy_path() except that any curves |
4272 | * in the path will be approximated with piecewise-linear |
4273 | * approximations, (accurate to within the current tolerance |
4274 | * value). That is, the result is guaranteed to not have any elements |
4275 | * of type %CAIRO_PATH_CURVE_TO which will instead be replaced by a |
4276 | * series of %CAIRO_PATH_LINE_TO elements. |
4277 | * |
4278 | * This function will always return a valid pointer, but the result |
4279 | * will have no data (<literal>data==%NULL</literal> and |
4280 | * <literal>num_data==0</literal>), if either of the following |
4281 | * conditions hold: |
4282 | * |
4283 | * <orderedlist> |
4284 | * <listitem>If there is insufficient memory to copy the path. In this |
4285 | * case <literal>path->status</literal> will be set to |
4286 | * %CAIRO_STATUS_NO_MEMORY.</listitem> |
4287 | * <listitem>If @cr is already in an error state. In this case |
4288 | * <literal>path->status</literal> will contain the same status that |
4289 | * would be returned by cairo_status().</listitem> |
4290 | * </orderedlist> |
4291 | * |
4292 | * Return value: the copy of the current path. The caller owns the |
4293 | * returned object and should call cairo_path_destroy() when finished |
4294 | * with it. |
4295 | * |
4296 | * Since: 1.0 |
4297 | **/ |
4298 | cairo_path_t * |
4299 | cairo_copy_path_flat_moz_cairo_copy_path_flat (cairo_t *cr) |
4300 | { |
4301 | if (unlikely (cr->status)(__builtin_expect (!!(cr->status), 0))) |
4302 | return _cairo_path_create_in_error (cr->status); |
4303 | |
4304 | return cr->backend->copy_path_flat (cr); |
4305 | } |
4306 | |
4307 | /** |
4308 | * cairo_append_path: |
4309 | * @cr: a cairo context |
4310 | * @path: path to be appended |
4311 | * |
4312 | * Append the @path onto the current path. The @path may be either the |
4313 | * return value from one of cairo_copy_path() or |
4314 | * cairo_copy_path_flat() or it may be constructed manually. See |
4315 | * #cairo_path_t for details on how the path data structure should be |
4316 | * initialized, and note that <literal>path->status</literal> must be |
4317 | * initialized to %CAIRO_STATUS_SUCCESS. |
4318 | * |
4319 | * Since: 1.0 |
4320 | **/ |
4321 | void |
4322 | cairo_append_path_moz_cairo_append_path (cairo_t *cr, |
4323 | const cairo_path_t *path) |
4324 | { |
4325 | cairo_status_t status; |
4326 | |
4327 | if (unlikely (cr->status)(__builtin_expect (!!(cr->status), 0))) |
4328 | return; |
4329 | |
4330 | if (unlikely (path == NULL)(__builtin_expect (!!(path == ((void*)0)), 0))) { |
4331 | _cairo_set_error (cr, CAIRO_STATUS_NULL_POINTER); |
4332 | return; |
4333 | } |
4334 | |
4335 | if (unlikely (path->status)(__builtin_expect (!!(path->status), 0))) { |
4336 | if (path->status > CAIRO_STATUS_SUCCESS && |
4337 | path->status <= CAIRO_STATUS_LAST_STATUS) |
4338 | _cairo_set_error (cr, path->status); |
4339 | else |
4340 | _cairo_set_error (cr, CAIRO_STATUS_INVALID_STATUS); |
4341 | return; |
4342 | } |
4343 | |
4344 | if (path->num_data == 0) |
4345 | return; |
4346 | |
4347 | if (unlikely (path->data == NULL)(__builtin_expect (!!(path->data == ((void*)0)), 0))) { |
4348 | _cairo_set_error (cr, CAIRO_STATUS_NULL_POINTER); |
4349 | return; |
4350 | } |
4351 | |
4352 | status = cr->backend->append_path (cr, path); |
4353 | if (unlikely (status)(__builtin_expect (!!(status), 0))) |
4354 | _cairo_set_error (cr, status); |
4355 | } |
4356 | |
4357 | /** |
4358 | * cairo_status: |
4359 | * @cr: a cairo context |
4360 | * |
4361 | * Checks whether an error has previously occurred for this context. |
4362 | * |
4363 | * Returns: the current status of this context, see #cairo_status_t |
4364 | * |
4365 | * Since: 1.0 |
4366 | **/ |
4367 | cairo_status_t |
4368 | cairo_status_moz_cairo_status (cairo_t *cr) |
4369 | { |
4370 | return cr->status; |
4371 | } |