Rev 1892 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 1892 | Rev 3959 | ||
---|---|---|---|
Line 1... | Line 1... | ||
1 | /* -*- Mode: c; c-basic-offset: 4; indent-tabs-mode: t; tab-width: 8; -*- */ |
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 |
2 | /* cairo - a vector graphics library with display and print output |
3 | * |
3 | * |
4 | * Copyright © 2002 University of Southern California |
4 | * Copyright © 2002 University of Southern California |
5 | * Copyright © 2005 Red Hat, Inc. |
5 | * Copyright © 2005 Red Hat, Inc. |
- | 6 | * Copyright © 2011 Intel Corporation |
|
6 | * |
7 | * |
7 | * This library is free software; you can redistribute it and/or |
8 | * This library is free software; you can redistribute it and/or |
8 | * modify it either under the terms of the GNU Lesser General Public |
9 | * modify it either under the terms of the GNU Lesser General Public |
9 | * License version 2.1 as published by the Free Software Foundation |
10 | * License version 2.1 as published by the Free Software Foundation |
10 | * (the "LGPL") or, at your option, under the terms of the Mozilla |
11 | * (the "LGPL") or, at your option, under the terms of the Mozilla |
Line 32... | Line 33... | ||
32 | * The Initial Developer of the Original Code is University of Southern |
33 | * The Initial Developer of the Original Code is University of Southern |
33 | * California. |
34 | * California. |
34 | * |
35 | * |
35 | * Contributor(s): |
36 | * Contributor(s): |
36 | * Carl D. Worth |
37 | * Carl D. Worth |
- | 38 | * Chris Wilson |
|
37 | */ |
39 | */ |
Line 38... | Line 40... | ||
38 | 40 | ||
39 | #include "cairoint.h" |
41 | #include "cairoint.h" |
Line 40... | Line 42... | ||
40 | #include "cairo-private.h" |
42 | #include "cairo-private.h" |
41 | 43 | ||
42 | #include "cairo-arc-private.h" |
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" |
|
Line 43... | Line 50... | ||
43 | #include "cairo-error-private.h" |
50 | |
44 | #include "cairo-path-private.h" |
51 | #include |
45 | 52 | ||
46 | /** |
53 | /** |
Line 54... | Line 61... | ||
54 | * and drawing options for the #cairo_t, create shapes with |
61 | * and drawing options for the #cairo_t, create shapes with |
55 | * functions like cairo_move_to() and cairo_line_to(), and then |
62 | * functions like cairo_move_to() and cairo_line_to(), and then |
56 | * draw shapes with cairo_stroke() or cairo_fill(). |
63 | * draw shapes with cairo_stroke() or cairo_fill(). |
57 | * |
64 | * |
58 | * #cairo_t's can be pushed to a stack via cairo_save(). |
65 | * #cairo_t's can be pushed to a stack via cairo_save(). |
59 | * They may then safely be changed, without loosing the current state. |
66 | * They may then safely be changed, without losing the current state. |
60 | * Use cairo_restore() to restore to the saved state. |
67 | * Use cairo_restore() to restore to the saved state. |
61 | */ |
68 | **/ |
Line 62... | Line 69... | ||
62 | 69 | ||
63 | /** |
70 | /** |
64 | * SECTION:cairo-text |
71 | * SECTION:cairo-text |
65 | * @Title: text |
72 | * @Title: text |
Line 83... | Line 90... | ||
83 | * the user to convert text to a set of glyph indexes and positions. This |
90 | * the user to convert text to a set of glyph indexes and positions. This |
84 | * is a very hard problem and is best handled by external libraries, like |
91 | * is a very hard problem and is best handled by external libraries, like |
85 | * the pangocairo that is part of the Pango text layout and rendering library. |
92 | * the pangocairo that is part of the Pango text layout and rendering library. |
86 | * Pango is available from |
93 | * Pango is available from |
87 | * url="http://www.pango.org/">http://www.pango.org/. |
94 | * url="http://www.pango.org/">http://www.pango.org/. |
88 | */ |
95 | **/ |
Line 89... | Line 96... | ||
89 | 96 | ||
90 | /** |
97 | /** |
91 | * SECTION:cairo-transforms |
98 | * SECTION:cairo-transforms |
92 | * @Title: Transformations |
99 | * @Title: Transformations |
Line 96... | Line 103... | ||
96 | * The current transformation matrix, |
103 | * The current transformation matrix, |
97 | * two-dimensional affine transformation that maps all coordinates and other |
104 | * two-dimensional affine transformation that maps all coordinates and other |
98 | * drawing instruments from the |
105 | * drawing instruments from the |
99 | * surface's canonical coordinate system, also known as the |
106 | * surface's canonical coordinate system, also known as the |
100 | * space. |
107 | * space. |
101 | */ |
- | |
102 | - | ||
103 | #define CAIRO_TOLERANCE_MINIMUM _cairo_fixed_to_double(1) |
- | |
104 | - | ||
105 | #if !defined(INFINITY) |
- | |
106 | #define INFINITY HUGE_VAL |
- | |
107 | #endif |
- | |
108 | - | ||
109 | static const cairo_t _cairo_nil = { |
- | |
110 | CAIRO_REFERENCE_COUNT_INVALID, /* ref_count */ |
- | |
111 | CAIRO_STATUS_NO_MEMORY, /* status */ |
- | |
112 | { 0, 0, 0, NULL }, /* user_data */ |
- | |
113 | NULL, /* gstate */ |
- | |
114 | {{ 0 }, { 0 }}, /* gstate_tail */ |
- | |
115 | NULL, /* gstate_freelist */ |
- | |
116 | {{ /* path */ |
- | |
117 | { 0, 0 }, /* last_move_point */ |
- | |
118 | { 0, 0 }, /* current point */ |
- | |
119 | FALSE, /* has_current_point */ |
- | |
120 | FALSE, /* has_last_move_point */ |
- | |
121 | FALSE, /* has_curve_to */ |
- | |
122 | FALSE, /* is_box */ |
- | |
123 | FALSE, /* maybe_fill_region */ |
- | |
124 | TRUE, /* is_empty_fill */ |
- | |
125 | { {0, 0}, {0, 0}}, /* extents */ |
- | |
126 | {{{NULL,NULL}}} /* link */ |
- | |
127 | }} |
- | |
128 | }; |
- | |
129 | - | ||
130 | static const cairo_t _cairo_nil__null_pointer = { |
- | |
131 | CAIRO_REFERENCE_COUNT_INVALID, /* ref_count */ |
- | |
132 | CAIRO_STATUS_NULL_POINTER, /* status */ |
- | |
133 | { 0, 0, 0, NULL }, /* user_data */ |
- | |
134 | NULL, /* gstate */ |
- | |
135 | {{ 0 }, { 0 }}, /* gstate_tail */ |
- | |
136 | NULL, /* gstate_freelist */ |
- | |
137 | {{ /* path */ |
- | |
138 | { 0, 0 }, /* last_move_point */ |
- | |
139 | { 0, 0 }, /* current point */ |
- | |
140 | FALSE, /* has_current_point */ |
- | |
141 | FALSE, /* has_last_move_point */ |
- | |
142 | FALSE, /* has_curve_to */ |
- | |
143 | FALSE, /* is_box */ |
- | |
144 | FALSE, /* maybe_fill_region */ |
- | |
145 | TRUE, /* is_empty_fill */ |
- | |
146 | { {0, 0}, {0, 0}}, /* extents */ |
- | |
147 | {{{NULL,NULL}}} /* link */ |
- | |
148 | }} |
- | |
149 | }; |
- | |
150 | #include |
- | |
151 | - | ||
152 | /** |
- | |
153 | * _cairo_error: |
- | |
154 | * @status: a status value indicating an error, (eg. not |
- | |
155 | * %CAIRO_STATUS_SUCCESS) |
- | |
156 | * |
- | |
157 | * Checks that status is an error status, but does nothing else. |
- | |
158 | * |
- | |
159 | * All assignments of an error status to any user-visible object |
- | |
160 | * within the cairo application should result in a call to |
- | |
161 | * _cairo_error(). |
- | |
162 | * |
- | |
163 | * The purpose of this function is to allow the user to set a |
- | |
164 | * breakpoint in _cairo_error() to generate a stack trace for when the |
- | |
165 | * user causes cairo to detect an error. |
- | |
166 | * |
- | |
167 | * Return value: the error status. |
- | |
168 | **/ |
108 | **/ |
169 | cairo_status_t |
- | |
170 | _cairo_error (cairo_status_t status) |
- | |
171 | { |
- | |
172 | CAIRO_ENSURE_UNIQUE; |
- | |
173 | assert (_cairo_status_is_error (status)); |
- | |
Line -... | Line 109... | ||
- | 109 | ||
174 | 110 | #define DEFINE_NIL_CONTEXT(status) \ |
|
- | 111 | { \ |
|
- | 112 | CAIRO_REFERENCE_COUNT_INVALID, /* ref_count */ \ |
|
- | 113 | status, /* status */ \ |
|
- | 114 | { 0, 0, 0, NULL }, /* user_data */ \ |
|
- | 115 | NULL \ |
|
- | 116 | } |
|
- | 117 | ||
- | 118 | static const cairo_t _cairo_nil[] = { |
|
- | 119 | DEFINE_NIL_CONTEXT (CAIRO_STATUS_NO_MEMORY), |
|
- | 120 | DEFINE_NIL_CONTEXT (CAIRO_STATUS_INVALID_RESTORE), |
|
- | 121 | DEFINE_NIL_CONTEXT (CAIRO_STATUS_INVALID_POP_GROUP), |
|
- | 122 | DEFINE_NIL_CONTEXT (CAIRO_STATUS_NO_CURRENT_POINT), |
|
- | 123 | DEFINE_NIL_CONTEXT (CAIRO_STATUS_INVALID_MATRIX), |
|
- | 124 | DEFINE_NIL_CONTEXT (CAIRO_STATUS_INVALID_STATUS), |
|
- | 125 | DEFINE_NIL_CONTEXT (CAIRO_STATUS_NULL_POINTER), |
|
- | 126 | DEFINE_NIL_CONTEXT (CAIRO_STATUS_INVALID_STRING), |
|
- | 127 | DEFINE_NIL_CONTEXT (CAIRO_STATUS_INVALID_PATH_DATA), |
|
- | 128 | DEFINE_NIL_CONTEXT (CAIRO_STATUS_READ_ERROR), |
|
- | 129 | DEFINE_NIL_CONTEXT (CAIRO_STATUS_WRITE_ERROR), |
|
- | 130 | DEFINE_NIL_CONTEXT (CAIRO_STATUS_SURFACE_FINISHED), |
|
- | 131 | DEFINE_NIL_CONTEXT (CAIRO_STATUS_SURFACE_TYPE_MISMATCH), |
|
- | 132 | DEFINE_NIL_CONTEXT (CAIRO_STATUS_PATTERN_TYPE_MISMATCH), |
|
- | 133 | DEFINE_NIL_CONTEXT (CAIRO_STATUS_INVALID_CONTENT), |
|
- | 134 | DEFINE_NIL_CONTEXT (CAIRO_STATUS_INVALID_FORMAT), |
|
- | 135 | DEFINE_NIL_CONTEXT (CAIRO_STATUS_INVALID_VISUAL), |
|
- | 136 | DEFINE_NIL_CONTEXT (CAIRO_STATUS_FILE_NOT_FOUND), |
|
- | 137 | DEFINE_NIL_CONTEXT (CAIRO_STATUS_INVALID_DASH), |
|
- | 138 | DEFINE_NIL_CONTEXT (CAIRO_STATUS_INVALID_DSC_COMMENT), |
|
- | 139 | DEFINE_NIL_CONTEXT (CAIRO_STATUS_INVALID_INDEX), |
|
- | 140 | DEFINE_NIL_CONTEXT (CAIRO_STATUS_CLIP_NOT_REPRESENTABLE), |
|
- | 141 | DEFINE_NIL_CONTEXT (CAIRO_STATUS_TEMP_FILE_ERROR), |
|
- | 142 | DEFINE_NIL_CONTEXT (CAIRO_STATUS_INVALID_STRIDE), |
|
- | 143 | DEFINE_NIL_CONTEXT (CAIRO_STATUS_FONT_TYPE_MISMATCH), |
|
- | 144 | DEFINE_NIL_CONTEXT (CAIRO_STATUS_USER_FONT_IMMUTABLE), |
|
- | 145 | DEFINE_NIL_CONTEXT (CAIRO_STATUS_USER_FONT_ERROR), |
|
- | 146 | DEFINE_NIL_CONTEXT (CAIRO_STATUS_NEGATIVE_COUNT), |
|
- | 147 | DEFINE_NIL_CONTEXT (CAIRO_STATUS_INVALID_CLUSTERS), |
|
- | 148 | DEFINE_NIL_CONTEXT (CAIRO_STATUS_INVALID_SLANT), |
|
- | 149 | DEFINE_NIL_CONTEXT (CAIRO_STATUS_INVALID_WEIGHT), |
|
- | 150 | DEFINE_NIL_CONTEXT (CAIRO_STATUS_INVALID_SIZE), |
|
- | 151 | DEFINE_NIL_CONTEXT (CAIRO_STATUS_USER_FONT_NOT_IMPLEMENTED), |
|
- | 152 | DEFINE_NIL_CONTEXT (CAIRO_STATUS_DEVICE_TYPE_MISMATCH), |
|
- | 153 | DEFINE_NIL_CONTEXT (CAIRO_STATUS_DEVICE_ERROR), |
|
- | 154 | DEFINE_NIL_CONTEXT (CAIRO_STATUS_INVALID_MESH_CONSTRUCTION), |
|
175 | return status; |
155 | DEFINE_NIL_CONTEXT (CAIRO_STATUS_DEVICE_FINISHED) |
- | 156 | }; |
|
Line 176... | Line 157... | ||
176 | } |
157 | COMPILE_TIME_ASSERT (ARRAY_LENGTH (_cairo_nil) == CAIRO_STATUS_LAST_STATUS - 1); |
177 | 158 | ||
178 | /** |
159 | /** |
179 | * _cairo_set_error: |
160 | * _cairo_set_error: |
Line 197... | Line 178... | ||
197 | /* Don't overwrite an existing error. This preserves the first |
178 | /* Don't overwrite an existing error. This preserves the first |
198 | * error, which is the most significant. */ |
179 | * error, which is the most significant. */ |
199 | _cairo_status_set_error (&cr->status, _cairo_error (status)); |
180 | _cairo_status_set_error (&cr->status, _cairo_error (status)); |
200 | } |
181 | } |
Line 201... | Line -... | ||
201 | - | ||
202 | /* We keep a small stash of contexts to reduce malloc pressure */ |
- | |
203 | #define CAIRO_STASH_SIZE 4 |
- | |
204 | #if CAIRO_NO_MUTEX |
- | |
205 | static struct { |
- | |
206 | cairo_t pool[CAIRO_STASH_SIZE]; |
- | |
207 | int occupied; |
- | |
208 | } _context_stash; |
- | |
209 | - | ||
210 | static cairo_t * |
- | |
211 | _context_get (void) |
- | |
212 | { |
- | |
213 | int avail; |
- | |
214 | - | ||
215 | avail = ffs (~_context_stash.occupied) - 1; |
- | |
216 | if (avail >= CAIRO_STASH_SIZE) |
- | |
217 | return malloc (sizeof (cairo_t)); |
- | |
218 | - | ||
219 | _context_stash.occupied |= 1 << avail; |
- | |
220 | return &_context_stash.pool[avail]; |
- | |
221 | } |
- | |
222 | - | ||
223 | static void |
- | |
224 | _context_put (cairo_t *cr) |
- | |
225 | { |
- | |
226 | if (cr < &_context_stash.pool[0] || |
- | |
227 | cr >= &_context_stash.pool[CAIRO_STASH_SIZE]) |
- | |
228 | { |
- | |
229 | free (cr); |
- | |
230 | return; |
- | |
231 | } |
- | |
232 | - | ||
233 | _context_stash.occupied &= ~(1 << (cr - &_context_stash.pool[0])); |
- | |
234 | } |
- | |
235 | #elif HAS_ATOMIC_OPS |
- | |
236 | static struct { |
- | |
237 | cairo_t pool[CAIRO_STASH_SIZE]; |
- | |
238 | cairo_atomic_int_t occupied; |
- | |
239 | } _context_stash; |
- | |
240 | - | ||
241 | static cairo_t * |
- | |
242 | _context_get (void) |
- | |
243 | { |
- | |
244 | cairo_atomic_int_t avail, old, new; |
- | |
245 | - | ||
246 | do { |
- | |
247 | old = _cairo_atomic_int_get (&_context_stash.occupied); |
- | |
248 | avail = ffs (~old) - 1; |
- | |
249 | if (avail >= CAIRO_STASH_SIZE) |
- | |
250 | return malloc (sizeof (cairo_t)); |
- | |
251 | - | ||
252 | new = old | (1 << avail); |
- | |
253 | } while (! _cairo_atomic_int_cmpxchg (&_context_stash.occupied, old, new)); |
- | |
254 | - | ||
255 | return &_context_stash.pool[avail]; |
- | |
256 | } |
- | |
257 | - | ||
258 | static void |
- | |
259 | _context_put (cairo_t *cr) |
- | |
260 | { |
- | |
261 | cairo_atomic_int_t old, new, avail; |
- | |
262 | - | ||
263 | if (cr < &_context_stash.pool[0] || |
- | |
264 | cr >= &_context_stash.pool[CAIRO_STASH_SIZE]) |
- | |
265 | { |
- | |
266 | free (cr); |
- | |
267 | return; |
- | |
268 | } |
- | |
269 | - | ||
270 | avail = ~(1 << (cr - &_context_stash.pool[0])); |
- | |
271 | do { |
- | |
272 | old = _cairo_atomic_int_get (&_context_stash.occupied); |
- | |
273 | new = old & avail; |
- | |
274 | } while (! _cairo_atomic_int_cmpxchg (&_context_stash.occupied, old, new)); |
- | |
275 | } |
- | |
276 | #else |
- | |
277 | #define _context_get() malloc (sizeof (cairo_t)) |
- | |
278 | #define _context_put(cr) free (cr) |
- | |
279 | #endif |
- | |
280 | - | ||
281 | /* XXX This should disappear in favour of a common pool of error objects. */ |
- | |
282 | static cairo_t *_cairo_nil__objects[CAIRO_STATUS_LAST_STATUS + 1]; |
- | |
283 | 182 | ||
284 | static cairo_t * |
183 | cairo_t * |
285 | _cairo_create_in_error (cairo_status_t status) |
184 | _cairo_create_in_error (cairo_status_t status) |
286 | { |
185 | { |
Line 287... | Line 186... | ||
287 | cairo_t *cr; |
186 | cairo_t *cr; |
Line 288... | Line -... | ||
288 | - | ||
289 | assert (status != CAIRO_STATUS_SUCCESS); |
- | |
290 | - | ||
291 | /* special case OOM in order to avoid another allocation */ |
- | |
292 | switch ((int) status) { |
- | |
293 | case CAIRO_STATUS_NO_MEMORY: |
- | |
294 | return (cairo_t *) &_cairo_nil; |
- | |
295 | case CAIRO_STATUS_NULL_POINTER: |
- | |
296 | return (cairo_t *) &_cairo_nil__null_pointer; |
- | |
297 | } |
- | |
298 | - | ||
299 | CAIRO_MUTEX_LOCK (_cairo_error_mutex); |
- | |
300 | cr = _cairo_nil__objects[status]; |
- | |
301 | if (cr == NULL) { |
- | |
302 | cr = malloc (sizeof (cairo_t)); |
187 | |
303 | if (unlikely (cr == NULL)) { |
- | |
304 | CAIRO_MUTEX_UNLOCK (_cairo_error_mutex); |
- | |
305 | _cairo_error_throw (CAIRO_STATUS_NO_MEMORY); |
- | |
306 | return (cairo_t *) &_cairo_nil; |
- | |
307 | } |
188 | assert (status != CAIRO_STATUS_SUCCESS); |
308 | - | ||
309 | *cr = _cairo_nil; |
- | |
310 | cr->status = status; |
- | |
Line 311... | Line 189... | ||
311 | _cairo_nil__objects[status] = cr; |
189 | |
312 | } |
190 | cr = (cairo_t *) &_cairo_nil[status - CAIRO_STATUS_NO_MEMORY]; |
Line 313... | Line -... | ||
313 | CAIRO_MUTEX_UNLOCK (_cairo_error_mutex); |
- | |
314 | - | ||
315 | return cr; |
- | |
316 | } |
- | |
317 | - | ||
318 | void |
- | |
319 | _cairo_reset_static_data (void) |
- | |
320 | { |
- | |
321 | int status; |
- | |
322 | - | ||
323 | CAIRO_MUTEX_LOCK (_cairo_error_mutex); |
- | |
324 | for (status = CAIRO_STATUS_SUCCESS; |
- | |
325 | status <= CAIRO_STATUS_LAST_STATUS; |
- | |
326 | status++) |
- | |
327 | { |
- | |
328 | if (_cairo_nil__objects[status] != NULL) { |
- | |
329 | free (_cairo_nil__objects[status]); |
- | |
330 | _cairo_nil__objects[status] = NULL; |
- | |
331 | } |
191 | assert (status == cr->status); |
332 | } |
192 | |
333 | CAIRO_MUTEX_UNLOCK (_cairo_error_mutex); |
193 | return cr; |
334 | } |
194 | } |
335 | 195 | ||
336 | /** |
196 | /** |
337 | * cairo_create: |
197 | * cairo_create: |
338 | * @target: target surface for the context |
198 | * @target: target surface for the context |
339 | * |
199 | * |
- | 200 | * Creates a new #cairo_t with all graphics state parameters set to |
|
340 | * Creates a new #cairo_t with all graphics state parameters set to |
201 | * default values and with @target as a target surface. The target |
341 | * default values and with @target as a target surface. The target |
202 | * surface should be constructed with a backend-specific function such |
342 | * surface should be constructed with a backend-specific function such |
203 | * as cairo_image_surface_create() (or any other |
343 | * as cairo_image_surface_create() (or any other |
204 | * |
344 | * cairo_ |
205 | * variant). |
345 | * |
206 | * |
346 | * This function references @target, so you can immediately |
207 | * This function references @target, so you can immediately |
347 | * call cairo_surface_destroy() on it if you don't need to |
208 | * call cairo_surface_destroy() on it if you don't need to |
348 | * maintain a separate reference to it. |
209 | * maintain a separate reference to it. |
349 | * |
210 | * |
350 | * Return value: a newly allocated #cairo_t with a reference |
211 | * Return value: a newly allocated #cairo_t with a reference |
- | 212 | * count of 1. The initial reference count should be released |
|
- | 213 | * with cairo_destroy() when you are done using the #cairo_t. |
|
- | 214 | * This function never returns %NULL. If memory cannot be |
|
351 | * count of 1. The initial reference count should be released |
215 | * allocated, a special #cairo_t object will be returned on |
- | 216 | * which cairo_status() returns %CAIRO_STATUS_NO_MEMORY. If |
|
352 | * with cairo_destroy() when you are done using the #cairo_t. |
217 | * you attempt to target a surface which does not support |
353 | * This function never returns %NULL. If memory cannot be |
218 | * writing (such as #cairo_mime_surface_t) then a |
354 | * allocated, a special #cairo_t object will be returned on |
219 | * %CAIRO_STATUS_WRITE_ERROR will be raised. You can use this |
355 | * which cairo_status() returns %CAIRO_STATUS_NO_MEMORY. |
220 | * object normally, but no drawing will be done. |
356 | * You can use this object normally, but no drawing will |
221 | * |
357 | * be done. |
- | |
358 | **/ |
- | |
359 | cairo_t * |
- | |
360 | cairo_create (cairo_surface_t *target) |
222 | * Since: 1.0 |
361 | { |
223 | **/ |
362 | cairo_t *cr; |
224 | cairo_t * |
363 | cairo_status_t status; |
225 | cairo_create (cairo_surface_t *target) |
Line 364... | Line -... | ||
364 | - | ||
365 | if (unlikely (target == NULL)) |
226 | { |
366 | return _cairo_create_in_error (_cairo_error (CAIRO_STATUS_NULL_POINTER)); |
227 | if (unlikely (target == NULL)) |
Line 367... | Line 228... | ||
367 | if (unlikely (target->status)) |
228 | return _cairo_create_in_error (_cairo_error (CAIRO_STATUS_NULL_POINTER)); |
Line -... | Line 229... | ||
- | 229 | if (unlikely (target->status)) |
|
368 | return _cairo_create_in_error (target->status); |
230 | return _cairo_create_in_error (target->status); |
Line -... | Line 231... | ||
- | 231 | ||
- | 232 | if (target->backend->create_context == NULL) |
|
- | 233 | return _cairo_create_in_error (_cairo_error (CAIRO_STATUS_WRITE_ERROR)); |
|
- | 234 | ||
- | 235 | return target->backend->create_context (target); |
|
- | 236 | ||
369 | 237 | } |
|
370 | cr = _context_get (); |
- | |
371 | if (unlikely (cr == NULL)) |
- | |
372 | return _cairo_create_in_error (_cairo_error (CAIRO_STATUS_NO_MEMORY)); |
- | |
373 | - | ||
374 | CAIRO_REFERENCE_COUNT_INIT (&cr->ref_count, 1); |
- | |
375 | - | ||
376 | cr->status = CAIRO_STATUS_SUCCESS; |
- | |
377 | - | ||
378 | _cairo_user_data_array_init (&cr->user_data); |
- | |
379 | _cairo_path_fixed_init (cr->path); |
- | |
380 | - | ||
Line 381... | Line 238... | ||
381 | cr->gstate = &cr->gstate_tail[0]; |
238 | slim_hidden_def (cairo_create); |
382 | cr->gstate_freelist = &cr->gstate_tail[1]; |
239 | |
383 | cr->gstate_tail[1].next = NULL; |
- | |
Line 384... | Line 240... | ||
384 | 240 | void |
|
385 | status = _cairo_gstate_init (cr->gstate, target); |
241 | _cairo_init (cairo_t *cr, |
386 | if (unlikely (status)) { |
242 | const cairo_backend_t *backend) |
387 | _context_put (cr); |
243 | { |
Line 402... | Line 258... | ||
402 | * |
258 | * |
403 | * The number of references to a #cairo_t can be get using |
259 | * The number of references to a #cairo_t can be get using |
404 | * cairo_get_reference_count(). |
260 | * cairo_get_reference_count(). |
405 | * |
261 | * |
406 | * Return value: the referenced #cairo_t. |
262 | * Return value: the referenced #cairo_t. |
- | 263 | * |
|
- | 264 | * Since: 1.0 |
|
407 | **/ |
265 | **/ |
408 | cairo_t * |
266 | cairo_t * |
409 | cairo_reference (cairo_t *cr) |
267 | cairo_reference (cairo_t *cr) |
410 | { |
268 | { |
411 | if (cr == NULL || CAIRO_REFERENCE_COUNT_IS_INVALID (&cr->ref_count)) |
269 | if (cr == NULL || CAIRO_REFERENCE_COUNT_IS_INVALID (&cr->ref_count)) |
Line 416... | Line 274... | ||
416 | _cairo_reference_count_inc (&cr->ref_count); |
274 | _cairo_reference_count_inc (&cr->ref_count); |
Line 417... | Line 275... | ||
417 | 275 | ||
418 | return cr; |
276 | return cr; |
Line -... | Line 277... | ||
- | 277 | } |
|
- | 278 | ||
- | 279 | void |
|
- | 280 | _cairo_fini (cairo_t *cr) |
|
- | 281 | { |
|
- | 282 | _cairo_user_data_array_fini (&cr->user_data); |
|
419 | } |
283 | } |
420 | 284 | ||
421 | /** |
285 | /** |
422 | * cairo_destroy: |
286 | * cairo_destroy: |
423 | * @cr: a #cairo_t |
287 | * @cr: a #cairo_t |
424 | * |
288 | * |
425 | * Decreases the reference count on @cr by one. If the result |
289 | * Decreases the reference count on @cr by one. If the result |
- | 290 | * is zero, then @cr and all associated resources are freed. |
|
- | 291 | * See cairo_reference(). |
|
426 | * is zero, then @cr and all associated resources are freed. |
292 | * |
427 | * See cairo_reference(). |
293 | * Since: 1.0 |
428 | **/ |
294 | **/ |
429 | void |
295 | void |
430 | cairo_destroy (cairo_t *cr) |
296 | cairo_destroy (cairo_t *cr) |
Line 435... | Line 301... | ||
435 | assert (CAIRO_REFERENCE_COUNT_HAS_REFERENCE (&cr->ref_count)); |
301 | assert (CAIRO_REFERENCE_COUNT_HAS_REFERENCE (&cr->ref_count)); |
Line 436... | Line 302... | ||
436 | 302 | ||
437 | if (! _cairo_reference_count_dec_and_test (&cr->ref_count)) |
303 | if (! _cairo_reference_count_dec_and_test (&cr->ref_count)) |
Line 438... | Line -... | ||
438 | return; |
- | |
439 | - | ||
440 | while (cr->gstate != &cr->gstate_tail[0]) { |
- | |
441 | if (_cairo_gstate_restore (&cr->gstate, &cr->gstate_freelist)) |
- | |
442 | break; |
- | |
443 | } |
- | |
444 | - | ||
445 | _cairo_gstate_fini (cr->gstate); |
- | |
446 | cr->gstate_freelist = cr->gstate_freelist->next; /* skip over tail[1] */ |
- | |
447 | while (cr->gstate_freelist != NULL) { |
- | |
448 | cairo_gstate_t *gstate = cr->gstate_freelist; |
- | |
449 | cr->gstate_freelist = gstate->next; |
- | |
450 | free (gstate); |
- | |
451 | } |
- | |
452 | - | ||
453 | _cairo_path_fixed_fini (cr->path); |
- | |
454 | - | ||
455 | _cairo_user_data_array_fini (&cr->user_data); |
- | |
456 | - | ||
457 | /* mark the context as invalid to protect against misuse */ |
- | |
458 | cr->status = CAIRO_STATUS_NULL_POINTER; |
304 | return; |
459 | 305 | ||
460 | _context_put (cr); |
306 | cr->backend->destroy (cr); |
Line 461... | Line 307... | ||
461 | } |
307 | } |
462 | slim_hidden_def (cairo_destroy); |
308 | slim_hidden_def (cairo_destroy); |
Line 477... | Line 323... | ||
477 | **/ |
323 | **/ |
478 | void * |
324 | void * |
479 | cairo_get_user_data (cairo_t *cr, |
325 | cairo_get_user_data (cairo_t *cr, |
480 | const cairo_user_data_key_t *key) |
326 | const cairo_user_data_key_t *key) |
481 | { |
327 | { |
482 | return _cairo_user_data_array_get_data (&cr->user_data, |
328 | return _cairo_user_data_array_get_data (&cr->user_data, key); |
483 | key); |
- | |
484 | } |
329 | } |
Line 485... | Line 330... | ||
485 | 330 | ||
486 | /** |
331 | /** |
487 | * cairo_set_user_data: |
332 | * cairo_set_user_data: |
Line 547... | Line 392... | ||
547 | * |
392 | * |
548 | * It isn't necessary to clear all saved states before |
393 | * It isn't necessary to clear all saved states before |
549 | * a #cairo_t is freed. If the reference count of a #cairo_t |
394 | * a #cairo_t is freed. If the reference count of a #cairo_t |
550 | * drops to zero in response to a call to cairo_destroy(), |
395 | * drops to zero in response to a call to cairo_destroy(), |
551 | * any saved states will be freed along with the #cairo_t. |
396 | * any saved states will be freed along with the #cairo_t. |
- | 397 | * |
|
- | 398 | * Since: 1.0 |
|
552 | **/ |
399 | **/ |
553 | void |
400 | void |
554 | cairo_save (cairo_t *cr) |
401 | cairo_save (cairo_t *cr) |
555 | { |
402 | { |
556 | cairo_status_t status; |
403 | cairo_status_t status; |
Line 557... | Line 404... | ||
557 | 404 | ||
558 | if (unlikely (cr->status)) |
405 | if (unlikely (cr->status)) |
Line 559... | Line 406... | ||
559 | return; |
406 | return; |
560 | 407 | ||
561 | status = _cairo_gstate_save (&cr->gstate, &cr->gstate_freelist); |
408 | status = cr->backend->save (cr); |
562 | if (unlikely (status)) |
409 | if (unlikely (status)) |
563 | _cairo_set_error (cr, status); |
410 | _cairo_set_error (cr, status); |
Line 569... | Line 416... | ||
569 | * @cr: a #cairo_t |
416 | * @cr: a #cairo_t |
570 | * |
417 | * |
571 | * Restores @cr to the state saved by a preceding call to |
418 | * Restores @cr to the state saved by a preceding call to |
572 | * cairo_save() and removes that state from the stack of |
419 | * cairo_save() and removes that state from the stack of |
573 | * saved states. |
420 | * saved states. |
- | 421 | * |
|
- | 422 | * Since: 1.0 |
|
574 | **/ |
423 | **/ |
575 | void |
424 | void |
576 | cairo_restore (cairo_t *cr) |
425 | cairo_restore (cairo_t *cr) |
577 | { |
426 | { |
578 | cairo_status_t status; |
427 | cairo_status_t status; |
Line 579... | Line 428... | ||
579 | 428 | ||
580 | if (unlikely (cr->status)) |
429 | if (unlikely (cr->status)) |
Line 581... | Line 430... | ||
581 | return; |
430 | return; |
582 | 431 | ||
583 | status = _cairo_gstate_restore (&cr->gstate, &cr->gstate_freelist); |
432 | status = cr->backend->restore (cr); |
584 | if (unlikely (status)) |
433 | if (unlikely (status)) |
585 | _cairo_set_error (cr, status); |
434 | _cairo_set_error (cr, status); |
Line 627... | Line 476... | ||
627 | * cairo_pop_group_to_source (cr); |
476 | * cairo_pop_group_to_source (cr); |
628 | * cairo_paint_with_alpha (cr, alpha); |
477 | * cairo_paint_with_alpha (cr, alpha); |
629 | * |
478 | * |
630 | * |
479 | * |
631 | * Since: 1.2 |
480 | * Since: 1.2 |
632 | */ |
481 | **/ |
633 | void |
482 | void |
634 | cairo_push_group (cairo_t *cr) |
483 | cairo_push_group (cairo_t *cr) |
635 | { |
484 | { |
636 | cairo_push_group_with_content (cr, CAIRO_CONTENT_COLOR_ALPHA); |
485 | cairo_push_group_with_content (cr, CAIRO_CONTENT_COLOR_ALPHA); |
637 | } |
486 | } |
Line 652... | Line 501... | ||
652 | * control this content type is the only distinction between this |
501 | * control this content type is the only distinction between this |
653 | * function and cairo_push_group() which you should see for a more |
502 | * function and cairo_push_group() which you should see for a more |
654 | * detailed description of group rendering. |
503 | * detailed description of group rendering. |
655 | * |
504 | * |
656 | * Since: 1.2 |
505 | * Since: 1.2 |
657 | */ |
506 | **/ |
658 | void |
507 | void |
659 | cairo_push_group_with_content (cairo_t *cr, cairo_content_t content) |
508 | cairo_push_group_with_content (cairo_t *cr, cairo_content_t content) |
660 | { |
509 | { |
661 | cairo_surface_t *group_surface; |
- | |
662 | cairo_clip_t *clip; |
- | |
663 | cairo_status_t status; |
510 | cairo_status_t status; |
Line 664... | Line 511... | ||
664 | 511 | ||
665 | if (unlikely (cr->status)) |
512 | if (unlikely (cr->status)) |
Line 666... | Line -... | ||
666 | return; |
- | |
667 | - | ||
668 | clip = _cairo_gstate_get_clip (cr->gstate); |
- | |
669 | if (clip->all_clipped) { |
- | |
670 | group_surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, 0, 0); |
- | |
671 | status = group_surface->status; |
- | |
672 | if (unlikely (status)) |
- | |
673 | goto bail; |
- | |
674 | } else { |
- | |
675 | cairo_surface_t *parent_surface; |
- | |
676 | const cairo_rectangle_int_t *clip_extents; |
- | |
677 | cairo_rectangle_int_t extents; |
- | |
678 | cairo_matrix_t matrix; |
- | |
679 | cairo_bool_t is_empty; |
- | |
680 | - | ||
681 | parent_surface = _cairo_gstate_get_target (cr->gstate); |
- | |
682 | - | ||
683 | /* Get the extents that we'll use in creating our new group surface */ |
- | |
684 | is_empty = _cairo_surface_get_extents (parent_surface, &extents); |
- | |
685 | clip_extents = _cairo_clip_get_extents (_cairo_gstate_get_clip (cr->gstate)); |
- | |
686 | if (clip_extents != NULL) |
- | |
687 | is_empty = _cairo_rectangle_intersect (&extents, clip_extents); |
- | |
688 | - | ||
689 | group_surface = _cairo_surface_create_similar_solid (parent_surface, |
- | |
690 | content, |
- | |
691 | extents.width, |
- | |
692 | extents.height, |
- | |
693 | CAIRO_COLOR_TRANSPARENT, |
- | |
694 | TRUE); |
- | |
695 | status = group_surface->status; |
- | |
696 | if (unlikely (status)) |
- | |
697 | goto bail; |
- | |
698 | - | ||
699 | /* Set device offsets on the new surface so that logically it appears at |
- | |
700 | * the same location on the parent surface -- when we pop_group this, |
- | |
701 | * the source pattern will get fixed up for the appropriate target surface |
- | |
702 | * device offsets, so we want to set our own surface offsets from /that/, |
- | |
703 | * and not from the device origin. */ |
- | |
704 | cairo_surface_set_device_offset (group_surface, |
- | |
705 | parent_surface->device_transform.x0 - extents.x, |
- | |
706 | parent_surface->device_transform.y0 - extents.y); |
- | |
707 | - | ||
708 | /* If we have a current path, we need to adjust it to compensate for |
- | |
709 | * the device offset just applied. */ |
- | |
710 | cairo_matrix_init_translate (&matrix, -extents.x, -extents.y); |
- | |
711 | _cairo_path_fixed_transform (cr->path, &matrix); |
- | |
712 | } |
- | |
713 | - | ||
714 | /* create a new gstate for the redirect */ |
- | |
715 | cairo_save (cr); |
- | |
716 | if (unlikely (cr->status)) |
- | |
717 | goto bail; |
- | |
718 | - | ||
719 | status = _cairo_gstate_redirect_target (cr->gstate, group_surface); |
- | |
720 | 513 | return; |
|
721 | bail: |
514 | |
722 | cairo_surface_destroy (group_surface); |
515 | status = cr->backend->push_group (cr, content); |
723 | if (unlikely (status)) |
516 | if (unlikely (status)) |
724 | _cairo_set_error (cr, status); |
517 | _cairo_set_error (cr, status); |
Line 747... | Line 540... | ||
747 | * Since: 1.2 |
540 | * Since: 1.2 |
748 | **/ |
541 | **/ |
749 | cairo_pattern_t * |
542 | cairo_pattern_t * |
750 | cairo_pop_group (cairo_t *cr) |
543 | cairo_pop_group (cairo_t *cr) |
751 | { |
544 | { |
752 | cairo_surface_t *group_surface, *parent_target; |
- | |
753 | cairo_pattern_t *group_pattern; |
545 | cairo_pattern_t *group_pattern; |
754 | cairo_matrix_t group_matrix, device_transform_matrix; |
- | |
755 | cairo_status_t status; |
- | |
Line 756... | Line 546... | ||
756 | 546 | ||
757 | if (unlikely (cr->status)) |
547 | if (unlikely (cr->status)) |
Line 758... | Line -... | ||
758 | return _cairo_pattern_create_in_error (cr->status); |
- | |
759 | - | ||
760 | /* Grab the active surfaces */ |
- | |
761 | group_surface = _cairo_gstate_get_target (cr->gstate); |
- | |
762 | parent_target = _cairo_gstate_get_parent_target (cr->gstate); |
- | |
763 | - | ||
764 | /* Verify that we are at the right nesting level */ |
- | |
765 | if (parent_target == NULL) { |
- | |
766 | _cairo_set_error (cr, CAIRO_STATUS_INVALID_POP_GROUP); |
- | |
767 | return _cairo_pattern_create_in_error (CAIRO_STATUS_INVALID_POP_GROUP); |
- | |
768 | } |
- | |
769 | - | ||
770 | /* We need to save group_surface before we restore; we don't need |
- | |
771 | * to reference parent_target and original_target, since the |
- | |
772 | * gstate will still hold refs to them once we restore. */ |
- | |
773 | group_surface = cairo_surface_reference (group_surface); |
- | |
774 | - | ||
775 | cairo_restore (cr); |
- | |
776 | - | ||
777 | if (unlikely (cr->status)) { |
- | |
778 | group_pattern = _cairo_pattern_create_in_error (cr->status); |
- | |
779 | goto done; |
- | |
780 | } |
548 | return _cairo_pattern_create_in_error (cr->status); |
781 | 549 | ||
782 | group_pattern = cairo_pattern_create_for_surface (group_surface); |
- | |
783 | status = group_pattern->status; |
550 | group_pattern = cr->backend->pop_group (cr); |
784 | if (unlikely (status)) { |
- | |
785 | _cairo_set_error (cr, status); |
- | |
786 | goto done; |
- | |
787 | } |
- | |
788 | - | ||
789 | _cairo_gstate_get_matrix (cr->gstate, &group_matrix); |
- | |
790 | /* Transform by group_matrix centered around device_transform so that when |
- | |
791 | * we call _cairo_gstate_copy_transformed_pattern the result is a pattern |
- | |
792 | * with a matrix equivalent to the device_transform of group_surface. */ |
- | |
793 | if (_cairo_surface_has_device_transform (group_surface)) { |
- | |
794 | cairo_pattern_set_matrix (group_pattern, &group_surface->device_transform); |
- | |
795 | _cairo_pattern_transform (group_pattern, &group_matrix); |
- | |
796 | _cairo_pattern_transform (group_pattern, &group_surface->device_transform_inverse); |
- | |
797 | } else { |
- | |
798 | cairo_pattern_set_matrix (group_pattern, &group_matrix); |
- | |
799 | } |
- | |
800 | - | ||
801 | /* If we have a current path, we need to adjust it to compensate for |
- | |
802 | * the device offset just removed. */ |
- | |
803 | cairo_matrix_multiply (&device_transform_matrix, |
- | |
804 | &_cairo_gstate_get_target (cr->gstate)->device_transform, |
- | |
805 | &group_surface->device_transform_inverse); |
- | |
806 | _cairo_path_fixed_transform (cr->path, &device_transform_matrix); |
- | |
807 | - | ||
Line 808... | Line 551... | ||
808 | done: |
551 | if (unlikely (group_pattern->status)) |
809 | cairo_surface_destroy (group_surface); |
552 | _cairo_set_error (cr, group_pattern->status); |
810 | 553 | ||
Line 822... | Line 565... | ||
822 | * |
565 | * |
823 | * The behavior of this function is equivalent to the sequence of |
566 | * The behavior of this function is equivalent to the sequence of |
824 | * operations: |
567 | * operations: |
825 | * |
568 | * |
826 | * |
569 | * |
827 | * #cairo_pattern_t *group = cairo_pop_group (cr); |
570 | * cairo_pattern_t *group = cairo_pop_group (cr); |
828 | * cairo_set_source (cr, group); |
571 | * cairo_set_source (cr, group); |
829 | * cairo_pattern_destroy (group); |
572 | * cairo_pattern_destroy (group); |
830 | * |
573 | * |
831 | * |
574 | * |
832 | * but is more convenient as their is no need for a variable to store |
575 | * but is more convenient as their is no need for a variable to store |
Line 857... | Line 600... | ||
857 | * Sets the compositing operator to be used for all drawing |
600 | * Sets the compositing operator to be used for all drawing |
858 | * operations. See #cairo_operator_t for details on the semantics of |
601 | * operations. See #cairo_operator_t for details on the semantics of |
859 | * each available compositing operator. |
602 | * each available compositing operator. |
860 | * |
603 | * |
861 | * The default operator is %CAIRO_OPERATOR_OVER. |
604 | * The default operator is %CAIRO_OPERATOR_OVER. |
- | 605 | * |
|
- | 606 | * Since: 1.0 |
|
862 | **/ |
607 | **/ |
863 | void |
608 | void |
864 | cairo_set_operator (cairo_t *cr, cairo_operator_t op) |
609 | cairo_set_operator (cairo_t *cr, cairo_operator_t op) |
865 | { |
610 | { |
866 | cairo_status_t status; |
611 | cairo_status_t status; |
Line 867... | Line 612... | ||
867 | 612 | ||
868 | if (unlikely (cr->status)) |
613 | if (unlikely (cr->status)) |
Line 869... | Line 614... | ||
869 | return; |
614 | return; |
870 | 615 | ||
871 | status = _cairo_gstate_set_operator (cr->gstate, op); |
616 | status = cr->backend->set_operator (cr, op); |
872 | if (unlikely (status)) |
617 | if (unlikely (status)) |
873 | _cairo_set_error (cr, status); |
618 | _cairo_set_error (cr, status); |
Line -... | Line 619... | ||
- | 619 | } |
|
- | 620 | slim_hidden_def (cairo_set_operator); |
|
874 | } |
621 | |
- | 622 | ||
- | 623 | #if 0 |
|
- | 624 | /** |
|
- | 625 | * cairo_set_opacity: |
|
875 | slim_hidden_def (cairo_set_operator); |
626 | * @cr: a #cairo_t |
876 | 627 | * @opacity: the level of opacity to use when compositing |
|
- | 628 | * |
|
877 | 629 | * Sets the compositing opacity to be used for all drawing |
|
- | 630 | * operations. The effect is to fade out the operations |
|
878 | static cairo_bool_t |
631 | * using the alpha value. |
- | 632 | * |
|
- | 633 | * The default opacity is 1. |
|
879 | _current_source_matches_solid (cairo_t *cr, |
634 | * |
880 | double red, |
635 | * Since: TBD |
881 | double green, |
- | |
882 | double blue, |
636 | **/ |
883 | double alpha) |
- | |
884 | { |
- | |
885 | const cairo_pattern_t *current; |
- | |
886 | cairo_color_t color; |
- | |
Line 887... | Line 637... | ||
887 | 637 | void |
|
888 | current = cr->gstate->source; |
638 | cairo_set_opacity (cairo_t *cr, double opacity) |
889 | if (current->type != CAIRO_PATTERN_TYPE_SOLID) |
- | |
890 | return FALSE; |
- | |
Line 891... | Line 639... | ||
891 | 639 | { |
|
892 | red = _cairo_restrict_value (red, 0.0, 1.0); |
640 | cairo_status_t status; |
893 | green = _cairo_restrict_value (green, 0.0, 1.0); |
641 | |
894 | blue = _cairo_restrict_value (blue, 0.0, 1.0); |
642 | if (unlikely (cr->status)) |
- | 643 | return; |
|
- | 644 | ||
895 | alpha = _cairo_restrict_value (alpha, 0.0, 1.0); |
645 | status = cr->backend->set_opacity (cr, opacity); |
896 | 646 | if (unlikely (status)) |
|
897 | _cairo_color_init_rgba (&color, red, green, blue, alpha); |
647 | _cairo_set_error (cr, status); |
898 | return _cairo_color_equal (&color, |
648 | } |
899 | &((cairo_solid_pattern_t *) current)->color); |
649 | #endif |
900 | } |
650 | |
901 | /** |
651 | /** |
Line 913... | Line 663... | ||
913 | * 1. If the values passed in are outside that range, they will be |
663 | * 1. If the values passed in are outside that range, they will be |
914 | * clamped. |
664 | * clamped. |
915 | * |
665 | * |
916 | * The default source pattern is opaque black, (that is, it is |
666 | * The default source pattern is opaque black, (that is, it is |
917 | * equivalent to cairo_set_source_rgb(cr, 0.0, 0.0, 0.0)). |
667 | * equivalent to cairo_set_source_rgb(cr, 0.0, 0.0, 0.0)). |
- | 668 | * |
|
- | 669 | * Since: 1.0 |
|
918 | **/ |
670 | **/ |
919 | void |
671 | void |
920 | cairo_set_source_rgb (cairo_t *cr, double red, double green, double blue) |
672 | cairo_set_source_rgb (cairo_t *cr, double red, double green, double blue) |
921 | { |
673 | { |
922 | cairo_pattern_t *pattern; |
674 | cairo_status_t status; |
Line 923... | Line 675... | ||
923 | 675 | ||
924 | if (unlikely (cr->status)) |
676 | if (unlikely (cr->status)) |
Line 925... | Line 677... | ||
925 | return; |
677 | return; |
926 | - | ||
927 | if (_current_source_matches_solid (cr, red, green, blue, 1.)) |
- | |
928 | return; |
- | |
929 | - | ||
930 | /* push the current pattern to the freed lists */ |
- | |
931 | cairo_set_source (cr, (cairo_pattern_t *) &_cairo_pattern_black); |
- | |
932 | 678 | ||
933 | pattern = cairo_pattern_create_rgb (red, green, blue); |
679 | status = cr->backend->set_source_rgba (cr, red, green, blue, 1.); |
934 | cairo_set_source (cr, pattern); |
680 | if (unlikely (status)) |
935 | cairo_pattern_destroy (pattern); |
681 | _cairo_set_error (cr, status); |
Line 936... | Line 682... | ||
936 | } |
682 | } |
937 | slim_hidden_def (cairo_set_source_rgb); |
683 | slim_hidden_def (cairo_set_source_rgb); |
Line 952... | Line 698... | ||
952 | * range 0 to 1. If the values passed in are outside that range, they |
698 | * range 0 to 1. If the values passed in are outside that range, they |
953 | * will be clamped. |
699 | * will be clamped. |
954 | * |
700 | * |
955 | * The default source pattern is opaque black, (that is, it is |
701 | * The default source pattern is opaque black, (that is, it is |
956 | * equivalent to cairo_set_source_rgba(cr, 0.0, 0.0, 0.0, 1.0)). |
702 | * equivalent to cairo_set_source_rgba(cr, 0.0, 0.0, 0.0, 1.0)). |
- | 703 | * |
|
- | 704 | * Since: 1.0 |
|
957 | **/ |
705 | **/ |
958 | void |
706 | void |
959 | cairo_set_source_rgba (cairo_t *cr, |
707 | cairo_set_source_rgba (cairo_t *cr, |
960 | double red, double green, double blue, |
708 | double red, double green, double blue, |
961 | double alpha) |
709 | double alpha) |
962 | { |
710 | { |
963 | cairo_pattern_t *pattern; |
711 | cairo_status_t status; |
Line 964... | Line 712... | ||
964 | 712 | ||
965 | if (unlikely (cr->status)) |
713 | if (unlikely (cr->status)) |
Line 966... | Line -... | ||
966 | return; |
- | |
967 | - | ||
968 | if (_current_source_matches_solid (cr, red, green, blue, alpha)) |
- | |
969 | return; |
- | |
970 | - | ||
971 | /* push the current pattern to the freed lists */ |
- | |
972 | cairo_set_source (cr, (cairo_pattern_t *) &_cairo_pattern_black); |
714 | return; |
973 | 715 | ||
974 | pattern = cairo_pattern_create_rgba (red, green, blue, alpha); |
716 | status = cr->backend->set_source_rgba (cr, red, green, blue, alpha); |
975 | cairo_set_source (cr, pattern); |
717 | if (unlikely (status)) |
Line 976... | Line 718... | ||
976 | cairo_pattern_destroy (pattern); |
718 | _cairo_set_error (cr, status); |
977 | } |
719 | } |
978 | 720 | ||
Line 996... | Line 738... | ||
996 | * above, all other pattern attributes, (such as its extend mode), are |
738 | * above, all other pattern attributes, (such as its extend mode), are |
997 | * set to the default values as in cairo_pattern_create_for_surface(). |
739 | * set to the default values as in cairo_pattern_create_for_surface(). |
998 | * The resulting pattern can be queried with cairo_get_source() so |
740 | * The resulting pattern can be queried with cairo_get_source() so |
999 | * that these attributes can be modified if desired, (eg. to create a |
741 | * that these attributes can be modified if desired, (eg. to create a |
1000 | * repeating pattern with cairo_pattern_set_extend()). |
742 | * repeating pattern with cairo_pattern_set_extend()). |
- | 743 | * |
|
- | 744 | * Since: 1.0 |
|
1001 | **/ |
745 | **/ |
1002 | void |
746 | void |
1003 | cairo_set_source_surface (cairo_t *cr, |
747 | cairo_set_source_surface (cairo_t *cr, |
1004 | cairo_surface_t *surface, |
748 | cairo_surface_t *surface, |
1005 | double x, |
749 | double x, |
1006 | double y) |
750 | double y) |
1007 | { |
751 | { |
1008 | cairo_pattern_t *pattern; |
- | |
1009 | cairo_matrix_t matrix; |
752 | cairo_status_t status; |
Line 1010... | Line 753... | ||
1010 | 753 | ||
1011 | if (unlikely (cr->status)) |
754 | if (unlikely (cr->status)) |
Line 1012... | Line 755... | ||
1012 | return; |
755 | return; |
1013 | 756 | ||
1014 | /* push the current pattern to the freed lists */ |
757 | if (unlikely (surface == NULL)) { |
1015 | cairo_set_source (cr, (cairo_pattern_t *) &_cairo_pattern_black); |
- | |
1016 | 758 | _cairo_set_error (cr, CAIRO_STATUS_NULL_POINTER); |
|
1017 | pattern = cairo_pattern_create_for_surface (surface); |
- | |
1018 | - | ||
Line -... | Line 759... | ||
- | 759 | return; |
|
1019 | cairo_matrix_init_translate (&matrix, -x, -y); |
760 | } |
1020 | cairo_pattern_set_matrix (pattern, &matrix); |
761 | |
1021 | 762 | status = cr->backend->set_source_surface (cr, surface, x, y); |
|
1022 | cairo_set_source (cr, pattern); |
763 | if (unlikely (status)) |
Line 1023... | Line 764... | ||
1023 | cairo_pattern_destroy (pattern); |
764 | _cairo_set_error (cr, status); |
1024 | } |
765 | } |
1025 | slim_hidden_def (cairo_set_source_surface); |
766 | slim_hidden_def (cairo_set_source_surface); |
1026 | 767 | ||
1027 | /** |
768 | /** |
1028 | * cairo_set_source |
769 | * cairo_set_source: |
1029 | * @cr: a cairo context |
770 | * @cr: a cairo context |
Line 1040... | Line 781... | ||
1040 | * will not affect the source pattern. See cairo_pattern_set_matrix(). |
781 | * will not affect the source pattern. See cairo_pattern_set_matrix(). |
1041 | * |
782 | * |
1042 | * The default source pattern is a solid pattern that is opaque black, |
783 | * The default source pattern is a solid pattern that is opaque black, |
1043 | * (that is, it is equivalent to cairo_set_source_rgb(cr, 0.0, 0.0, |
784 | * (that is, it is equivalent to cairo_set_source_rgb(cr, 0.0, 0.0, |
1044 | * 0.0)). |
785 | * 0.0)). |
- | 786 | * |
|
- | 787 | * Since: 1.0 |
|
1045 | **/ |
788 | **/ |
1046 | void |
789 | void |
1047 | cairo_set_source (cairo_t *cr, cairo_pattern_t *source) |
790 | cairo_set_source (cairo_t *cr, cairo_pattern_t *source) |
1048 | { |
791 | { |
1049 | cairo_status_t status; |
792 | cairo_status_t status; |
Line 1050... | Line 793... | ||
1050 | 793 | ||
1051 | if (unlikely (cr->status)) |
794 | if (unlikely (cr->status)) |
Line 1052... | Line 795... | ||
1052 | return; |
795 | return; |
1053 | 796 | ||
1054 | if (source == NULL) { |
797 | if (unlikely (source == NULL)) { |
1055 | _cairo_set_error (cr, CAIRO_STATUS_NULL_POINTER); |
798 | _cairo_set_error (cr, CAIRO_STATUS_NULL_POINTER); |
Line 1056... | Line 799... | ||
1056 | return; |
799 | return; |
1057 | } |
800 | } |
1058 | 801 | ||
1059 | if (source->status) { |
802 | if (unlikely (source->status)) { |
Line 1060... | Line 803... | ||
1060 | _cairo_set_error (cr, source->status); |
803 | _cairo_set_error (cr, source->status); |
1061 | return; |
804 | return; |
1062 | } |
805 | } |
1063 | 806 | ||
1064 | status = _cairo_gstate_set_source (cr->gstate, source); |
807 | status = cr->backend->set_source (cr, source); |
Line 1074... | Line 817... | ||
1074 | * Gets the current source pattern for @cr. |
817 | * Gets the current source pattern for @cr. |
1075 | * |
818 | * |
1076 | * Return value: the current source pattern. This object is owned by |
819 | * Return value: the current source pattern. This object is owned by |
1077 | * cairo. To keep a reference to it, you must call |
820 | * cairo. To keep a reference to it, you must call |
1078 | * cairo_pattern_reference(). |
821 | * cairo_pattern_reference(). |
- | 822 | * |
|
- | 823 | * Since: 1.0 |
|
1079 | **/ |
824 | **/ |
1080 | cairo_pattern_t * |
825 | cairo_pattern_t * |
1081 | cairo_get_source (cairo_t *cr) |
826 | cairo_get_source (cairo_t *cr) |
1082 | { |
827 | { |
1083 | if (unlikely (cr->status)) |
828 | if (unlikely (cr->status)) |
1084 | return _cairo_pattern_create_in_error (cr->status); |
829 | return _cairo_pattern_create_in_error (cr->status); |
Line 1085... | Line 830... | ||
1085 | 830 | ||
1086 | return _cairo_gstate_get_source (cr->gstate); |
831 | return cr->backend->get_source (cr); |
Line 1087... | Line 832... | ||
1087 | } |
832 | } |
1088 | 833 | ||
1089 | /** |
834 | /** |
Line 1099... | Line 844... | ||
1099 | * appearance. (Reducing the value from the default value of 0.1 |
844 | * appearance. (Reducing the value from the default value of 0.1 |
1100 | * is unlikely to improve appearance significantly.) The accuracy of paths |
845 | * is unlikely to improve appearance significantly.) The accuracy of paths |
1101 | * within Cairo is limited by the precision of its internal arithmetic, and |
846 | * within Cairo is limited by the precision of its internal arithmetic, and |
1102 | * the prescribed @tolerance is restricted to the smallest |
847 | * the prescribed @tolerance is restricted to the smallest |
1103 | * representable internal value. |
848 | * representable internal value. |
- | 849 | * |
|
- | 850 | * Since: 1.0 |
|
1104 | **/ |
851 | **/ |
1105 | void |
852 | void |
1106 | cairo_set_tolerance (cairo_t *cr, double tolerance) |
853 | cairo_set_tolerance (cairo_t *cr, double tolerance) |
1107 | { |
854 | { |
1108 | cairo_status_t status; |
855 | cairo_status_t status; |
Line 1109... | Line 856... | ||
1109 | 856 | ||
1110 | if (unlikely (cr->status)) |
857 | if (unlikely (cr->status)) |
Line 1111... | Line -... | ||
1111 | return; |
- | |
1112 | - | ||
1113 | if (tolerance < CAIRO_TOLERANCE_MINIMUM) |
- | |
1114 | tolerance = CAIRO_TOLERANCE_MINIMUM; |
858 | return; |
1115 | 859 | ||
1116 | status = _cairo_gstate_set_tolerance (cr->gstate, tolerance); |
860 | status = cr->backend->set_tolerance (cr, tolerance); |
1117 | if (unlikely (status)) |
861 | if (unlikely (status)) |
1118 | _cairo_set_error (cr, status); |
862 | _cairo_set_error (cr, status); |
Line 1129... | Line 873... | ||
1129 | * a particular value. At the current time, no backend supports |
873 | * a particular value. At the current time, no backend supports |
1130 | * %CAIRO_ANTIALIAS_SUBPIXEL when drawing shapes. |
874 | * %CAIRO_ANTIALIAS_SUBPIXEL when drawing shapes. |
1131 | * |
875 | * |
1132 | * Note that this option does not affect text rendering, instead see |
876 | * Note that this option does not affect text rendering, instead see |
1133 | * cairo_font_options_set_antialias(). |
877 | * cairo_font_options_set_antialias(). |
- | 878 | * |
|
- | 879 | * Since: 1.0 |
|
1134 | **/ |
880 | **/ |
1135 | void |
881 | void |
1136 | cairo_set_antialias (cairo_t *cr, cairo_antialias_t antialias) |
882 | cairo_set_antialias (cairo_t *cr, cairo_antialias_t antialias) |
1137 | { |
883 | { |
1138 | cairo_status_t status; |
884 | cairo_status_t status; |
Line 1139... | Line 885... | ||
1139 | 885 | ||
1140 | if (unlikely (cr->status)) |
886 | if (unlikely (cr->status)) |
Line 1141... | Line 887... | ||
1141 | return; |
887 | return; |
1142 | 888 | ||
1143 | status = _cairo_gstate_set_antialias (cr->gstate, antialias); |
889 | status = cr->backend->set_antialias (cr, antialias); |
1144 | if (unlikely (status)) |
890 | if (unlikely (status)) |
Line 1145... | Line 891... | ||
1145 | _cairo_set_error (cr, status); |
891 | _cairo_set_error (cr, status); |
Line 1155... | Line 901... | ||
1155 | * (potentially self-intersecting) path. The current fill rule affects |
901 | * (potentially self-intersecting) path. The current fill rule affects |
1156 | * both cairo_fill() and cairo_clip(). See #cairo_fill_rule_t for details |
902 | * both cairo_fill() and cairo_clip(). See #cairo_fill_rule_t for details |
1157 | * on the semantics of each available fill rule. |
903 | * on the semantics of each available fill rule. |
1158 | * |
904 | * |
1159 | * The default fill rule is %CAIRO_FILL_RULE_WINDING. |
905 | * The default fill rule is %CAIRO_FILL_RULE_WINDING. |
- | 906 | * |
|
- | 907 | * Since: 1.0 |
|
1160 | **/ |
908 | **/ |
1161 | void |
909 | void |
1162 | cairo_set_fill_rule (cairo_t *cr, cairo_fill_rule_t fill_rule) |
910 | cairo_set_fill_rule (cairo_t *cr, cairo_fill_rule_t fill_rule) |
1163 | { |
911 | { |
1164 | cairo_status_t status; |
912 | cairo_status_t status; |
Line 1165... | Line 913... | ||
1165 | 913 | ||
1166 | if (unlikely (cr->status)) |
914 | if (unlikely (cr->status)) |
Line 1167... | Line 915... | ||
1167 | return; |
915 | return; |
1168 | 916 | ||
1169 | status = _cairo_gstate_set_fill_rule (cr->gstate, fill_rule); |
917 | status = cr->backend->set_fill_rule (cr, fill_rule); |
1170 | if (unlikely (status)) |
918 | if (unlikely (status)) |
Line 1171... | Line 919... | ||
1171 | _cairo_set_error (cr, status); |
919 | _cairo_set_error (cr, status); |
Line 1194... | Line 942... | ||
1194 | * examined by cairo_stroke(), cairo_stroke_extents(), and |
942 | * examined by cairo_stroke(), cairo_stroke_extents(), and |
1195 | * cairo_stroke_to_path(), but does not have any effect during path |
943 | * cairo_stroke_to_path(), but does not have any effect during path |
1196 | * construction. |
944 | * construction. |
1197 | * |
945 | * |
1198 | * The default line width value is 2.0. |
946 | * The default line width value is 2.0. |
- | 947 | * |
|
- | 948 | * Since: 1.0 |
|
1199 | **/ |
949 | **/ |
1200 | void |
950 | void |
1201 | cairo_set_line_width (cairo_t *cr, double width) |
951 | cairo_set_line_width (cairo_t *cr, double width) |
1202 | { |
952 | { |
1203 | cairo_status_t status; |
953 | cairo_status_t status; |
Line 1206... | Line 956... | ||
1206 | return; |
956 | return; |
Line 1207... | Line 957... | ||
1207 | 957 | ||
1208 | if (width < 0.) |
958 | if (width < 0.) |
Line 1209... | Line 959... | ||
1209 | width = 0.; |
959 | width = 0.; |
1210 | 960 | ||
1211 | status = _cairo_gstate_set_line_width (cr->gstate, width); |
961 | status = cr->backend->set_line_width (cr, width); |
1212 | if (unlikely (status)) |
962 | if (unlikely (status)) |
1213 | _cairo_set_error (cr, status); |
963 | _cairo_set_error (cr, status); |
Line 1227... | Line 977... | ||
1227 | * examined by cairo_stroke(), cairo_stroke_extents(), and |
977 | * examined by cairo_stroke(), cairo_stroke_extents(), and |
1228 | * cairo_stroke_to_path(), but does not have any effect during path |
978 | * cairo_stroke_to_path(), but does not have any effect during path |
1229 | * construction. |
979 | * construction. |
1230 | * |
980 | * |
1231 | * The default line cap style is %CAIRO_LINE_CAP_BUTT. |
981 | * The default line cap style is %CAIRO_LINE_CAP_BUTT. |
- | 982 | * |
|
- | 983 | * Since: 1.0 |
|
1232 | **/ |
984 | **/ |
1233 | void |
985 | void |
1234 | cairo_set_line_cap (cairo_t *cr, cairo_line_cap_t line_cap) |
986 | cairo_set_line_cap (cairo_t *cr, cairo_line_cap_t line_cap) |
1235 | { |
987 | { |
1236 | cairo_status_t status; |
988 | cairo_status_t status; |
Line 1237... | Line 989... | ||
1237 | 989 | ||
1238 | if (unlikely (cr->status)) |
990 | if (unlikely (cr->status)) |
Line 1239... | Line 991... | ||
1239 | return; |
991 | return; |
1240 | 992 | ||
1241 | status = _cairo_gstate_set_line_cap (cr->gstate, line_cap); |
993 | status = cr->backend->set_line_cap (cr, line_cap); |
1242 | if (unlikely (status)) |
994 | if (unlikely (status)) |
1243 | _cairo_set_error (cr, status); |
995 | _cairo_set_error (cr, status); |
Line 1257... | Line 1009... | ||
1257 | * examined by cairo_stroke(), cairo_stroke_extents(), and |
1009 | * examined by cairo_stroke(), cairo_stroke_extents(), and |
1258 | * cairo_stroke_to_path(), but does not have any effect during path |
1010 | * cairo_stroke_to_path(), but does not have any effect during path |
1259 | * construction. |
1011 | * construction. |
1260 | * |
1012 | * |
1261 | * The default line join style is %CAIRO_LINE_JOIN_MITER. |
1013 | * The default line join style is %CAIRO_LINE_JOIN_MITER. |
- | 1014 | * |
|
- | 1015 | * Since: 1.0 |
|
1262 | **/ |
1016 | **/ |
1263 | void |
1017 | void |
1264 | cairo_set_line_join (cairo_t *cr, cairo_line_join_t line_join) |
1018 | cairo_set_line_join (cairo_t *cr, cairo_line_join_t line_join) |
1265 | { |
1019 | { |
1266 | cairo_status_t status; |
1020 | cairo_status_t status; |
Line 1267... | Line 1021... | ||
1267 | 1021 | ||
1268 | if (unlikely (cr->status)) |
1022 | if (unlikely (cr->status)) |
Line 1269... | Line 1023... | ||
1269 | return; |
1023 | return; |
1270 | 1024 | ||
1271 | status = _cairo_gstate_set_line_join (cr->gstate, line_join); |
1025 | status = cr->backend->set_line_join (cr, line_join); |
1272 | if (unlikely (status)) |
1026 | if (unlikely (status)) |
1273 | _cairo_set_error (cr, status); |
1027 | _cairo_set_error (cr, status); |
Line 1303... | Line 1057... | ||
1303 | * @dashes. |
1057 | * @dashes. |
1304 | * |
1058 | * |
1305 | * If any value in @dashes is negative, or if all values are 0, then |
1059 | * 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 |
1060 | * @cr will be put into an error state with a status of |
1307 | * %CAIRO_STATUS_INVALID_DASH. |
1061 | * %CAIRO_STATUS_INVALID_DASH. |
- | 1062 | * |
|
- | 1063 | * Since: 1.0 |
|
1308 | **/ |
1064 | **/ |
1309 | void |
1065 | void |
1310 | cairo_set_dash (cairo_t *cr, |
1066 | cairo_set_dash (cairo_t *cr, |
1311 | const double *dashes, |
1067 | const double *dashes, |
1312 | int num_dashes, |
1068 | int num_dashes, |
Line 1315... | Line 1071... | ||
1315 | cairo_status_t status; |
1071 | cairo_status_t status; |
Line 1316... | Line 1072... | ||
1316 | 1072 | ||
1317 | if (unlikely (cr->status)) |
1073 | if (unlikely (cr->status)) |
Line 1318... | Line 1074... | ||
1318 | return; |
1074 | return; |
1319 | - | ||
1320 | status = _cairo_gstate_set_dash (cr->gstate, |
1075 | |
1321 | dashes, num_dashes, offset); |
1076 | status = cr->backend->set_dash (cr, dashes, num_dashes, offset); |
1322 | if (unlikely (status)) |
1077 | if (unlikely (status)) |
Line 1323... | Line 1078... | ||
1323 | _cairo_set_error (cr, status); |
1078 | _cairo_set_error (cr, status); |
Line 1333... | Line 1088... | ||
1333 | * See also cairo_set_dash() and cairo_get_dash(). |
1088 | * See also cairo_set_dash() and cairo_get_dash(). |
1334 | * |
1089 | * |
1335 | * Return value: the length of the dash array, or 0 if no dash array set. |
1090 | * Return value: the length of the dash array, or 0 if no dash array set. |
1336 | * |
1091 | * |
1337 | * Since: 1.4 |
1092 | * Since: 1.4 |
1338 | */ |
1093 | **/ |
1339 | int |
1094 | int |
1340 | cairo_get_dash_count (cairo_t *cr) |
1095 | cairo_get_dash_count (cairo_t *cr) |
1341 | { |
1096 | { |
1342 | int num_dashes; |
1097 | int num_dashes; |
Line 1343... | Line 1098... | ||
1343 | 1098 | ||
1344 | if (unlikely (cr->status)) |
1099 | if (unlikely (cr->status)) |
Line 1345... | Line 1100... | ||
1345 | return 0; |
1100 | return 0; |
Line 1346... | Line 1101... | ||
1346 | 1101 | ||
1347 | _cairo_gstate_get_dash (cr->gstate, NULL, &num_dashes, NULL); |
1102 | cr->backend->get_dash (cr, NULL, &num_dashes, NULL); |
Line 1348... | Line 1103... | ||
1348 | 1103 | ||
Line 1367... | Line 1122... | ||
1367 | double *offset) |
1122 | double *offset) |
1368 | { |
1123 | { |
1369 | if (unlikely (cr->status)) |
1124 | if (unlikely (cr->status)) |
1370 | return; |
1125 | return; |
Line 1371... | Line 1126... | ||
1371 | 1126 | ||
1372 | _cairo_gstate_get_dash (cr->gstate, dashes, NULL, offset); |
1127 | cr->backend->get_dash (cr, dashes, NULL, offset); |
Line 1373... | Line 1128... | ||
1373 | } |
1128 | } |
1374 | 1129 | ||
1375 | /** |
1130 | /** |
Line 1397... | Line 1152... | ||
1397 | * at 60 degrees, and a miter limit of 1.414 makes the cutoff at 90 |
1152 | * at 60 degrees, and a miter limit of 1.414 makes the cutoff at 90 |
1398 | * degrees. |
1153 | * degrees. |
1399 | * |
1154 | * |
1400 | * A miter limit for a desired angle can be computed as: miter limit = |
1155 | * A miter limit for a desired angle can be computed as: miter limit = |
1401 | * 1/sin(angle/2) |
1156 | * 1/sin(angle/2) |
- | 1157 | * |
|
- | 1158 | * Since: 1.0 |
|
1402 | **/ |
1159 | **/ |
1403 | void |
1160 | void |
1404 | cairo_set_miter_limit (cairo_t *cr, double limit) |
1161 | cairo_set_miter_limit (cairo_t *cr, double limit) |
1405 | { |
1162 | { |
1406 | cairo_status_t status; |
1163 | cairo_status_t status; |
Line 1407... | Line 1164... | ||
1407 | 1164 | ||
1408 | if (unlikely (cr->status)) |
1165 | if (unlikely (cr->status)) |
Line 1409... | Line 1166... | ||
1409 | return; |
1166 | return; |
1410 | 1167 | ||
1411 | status = _cairo_gstate_set_miter_limit (cr->gstate, limit); |
1168 | status = cr->backend->set_miter_limit (cr, limit); |
1412 | if (unlikely (status)) |
1169 | if (unlikely (status)) |
Line 1413... | Line 1170... | ||
1413 | _cairo_set_error (cr, status); |
1170 | _cairo_set_error (cr, status); |
Line 1422... | Line 1179... | ||
1422 | * Modifies the current transformation matrix (CTM) by translating the |
1179 | * Modifies the current transformation matrix (CTM) by translating the |
1423 | * user-space origin by (@tx, @ty). This offset is interpreted as a |
1180 | * user-space origin by (@tx, @ty). This offset is interpreted as a |
1424 | * user-space coordinate according to the CTM in place before the new |
1181 | * user-space coordinate according to the CTM in place before the new |
1425 | * call to cairo_translate(). In other words, the translation of the |
1182 | * call to cairo_translate(). In other words, the translation of the |
1426 | * user-space origin takes place after any existing transformation. |
1183 | * user-space origin takes place after any existing transformation. |
- | 1184 | * |
|
- | 1185 | * Since: 1.0 |
|
1427 | **/ |
1186 | **/ |
1428 | void |
1187 | void |
1429 | cairo_translate (cairo_t *cr, double tx, double ty) |
1188 | cairo_translate (cairo_t *cr, double tx, double ty) |
1430 | { |
1189 | { |
1431 | cairo_status_t status; |
1190 | cairo_status_t status; |
Line 1432... | Line 1191... | ||
1432 | 1191 | ||
1433 | if (unlikely (cr->status)) |
1192 | if (unlikely (cr->status)) |
Line 1434... | Line 1193... | ||
1434 | return; |
1193 | return; |
1435 | 1194 | ||
1436 | status = _cairo_gstate_translate (cr->gstate, tx, ty); |
1195 | status = cr->backend->translate (cr, tx, ty); |
1437 | if (unlikely (status)) |
1196 | if (unlikely (status)) |
1438 | _cairo_set_error (cr, status); |
1197 | _cairo_set_error (cr, status); |
Line 1447... | Line 1206... | ||
1447 | * |
1206 | * |
1448 | * Modifies the current transformation matrix (CTM) by scaling the X |
1207 | * Modifies the current transformation matrix (CTM) by scaling the X |
1449 | * and Y user-space axes by @sx and @sy respectively. The scaling of |
1208 | * and Y user-space axes by @sx and @sy respectively. The scaling of |
1450 | * the axes takes place after any existing transformation of user |
1209 | * the axes takes place after any existing transformation of user |
1451 | * space. |
1210 | * space. |
- | 1211 | * |
|
- | 1212 | * Since: 1.0 |
|
1452 | **/ |
1213 | **/ |
1453 | void |
1214 | void |
1454 | cairo_scale (cairo_t *cr, double sx, double sy) |
1215 | cairo_scale (cairo_t *cr, double sx, double sy) |
1455 | { |
1216 | { |
1456 | cairo_status_t status; |
1217 | cairo_status_t status; |
Line 1457... | Line 1218... | ||
1457 | 1218 | ||
1458 | if (unlikely (cr->status)) |
1219 | if (unlikely (cr->status)) |
Line 1459... | Line 1220... | ||
1459 | return; |
1220 | return; |
1460 | 1221 | ||
1461 | status = _cairo_gstate_scale (cr->gstate, sx, sy); |
1222 | status = cr->backend->scale (cr, sx, sy); |
1462 | if (unlikely (status)) |
1223 | if (unlikely (status)) |
1463 | _cairo_set_error (cr, status); |
1224 | _cairo_set_error (cr, status); |
Line 1473... | Line 1234... | ||
1473 | * Modifies the current transformation matrix (CTM) by rotating the |
1234 | * Modifies the current transformation matrix (CTM) by rotating the |
1474 | * user-space axes by @angle radians. The rotation of the axes takes |
1235 | * user-space axes by @angle radians. The rotation of the axes takes |
1475 | * places after any existing transformation of user space. The |
1236 | * places after any existing transformation of user space. The |
1476 | * rotation direction for positive angles is from the positive X axis |
1237 | * rotation direction for positive angles is from the positive X axis |
1477 | * toward the positive Y axis. |
1238 | * toward the positive Y axis. |
- | 1239 | * |
|
- | 1240 | * Since: 1.0 |
|
1478 | **/ |
1241 | **/ |
1479 | void |
1242 | void |
1480 | cairo_rotate (cairo_t *cr, double angle) |
1243 | cairo_rotate (cairo_t *cr, double angle) |
1481 | { |
1244 | { |
1482 | cairo_status_t status; |
1245 | cairo_status_t status; |
Line 1483... | Line 1246... | ||
1483 | 1246 | ||
1484 | if (unlikely (cr->status)) |
1247 | if (unlikely (cr->status)) |
Line 1485... | Line 1248... | ||
1485 | return; |
1248 | return; |
1486 | 1249 | ||
1487 | status = _cairo_gstate_rotate (cr->gstate, angle); |
1250 | status = cr->backend->rotate (cr, angle); |
1488 | if (unlikely (status)) |
1251 | if (unlikely (status)) |
Line 1489... | Line 1252... | ||
1489 | _cairo_set_error (cr, status); |
1252 | _cairo_set_error (cr, status); |
Line 1495... | Line 1258... | ||
1495 | * @matrix: a transformation to be applied to the user-space axes |
1258 | * @matrix: a transformation to be applied to the user-space axes |
1496 | * |
1259 | * |
1497 | * Modifies the current transformation matrix (CTM) by applying |
1260 | * Modifies the current transformation matrix (CTM) by applying |
1498 | * @matrix as an additional transformation. The new transformation of |
1261 | * @matrix as an additional transformation. The new transformation of |
1499 | * user space takes place after any existing transformation. |
1262 | * user space takes place after any existing transformation. |
- | 1263 | * |
|
- | 1264 | * Since: 1.0 |
|
1500 | **/ |
1265 | **/ |
1501 | void |
1266 | void |
1502 | cairo_transform (cairo_t *cr, |
1267 | cairo_transform (cairo_t *cr, |
1503 | const cairo_matrix_t *matrix) |
1268 | const cairo_matrix_t *matrix) |
1504 | { |
1269 | { |
1505 | cairo_status_t status; |
1270 | cairo_status_t status; |
Line 1506... | Line 1271... | ||
1506 | 1271 | ||
1507 | if (unlikely (cr->status)) |
1272 | if (unlikely (cr->status)) |
Line 1508... | Line 1273... | ||
1508 | return; |
1273 | return; |
1509 | 1274 | ||
1510 | status = _cairo_gstate_transform (cr->gstate, matrix); |
1275 | status = cr->backend->transform (cr, matrix); |
1511 | if (unlikely (status)) |
1276 | if (unlikely (status)) |
1512 | _cairo_set_error (cr, status); |
1277 | _cairo_set_error (cr, status); |
Line 1518... | Line 1283... | ||
1518 | * @cr: a cairo context |
1283 | * @cr: a cairo context |
1519 | * @matrix: a transformation matrix from user space to device space |
1284 | * @matrix: a transformation matrix from user space to device space |
1520 | * |
1285 | * |
1521 | * Modifies the current transformation matrix (CTM) by setting it |
1286 | * Modifies the current transformation matrix (CTM) by setting it |
1522 | * equal to @matrix. |
1287 | * equal to @matrix. |
- | 1288 | * |
|
- | 1289 | * Since: 1.0 |
|
1523 | **/ |
1290 | **/ |
1524 | void |
1291 | void |
1525 | cairo_set_matrix (cairo_t *cr, |
1292 | cairo_set_matrix (cairo_t *cr, |
1526 | const cairo_matrix_t *matrix) |
1293 | const cairo_matrix_t *matrix) |
1527 | { |
1294 | { |
1528 | cairo_status_t status; |
1295 | cairo_status_t status; |
Line 1529... | Line 1296... | ||
1529 | 1296 | ||
1530 | if (unlikely (cr->status)) |
1297 | if (unlikely (cr->status)) |
Line 1531... | Line 1298... | ||
1531 | return; |
1298 | return; |
1532 | 1299 | ||
1533 | status = _cairo_gstate_set_matrix (cr->gstate, matrix); |
1300 | status = cr->backend->set_matrix (cr, matrix); |
1534 | if (unlikely (status)) |
1301 | if (unlikely (status)) |
1535 | _cairo_set_error (cr, status); |
1302 | _cairo_set_error (cr, status); |
Line 1542... | Line 1309... | ||
1542 | * |
1309 | * |
1543 | * Resets the current transformation matrix (CTM) by setting it equal |
1310 | * Resets the current transformation matrix (CTM) by setting it equal |
1544 | * to the identity matrix. That is, the user-space and device-space |
1311 | * to the identity matrix. That is, the user-space and device-space |
1545 | * axes will be aligned and one user-space unit will transform to one |
1312 | * axes will be aligned and one user-space unit will transform to one |
1546 | * device-space unit. |
1313 | * device-space unit. |
- | 1314 | * |
|
- | 1315 | * Since: 1.0 |
|
1547 | **/ |
1316 | **/ |
1548 | void |
1317 | void |
1549 | cairo_identity_matrix (cairo_t *cr) |
1318 | cairo_identity_matrix (cairo_t *cr) |
1550 | { |
1319 | { |
- | 1320 | cairo_status_t status; |
|
- | 1321 | ||
1551 | if (unlikely (cr->status)) |
1322 | if (unlikely (cr->status)) |
1552 | return; |
1323 | return; |
Line 1553... | Line 1324... | ||
1553 | 1324 | ||
- | 1325 | status = cr->backend->set_identity_matrix (cr); |
|
- | 1326 | if (unlikely (status)) |
|
1554 | _cairo_gstate_identity_matrix (cr->gstate); |
1327 | _cairo_set_error (cr, status); |
Line 1555... | Line 1328... | ||
1555 | } |
1328 | } |
1556 | 1329 | ||
1557 | /** |
1330 | /** |
Line 1561... | Line 1334... | ||
1561 | * @y: Y value of coordinate (in/out parameter) |
1334 | * @y: Y value of coordinate (in/out parameter) |
1562 | * |
1335 | * |
1563 | * Transform a coordinate from user space to device space by |
1336 | * Transform a coordinate from user space to device space by |
1564 | * multiplying the given point by the current transformation matrix |
1337 | * multiplying the given point by the current transformation matrix |
1565 | * (CTM). |
1338 | * (CTM). |
- | 1339 | * |
|
- | 1340 | * Since: 1.0 |
|
1566 | **/ |
1341 | **/ |
1567 | void |
1342 | void |
1568 | cairo_user_to_device (cairo_t *cr, double *x, double *y) |
1343 | cairo_user_to_device (cairo_t *cr, double *x, double *y) |
1569 | { |
1344 | { |
1570 | if (unlikely (cr->status)) |
1345 | if (unlikely (cr->status)) |
1571 | return; |
1346 | return; |
Line 1572... | Line 1347... | ||
1572 | 1347 | ||
1573 | _cairo_gstate_user_to_device (cr->gstate, x, y); |
1348 | cr->backend->user_to_device (cr, x, y); |
1574 | } |
1349 | } |
Line 1575... | Line 1350... | ||
1575 | slim_hidden_def (cairo_user_to_device); |
1350 | slim_hidden_def (cairo_user_to_device); |
1576 | 1351 | ||
Line 1582... | Line 1357... | ||
1582 | * |
1357 | * |
1583 | * Transform a distance vector from user space to device space. This |
1358 | * Transform a distance vector from user space to device space. This |
1584 | * function is similar to cairo_user_to_device() except that the |
1359 | * function is similar to cairo_user_to_device() except that the |
1585 | * translation components of the CTM will be ignored when transforming |
1360 | * translation components of the CTM will be ignored when transforming |
1586 | * (@dx,@dy). |
1361 | * (@dx,@dy). |
- | 1362 | * |
|
- | 1363 | * Since: 1.0 |
|
1587 | **/ |
1364 | **/ |
1588 | void |
1365 | void |
1589 | cairo_user_to_device_distance (cairo_t *cr, double *dx, double *dy) |
1366 | cairo_user_to_device_distance (cairo_t *cr, double *dx, double *dy) |
1590 | { |
1367 | { |
1591 | if (unlikely (cr->status)) |
1368 | if (unlikely (cr->status)) |
1592 | return; |
1369 | return; |
Line 1593... | Line 1370... | ||
1593 | 1370 | ||
1594 | _cairo_gstate_user_to_device_distance (cr->gstate, dx, dy); |
1371 | cr->backend->user_to_device_distance (cr, dx, dy); |
1595 | } |
1372 | } |
Line 1596... | Line 1373... | ||
1596 | slim_hidden_def (cairo_user_to_device_distance); |
1373 | slim_hidden_def (cairo_user_to_device_distance); |
1597 | 1374 | ||
Line 1602... | Line 1379... | ||
1602 | * @y: Y value of coordinate (in/out parameter) |
1379 | * @y: Y value of coordinate (in/out parameter) |
1603 | * |
1380 | * |
1604 | * Transform a coordinate from device space to user space by |
1381 | * Transform a coordinate from device space to user space by |
1605 | * multiplying the given point by the inverse of the current |
1382 | * multiplying the given point by the inverse of the current |
1606 | * transformation matrix (CTM). |
1383 | * transformation matrix (CTM). |
- | 1384 | * |
|
- | 1385 | * Since: 1.0 |
|
1607 | **/ |
1386 | **/ |
1608 | void |
1387 | void |
1609 | cairo_device_to_user (cairo_t *cr, double *x, double *y) |
1388 | cairo_device_to_user (cairo_t *cr, double *x, double *y) |
1610 | { |
1389 | { |
1611 | if (unlikely (cr->status)) |
1390 | if (unlikely (cr->status)) |
1612 | return; |
1391 | return; |
Line 1613... | Line 1392... | ||
1613 | 1392 | ||
1614 | _cairo_gstate_device_to_user (cr->gstate, x, y); |
1393 | cr->backend->device_to_user (cr, x, y); |
- | 1394 | } |
|
Line 1615... | Line 1395... | ||
1615 | } |
1395 | slim_hidden_def (cairo_device_to_user); |
1616 | 1396 | ||
1617 | /** |
1397 | /** |
1618 | * cairo_device_to_user_distance: |
1398 | * cairo_device_to_user_distance: |
Line 1622... | Line 1402... | ||
1622 | * |
1402 | * |
1623 | * Transform a distance vector from device space to user space. This |
1403 | * Transform a distance vector from device space to user space. This |
1624 | * function is similar to cairo_device_to_user() except that the |
1404 | * function is similar to cairo_device_to_user() except that the |
1625 | * translation components of the inverse CTM will be ignored when |
1405 | * translation components of the inverse CTM will be ignored when |
1626 | * transforming (@dx,@dy). |
1406 | * transforming (@dx,@dy). |
- | 1407 | * |
|
- | 1408 | * Since: 1.0 |
|
1627 | **/ |
1409 | **/ |
1628 | void |
1410 | void |
1629 | cairo_device_to_user_distance (cairo_t *cr, double *dx, double *dy) |
1411 | cairo_device_to_user_distance (cairo_t *cr, double *dx, double *dy) |
1630 | { |
1412 | { |
1631 | if (unlikely (cr->status)) |
1413 | if (unlikely (cr->status)) |
1632 | return; |
1414 | return; |
Line 1633... | Line 1415... | ||
1633 | 1415 | ||
1634 | _cairo_gstate_device_to_user_distance (cr->gstate, dx, dy); |
1416 | cr->backend->device_to_user_distance (cr, dx, dy); |
Line 1635... | Line 1417... | ||
1635 | } |
1417 | } |
1636 | 1418 | ||
1637 | /** |
1419 | /** |
1638 | * cairo_new_path: |
1420 | * cairo_new_path: |
1639 | * @cr: a cairo context |
1421 | * @cr: a cairo context |
1640 | * |
1422 | * |
1641 | * Clears the current path. After this call there will be no path and |
- | |
1642 | * no current point. |
- | |
1643 | **/ |
- | |
1644 | void |
- | |
1645 | cairo_new_path (cairo_t *cr) |
- | |
1646 | { |
- | |
1647 | if (unlikely (cr->status)) |
- | |
1648 | return; |
- | |
1649 | - | ||
1650 | _cairo_path_fixed_fini (cr->path); |
- | |
1651 | _cairo_path_fixed_init (cr->path); |
- | |
1652 | } |
- | |
1653 | slim_hidden_def(cairo_new_path); |
- | |
1654 | - | ||
1655 | /** |
- | |
1656 | * cairo_move_to: |
- | |
1657 | * @cr: a cairo context |
- | |
1658 | * @x: the X coordinate of the new position |
1423 | * Clears the current path. After this call there will be no path and |
1659 | * @y: the Y coordinate of the new position |
- | |
1660 | * |
1424 | * no current point. |
1661 | * Begin a new sub-path. After this call the current point will be (@x, |
1425 | * |
1662 | * @y). |
1426 | * Since: 1.0 |
1663 | **/ |
1427 | **/ |
1664 | void |
1428 | void |
1665 | cairo_move_to (cairo_t *cr, double x, double y) |
1429 | cairo_new_path (cairo_t *cr) |
1666 | { |
- | |
Line 1667... | Line 1430... | ||
1667 | cairo_status_t status; |
1430 | { |
1668 | cairo_fixed_t x_fixed, y_fixed; |
1431 | cairo_status_t status; |
Line 1669... | Line 1432... | ||
1669 | 1432 | ||
1670 | if (unlikely (cr->status)) |
- | |
1671 | return; |
- | |
1672 | - | ||
1673 | _cairo_gstate_user_to_backend (cr->gstate, &x, &y); |
- | |
1674 | x_fixed = _cairo_fixed_from_double (x); |
1433 | if (unlikely (cr->status)) |
1675 | y_fixed = _cairo_fixed_from_double (y); |
1434 | return; |
1676 | 1435 | ||
1677 | status = _cairo_path_fixed_move_to (cr->path, x_fixed, y_fixed); |
1436 | status = cr->backend->new_path (cr); |
Line 1678... | Line 1437... | ||
1678 | if (unlikely (status)) |
1437 | if (unlikely (status)) |
1679 | _cairo_set_error (cr, status); |
1438 | _cairo_set_error (cr, status); |
1680 | } |
1439 | } |
1681 | slim_hidden_def(cairo_move_to); |
1440 | slim_hidden_def(cairo_new_path); |
Line 1699... | Line 1458... | ||
1699 | * Since: 1.2 |
1458 | * Since: 1.2 |
1700 | **/ |
1459 | **/ |
1701 | void |
1460 | void |
1702 | cairo_new_sub_path (cairo_t *cr) |
1461 | cairo_new_sub_path (cairo_t *cr) |
1703 | { |
1462 | { |
- | 1463 | cairo_status_t status; |
|
- | 1464 | ||
1704 | if (unlikely (cr->status)) |
1465 | if (unlikely (cr->status)) |
1705 | return; |
1466 | return; |
Line 1706... | Line 1467... | ||
1706 | 1467 | ||
- | 1468 | status = cr->backend->new_sub_path (cr); |
|
- | 1469 | if (unlikely (status)) |
|
1707 | _cairo_path_fixed_new_sub_path (cr->path); |
1470 | _cairo_set_error (cr, status); |
Line 1708... | Line 1471... | ||
1708 | } |
1471 | } |
- | 1472 | ||
- | 1473 | /** |
|
- | 1474 | * cairo_move_to: |
|
- | 1475 | * @cr: a cairo context |
|
- | 1476 | * @x: the X coordinate of the new position |
|
- | 1477 | * @y: the Y coordinate of the new position |
|
- | 1478 | * |
|
- | 1479 | * Begin a new sub-path. After this call the current point will be (@x, |
|
- | 1480 | * @y). |
|
- | 1481 | * |
|
- | 1482 | * Since: 1.0 |
|
- | 1483 | **/ |
|
- | 1484 | void |
|
- | 1485 | cairo_move_to (cairo_t *cr, double x, double y) |
|
- | 1486 | { |
|
- | 1487 | cairo_status_t status; |
|
- | 1488 | ||
- | 1489 | if (unlikely (cr->status)) |
|
- | 1490 | return; |
|
- | 1491 | ||
- | 1492 | status = cr->backend->move_to (cr, x, y); |
|
- | 1493 | if (unlikely (status)) |
|
- | 1494 | _cairo_set_error (cr, status); |
|
- | 1495 | } |
|
- | 1496 | slim_hidden_def(cairo_move_to); |
|
- | 1497 | ||
1709 | 1498 | ||
1710 | /** |
1499 | /** |
1711 | * cairo_line_to: |
1500 | * cairo_line_to: |
1712 | * @cr: a cairo context |
1501 | * @cr: a cairo context |
1713 | * @x: the X coordinate of the end of the new line |
1502 | * @x: the X coordinate of the end of the new line |
Line 1717... | Line 1506... | ||
1717 | * in user-space coordinates. After this call the current point |
1506 | * in user-space coordinates. After this call the current point |
1718 | * will be (@x, @y). |
1507 | * will be (@x, @y). |
1719 | * |
1508 | * |
1720 | * If there is no current point before the call to cairo_line_to() |
1509 | * If there is no current point before the call to cairo_line_to() |
1721 | * this function will behave as cairo_move_to(@cr, @x, @y). |
1510 | * this function will behave as cairo_move_to(@cr, @x, @y). |
- | 1511 | * |
|
- | 1512 | * Since: 1.0 |
|
1722 | **/ |
1513 | **/ |
1723 | void |
1514 | void |
1724 | cairo_line_to (cairo_t *cr, double x, double y) |
1515 | cairo_line_to (cairo_t *cr, double x, double y) |
1725 | { |
1516 | { |
1726 | cairo_status_t status; |
1517 | cairo_status_t status; |
1727 | cairo_fixed_t x_fixed, y_fixed; |
- | |
Line 1728... | Line 1518... | ||
1728 | 1518 | ||
1729 | if (unlikely (cr->status)) |
1519 | if (unlikely (cr->status)) |
Line 1730... | Line -... | ||
1730 | return; |
- | |
1731 | - | ||
1732 | _cairo_gstate_user_to_backend (cr->gstate, &x, &y); |
- | |
1733 | x_fixed = _cairo_fixed_from_double (x); |
- | |
1734 | y_fixed = _cairo_fixed_from_double (y); |
1520 | return; |
1735 | 1521 | ||
1736 | status = _cairo_path_fixed_line_to (cr->path, x_fixed, y_fixed); |
1522 | status = cr->backend->line_to (cr, x, y); |
1737 | if (unlikely (status)) |
1523 | if (unlikely (status)) |
1738 | _cairo_set_error (cr, status); |
1524 | _cairo_set_error (cr, status); |
Line 1755... | Line 1541... | ||
1755 | * will be (@x3, @y3). |
1541 | * will be (@x3, @y3). |
1756 | * |
1542 | * |
1757 | * If there is no current point before the call to cairo_curve_to() |
1543 | * If there is no current point before the call to cairo_curve_to() |
1758 | * this function will behave as if preceded by a call to |
1544 | * this function will behave as if preceded by a call to |
1759 | * cairo_move_to(@cr, @x1, @y1). |
1545 | * cairo_move_to(@cr, @x1, @y1). |
- | 1546 | * |
|
- | 1547 | * Since: 1.0 |
|
1760 | **/ |
1548 | **/ |
1761 | void |
1549 | void |
1762 | cairo_curve_to (cairo_t *cr, |
1550 | cairo_curve_to (cairo_t *cr, |
1763 | double x1, double y1, |
1551 | double x1, double y1, |
1764 | double x2, double y2, |
1552 | double x2, double y2, |
1765 | double x3, double y3) |
1553 | double x3, double y3) |
1766 | { |
1554 | { |
1767 | cairo_status_t status; |
1555 | cairo_status_t status; |
1768 | cairo_fixed_t x1_fixed, y1_fixed; |
- | |
1769 | cairo_fixed_t x2_fixed, y2_fixed; |
- | |
1770 | cairo_fixed_t x3_fixed, y3_fixed; |
- | |
Line 1771... | Line 1556... | ||
1771 | 1556 | ||
1772 | if (unlikely (cr->status)) |
1557 | if (unlikely (cr->status)) |
Line 1773... | Line -... | ||
1773 | return; |
- | |
1774 | - | ||
1775 | _cairo_gstate_user_to_backend (cr->gstate, &x1, &y1); |
- | |
1776 | _cairo_gstate_user_to_backend (cr->gstate, &x2, &y2); |
- | |
1777 | _cairo_gstate_user_to_backend (cr->gstate, &x3, &y3); |
- | |
1778 | - | ||
1779 | x1_fixed = _cairo_fixed_from_double (x1); |
- | |
1780 | y1_fixed = _cairo_fixed_from_double (y1); |
- | |
1781 | - | ||
1782 | x2_fixed = _cairo_fixed_from_double (x2); |
- | |
1783 | y2_fixed = _cairo_fixed_from_double (y2); |
- | |
1784 | - | ||
1785 | x3_fixed = _cairo_fixed_from_double (x3); |
- | |
1786 | y3_fixed = _cairo_fixed_from_double (y3); |
1558 | return; |
1787 | 1559 | ||
1788 | status = _cairo_path_fixed_curve_to (cr->path, |
1560 | status = cr->backend->curve_to (cr, |
1789 | x1_fixed, y1_fixed, |
1561 | x1, y1, |
1790 | x2_fixed, y2_fixed, |
1562 | x2, y2, |
1791 | x3_fixed, y3_fixed); |
1563 | x3, y3); |
1792 | if (unlikely (status)) |
1564 | if (unlikely (status)) |
1793 | _cairo_set_error (cr, status); |
1565 | _cairo_set_error (cr, status); |
Line 1804... | Line 1576... | ||
1804 | * @angle2: the end angle, in radians |
1576 | * @angle2: the end angle, in radians |
1805 | * |
1577 | * |
1806 | * Adds a circular arc of the given @radius to the current path. The |
1578 | * Adds a circular arc of the given @radius to the current path. The |
1807 | * arc is centered at (@xc, @yc), begins at @angle1 and proceeds in |
1579 | * arc is centered at (@xc, @yc), begins at @angle1 and proceeds in |
1808 | * the direction of increasing angles to end at @angle2. If @angle2 is |
1580 | * the direction of increasing angles to end at @angle2. If @angle2 is |
1809 | * less than @angle1 it will be progressively increased by 2*M_PI |
1581 | * less than @angle1 it will be progressively increased by |
1810 | * until it is greater than @angle1. |
1582 | * |
1811 | * |
1583 | * |
1812 | * If there is a current point, an initial line segment will be added |
1584 | * If there is a current point, an initial line segment will be added |
1813 | * to the path to connect the current point to the beginning of the |
1585 | * to the path to connect the current point to the beginning of the |
1814 | * arc. If this initial line is undesired, it can be avoided by |
1586 | * arc. If this initial line is undesired, it can be avoided by |
1815 | * calling cairo_new_sub_path() before calling cairo_arc(). |
1587 | * calling cairo_new_sub_path() before calling cairo_arc(). |
1816 | * |
1588 | * |
1817 | * Angles are measured in radians. An angle of 0.0 is in the direction |
1589 | * Angles are measured in radians. An angle of 0.0 is in the direction |
1818 | * of the positive X axis (in user space). An angle of %M_PI/2.0 radians |
1590 | * of the positive X axis (in user space). An angle of |
- | 1591 | * |
|
1819 | * (90 degrees) is in the direction of the positive Y axis (in |
1592 | * direction of the positive Y axis (in user space). Angles increase |
1820 | * user space). Angles increase in the direction from the positive X |
1593 | * in the direction from the positive X axis toward the positive Y |
1821 | * axis toward the positive Y axis. So with the default transformation |
1594 | * axis. So with the default transformation matrix, angles increase in |
1822 | * matrix, angles increase in a clockwise direction. |
1595 | * a clockwise direction. |
1823 | * |
1596 | * |
1824 | * (To convert from degrees to radians, use |
1597 | * (To convert from degrees to radians, use |
1825 | * 180.).) |
1598 | * 180.).) |
1826 | * |
1599 | * |
1827 | * This function gives the arc in the direction of increasing angles; |
1600 | * This function gives the arc in the direction of increasing angles; |
Line 1838... | Line 1611... | ||
1838 | * cairo_translate (cr, x + width / 2., y + height / 2.); |
1611 | * cairo_translate (cr, x + width / 2., y + height / 2.); |
1839 | * cairo_scale (cr, width / 2., height / 2.); |
1612 | * cairo_scale (cr, width / 2., height / 2.); |
1840 | * cairo_arc (cr, 0., 0., 1., 0., 2 * M_PI); |
1613 | * cairo_arc (cr, 0., 0., 1., 0., 2 * M_PI); |
1841 | * cairo_restore (cr); |
1614 | * cairo_restore (cr); |
1842 | * |
1615 | * |
- | 1616 | * |
|
- | 1617 | * Since: 1.0 |
|
1843 | **/ |
1618 | **/ |
1844 | void |
1619 | void |
1845 | cairo_arc (cairo_t *cr, |
1620 | cairo_arc (cairo_t *cr, |
1846 | double xc, double yc, |
1621 | double xc, double yc, |
1847 | double radius, |
1622 | double radius, |
1848 | double angle1, double angle2) |
1623 | double angle1, double angle2) |
1849 | { |
1624 | { |
1850 | if (unlikely (cr->status)) |
1625 | cairo_status_t status; |
1851 | return; |
- | |
Line 1852... | Line -... | ||
1852 | - | ||
1853 | /* Do nothing, successfully, if radius is <= 0 */ |
1626 | |
1854 | if (radius <= 0.0) { |
- | |
1855 | cairo_line_to (cr, xc, yc); /* might become a move_to */ |
- | |
1856 | cairo_line_to (cr, xc, yc); |
1627 | if (unlikely (cr->status)) |
1857 | return; |
- | |
Line 1858... | Line 1628... | ||
1858 | } |
1628 | return; |
- | 1629 | ||
- | 1630 | if (angle2 < angle1) { |
|
- | 1631 | /* increase angle2 by multiples of full circle until it |
|
- | 1632 | * satisfies angle2 >= angle1 */ |
|
1859 | 1633 | angle2 = fmod (angle2 - angle1, 2 * M_PI); |
|
- | 1634 | if (angle2 < 0) |
|
- | 1635 | angle2 += 2 * M_PI; |
|
Line 1860... | Line -... | ||
1860 | while (angle2 < angle1) |
- | |
1861 | angle2 += 2 * M_PI; |
1636 | angle2 += angle1; |
1862 | 1637 | } |
|
1863 | cairo_line_to (cr, |
- | |
1864 | xc + radius * cos (angle1), |
1638 | |
1865 | yc + radius * sin (angle1)); |
- | |
1866 | 1639 | status = cr->backend->arc (cr, xc, yc, radius, angle1, angle2, TRUE); |
|
Line 1867... | Line 1640... | ||
1867 | _cairo_arc_path (cr, xc, yc, radius, |
1640 | if (unlikely (status)) |
1868 | angle1, angle2); |
1641 | _cairo_set_error (cr, status); |
1869 | } |
1642 | } |
Line 1878... | Line 1651... | ||
1878 | * @angle2: the end angle, in radians |
1651 | * @angle2: the end angle, in radians |
1879 | * |
1652 | * |
1880 | * Adds a circular arc of the given @radius to the current path. The |
1653 | * Adds a circular arc of the given @radius to the current path. The |
1881 | * arc is centered at (@xc, @yc), begins at @angle1 and proceeds in |
1654 | * arc is centered at (@xc, @yc), begins at @angle1 and proceeds in |
1882 | * the direction of decreasing angles to end at @angle2. If @angle2 is |
1655 | * the direction of decreasing angles to end at @angle2. If @angle2 is |
1883 | * greater than @angle1 it will be progressively decreased by 2*M_PI |
1656 | * greater than @angle1 it will be progressively decreased by |
1884 | * until it is less than @angle1. |
1657 | * |
1885 | * |
1658 | * |
1886 | * See cairo_arc() for more details. This function differs only in the |
1659 | * See cairo_arc() for more details. This function differs only in the |
1887 | * direction of the arc between the two angles. |
1660 | * direction of the arc between the two angles. |
- | 1661 | * |
|
- | 1662 | * Since: 1.0 |
|
1888 | **/ |
1663 | **/ |
1889 | void |
1664 | void |
1890 | cairo_arc_negative (cairo_t *cr, |
1665 | cairo_arc_negative (cairo_t *cr, |
1891 | double xc, double yc, |
1666 | double xc, double yc, |
1892 | double radius, |
1667 | double radius, |
1893 | double angle1, double angle2) |
1668 | double angle1, double angle2) |
1894 | { |
1669 | { |
1895 | if (unlikely (cr->status)) |
1670 | cairo_status_t status; |
1896 | return; |
- | |
Line 1897... | Line -... | ||
1897 | - | ||
1898 | /* Do nothing, successfully, if radius is <= 0 */ |
1671 | |
1899 | if (radius <= 0.0) |
1672 | if (unlikely (cr->status)) |
Line 1900... | Line 1673... | ||
1900 | return; |
1673 | return; |
- | 1674 | ||
- | 1675 | if (angle2 > angle1) { |
|
- | 1676 | /* decrease angle2 by multiples of full circle until it |
|
- | 1677 | * satisfies angle2 <= angle1 */ |
|
1901 | 1678 | angle2 = fmod (angle2 - angle1, 2 * M_PI); |
|
- | 1679 | if (angle2 > 0) |
|
- | 1680 | angle2 -= 2 * M_PI; |
|
Line 1902... | Line -... | ||
1902 | while (angle2 > angle1) |
- | |
1903 | angle2 -= 2 * M_PI; |
1681 | angle2 += angle1; |
1904 | 1682 | } |
|
1905 | cairo_line_to (cr, |
- | |
1906 | xc + radius * cos (angle1), |
1683 | |
1907 | yc + radius * sin (angle1)); |
- | |
1908 | 1684 | status = cr->backend->arc (cr, xc, yc, radius, angle1, angle2, FALSE); |
|
Line 1909... | Line 1685... | ||
1909 | _cairo_arc_path_negative (cr, xc, yc, radius, |
1685 | if (unlikely (status)) |
1910 | angle1, angle2); |
1686 | _cairo_set_error (cr, status); |
1911 | } |
1687 | } |
Line 1920... | Line 1696... | ||
1920 | cairo_status_t status; |
1696 | cairo_status_t status; |
Line 1921... | Line 1697... | ||
1921 | 1697 | ||
1922 | if (unlikely (cr->status)) |
1698 | if (unlikely (cr->status)) |
Line 1923... | Line 1699... | ||
1923 | return; |
1699 | return; |
- | 1700 | ||
- | 1701 | status = cr->backend->arc_to (cr, x1, y1, x2, y2, radius); |
|
- | 1702 | if (unlikely (status)) |
|
- | 1703 | _cairo_set_error (cr, status); |
|
- | 1704 | } |
|
- | 1705 | ||
1924 | 1706 | void |
|
1925 | status = _cairo_gstate_arc_to (cr->gstate, |
1707 | cairo_rel_arc_to (cairo_t *cr, |
1926 | x1, y1, |
1708 | double dx1, double dy1, |
- | 1709 | double dx2, double dy2, |
|
- | 1710 | double radius) |
|
- | 1711 | { |
|
- | 1712 | cairo_status_t status; |
|
- | 1713 | ||
- | 1714 | if (unlikely (cr->status)) |
|
- | 1715 | return; |
|
1927 | x2, y2, |
1716 | |
1928 | radius); |
1717 | status = cr->backend->rel_arc_to (cr, dx1, dy1, dx2, dy2, radius); |
1929 | if (unlikely (status)) |
1718 | if (unlikely (status)) |
1930 | _cairo_set_error (cr, status); |
1719 | _cairo_set_error (cr, status); |
Line 1944... | Line 1733... | ||
1944 | * is logically equivalent to cairo_move_to(@cr, x + @dx, y + @dy). |
1733 | * is logically equivalent to cairo_move_to(@cr, x + @dx, y + @dy). |
1945 | * |
1734 | * |
1946 | * It is an error to call this function with no current point. Doing |
1735 | * It is an error to call this function with no current point. Doing |
1947 | * so will cause @cr to shutdown with a status of |
1736 | * so will cause @cr to shutdown with a status of |
1948 | * %CAIRO_STATUS_NO_CURRENT_POINT. |
1737 | * %CAIRO_STATUS_NO_CURRENT_POINT. |
- | 1738 | * |
|
- | 1739 | * Since: 1.0 |
|
1949 | **/ |
1740 | **/ |
1950 | void |
1741 | void |
1951 | cairo_rel_move_to (cairo_t *cr, double dx, double dy) |
1742 | cairo_rel_move_to (cairo_t *cr, double dx, double dy) |
1952 | { |
1743 | { |
1953 | cairo_fixed_t dx_fixed, dy_fixed; |
- | |
1954 | cairo_status_t status; |
1744 | cairo_status_t status; |
Line 1955... | Line 1745... | ||
1955 | 1745 | ||
1956 | if (unlikely (cr->status)) |
1746 | if (unlikely (cr->status)) |
Line 1957... | Line -... | ||
1957 | return; |
- | |
1958 | - | ||
1959 | _cairo_gstate_user_to_device_distance (cr->gstate, &dx, &dy); |
- | |
1960 | - | ||
1961 | dx_fixed = _cairo_fixed_from_double (dx); |
- | |
1962 | dy_fixed = _cairo_fixed_from_double (dy); |
1747 | return; |
1963 | 1748 | ||
1964 | status = _cairo_path_fixed_rel_move_to (cr->path, dx_fixed, dy_fixed); |
1749 | status = cr->backend->rel_move_to (cr, dx, dy); |
1965 | if (unlikely (status)) |
1750 | if (unlikely (status)) |
Line 1966... | Line 1751... | ||
1966 | _cairo_set_error (cr, status); |
1751 | _cairo_set_error (cr, status); |
Line 1981... | Line 1766... | ||
1981 | * is logically equivalent to cairo_line_to(@cr, x + @dx, y + @dy). |
1766 | * is logically equivalent to cairo_line_to(@cr, x + @dx, y + @dy). |
1982 | * |
1767 | * |
1983 | * It is an error to call this function with no current point. Doing |
1768 | * It is an error to call this function with no current point. Doing |
1984 | * so will cause @cr to shutdown with a status of |
1769 | * so will cause @cr to shutdown with a status of |
1985 | * %CAIRO_STATUS_NO_CURRENT_POINT. |
1770 | * %CAIRO_STATUS_NO_CURRENT_POINT. |
- | 1771 | * |
|
- | 1772 | * Since: 1.0 |
|
1986 | **/ |
1773 | **/ |
1987 | void |
1774 | void |
1988 | cairo_rel_line_to (cairo_t *cr, double dx, double dy) |
1775 | cairo_rel_line_to (cairo_t *cr, double dx, double dy) |
1989 | { |
1776 | { |
1990 | cairo_fixed_t dx_fixed, dy_fixed; |
- | |
1991 | cairo_status_t status; |
1777 | cairo_status_t status; |
Line 1992... | Line 1778... | ||
1992 | 1778 | ||
1993 | if (unlikely (cr->status)) |
1779 | if (unlikely (cr->status)) |
Line 1994... | Line -... | ||
1994 | return; |
- | |
1995 | - | ||
1996 | _cairo_gstate_user_to_device_distance (cr->gstate, &dx, &dy); |
- | |
1997 | - | ||
1998 | dx_fixed = _cairo_fixed_from_double (dx); |
- | |
1999 | dy_fixed = _cairo_fixed_from_double (dy); |
1780 | return; |
2000 | 1781 | ||
2001 | status = _cairo_path_fixed_rel_line_to (cr->path, dx_fixed, dy_fixed); |
1782 | status = cr->backend->rel_line_to (cr, dx, dy); |
2002 | if (unlikely (status)) |
1783 | if (unlikely (status)) |
2003 | _cairo_set_error (cr, status); |
1784 | _cairo_set_error (cr, status); |
Line 2026... | Line 1807... | ||
2026 | * cairo_curve_to(@cr, x+@dx1, y+@dy1, x+@dx2, y+@dy2, x+@dx3, y+@dy3). |
1807 | * cairo_curve_to(@cr, x+@dx1, y+@dy1, x+@dx2, y+@dy2, x+@dx3, y+@dy3). |
2027 | * |
1808 | * |
2028 | * It is an error to call this function with no current point. Doing |
1809 | * It is an error to call this function with no current point. Doing |
2029 | * so will cause @cr to shutdown with a status of |
1810 | * so will cause @cr to shutdown with a status of |
2030 | * %CAIRO_STATUS_NO_CURRENT_POINT. |
1811 | * %CAIRO_STATUS_NO_CURRENT_POINT. |
- | 1812 | * |
|
- | 1813 | * Since: 1.0 |
|
2031 | **/ |
1814 | **/ |
2032 | void |
1815 | void |
2033 | cairo_rel_curve_to (cairo_t *cr, |
1816 | cairo_rel_curve_to (cairo_t *cr, |
2034 | double dx1, double dy1, |
1817 | double dx1, double dy1, |
2035 | double dx2, double dy2, |
1818 | double dx2, double dy2, |
2036 | double dx3, double dy3) |
1819 | double dx3, double dy3) |
2037 | { |
1820 | { |
2038 | cairo_fixed_t dx1_fixed, dy1_fixed; |
- | |
2039 | cairo_fixed_t dx2_fixed, dy2_fixed; |
- | |
2040 | cairo_fixed_t dx3_fixed, dy3_fixed; |
- | |
2041 | cairo_status_t status; |
1821 | cairo_status_t status; |
Line 2042... | Line 1822... | ||
2042 | 1822 | ||
2043 | if (unlikely (cr->status)) |
1823 | if (unlikely (cr->status)) |
Line 2044... | Line -... | ||
2044 | return; |
- | |
2045 | - | ||
2046 | _cairo_gstate_user_to_device_distance (cr->gstate, &dx1, &dy1); |
- | |
2047 | _cairo_gstate_user_to_device_distance (cr->gstate, &dx2, &dy2); |
- | |
2048 | _cairo_gstate_user_to_device_distance (cr->gstate, &dx3, &dy3); |
- | |
2049 | - | ||
2050 | dx1_fixed = _cairo_fixed_from_double (dx1); |
- | |
2051 | dy1_fixed = _cairo_fixed_from_double (dy1); |
- | |
2052 | - | ||
2053 | dx2_fixed = _cairo_fixed_from_double (dx2); |
- | |
2054 | dy2_fixed = _cairo_fixed_from_double (dy2); |
- | |
2055 | - | ||
2056 | dx3_fixed = _cairo_fixed_from_double (dx3); |
- | |
2057 | dy3_fixed = _cairo_fixed_from_double (dy3); |
1824 | return; |
2058 | 1825 | ||
2059 | status = _cairo_path_fixed_rel_curve_to (cr->path, |
1826 | status = cr->backend->rel_curve_to (cr, |
2060 | dx1_fixed, dy1_fixed, |
1827 | dx1, dy1, |
2061 | dx2_fixed, dy2_fixed, |
1828 | dx2, dy2, |
2062 | dx3_fixed, dy3_fixed); |
1829 | dx3, dy3); |
2063 | if (unlikely (status)) |
1830 | if (unlikely (status)) |
Line 2064... | Line 1831... | ||
2064 | _cairo_set_error (cr, status); |
1831 | _cairo_set_error (cr, status); |
Line 2081... | Line 1848... | ||
2081 | * cairo_rel_line_to (cr, width, 0); |
1848 | * cairo_rel_line_to (cr, width, 0); |
2082 | * cairo_rel_line_to (cr, 0, height); |
1849 | * cairo_rel_line_to (cr, 0, height); |
2083 | * cairo_rel_line_to (cr, -width, 0); |
1850 | * cairo_rel_line_to (cr, -width, 0); |
2084 | * cairo_close_path (cr); |
1851 | * cairo_close_path (cr); |
2085 | * |
1852 | * |
- | 1853 | * |
|
- | 1854 | * Since: 1.0 |
|
2086 | **/ |
1855 | **/ |
2087 | void |
1856 | void |
2088 | cairo_rectangle (cairo_t *cr, |
1857 | cairo_rectangle (cairo_t *cr, |
2089 | double x, double y, |
1858 | double x, double y, |
2090 | double width, double height) |
1859 | double width, double height) |
2091 | { |
1860 | { |
- | 1861 | cairo_status_t status; |
|
- | 1862 | ||
2092 | if (unlikely (cr->status)) |
1863 | if (unlikely (cr->status)) |
2093 | return; |
1864 | return; |
Line 2094... | Line -... | ||
2094 | - | ||
2095 | cairo_move_to (cr, x, y); |
1865 | |
2096 | cairo_rel_line_to (cr, width, 0); |
1866 | status = cr->backend->rectangle (cr, x, y, width, height); |
2097 | cairo_rel_line_to (cr, 0, height); |
1867 | if (unlikely (status)) |
2098 | cairo_rel_line_to (cr, -width, 0); |
- | |
2099 | cairo_close_path (cr); |
1868 | _cairo_set_error (cr, status); |
Line 2100... | Line 1869... | ||
2100 | } |
1869 | } |
2101 | 1870 | ||
2102 | #if 0 |
1871 | #if 0 |
Line 2140... | Line 1909... | ||
2140 | * the CLOSE_PATH element, (which can be seen in cairo_copy_path() for |
1909 | * the CLOSE_PATH element, (which can be seen in cairo_copy_path() for |
2141 | * example). This can simplify path processing in some cases as it may |
1910 | * example). This can simplify path processing in some cases as it may |
2142 | * not be necessary to save the "last move_to point" during processing |
1911 | * not be necessary to save the "last move_to point" during processing |
2143 | * as the MOVE_TO immediately after the CLOSE_PATH will provide that |
1912 | * as the MOVE_TO immediately after the CLOSE_PATH will provide that |
2144 | * point. |
1913 | * point. |
- | 1914 | * |
|
- | 1915 | * Since: 1.0 |
|
2145 | **/ |
1916 | **/ |
2146 | void |
1917 | void |
2147 | cairo_close_path (cairo_t *cr) |
1918 | cairo_close_path (cairo_t *cr) |
2148 | { |
1919 | { |
2149 | cairo_status_t status; |
1920 | cairo_status_t status; |
Line 2150... | Line 1921... | ||
2150 | 1921 | ||
2151 | if (unlikely (cr->status)) |
1922 | if (unlikely (cr->status)) |
Line 2152... | Line 1923... | ||
2152 | return; |
1923 | return; |
2153 | 1924 | ||
2154 | status = _cairo_path_fixed_close_path (cr->path); |
1925 | status = cr->backend->close_path (cr); |
2155 | if (unlikely (status)) |
1926 | if (unlikely (status)) |
2156 | _cairo_set_error (cr, status); |
1927 | _cairo_set_error (cr, status); |
Line 2203... | Line 1974... | ||
2203 | *y2 = 0.0; |
1974 | *y2 = 0.0; |
Line 2204... | Line 1975... | ||
2204 | 1975 | ||
2205 | return; |
1976 | return; |
Line 2206... | Line 1977... | ||
2206 | } |
1977 | } |
2207 | - | ||
2208 | _cairo_gstate_path_extents (cr->gstate, |
- | |
2209 | cr->path, |
1978 | |
Line 2210... | Line 1979... | ||
2210 | x1, y1, x2, y2); |
1979 | cr->backend->path_extents (cr, x1, y1, x2, y2); |
2211 | } |
1980 | } |
2212 | 1981 | ||
2213 | /** |
1982 | /** |
2214 | * cairo_paint: |
1983 | * cairo_paint: |
2215 | * @cr: a cairo context |
1984 | * @cr: a cairo context |
- | 1985 | * |
|
- | 1986 | * A drawing operator that paints the current source everywhere within |
|
2216 | * |
1987 | * the current clip region. |
2217 | * A drawing operator that paints the current source everywhere within |
1988 | * |
2218 | * the current clip region. |
1989 | * Since: 1.0 |
2219 | **/ |
1990 | **/ |
2220 | void |
1991 | void |
Line 2221... | Line 1992... | ||
2221 | cairo_paint (cairo_t *cr) |
1992 | cairo_paint (cairo_t *cr) |
2222 | { |
1993 | { |
Line 2223... | Line 1994... | ||
2223 | cairo_status_t status; |
1994 | cairo_status_t status; |
2224 | 1995 | ||
2225 | if (unlikely (cr->status)) |
1996 | if (unlikely (cr->status)) |
2226 | return; |
1997 | return; |
2227 | 1998 | ||
Line 2238... | Line 2009... | ||
2238 | * |
2009 | * |
2239 | * A drawing operator that paints the current source everywhere within |
2010 | * A drawing operator that paints the current source everywhere within |
2240 | * the current clip region using a mask of constant alpha value |
2011 | * the current clip region using a mask of constant alpha value |
2241 | * @alpha. The effect is similar to cairo_paint(), but the drawing |
2012 | * @alpha. The effect is similar to cairo_paint(), but the drawing |
2242 | * is faded out using the alpha value. |
2013 | * is faded out using the alpha value. |
- | 2014 | * |
|
- | 2015 | * Since: 1.0 |
|
2243 | **/ |
2016 | **/ |
2244 | void |
2017 | void |
2245 | cairo_paint_with_alpha (cairo_t *cr, |
2018 | cairo_paint_with_alpha (cairo_t *cr, |
2246 | double alpha) |
2019 | double alpha) |
2247 | { |
2020 | { |
2248 | cairo_status_t status; |
2021 | cairo_status_t status; |
2249 | cairo_color_t color; |
- | |
2250 | cairo_solid_pattern_t pattern; |
- | |
Line 2251... | Line 2022... | ||
2251 | 2022 | ||
2252 | if (unlikely (cr->status)) |
2023 | if (unlikely (cr->status)) |
Line 2253... | Line -... | ||
2253 | return; |
- | |
2254 | - | ||
2255 | if (CAIRO_ALPHA_IS_OPAQUE (alpha)) { |
- | |
2256 | cairo_paint (cr); |
- | |
2257 | return; |
- | |
2258 | } |
- | |
2259 | - | ||
2260 | if (CAIRO_ALPHA_IS_ZERO (alpha) && |
- | |
2261 | _cairo_operator_bounded_by_mask (cr->gstate->op)) { |
- | |
2262 | return; |
- | |
2263 | } |
- | |
2264 | - | ||
2265 | _cairo_color_init_rgba (&color, 0., 0., 0., alpha); |
- | |
2266 | _cairo_pattern_init_solid (&pattern, &color); |
2024 | return; |
2267 | 2025 | ||
2268 | status = _cairo_gstate_mask (cr->gstate, &pattern.base); |
2026 | status = cr->backend->paint_with_alpha (cr, alpha); |
2269 | if (unlikely (status)) |
- | |
2270 | _cairo_set_error (cr, status); |
- | |
2271 | 2027 | if (unlikely (status)) |
|
Line 2272... | Line 2028... | ||
2272 | _cairo_pattern_fini (&pattern.base); |
2028 | _cairo_set_error (cr, status); |
2273 | } |
2029 | } |
2274 | 2030 | ||
Line 2279... | Line 2035... | ||
2279 | * |
2035 | * |
2280 | * A drawing operator that paints the current source |
2036 | * A drawing operator that paints the current source |
2281 | * using the alpha channel of @pattern as a mask. (Opaque |
2037 | * using the alpha channel of @pattern as a mask. (Opaque |
2282 | * areas of @pattern are painted with the source, transparent |
2038 | * areas of @pattern are painted with the source, transparent |
2283 | * areas are not painted.) |
2039 | * areas are not painted.) |
- | 2040 | * |
|
- | 2041 | * Since: 1.0 |
|
2284 | */ |
2042 | **/ |
2285 | void |
2043 | void |
2286 | cairo_mask (cairo_t *cr, |
2044 | cairo_mask (cairo_t *cr, |
2287 | cairo_pattern_t *pattern) |
2045 | cairo_pattern_t *pattern) |
2288 | { |
2046 | { |
2289 | cairo_status_t status; |
2047 | cairo_status_t status; |
Line 2290... | Line 2048... | ||
2290 | 2048 | ||
2291 | if (unlikely (cr->status)) |
2049 | if (unlikely (cr->status)) |
Line 2292... | Line 2050... | ||
2292 | return; |
2050 | return; |
2293 | 2051 | ||
2294 | if (pattern == NULL) { |
2052 | if (unlikely (pattern == NULL)) { |
2295 | _cairo_set_error (cr, CAIRO_STATUS_NULL_POINTER); |
2053 | _cairo_set_error (cr, CAIRO_STATUS_NULL_POINTER); |
Line 2296... | Line 2054... | ||
2296 | return; |
2054 | return; |
2297 | } |
2055 | } |
2298 | 2056 | ||
2299 | if (pattern->status) { |
2057 | if (unlikely (pattern->status)) { |
Line 2300... | Line 2058... | ||
2300 | _cairo_set_error (cr, pattern->status); |
2058 | _cairo_set_error (cr, pattern->status); |
2301 | return; |
2059 | return; |
2302 | } |
2060 | } |
2303 | 2061 | ||
2304 | status = _cairo_gstate_mask (cr->gstate, pattern); |
2062 | status = cr->backend->mask (cr, pattern); |
Line 2316... | Line 2074... | ||
2316 | * |
2074 | * |
2317 | * A drawing operator that paints the current source |
2075 | * A drawing operator that paints the current source |
2318 | * using the alpha channel of @surface as a mask. (Opaque |
2076 | * using the alpha channel of @surface as a mask. (Opaque |
2319 | * areas of @surface are painted with the source, transparent |
2077 | * areas of @surface are painted with the source, transparent |
2320 | * areas are not painted.) |
2078 | * areas are not painted.) |
- | 2079 | * |
|
- | 2080 | * Since: 1.0 |
|
2321 | */ |
2081 | **/ |
2322 | void |
2082 | void |
2323 | cairo_mask_surface (cairo_t *cr, |
2083 | cairo_mask_surface (cairo_t *cr, |
2324 | cairo_surface_t *surface, |
2084 | cairo_surface_t *surface, |
2325 | double surface_x, |
2085 | double surface_x, |
2326 | double surface_y) |
2086 | double surface_y) |
Line 2370... | Line 2130... | ||
2370 | * sub-path will not be drawn at all, (since the correct orientation |
2130 | * sub-path will not be drawn at all, (since the correct orientation |
2371 | * is indeterminate). |
2131 | * is indeterminate). |
2372 | * |
2132 | * |
2373 | * In no case will a cap style of %CAIRO_LINE_CAP_BUTT cause anything |
2133 | * In no case will a cap style of %CAIRO_LINE_CAP_BUTT cause anything |
2374 | * to be drawn in the case of either degenerate segments or sub-paths. |
2134 | * to be drawn in the case of either degenerate segments or sub-paths. |
- | 2135 | * |
|
- | 2136 | * Since: 1.0 |
|
2375 | **/ |
2137 | **/ |
2376 | void |
2138 | void |
2377 | cairo_stroke (cairo_t *cr) |
2139 | cairo_stroke (cairo_t *cr) |
2378 | { |
2140 | { |
2379 | cairo_stroke_preserve (cr); |
2141 | cairo_status_t status; |
Line -... | Line 2142... | ||
- | 2142 | ||
- | 2143 | if (unlikely (cr->status)) |
|
- | 2144 | return; |
|
- | 2145 | ||
- | 2146 | status = cr->backend->stroke (cr); |
|
2380 | 2147 | if (unlikely (status)) |
|
2381 | cairo_new_path (cr); |
2148 | _cairo_set_error (cr, status); |
2382 | } |
2149 | } |
Line 2383... | Line 2150... | ||
2383 | slim_hidden_def(cairo_stroke); |
2150 | slim_hidden_def(cairo_stroke); |
2384 | 2151 | ||
Line 2392... | Line 2159... | ||
2392 | * cairo context. |
2159 | * cairo context. |
2393 | * |
2160 | * |
2394 | * See cairo_set_line_width(), cairo_set_line_join(), |
2161 | * See cairo_set_line_width(), cairo_set_line_join(), |
2395 | * cairo_set_line_cap(), cairo_set_dash(), and |
2162 | * cairo_set_line_cap(), cairo_set_dash(), and |
2396 | * cairo_stroke_preserve(). |
2163 | * cairo_stroke_preserve(). |
- | 2164 | * |
|
- | 2165 | * Since: 1.0 |
|
2397 | **/ |
2166 | **/ |
2398 | void |
2167 | void |
2399 | cairo_stroke_preserve (cairo_t *cr) |
2168 | cairo_stroke_preserve (cairo_t *cr) |
2400 | { |
2169 | { |
2401 | cairo_status_t status; |
2170 | cairo_status_t status; |
Line 2402... | Line 2171... | ||
2402 | 2171 | ||
2403 | if (unlikely (cr->status)) |
2172 | if (unlikely (cr->status)) |
Line 2404... | Line 2173... | ||
2404 | return; |
2173 | return; |
2405 | 2174 | ||
2406 | status = _cairo_gstate_stroke (cr->gstate, cr->path); |
2175 | status = cr->backend->stroke_preserve (cr); |
2407 | if (unlikely (status)) |
2176 | if (unlikely (status)) |
2408 | _cairo_set_error (cr, status); |
2177 | _cairo_set_error (cr, status); |
Line 2416... | Line 2185... | ||
2416 | * A drawing operator that fills the current path according to the |
2185 | * A drawing operator that fills the current path according to the |
2417 | * current fill rule, (each sub-path is implicitly closed before being |
2186 | * current fill rule, (each sub-path is implicitly closed before being |
2418 | * filled). After cairo_fill(), the current path will be cleared from |
2187 | * filled). After cairo_fill(), the current path will be cleared from |
2419 | * the cairo context. See cairo_set_fill_rule() and |
2188 | * the cairo context. See cairo_set_fill_rule() and |
2420 | * cairo_fill_preserve(). |
2189 | * cairo_fill_preserve(). |
- | 2190 | * |
|
- | 2191 | * Since: 1.0 |
|
2421 | **/ |
2192 | **/ |
2422 | void |
2193 | void |
2423 | cairo_fill (cairo_t *cr) |
2194 | cairo_fill (cairo_t *cr) |
2424 | { |
2195 | { |
2425 | cairo_fill_preserve (cr); |
2196 | cairo_status_t status; |
- | 2197 | ||
- | 2198 | if (unlikely (cr->status)) |
|
- | 2199 | return; |
|
Line -... | Line 2200... | ||
- | 2200 | ||
- | 2201 | status = cr->backend->fill (cr); |
|
2426 | 2202 | if (unlikely (status)) |
|
2427 | cairo_new_path (cr); |
2203 | _cairo_set_error (cr, status); |
Line 2428... | Line 2204... | ||
2428 | } |
2204 | } |
2429 | 2205 | ||
2430 | /** |
2206 | /** |
Line 2435... | Line 2211... | ||
2435 | * current fill rule, (each sub-path is implicitly closed before being |
2211 | * current fill rule, (each sub-path is implicitly closed before being |
2436 | * filled). Unlike cairo_fill(), cairo_fill_preserve() preserves the |
2212 | * filled). Unlike cairo_fill(), cairo_fill_preserve() preserves the |
2437 | * path within the cairo context. |
2213 | * path within the cairo context. |
2438 | * |
2214 | * |
2439 | * See cairo_set_fill_rule() and cairo_fill(). |
2215 | * See cairo_set_fill_rule() and cairo_fill(). |
- | 2216 | * |
|
- | 2217 | * Since: 1.0 |
|
2440 | **/ |
2218 | **/ |
2441 | void |
2219 | void |
2442 | cairo_fill_preserve (cairo_t *cr) |
2220 | cairo_fill_preserve (cairo_t *cr) |
2443 | { |
2221 | { |
2444 | cairo_status_t status; |
2222 | cairo_status_t status; |
Line 2445... | Line 2223... | ||
2445 | 2223 | ||
2446 | if (unlikely (cr->status)) |
2224 | if (unlikely (cr->status)) |
Line 2447... | Line 2225... | ||
2447 | return; |
2225 | return; |
2448 | 2226 | ||
2449 | status = _cairo_gstate_fill (cr->gstate, cr->path); |
2227 | status = cr->backend->fill_preserve (cr); |
2450 | if (unlikely (status)) |
2228 | if (unlikely (status)) |
2451 | _cairo_set_error (cr, status); |
2229 | _cairo_set_error (cr, status); |
Line 2461... | Line 2239... | ||
2461 | * for the next page too. Use cairo_show_page() if you want to get an |
2239 | * for the next page too. Use cairo_show_page() if you want to get an |
2462 | * empty page after the emission. |
2240 | * empty page after the emission. |
2463 | * |
2241 | * |
2464 | * This is a convenience function that simply calls |
2242 | * This is a convenience function that simply calls |
2465 | * cairo_surface_copy_page() on @cr's target. |
2243 | * cairo_surface_copy_page() on @cr's target. |
- | 2244 | * |
|
- | 2245 | * Since: 1.0 |
|
2466 | **/ |
2246 | **/ |
2467 | void |
2247 | void |
2468 | cairo_copy_page (cairo_t *cr) |
2248 | cairo_copy_page (cairo_t *cr) |
2469 | { |
2249 | { |
2470 | cairo_status_t status; |
2250 | cairo_status_t status; |
Line 2471... | Line 2251... | ||
2471 | 2251 | ||
2472 | if (unlikely (cr->status)) |
2252 | if (unlikely (cr->status)) |
Line 2473... | Line 2253... | ||
2473 | return; |
2253 | return; |
2474 | 2254 | ||
2475 | status = _cairo_gstate_copy_page (cr->gstate); |
2255 | status = cr->backend->copy_page (cr); |
2476 | if (unlikely (status)) |
2256 | if (unlikely (status)) |
Line 2477... | Line 2257... | ||
2477 | _cairo_set_error (cr, status); |
2257 | _cairo_set_error (cr, status); |
Line 2484... | Line 2264... | ||
2484 | * Emits and clears the current page for backends that support multiple |
2264 | * Emits and clears the current page for backends that support multiple |
2485 | * pages. Use cairo_copy_page() if you don't want to clear the page. |
2265 | * pages. Use cairo_copy_page() if you don't want to clear the page. |
2486 | * |
2266 | * |
2487 | * This is a convenience function that simply calls |
2267 | * This is a convenience function that simply calls |
2488 | * cairo_surface_show_page() on @cr's target. |
2268 | * cairo_surface_show_page() on @cr's target. |
- | 2269 | * |
|
- | 2270 | * Since: 1.0 |
|
2489 | **/ |
2271 | **/ |
2490 | void |
2272 | void |
2491 | cairo_show_page (cairo_t *cr) |
2273 | cairo_show_page (cairo_t *cr) |
2492 | { |
2274 | { |
2493 | cairo_status_t status; |
2275 | cairo_status_t status; |
Line 2494... | Line 2276... | ||
2494 | 2276 | ||
2495 | if (unlikely (cr->status)) |
2277 | if (unlikely (cr->status)) |
Line 2496... | Line 2278... | ||
2496 | return; |
2278 | return; |
2497 | 2279 | ||
2498 | status = _cairo_gstate_show_page (cr->gstate); |
2280 | status = cr->backend->show_page (cr); |
2499 | if (unlikely (status)) |
2281 | if (unlikely (status)) |
Line 2500... | Line 2282... | ||
2500 | _cairo_set_error (cr, status); |
2282 | _cairo_set_error (cr, status); |
Line 2515... | Line 2297... | ||
2515 | * cairo_set_line_cap(), cairo_set_dash(), and |
2297 | * cairo_set_line_cap(), cairo_set_dash(), and |
2516 | * cairo_stroke_preserve(). |
2298 | * cairo_stroke_preserve(). |
2517 | * |
2299 | * |
2518 | * Return value: A non-zero value if the point is inside, or zero if |
2300 | * Return value: A non-zero value if the point is inside, or zero if |
2519 | * outside. |
2301 | * outside. |
- | 2302 | * |
|
- | 2303 | * Since: 1.0 |
|
2520 | **/ |
2304 | **/ |
2521 | cairo_bool_t |
2305 | cairo_bool_t |
2522 | cairo_in_stroke (cairo_t *cr, double x, double y) |
2306 | cairo_in_stroke (cairo_t *cr, double x, double y) |
2523 | { |
2307 | { |
2524 | cairo_status_t status; |
2308 | cairo_status_t status; |
2525 | cairo_bool_t inside = FALSE; |
2309 | cairo_bool_t inside = FALSE; |
Line 2526... | Line 2310... | ||
2526 | 2310 | ||
2527 | if (unlikely (cr->status)) |
2311 | if (unlikely (cr->status)) |
Line 2528... | Line 2312... | ||
2528 | return FALSE; |
2312 | return FALSE; |
2529 | - | ||
2530 | status = _cairo_gstate_in_stroke (cr->gstate, |
- | |
2531 | cr->path, |
2313 | |
2532 | x, y, &inside); |
2314 | status = cr->backend->in_stroke (cr, x, y, &inside); |
Line 2533... | Line 2315... | ||
2533 | if (unlikely (status)) |
2315 | if (unlikely (status)) |
2534 | _cairo_set_error (cr, status); |
2316 | _cairo_set_error (cr, status); |
Line 2549... | Line 2331... | ||
2549 | * |
2331 | * |
2550 | * See cairo_fill(), cairo_set_fill_rule() and cairo_fill_preserve(). |
2332 | * See cairo_fill(), cairo_set_fill_rule() and cairo_fill_preserve(). |
2551 | * |
2333 | * |
2552 | * Return value: A non-zero value if the point is inside, or zero if |
2334 | * Return value: A non-zero value if the point is inside, or zero if |
2553 | * outside. |
2335 | * outside. |
- | 2336 | * |
|
- | 2337 | * Since: 1.0 |
|
2554 | **/ |
2338 | **/ |
2555 | cairo_bool_t |
2339 | cairo_bool_t |
2556 | cairo_in_fill (cairo_t *cr, double x, double y) |
2340 | cairo_in_fill (cairo_t *cr, double x, double y) |
2557 | { |
2341 | { |
- | 2342 | cairo_status_t status; |
|
- | 2343 | cairo_bool_t inside = FALSE; |
|
- | 2344 | ||
2558 | if (unlikely (cr->status)) |
2345 | if (unlikely (cr->status)) |
2559 | return FALSE; |
2346 | return FALSE; |
Line 2560... | Line 2347... | ||
2560 | 2347 | ||
- | 2348 | status = cr->backend->in_fill (cr, x, y, &inside); |
|
- | 2349 | if (unlikely (status)) |
|
- | 2350 | _cairo_set_error (cr, status); |
|
- | 2351 | ||
2561 | return _cairo_gstate_in_fill (cr->gstate, cr->path, x, y); |
2352 | return inside; |
Line 2562... | Line 2353... | ||
2562 | } |
2353 | } |
2563 | 2354 | ||
2564 | /** |
2355 | /** |
Line 2586... | Line 2377... | ||
2586 | * performance if non-inked path extents are desired. |
2377 | * performance if non-inked path extents are desired. |
2587 | * |
2378 | * |
2588 | * See cairo_stroke(), cairo_set_line_width(), cairo_set_line_join(), |
2379 | * See cairo_stroke(), cairo_set_line_width(), cairo_set_line_join(), |
2589 | * cairo_set_line_cap(), cairo_set_dash(), and |
2380 | * cairo_set_line_cap(), cairo_set_dash(), and |
2590 | * cairo_stroke_preserve(). |
2381 | * cairo_stroke_preserve(). |
- | 2382 | * |
|
- | 2383 | * Since: 1.0 |
|
2591 | **/ |
2384 | **/ |
2592 | void |
2385 | void |
2593 | cairo_stroke_extents (cairo_t *cr, |
2386 | cairo_stroke_extents (cairo_t *cr, |
2594 | double *x1, double *y1, double *x2, double *y2) |
2387 | double *x1, double *y1, double *x2, double *y2) |
2595 | { |
2388 | { |
Line 2606... | Line 2399... | ||
2606 | *y2 = 0.0; |
2399 | *y2 = 0.0; |
Line 2607... | Line 2400... | ||
2607 | 2400 | ||
2608 | return; |
2401 | return; |
Line 2609... | Line 2402... | ||
2609 | } |
2402 | } |
2610 | - | ||
2611 | status = _cairo_gstate_stroke_extents (cr->gstate, |
- | |
2612 | cr->path, |
2403 | |
2613 | x1, y1, x2, y2); |
2404 | status = cr->backend->stroke_extents (cr, x1, y1, x2, y2); |
2614 | if (unlikely (status)) |
2405 | if (unlikely (status)) |
Line 2615... | Line 2406... | ||
2615 | _cairo_set_error (cr, status); |
2406 | _cairo_set_error (cr, status); |
Line 2637... | Line 2428... | ||
2637 | * compute the precise inked areas in light of the fill rule, so |
2428 | * compute the precise inked areas in light of the fill rule, so |
2638 | * cairo_path_extents() may be more desirable for sake of performance |
2429 | * cairo_path_extents() may be more desirable for sake of performance |
2639 | * if the non-inked path extents are desired. |
2430 | * if the non-inked path extents are desired. |
2640 | * |
2431 | * |
2641 | * See cairo_fill(), cairo_set_fill_rule() and cairo_fill_preserve(). |
2432 | * See cairo_fill(), cairo_set_fill_rule() and cairo_fill_preserve(). |
- | 2433 | * |
|
- | 2434 | * Since: 1.0 |
|
2642 | **/ |
2435 | **/ |
2643 | void |
2436 | void |
2644 | cairo_fill_extents (cairo_t *cr, |
2437 | cairo_fill_extents (cairo_t *cr, |
2645 | double *x1, double *y1, double *x2, double *y2) |
2438 | double *x1, double *y1, double *x2, double *y2) |
2646 | { |
2439 | { |
Line 2657... | Line 2450... | ||
2657 | *y2 = 0.0; |
2450 | *y2 = 0.0; |
Line 2658... | Line 2451... | ||
2658 | 2451 | ||
2659 | return; |
2452 | return; |
Line 2660... | Line 2453... | ||
2660 | } |
2453 | } |
2661 | - | ||
2662 | status = _cairo_gstate_fill_extents (cr->gstate, |
- | |
2663 | cr->path, |
2454 | |
2664 | x1, y1, x2, y2); |
2455 | status = cr->backend->fill_extents (cr, x1, y1, x2, y2); |
2665 | if (unlikely (status)) |
2456 | if (unlikely (status)) |
Line 2666... | Line 2457... | ||
2666 | _cairo_set_error (cr, status); |
2457 | _cairo_set_error (cr, status); |
Line 2685... | Line 2476... | ||
2685 | * larger. But the current clip is part of the graphics state, so a |
2476 | * larger. But the current clip is part of the graphics state, so a |
2686 | * temporary restriction of the clip region can be achieved by |
2477 | * temporary restriction of the clip region can be achieved by |
2687 | * calling cairo_clip() within a cairo_save()/cairo_restore() |
2478 | * calling cairo_clip() within a cairo_save()/cairo_restore() |
2688 | * pair. The only other means of increasing the size of the clip |
2479 | * pair. The only other means of increasing the size of the clip |
2689 | * region is cairo_reset_clip(). |
2480 | * region is cairo_reset_clip(). |
- | 2481 | * |
|
- | 2482 | * Since: 1.0 |
|
2690 | **/ |
2483 | **/ |
2691 | void |
2484 | void |
2692 | cairo_clip (cairo_t *cr) |
2485 | cairo_clip (cairo_t *cr) |
2693 | { |
2486 | { |
2694 | cairo_clip_preserve (cr); |
2487 | cairo_status_t status; |
- | 2488 | ||
- | 2489 | if (unlikely (cr->status)) |
|
- | 2490 | return; |
|
Line -... | Line 2491... | ||
- | 2491 | ||
- | 2492 | status = cr->backend->clip (cr); |
|
2695 | 2493 | if (unlikely (status)) |
|
2696 | cairo_new_path (cr); |
2494 | _cairo_set_error (cr, status); |
Line 2697... | Line 2495... | ||
2697 | } |
2495 | } |
2698 | 2496 | ||
2699 | /** |
2497 | /** |
Line 2715... | Line 2513... | ||
2715 | * larger. But the current clip is part of the graphics state, so a |
2513 | * larger. But the current clip is part of the graphics state, so a |
2716 | * temporary restriction of the clip region can be achieved by |
2514 | * temporary restriction of the clip region can be achieved by |
2717 | * calling cairo_clip_preserve() within a cairo_save()/cairo_restore() |
2515 | * calling cairo_clip_preserve() within a cairo_save()/cairo_restore() |
2718 | * pair. The only other means of increasing the size of the clip |
2516 | * pair. The only other means of increasing the size of the clip |
2719 | * region is cairo_reset_clip(). |
2517 | * region is cairo_reset_clip(). |
- | 2518 | * |
|
- | 2519 | * Since: 1.0 |
|
2720 | **/ |
2520 | **/ |
2721 | void |
2521 | void |
2722 | cairo_clip_preserve (cairo_t *cr) |
2522 | cairo_clip_preserve (cairo_t *cr) |
2723 | { |
2523 | { |
2724 | cairo_status_t status; |
2524 | cairo_status_t status; |
Line 2725... | Line 2525... | ||
2725 | 2525 | ||
2726 | if (unlikely (cr->status)) |
2526 | if (unlikely (cr->status)) |
Line 2727... | Line 2527... | ||
2727 | return; |
2527 | return; |
2728 | 2528 | ||
2729 | status = _cairo_gstate_clip (cr->gstate, cr->path); |
2529 | status = cr->backend->clip_preserve (cr); |
2730 | if (unlikely (status)) |
2530 | if (unlikely (status)) |
2731 | _cairo_set_error (cr, status); |
2531 | _cairo_set_error (cr, status); |
Line 2745... | Line 2545... | ||
2745 | * Note that code meant to be reusable should not call |
2545 | * Note that code meant to be reusable should not call |
2746 | * cairo_reset_clip() as it will cause results unexpected by |
2546 | * cairo_reset_clip() as it will cause results unexpected by |
2747 | * higher-level code which calls cairo_clip(). Consider using |
2547 | * higher-level code which calls cairo_clip(). Consider using |
2748 | * cairo_save() and cairo_restore() around cairo_clip() as a more |
2548 | * cairo_save() and cairo_restore() around cairo_clip() as a more |
2749 | * robust means of temporarily restricting the clip region. |
2549 | * robust means of temporarily restricting the clip region. |
- | 2550 | * |
|
- | 2551 | * Since: 1.0 |
|
2750 | **/ |
2552 | **/ |
2751 | void |
2553 | void |
2752 | cairo_reset_clip (cairo_t *cr) |
2554 | cairo_reset_clip (cairo_t *cr) |
2753 | { |
2555 | { |
2754 | cairo_status_t status; |
2556 | cairo_status_t status; |
Line 2755... | Line 2557... | ||
2755 | 2557 | ||
2756 | if (unlikely (cr->status)) |
2558 | if (unlikely (cr->status)) |
Line 2757... | Line 2559... | ||
2757 | return; |
2559 | return; |
2758 | 2560 | ||
2759 | status = _cairo_gstate_reset_clip (cr->gstate); |
2561 | status = cr->backend->reset_clip (cr); |
2760 | if (unlikely (status)) |
2562 | if (unlikely (status)) |
Line 2761... | Line 2563... | ||
2761 | _cairo_set_error (cr, status); |
2563 | _cairo_set_error (cr, status); |
Line 2777... | Line 2579... | ||
2777 | void |
2579 | void |
2778 | cairo_clip_extents (cairo_t *cr, |
2580 | cairo_clip_extents (cairo_t *cr, |
2779 | double *x1, double *y1, |
2581 | double *x1, double *y1, |
2780 | double *x2, double *y2) |
2582 | double *x2, double *y2) |
2781 | { |
2583 | { |
2782 | if (unlikely (cr->status)) { |
2584 | cairo_status_t status; |
- | 2585 | ||
2783 | if (x1) |
2586 | if (x1) |
2784 | *x1 = 0.0; |
2587 | *x1 = 0.0; |
2785 | if (y1) |
2588 | if (y1) |
2786 | *y1 = 0.0; |
2589 | *y1 = 0.0; |
2787 | if (x2) |
2590 | if (x2) |
2788 | *x2 = 0.0; |
2591 | *x2 = 0.0; |
2789 | if (y2) |
2592 | if (y2) |
2790 | *y2 = 0.0; |
2593 | *y2 = 0.0; |
Line -... | Line 2594... | ||
- | 2594 | ||
2791 | 2595 | if (unlikely (cr->status)) |
|
2792 | return; |
- | |
Line 2793... | Line 2596... | ||
2793 | } |
2596 | return; |
2794 | - | ||
2795 | if (! _cairo_gstate_clip_extents (cr->gstate, x1, y1, x2, y2)) { |
2597 | |
2796 | *x1 = -INFINITY; |
- | |
2797 | *y1 = -INFINITY; |
2598 | status = cr->backend->clip_extents (cr, x1, y1, x2, y2); |
2798 | *x2 = +INFINITY; |
- | |
2799 | *y2 = +INFINITY; |
2599 | if (unlikely (status)) |
Line 2800... | Line 2600... | ||
2800 | } |
2600 | _cairo_set_error (cr, status); |
2801 | } |
2601 | } |
2802 | 2602 | ||
Line 2818... | Line 2618... | ||
2818 | * Since: 1.10 |
2618 | * Since: 1.10 |
2819 | **/ |
2619 | **/ |
2820 | cairo_bool_t |
2620 | cairo_bool_t |
2821 | cairo_in_clip (cairo_t *cr, double x, double y) |
2621 | cairo_in_clip (cairo_t *cr, double x, double y) |
2822 | { |
2622 | { |
- | 2623 | cairo_status_t status; |
|
- | 2624 | cairo_bool_t inside = FALSE; |
|
- | 2625 | ||
2823 | if (unlikely (cr->status)) |
2626 | if (unlikely (cr->status)) |
2824 | return FALSE; |
2627 | return FALSE; |
Line 2825... | Line 2628... | ||
2825 | 2628 | ||
2826 | return _cairo_gstate_in_clip (cr->gstate, x, y); |
- | |
2827 | } |
- | |
2828 | - | ||
2829 | static cairo_rectangle_list_t * |
- | |
2830 | _cairo_rectangle_list_create_in_error (cairo_status_t status) |
- | |
2831 | { |
- | |
2832 | cairo_rectangle_list_t *list; |
- | |
2833 | - | ||
2834 | if (status == CAIRO_STATUS_NO_MEMORY) |
- | |
2835 | return (cairo_rectangle_list_t*) &_cairo_rectangles_nil; |
- | |
2836 | - | ||
2837 | list = malloc (sizeof (cairo_rectangle_list_t)); |
2629 | status = cr->backend->in_clip (cr, x, y, &inside); |
2838 | if (unlikely (list == NULL)) { |
2630 | if (unlikely (status)) |
2839 | status = _cairo_error (CAIRO_STATUS_NO_MEMORY); |
- | |
2840 | return (cairo_rectangle_list_t*) &_cairo_rectangles_nil; |
- | |
Line 2841... | Line -... | ||
2841 | } |
- | |
2842 | - | ||
2843 | list->status = status; |
- | |
2844 | list->rectangles = NULL; |
2631 | _cairo_set_error (cr, status); |
2845 | list->num_rectangles = 0; |
2632 | |
Line 2846... | Line 2633... | ||
2846 | return list; |
2633 | return inside; |
2847 | } |
2634 | } |
2848 | 2635 | ||
Line 2867... | Line 2654... | ||
2867 | cairo_copy_clip_rectangle_list (cairo_t *cr) |
2654 | cairo_copy_clip_rectangle_list (cairo_t *cr) |
2868 | { |
2655 | { |
2869 | if (unlikely (cr->status)) |
2656 | if (unlikely (cr->status)) |
2870 | return _cairo_rectangle_list_create_in_error (cr->status); |
2657 | return _cairo_rectangle_list_create_in_error (cr->status); |
Line 2871... | Line 2658... | ||
2871 | 2658 | ||
2872 | return _cairo_gstate_copy_clip_rectangle_list (cr->gstate); |
2659 | return cr->backend->clip_copy_rectangle_list (cr); |
Line 2873... | Line 2660... | ||
2873 | } |
2660 | } |
2874 | 2661 | ||
2875 | /** |
2662 | /** |
Line 2920... | Line 2707... | ||
2920 | * Default slant is %CAIRO_FONT_SLANT_NORMAL, and default weight is |
2707 | * Default slant is %CAIRO_FONT_SLANT_NORMAL, and default weight is |
2921 | * %CAIRO_FONT_WEIGHT_NORMAL. |
2708 | * %CAIRO_FONT_WEIGHT_NORMAL. |
2922 | * |
2709 | * |
2923 | * This function is equivalent to a call to cairo_toy_font_face_create() |
2710 | * This function is equivalent to a call to cairo_toy_font_face_create() |
2924 | * followed by cairo_set_font_face(). |
2711 | * followed by cairo_set_font_face(). |
- | 2712 | * |
|
- | 2713 | * Since: 1.0 |
|
2925 | **/ |
2714 | **/ |
2926 | void |
2715 | void |
2927 | cairo_select_font_face (cairo_t *cr, |
2716 | cairo_select_font_face (cairo_t *cr, |
2928 | const char *family, |
2717 | const char *family, |
2929 | cairo_font_slant_t slant, |
2718 | cairo_font_slant_t slant, |
2930 | cairo_font_weight_t weight) |
2719 | cairo_font_weight_t weight) |
2931 | { |
2720 | { |
- | 2721 | cairo_font_face_t *font_face; |
|
2932 | cairo_status_t status; |
2722 | cairo_status_t status; |
Line 2933... | Line 2723... | ||
2933 | 2723 | ||
2934 | if (unlikely (cr->status)) |
2724 | if (unlikely (cr->status)) |
Line 2935... | Line 2725... | ||
2935 | return; |
2725 | return; |
- | 2726 | ||
- | 2727 | font_face = cairo_toy_font_face_create (family, slant, weight); |
|
- | 2728 | if (unlikely (font_face->status)) { |
|
- | 2729 | _cairo_set_error (cr, font_face->status); |
|
- | 2730 | return; |
|
- | 2731 | } |
|
- | 2732 | ||
- | 2733 | status = cr->backend->set_font_face (cr, font_face); |
|
2936 | 2734 | cairo_font_face_destroy (font_face); |
|
2937 | status = _cairo_gstate_select_font_face (cr->gstate, family, slant, weight); |
2735 | |
2938 | if (unlikely (status)) |
2736 | if (unlikely (status)) |
Line 2939... | Line 2737... | ||
2939 | _cairo_set_error (cr, status); |
2737 | _cairo_set_error (cr, status); |
Line 2944... | Line 2742... | ||
2944 | * @cr: a #cairo_t |
2742 | * @cr: a #cairo_t |
2945 | * @extents: a #cairo_font_extents_t object into which the results |
2743 | * @extents: a #cairo_font_extents_t object into which the results |
2946 | * will be stored. |
2744 | * will be stored. |
2947 | * |
2745 | * |
2948 | * Gets the font extents for the currently selected font. |
2746 | * Gets the font extents for the currently selected font. |
- | 2747 | * |
|
- | 2748 | * Since: 1.0 |
|
2949 | **/ |
2749 | **/ |
2950 | void |
2750 | void |
2951 | cairo_font_extents (cairo_t *cr, |
2751 | cairo_font_extents (cairo_t *cr, |
2952 | cairo_font_extents_t *extents) |
2752 | cairo_font_extents_t *extents) |
2953 | { |
2753 | { |
Line 2960... | Line 2760... | ||
2960 | extents->max_y_advance = 0.0; |
2760 | extents->max_y_advance = 0.0; |
Line 2961... | Line 2761... | ||
2961 | 2761 | ||
2962 | if (unlikely (cr->status)) |
2762 | if (unlikely (cr->status)) |
Line 2963... | Line 2763... | ||
2963 | return; |
2763 | return; |
2964 | 2764 | ||
2965 | status = _cairo_gstate_get_font_extents (cr->gstate, extents); |
2765 | status = cr->backend->font_extents (cr, extents); |
2966 | if (unlikely (status)) |
2766 | if (unlikely (status)) |
Line 2967... | Line 2767... | ||
2967 | _cairo_set_error (cr, status); |
2767 | _cairo_set_error (cr, status); |
Line 2973... | Line 2773... | ||
2973 | * @font_face: a #cairo_font_face_t, or %NULL to restore to the default font |
2773 | * @font_face: a #cairo_font_face_t, or %NULL to restore to the default font |
2974 | * |
2774 | * |
2975 | * Replaces the current #cairo_font_face_t object in the #cairo_t with |
2775 | * Replaces the current #cairo_font_face_t object in the #cairo_t with |
2976 | * @font_face. The replaced font face in the #cairo_t will be |
2776 | * @font_face. The replaced font face in the #cairo_t will be |
2977 | * destroyed if there are no other references to it. |
2777 | * destroyed if there are no other references to it. |
- | 2778 | * |
|
- | 2779 | * Since: 1.0 |
|
2978 | **/ |
2780 | **/ |
2979 | void |
2781 | void |
2980 | cairo_set_font_face (cairo_t *cr, |
2782 | cairo_set_font_face (cairo_t *cr, |
2981 | cairo_font_face_t *font_face) |
2783 | cairo_font_face_t *font_face) |
2982 | { |
2784 | { |
2983 | cairo_status_t status; |
2785 | cairo_status_t status; |
Line 2984... | Line 2786... | ||
2984 | 2786 | ||
2985 | if (unlikely (cr->status)) |
2787 | if (unlikely (cr->status)) |
Line 2986... | Line 2788... | ||
2986 | return; |
2788 | return; |
2987 | 2789 | ||
2988 | status = _cairo_gstate_set_font_face (cr->gstate, font_face); |
2790 | status = cr->backend->set_font_face (cr, font_face); |
2989 | if (unlikely (status)) |
2791 | if (unlikely (status)) |
Line 2990... | Line 2792... | ||
2990 | _cairo_set_error (cr, status); |
2792 | _cairo_set_error (cr, status); |
Line 3005... | Line 2807... | ||
3005 | * cairo_font_face_status() returns %CAIRO_STATUS_NO_MEMORY. Using |
2807 | * cairo_font_face_status() returns %CAIRO_STATUS_NO_MEMORY. Using |
3006 | * this nil object will cause its error state to propagate to other |
2808 | * this nil object will cause its error state to propagate to other |
3007 | * objects it is passed to, (for example, calling |
2809 | * objects it is passed to, (for example, calling |
3008 | * cairo_set_font_face() with a nil font will trigger an error that |
2810 | * cairo_set_font_face() with a nil font will trigger an error that |
3009 | * will shutdown the #cairo_t object). |
2811 | * will shutdown the #cairo_t object). |
- | 2812 | * |
|
- | 2813 | * Since: 1.0 |
|
3010 | **/ |
2814 | **/ |
3011 | cairo_font_face_t * |
2815 | cairo_font_face_t * |
3012 | cairo_get_font_face (cairo_t *cr) |
2816 | cairo_get_font_face (cairo_t *cr) |
3013 | { |
2817 | { |
3014 | cairo_status_t status; |
- | |
3015 | cairo_font_face_t *font_face; |
- | |
3016 | - | ||
3017 | if (unlikely (cr->status)) |
2818 | if (unlikely (cr->status)) |
3018 | return (cairo_font_face_t*) &_cairo_font_face_nil; |
2819 | return (cairo_font_face_t*) &_cairo_font_face_nil; |
Line 3019... | Line -... | ||
3019 | - | ||
3020 | status = _cairo_gstate_get_font_face (cr->gstate, &font_face); |
- | |
3021 | if (unlikely (status)) { |
- | |
3022 | _cairo_set_error (cr, status); |
- | |
3023 | return (cairo_font_face_t*) &_cairo_font_face_nil; |
- | |
3024 | } |
- | |
3025 | 2820 | ||
3026 | return font_face; |
2821 | return cr->backend->get_font_face (cr); |
Line 3027... | Line 2822... | ||
3027 | } |
2822 | } |
3028 | 2823 | ||
3029 | /** |
2824 | /** |
Line 3038... | Line 2833... | ||
3038 | * em-square being a @size by @size square in user space.) |
2833 | * em-square being a @size by @size square in user space.) |
3039 | * |
2834 | * |
3040 | * If text is drawn without a call to cairo_set_font_size(), (nor |
2835 | * If text is drawn without a call to cairo_set_font_size(), (nor |
3041 | * cairo_set_font_matrix() nor cairo_set_scaled_font()), the default |
2836 | * cairo_set_font_matrix() nor cairo_set_scaled_font()), the default |
3042 | * font size is 10.0. |
2837 | * font size is 10.0. |
- | 2838 | * |
|
- | 2839 | * Since: 1.0 |
|
3043 | **/ |
2840 | **/ |
3044 | void |
2841 | void |
3045 | cairo_set_font_size (cairo_t *cr, double size) |
2842 | cairo_set_font_size (cairo_t *cr, double size) |
3046 | { |
2843 | { |
3047 | cairo_status_t status; |
2844 | cairo_status_t status; |
Line 3048... | Line 2845... | ||
3048 | 2845 | ||
3049 | if (unlikely (cr->status)) |
2846 | if (unlikely (cr->status)) |
Line 3050... | Line 2847... | ||
3050 | return; |
2847 | return; |
3051 | 2848 | ||
3052 | status = _cairo_gstate_set_font_size (cr->gstate, size); |
2849 | status = cr->backend->set_font_size (cr, size); |
3053 | if (unlikely (status)) |
2850 | if (unlikely (status)) |
3054 | _cairo_set_error (cr, status); |
2851 | _cairo_set_error (cr, status); |
Line 3055... | Line 2852... | ||
3055 | } |
2852 | } |
3056 | slim_hidden_def (cairo_set_font_size); |
2853 | slim_hidden_def (cairo_set_font_size); |
3057 | 2854 | ||
3058 | /** |
2855 | /** |
3059 | * cairo_set_font_matrix |
2856 | * cairo_set_font_matrix: |
3060 | * @cr: a #cairo_t |
2857 | * @cr: a #cairo_t |
3061 | * @matrix: a #cairo_matrix_t describing a transform to be applied to |
2858 | * @matrix: a #cairo_matrix_t describing a transform to be applied to |
3062 | * the current font. |
2859 | * the current font. |
3063 | * |
2860 | * |
3064 | * Sets the current font matrix to @matrix. The font matrix gives a |
2861 | * Sets the current font matrix to @matrix. The font matrix gives a |
3065 | * transformation from the design space of the font (in this space, |
2862 | * transformation from the design space of the font (in this space, |
3066 | * the em-square is 1 unit by 1 unit) to user space. Normally, a |
2863 | * the em-square is 1 unit by 1 unit) to user space. Normally, a |
- | 2864 | * simple scale is used (see cairo_set_font_size()), but a more |
|
- | 2865 | * complex font matrix can be used to shear the font |
|
3067 | * simple scale is used (see cairo_set_font_size()), but a more |
2866 | * or stretch it unequally along the two axes |
3068 | * complex font matrix can be used to shear the font |
2867 | * |
3069 | * or stretch it unequally along the two axes |
2868 | * Since: 1.0 |
3070 | **/ |
2869 | **/ |
3071 | void |
2870 | void |
3072 | cairo_set_font_matrix (cairo_t *cr, |
2871 | cairo_set_font_matrix (cairo_t *cr, |
Line 3073... | Line 2872... | ||
3073 | const cairo_matrix_t *matrix) |
2872 | const cairo_matrix_t *matrix) |
3074 | { |
2873 | { |
Line 3075... | Line 2874... | ||
3075 | cairo_status_t status; |
2874 | cairo_status_t status; |
3076 | 2875 | ||
3077 | if (unlikely (cr->status)) |
2876 | if (unlikely (cr->status)) |
3078 | return; |
2877 | return; |
- | 2878 | ||
Line 3079... | Line 2879... | ||
3079 | 2879 | status = cr->backend->set_font_matrix (cr, matrix); |
|
3080 | status = _cairo_gstate_set_font_matrix (cr->gstate, matrix); |
2880 | if (unlikely (status)) |
3081 | if (unlikely (status)) |
2881 | _cairo_set_error (cr, status); |
3082 | _cairo_set_error (cr, status); |
2882 | } |
3083 | } |
2883 | slim_hidden_def (cairo_set_font_matrix); |
3084 | 2884 | ||
3085 | /** |
2885 | /** |
- | 2886 | * cairo_get_font_matrix: |
|
- | 2887 | * @cr: a #cairo_t |
|
3086 | * cairo_get_font_matrix |
2888 | * @matrix: return value for the matrix |
3087 | * @cr: a #cairo_t |
2889 | * |
3088 | * @matrix: return value for the matrix |
2890 | * Stores the current font matrix into @matrix. See |
3089 | * |
2891 | * cairo_set_font_matrix(). |
3090 | * Stores the current font matrix into @matrix. See |
2892 | * |
3091 | * cairo_set_font_matrix(). |
2893 | * Since: 1.0 |
3092 | **/ |
2894 | **/ |
3093 | void |
2895 | void |
Line 3094... | Line 2896... | ||
3094 | cairo_get_font_matrix (cairo_t *cr, cairo_matrix_t *matrix) |
2896 | cairo_get_font_matrix (cairo_t *cr, cairo_matrix_t *matrix) |
3095 | { |
2897 | { |
Line 3096... | Line 2898... | ||
3096 | if (unlikely (cr->status)) { |
2898 | if (unlikely (cr->status)) { |
3097 | cairo_matrix_init_identity (matrix); |
2899 | cairo_matrix_init_identity (matrix); |
3098 | return; |
2900 | return; |
Line 3109... | Line 2911... | ||
3109 | * Sets a set of custom font rendering options for the #cairo_t. |
2911 | * Sets a set of custom font rendering options for the #cairo_t. |
3110 | * Rendering options are derived by merging these options with the |
2912 | * Rendering options are derived by merging these options with the |
3111 | * options derived from underlying surface; if the value in @options |
2913 | * options derived from underlying surface; if the value in @options |
3112 | * has a default value (like %CAIRO_ANTIALIAS_DEFAULT), then the value |
2914 | * has a default value (like %CAIRO_ANTIALIAS_DEFAULT), then the value |
3113 | * from the surface is used. |
2915 | * from the surface is used. |
- | 2916 | * |
|
- | 2917 | * Since: 1.0 |
|
3114 | **/ |
2918 | **/ |
3115 | void |
2919 | void |
3116 | cairo_set_font_options (cairo_t *cr, |
2920 | cairo_set_font_options (cairo_t *cr, |
3117 | const cairo_font_options_t *options) |
2921 | const cairo_font_options_t *options) |
3118 | { |
2922 | { |
Line 3125... | Line 2929... | ||
3125 | if (unlikely (status)) { |
2929 | if (unlikely (status)) { |
3126 | _cairo_set_error (cr, status); |
2930 | _cairo_set_error (cr, status); |
3127 | return; |
2931 | return; |
3128 | } |
2932 | } |
Line 3129... | Line 2933... | ||
3129 | 2933 | ||
- | 2934 | status = cr->backend->set_font_options (cr, options); |
|
- | 2935 | if (unlikely (status)) |
|
3130 | _cairo_gstate_set_font_options (cr->gstate, options); |
2936 | _cairo_set_error (cr, status); |
3131 | } |
2937 | } |
Line 3132... | Line 2938... | ||
3132 | slim_hidden_def (cairo_set_font_options); |
2938 | slim_hidden_def (cairo_set_font_options); |
3133 | 2939 | ||
Line 3139... | Line 2945... | ||
3139 | * |
2945 | * |
3140 | * Retrieves font rendering options set via #cairo_set_font_options. |
2946 | * Retrieves font rendering options set via #cairo_set_font_options. |
3141 | * Note that the returned options do not include any options derived |
2947 | * Note that the returned options do not include any options derived |
3142 | * from the underlying surface; they are literally the options |
2948 | * from the underlying surface; they are literally the options |
3143 | * passed to cairo_set_font_options(). |
2949 | * passed to cairo_set_font_options(). |
- | 2950 | * |
|
- | 2951 | * Since: 1.0 |
|
3144 | **/ |
2952 | **/ |
3145 | void |
2953 | void |
3146 | cairo_get_font_options (cairo_t *cr, |
2954 | cairo_get_font_options (cairo_t *cr, |
3147 | cairo_font_options_t *options) |
2955 | cairo_font_options_t *options) |
3148 | { |
2956 | { |
Line 3153... | Line 2961... | ||
3153 | if (unlikely (cr->status)) { |
2961 | if (unlikely (cr->status)) { |
3154 | _cairo_font_options_init_default (options); |
2962 | _cairo_font_options_init_default (options); |
3155 | return; |
2963 | return; |
3156 | } |
2964 | } |
Line 3157... | Line 2965... | ||
3157 | 2965 | ||
3158 | _cairo_gstate_get_font_options (cr->gstate, options); |
2966 | cr->backend->get_font_options (cr, options); |
Line 3159... | Line 2967... | ||
3159 | } |
2967 | } |
3160 | 2968 | ||
3161 | /** |
2969 | /** |
Line 3174... | Line 2982... | ||
3174 | void |
2982 | void |
3175 | cairo_set_scaled_font (cairo_t *cr, |
2983 | cairo_set_scaled_font (cairo_t *cr, |
3176 | const cairo_scaled_font_t *scaled_font) |
2984 | const cairo_scaled_font_t *scaled_font) |
3177 | { |
2985 | { |
3178 | cairo_status_t status; |
2986 | cairo_status_t status; |
3179 | cairo_bool_t was_previous; |
- | |
Line 3180... | Line 2987... | ||
3180 | 2987 | ||
3181 | if (unlikely (cr->status)) |
2988 | if (unlikely (cr->status)) |
Line 3182... | Line 2989... | ||
3182 | return; |
2989 | return; |
3183 | 2990 | ||
3184 | if (scaled_font == NULL) { |
2991 | if ((scaled_font == NULL)) { |
3185 | status = _cairo_error (CAIRO_STATUS_NULL_POINTER); |
2992 | _cairo_set_error (cr, _cairo_error (CAIRO_STATUS_NULL_POINTER)); |
Line 3186... | Line 2993... | ||
3186 | goto BAIL; |
2993 | return; |
3187 | } |
2994 | } |
3188 | - | ||
3189 | status = scaled_font->status; |
- | |
3190 | if (unlikely (status)) |
2995 | |
3191 | goto BAIL; |
2996 | status = scaled_font->status; |
- | 2997 | if (unlikely (status)) { |
|
Line 3192... | Line -... | ||
3192 | - | ||
3193 | if (scaled_font == cr->gstate->scaled_font) |
- | |
3194 | return; |
2998 | _cairo_set_error (cr, status); |
3195 | - | ||
3196 | was_previous = scaled_font == cr->gstate->previous_scaled_font; |
- | |
3197 | - | ||
3198 | status = _cairo_gstate_set_font_face (cr->gstate, scaled_font->font_face); |
- | |
3199 | if (unlikely (status)) |
2999 | return; |
3200 | goto BAIL; |
- | |
3201 | - | ||
3202 | status = _cairo_gstate_set_font_matrix (cr->gstate, &scaled_font->font_matrix); |
- | |
3203 | if (unlikely (status)) |
- | |
3204 | goto BAIL; |
- | |
3205 | - | ||
3206 | _cairo_gstate_set_font_options (cr->gstate, &scaled_font->options); |
- | |
3207 | - | ||
3208 | if (was_previous) |
- | |
3209 | cr->gstate->scaled_font = cairo_scaled_font_reference ((cairo_scaled_font_t *) scaled_font); |
- | |
3210 | 3000 | } |
|
3211 | return; |
3001 | |
Line 3212... | Line 3002... | ||
3212 | 3002 | status = cr->backend->set_scaled_font (cr, (cairo_scaled_font_t *) scaled_font); |
|
3213 | BAIL: |
3003 | if (unlikely (status)) |
Line 3235... | Line 3025... | ||
3235 | * Since: 1.4 |
3025 | * Since: 1.4 |
3236 | **/ |
3026 | **/ |
3237 | cairo_scaled_font_t * |
3027 | cairo_scaled_font_t * |
3238 | cairo_get_scaled_font (cairo_t *cr) |
3028 | cairo_get_scaled_font (cairo_t *cr) |
3239 | { |
3029 | { |
3240 | cairo_status_t status; |
- | |
3241 | cairo_scaled_font_t *scaled_font; |
- | |
3242 | - | ||
3243 | if (unlikely (cr->status)) |
3030 | if (unlikely (cr->status)) |
3244 | return _cairo_scaled_font_create_in_error (cr->status); |
3031 | return _cairo_scaled_font_create_in_error (cr->status); |
Line 3245... | Line -... | ||
3245 | - | ||
3246 | status = _cairo_gstate_get_scaled_font (cr->gstate, &scaled_font); |
- | |
3247 | if (unlikely (status)) { |
- | |
3248 | _cairo_set_error (cr, status); |
- | |
3249 | return _cairo_scaled_font_create_in_error (status); |
- | |
3250 | } |
- | |
3251 | 3032 | ||
3252 | return scaled_font; |
3033 | return cr->backend->get_scaled_font (cr); |
- | 3034 | } |
|
Line 3253... | Line 3035... | ||
3253 | } |
3035 | slim_hidden_def (cairo_get_scaled_font); |
3254 | 3036 | ||
3255 | /** |
3037 | /** |
3256 | * cairo_text_extents: |
3038 | * cairo_text_extents: |
Line 3269... | Line 3051... | ||
3269 | * size of the rectangle (extents.width and extents.height). They do |
3051 | * size of the rectangle (extents.width and extents.height). They do |
3270 | * contribute indirectly by changing the position of non-whitespace |
3052 | * contribute indirectly by changing the position of non-whitespace |
3271 | * characters. In particular, trailing whitespace characters are |
3053 | * characters. In particular, trailing whitespace characters are |
3272 | * likely to not affect the size of the rectangle, though they will |
3054 | * likely to not affect the size of the rectangle, though they will |
3273 | * affect the x_advance and y_advance values. |
3055 | * affect the x_advance and y_advance values. |
- | 3056 | * |
|
- | 3057 | * Since: 1.0 |
|
3274 | **/ |
3058 | **/ |
3275 | void |
3059 | void |
3276 | cairo_text_extents (cairo_t *cr, |
3060 | cairo_text_extents (cairo_t *cr, |
3277 | const char *utf8, |
3061 | const char *utf8, |
3278 | cairo_text_extents_t *extents) |
3062 | cairo_text_extents_t *extents) |
3279 | { |
3063 | { |
3280 | cairo_status_t status; |
3064 | cairo_status_t status; |
- | 3065 | cairo_scaled_font_t *scaled_font; |
|
3281 | cairo_glyph_t *glyphs = NULL; |
3066 | cairo_glyph_t *glyphs = NULL; |
3282 | int num_glyphs; |
3067 | int num_glyphs = 0; |
3283 | double x, y; |
3068 | double x, y; |
Line 3284... | Line 3069... | ||
3284 | 3069 | ||
3285 | extents->x_bearing = 0.0; |
3070 | extents->x_bearing = 0.0; |
3286 | extents->y_bearing = 0.0; |
3071 | extents->y_bearing = 0.0; |
Line 3293... | Line 3078... | ||
3293 | return; |
3078 | return; |
Line 3294... | Line 3079... | ||
3294 | 3079 | ||
3295 | if (utf8 == NULL) |
3080 | if (utf8 == NULL) |
Line 3296... | Line 3081... | ||
3296 | return; |
3081 | return; |
- | 3082 | ||
- | 3083 | scaled_font = cairo_get_scaled_font (cr); |
|
- | 3084 | if (unlikely (scaled_font->status)) { |
|
- | 3085 | _cairo_set_error (cr, scaled_font->status); |
|
Line -... | Line 3086... | ||
- | 3086 | return; |
|
3297 | 3087 | } |
|
3298 | cairo_get_current_point (cr, &x, &y); |
3088 | |
3299 | 3089 | cairo_get_current_point (cr, &x, &y); |
|
3300 | status = _cairo_gstate_text_to_glyphs (cr->gstate, |
3090 | status = cairo_scaled_font_text_to_glyphs (scaled_font, |
3301 | x, y, |
3091 | x, y, |
3302 | utf8, strlen (utf8), |
- | |
Line 3303... | Line 3092... | ||
3303 | &glyphs, &num_glyphs, |
3092 | utf8, -1, |
3304 | NULL, NULL, |
3093 | &glyphs, &num_glyphs, |
3305 | NULL); |
3094 | NULL, NULL, NULL); |
3306 | 3095 | ||
- | 3096 | if (likely (status == CAIRO_STATUS_SUCCESS)) { |
|
3307 | if (status == CAIRO_STATUS_SUCCESS) |
3097 | status = cr->backend->glyph_extents (cr, |
Line 3308... | Line 3098... | ||
3308 | status = _cairo_gstate_glyph_extents (cr->gstate, |
3098 | glyphs, num_glyphs, |
3309 | glyphs, num_glyphs, |
3099 | extents); |
3310 | extents); |
3100 | } |
Line 3329... | Line 3119... | ||
3329 | * amount by which the current point would be advanced by |
3119 | * amount by which the current point would be advanced by |
3330 | * cairo_show_glyphs(). |
3120 | * cairo_show_glyphs(). |
3331 | * |
3121 | * |
3332 | * Note that whitespace glyphs do not contribute to the size of the |
3122 | * Note that whitespace glyphs do not contribute to the size of the |
3333 | * rectangle (extents.width and extents.height). |
3123 | * rectangle (extents.width and extents.height). |
- | 3124 | * |
|
- | 3125 | * Since: 1.0 |
|
3334 | **/ |
3126 | **/ |
3335 | void |
3127 | void |
3336 | cairo_glyph_extents (cairo_t *cr, |
3128 | cairo_glyph_extents (cairo_t *cr, |
3337 | const cairo_glyph_t *glyphs, |
3129 | const cairo_glyph_t *glyphs, |
3338 | int num_glyphs, |
3130 | int num_glyphs, |
Line 3351... | Line 3143... | ||
3351 | return; |
3143 | return; |
Line 3352... | Line 3144... | ||
3352 | 3144 | ||
3353 | if (num_glyphs == 0) |
3145 | if (num_glyphs == 0) |
Line 3354... | Line 3146... | ||
3354 | return; |
3146 | return; |
3355 | 3147 | ||
3356 | if (num_glyphs < 0) { |
3148 | if (unlikely (num_glyphs < 0)) { |
3357 | _cairo_set_error (cr, CAIRO_STATUS_NEGATIVE_COUNT); |
3149 | _cairo_set_error (cr, CAIRO_STATUS_NEGATIVE_COUNT); |
Line 3358... | Line 3150... | ||
3358 | return; |
3150 | return; |
3359 | } |
3151 | } |
3360 | 3152 | ||
3361 | if (glyphs == NULL) { |
3153 | if (unlikely (glyphs == NULL)) { |
Line 3362... | Line 3154... | ||
3362 | _cairo_set_error (cr, CAIRO_STATUS_NULL_POINTER); |
3154 | _cairo_set_error (cr, CAIRO_STATUS_NULL_POINTER); |
3363 | return; |
- | |
3364 | } |
3155 | return; |
3365 | 3156 | } |
|
3366 | status = _cairo_gstate_glyph_extents (cr->gstate, glyphs, num_glyphs, |
3157 | |
Line 3367... | Line 3158... | ||
3367 | extents); |
3158 | status = cr->backend->glyph_extents (cr, glyphs, num_glyphs, extents); |
Line 3393... | Line 3184... | ||
3393 | * Note: The cairo_show_text() function call is part of what the cairo |
3184 | * Note: The cairo_show_text() function call is part of what the cairo |
3394 | * designers call the "toy" text API. It is convenient for short demos |
3185 | * designers call the "toy" text API. It is convenient for short demos |
3395 | * and simple programs, but it is not expected to be adequate for |
3186 | * and simple programs, but it is not expected to be adequate for |
3396 | * serious text-using applications. See cairo_show_glyphs() for the |
3187 | * serious text-using applications. See cairo_show_glyphs() for the |
3397 | * "real" text display API in cairo. |
3188 | * "real" text display API in cairo. |
- | 3189 | * |
|
- | 3190 | * Since: 1.0 |
|
3398 | **/ |
3191 | **/ |
3399 | void |
3192 | void |
3400 | cairo_show_text (cairo_t *cr, const char *utf8) |
3193 | cairo_show_text (cairo_t *cr, const char *utf8) |
3401 | { |
3194 | { |
3402 | cairo_text_extents_t extents; |
3195 | cairo_text_extents_t extents; |
Line 3407... | Line 3200... | ||
3407 | cairo_text_cluster_flags_t cluster_flags; |
3200 | cairo_text_cluster_flags_t cluster_flags; |
3408 | double x, y; |
3201 | double x, y; |
3409 | cairo_bool_t has_show_text_glyphs; |
3202 | cairo_bool_t has_show_text_glyphs; |
3410 | cairo_glyph_t stack_glyphs[CAIRO_STACK_ARRAY_LENGTH (cairo_glyph_t)]; |
3203 | cairo_glyph_t stack_glyphs[CAIRO_STACK_ARRAY_LENGTH (cairo_glyph_t)]; |
3411 | cairo_text_cluster_t stack_clusters[CAIRO_STACK_ARRAY_LENGTH (cairo_text_cluster_t)]; |
3204 | cairo_text_cluster_t stack_clusters[CAIRO_STACK_ARRAY_LENGTH (cairo_text_cluster_t)]; |
- | 3205 | cairo_scaled_font_t *scaled_font; |
|
- | 3206 | cairo_glyph_text_info_t info, *i; |
|
Line 3412... | Line 3207... | ||
3412 | 3207 | ||
3413 | if (unlikely (cr->status)) |
3208 | if (unlikely (cr->status)) |
Line 3414... | Line 3209... | ||
3414 | return; |
3209 | return; |
3415 | 3210 | ||
Line 3416... | Line 3211... | ||
3416 | if (utf8 == NULL) |
3211 | if (utf8 == NULL) |
- | 3212 | return; |
|
- | 3213 | ||
- | 3214 | scaled_font = cairo_get_scaled_font (cr); |
|
- | 3215 | if (unlikely (scaled_font->status)) { |
|
Line 3417... | Line 3216... | ||
3417 | return; |
3216 | _cairo_set_error (cr, scaled_font->status); |
Line 3418... | Line 3217... | ||
3418 | 3217 | return; |
|
3419 | cairo_get_current_point (cr, &x, &y); |
3218 | } |
Line 3432... | Line 3231... | ||
3432 | } else { |
3231 | } else { |
3433 | clusters = NULL; |
3232 | clusters = NULL; |
3434 | num_clusters = 0; |
3233 | num_clusters = 0; |
3435 | } |
3234 | } |
Line -... | Line 3235... | ||
- | 3235 | ||
3436 | 3236 | cairo_get_current_point (cr, &x, &y); |
|
3437 | status = _cairo_gstate_text_to_glyphs (cr->gstate, |
3237 | status = cairo_scaled_font_text_to_glyphs (scaled_font, |
3438 | x, y, |
3238 | x, y, |
3439 | utf8, utf8_len, |
3239 | utf8, utf8_len, |
3440 | &glyphs, &num_glyphs, |
3240 | &glyphs, &num_glyphs, |
3441 | has_show_text_glyphs ? &clusters : NULL, &num_clusters, |
3241 | has_show_text_glyphs ? &clusters : NULL, &num_clusters, |
Line 3444... | Line 3244... | ||
3444 | goto BAIL; |
3244 | goto BAIL; |
Line 3445... | Line 3245... | ||
3445 | 3245 | ||
3446 | if (num_glyphs == 0) |
3246 | if (num_glyphs == 0) |
Line -... | Line 3247... | ||
- | 3247 | return; |
|
3447 | return; |
3248 | |
- | 3249 | i = NULL; |
|
3448 | 3250 | if (has_show_text_glyphs) { |
|
3449 | status = _cairo_gstate_show_text_glyphs (cr->gstate, |
3251 | info.utf8 = utf8; |
3450 | utf8, utf8_len, |
3252 | info.utf8_len = utf8_len; |
3451 | glyphs, num_glyphs, |
3253 | info.clusters = clusters; |
- | 3254 | info.num_clusters = num_clusters; |
|
- | 3255 | info.cluster_flags = cluster_flags; |
|
- | 3256 | i = &info; |
|
- | 3257 | } |
|
3452 | clusters, num_clusters, |
3258 | |
3453 | cluster_flags); |
3259 | status = cr->backend->glyphs (cr, glyphs, num_glyphs, i); |
Line 3454... | Line 3260... | ||
3454 | if (unlikely (status)) |
3260 | if (unlikely (status)) |
3455 | goto BAIL; |
3261 | goto BAIL; |
3456 | - | ||
3457 | last_glyph = &glyphs[num_glyphs - 1]; |
- | |
3458 | status = _cairo_gstate_glyph_extents (cr->gstate, |
3262 | |
3459 | last_glyph, 1, |
3263 | last_glyph = &glyphs[num_glyphs - 1]; |
Line 3460... | Line 3264... | ||
3460 | &extents); |
3264 | status = cr->backend->glyph_extents (cr, last_glyph, 1, &extents); |
3461 | if (unlikely (status)) |
3265 | if (unlikely (status)) |
3462 | goto BAIL; |
3266 | goto BAIL; |
Line 3463... | Line 3267... | ||
3463 | 3267 | ||
3464 | x = last_glyph->x + extents.x_advance; |
3268 | x = last_glyph->x + extents.x_advance; |
3465 | y = last_glyph->y + extents.y_advance; |
3269 | y = last_glyph->y + extents.y_advance; |
3466 | cairo_move_to (cr, x, y); |
3270 | cr->backend->move_to (cr, x, y); |
Line 3482... | Line 3286... | ||
3482 | * @num_glyphs: number of glyphs to show |
3286 | * @num_glyphs: number of glyphs to show |
3483 | * |
3287 | * |
3484 | * A drawing operator that generates the shape from an array of glyphs, |
3288 | * A drawing operator that generates the shape from an array of glyphs, |
3485 | * rendered according to the current font face, font size |
3289 | * rendered according to the current font face, font size |
3486 | * (font matrix), and font options. |
3290 | * (font matrix), and font options. |
- | 3291 | * |
|
- | 3292 | * Since: 1.0 |
|
3487 | **/ |
3293 | **/ |
3488 | void |
3294 | void |
3489 | cairo_show_glyphs (cairo_t *cr, const cairo_glyph_t *glyphs, int num_glyphs) |
3295 | cairo_show_glyphs (cairo_t *cr, const cairo_glyph_t *glyphs, int num_glyphs) |
3490 | { |
3296 | { |
3491 | cairo_status_t status; |
3297 | cairo_status_t status; |
Line 3504... | Line 3310... | ||
3504 | if (glyphs == NULL) { |
3310 | if (glyphs == NULL) { |
3505 | _cairo_set_error (cr, CAIRO_STATUS_NULL_POINTER); |
3311 | _cairo_set_error (cr, CAIRO_STATUS_NULL_POINTER); |
3506 | return; |
3312 | return; |
3507 | } |
3313 | } |
Line 3508... | Line 3314... | ||
3508 | 3314 | ||
3509 | status = _cairo_gstate_show_text_glyphs (cr->gstate, |
- | |
3510 | NULL, 0, |
- | |
3511 | glyphs, num_glyphs, |
- | |
3512 | NULL, 0, |
- | |
3513 | FALSE); |
3315 | status = cr->backend->glyphs (cr, glyphs, num_glyphs, NULL); |
3514 | if (unlikely (status)) |
3316 | if (unlikely (status)) |
3515 | _cairo_set_error (cr, status); |
3317 | _cairo_set_error (cr, status); |
Line 3516... | Line 3318... | ||
3516 | } |
3318 | } |
Line 3586... | Line 3388... | ||
3586 | if (num_glyphs < 0 || utf8_len < 0 || num_clusters < 0) { |
3388 | if (num_glyphs < 0 || utf8_len < 0 || num_clusters < 0) { |
3587 | _cairo_set_error (cr, CAIRO_STATUS_NEGATIVE_COUNT); |
3389 | _cairo_set_error (cr, CAIRO_STATUS_NEGATIVE_COUNT); |
3588 | return; |
3390 | return; |
3589 | } |
3391 | } |
Line -... | Line 3392... | ||
- | 3392 | ||
- | 3393 | if (num_glyphs == 0 && utf8_len == 0) |
|
- | 3394 | return; |
|
- | 3395 | ||
3590 | 3396 | if (utf8) { |
|
3591 | /* Make sure clusters cover the entire glyphs and utf8 arrays, |
3397 | /* Make sure clusters cover the entire glyphs and utf8 arrays, |
3592 | * and that cluster boundaries are UTF-8 boundaries. */ |
3398 | * and that cluster boundaries are UTF-8 boundaries. */ |
3593 | status = _cairo_validate_text_clusters (utf8, utf8_len, |
3399 | status = _cairo_validate_text_clusters (utf8, utf8_len, |
3594 | glyphs, num_glyphs, |
3400 | glyphs, num_glyphs, |
Line 3600... | Line 3406... | ||
3600 | cairo_status_t status2; |
3406 | cairo_status_t status2; |
Line 3601... | Line 3407... | ||
3601 | 3407 | ||
3602 | status2 = _cairo_utf8_to_ucs4 (utf8, utf8_len, NULL, NULL); |
3408 | status2 = _cairo_utf8_to_ucs4 (utf8, utf8_len, NULL, NULL); |
3603 | if (status2) |
3409 | if (status2) |
- | 3410 | status = status2; |
|
- | 3411 | } else { |
|
Line 3604... | Line 3412... | ||
3604 | status = status2; |
3412 | cairo_glyph_text_info_t info; |
3605 | 3413 | ||
3606 | _cairo_set_error (cr, status); |
3414 | info.utf8 = utf8; |
3607 | return; |
- | |
3608 | } |
3415 | info.utf8_len = utf8_len; |
3609 | 3416 | info.clusters = clusters; |
|
Line 3610... | Line 3417... | ||
3610 | if (num_glyphs == 0 && utf8_len == 0) |
3417 | info.num_clusters = num_clusters; |
- | 3418 | info.cluster_flags = cluster_flags; |
|
3611 | return; |
3419 | |
3612 | 3420 | status = cr->backend->glyphs (cr, glyphs, num_glyphs, &info); |
|
3613 | status = _cairo_gstate_show_text_glyphs (cr->gstate, |
3421 | } |
3614 | utf8, utf8_len, |
3422 | } else { |
3615 | glyphs, num_glyphs, |
3423 | status = cr->backend->glyphs (cr, glyphs, num_glyphs, NULL); |
3616 | clusters, num_clusters, cluster_flags); |
3424 | } |
Line 3617... | Line 3425... | ||
3617 | if (unlikely (status)) |
3425 | if (unlikely (status)) |
Line 3639... | Line 3447... | ||
3639 | * Note: The cairo_text_path() function call is part of what the cairo |
3447 | * Note: The cairo_text_path() function call is part of what the cairo |
3640 | * designers call the "toy" text API. It is convenient for short demos |
3448 | * designers call the "toy" text API. It is convenient for short demos |
3641 | * and simple programs, but it is not expected to be adequate for |
3449 | * and simple programs, but it is not expected to be adequate for |
3642 | * serious text-using applications. See cairo_glyph_path() for the |
3450 | * serious text-using applications. See cairo_glyph_path() for the |
3643 | * "real" text path API in cairo. |
3451 | * "real" text path API in cairo. |
- | 3452 | * |
|
- | 3453 | * Since: 1.0 |
|
3644 | **/ |
3454 | **/ |
3645 | void |
3455 | void |
3646 | cairo_text_path (cairo_t *cr, const char *utf8) |
3456 | cairo_text_path (cairo_t *cr, const char *utf8) |
3647 | { |
3457 | { |
3648 | cairo_status_t status; |
3458 | cairo_status_t status; |
3649 | cairo_text_extents_t extents; |
3459 | cairo_text_extents_t extents; |
3650 | cairo_glyph_t stack_glyphs[CAIRO_STACK_ARRAY_LENGTH (cairo_glyph_t)]; |
3460 | cairo_glyph_t stack_glyphs[CAIRO_STACK_ARRAY_LENGTH (cairo_glyph_t)]; |
3651 | cairo_glyph_t *glyphs, *last_glyph; |
3461 | cairo_glyph_t *glyphs, *last_glyph; |
- | 3462 | cairo_scaled_font_t *scaled_font; |
|
3652 | int num_glyphs; |
3463 | int num_glyphs; |
3653 | double x, y; |
3464 | double x, y; |
Line 3654... | Line 3465... | ||
3654 | 3465 | ||
3655 | if (unlikely (cr->status)) |
3466 | if (unlikely (cr->status)) |
Line 3656... | Line 3467... | ||
3656 | return; |
3467 | return; |
3657 | 3468 | ||
Line 3658... | Line -... | ||
3658 | if (utf8 == NULL) |
- | |
Line 3659... | Line 3469... | ||
3659 | return; |
3469 | if (utf8 == NULL) |
3660 | 3470 | return; |
|
Line -... | Line 3471... | ||
- | 3471 | ||
- | 3472 | ||
- | 3473 | glyphs = stack_glyphs; |
|
- | 3474 | num_glyphs = ARRAY_LENGTH (stack_glyphs); |
|
- | 3475 | ||
- | 3476 | scaled_font = cairo_get_scaled_font (cr); |
|
- | 3477 | if (unlikely (scaled_font->status)) { |
|
3661 | cairo_get_current_point (cr, &x, &y); |
3478 | _cairo_set_error (cr, scaled_font->status); |
3662 | 3479 | return; |
|
3663 | glyphs = stack_glyphs; |
3480 | } |
3664 | num_glyphs = ARRAY_LENGTH (stack_glyphs); |
3481 | |
3665 | 3482 | cairo_get_current_point (cr, &x, &y); |
|
3666 | status = _cairo_gstate_text_to_glyphs (cr->gstate, |
- | |
3667 | x, y, |
- | |
3668 | utf8, strlen (utf8), |
- | |
3669 | &glyphs, &num_glyphs, |
- | |
Line 3670... | Line 3483... | ||
3670 | NULL, NULL, |
3483 | status = cairo_scaled_font_text_to_glyphs (scaled_font, |
3671 | NULL); |
3484 | x, y, |
Line 3672... | Line 3485... | ||
3672 | 3485 | utf8, -1, |
|
3673 | if (unlikely (status)) |
- | |
3674 | goto BAIL; |
- | |
Line 3675... | Line 3486... | ||
3675 | 3486 | &glyphs, &num_glyphs, |
|
3676 | if (num_glyphs == 0) |
3487 | NULL, NULL, NULL); |
Line 3677... | Line 3488... | ||
3677 | return; |
3488 | |
3678 | 3489 | if (num_glyphs == 0) |
|
3679 | status = _cairo_gstate_glyph_path (cr->gstate, |
- | |
3680 | glyphs, num_glyphs, |
- | |
Line 3681... | Line 3490... | ||
3681 | cr->path); |
3490 | return; |
3682 | 3491 | ||
Line 3683... | Line 3492... | ||
3683 | if (unlikely (status)) |
3492 | status = cr->backend->glyph_path (cr, glyphs, num_glyphs); |
3684 | goto BAIL; |
3493 | |
3685 | 3494 | if (unlikely (status)) |
|
Line 3686... | Line 3495... | ||
3686 | last_glyph = &glyphs[num_glyphs - 1]; |
3495 | goto BAIL; |
3687 | status = _cairo_gstate_glyph_extents (cr->gstate, |
3496 | |
3688 | last_glyph, 1, |
3497 | last_glyph = &glyphs[num_glyphs - 1]; |
Line 3710... | Line 3519... | ||
3710 | * @num_glyphs: number of glyphs to show |
3519 | * @num_glyphs: number of glyphs to show |
3711 | * |
3520 | * |
3712 | * Adds closed paths for the glyphs to the current path. The generated |
3521 | * Adds closed paths for the glyphs to the current path. The generated |
3713 | * path if filled, achieves an effect similar to that of |
3522 | * path if filled, achieves an effect similar to that of |
3714 | * cairo_show_glyphs(). |
3523 | * cairo_show_glyphs(). |
- | 3524 | * |
|
- | 3525 | * Since: 1.0 |
|
3715 | **/ |
3526 | **/ |
3716 | void |
3527 | void |
3717 | cairo_glyph_path (cairo_t *cr, const cairo_glyph_t *glyphs, int num_glyphs) |
3528 | cairo_glyph_path (cairo_t *cr, const cairo_glyph_t *glyphs, int num_glyphs) |
3718 | { |
3529 | { |
3719 | cairo_status_t status; |
3530 | cairo_status_t status; |
Line 3722... | Line 3533... | ||
3722 | return; |
3533 | return; |
Line 3723... | Line 3534... | ||
3723 | 3534 | ||
3724 | if (num_glyphs == 0) |
3535 | if (num_glyphs == 0) |
Line 3725... | Line 3536... | ||
3725 | return; |
3536 | return; |
3726 | 3537 | ||
3727 | if (num_glyphs < 0) { |
3538 | if (unlikely (num_glyphs < 0)) { |
3728 | _cairo_set_error (cr, CAIRO_STATUS_NEGATIVE_COUNT); |
3539 | _cairo_set_error (cr, CAIRO_STATUS_NEGATIVE_COUNT); |
Line 3729... | Line 3540... | ||
3729 | return; |
3540 | return; |
3730 | } |
3541 | } |
3731 | 3542 | ||
3732 | if (glyphs == NULL) { |
3543 | if (unlikely (glyphs == NULL)) { |
Line 3733... | Line 3544... | ||
3733 | _cairo_set_error (cr, CAIRO_STATUS_NULL_POINTER); |
3544 | _cairo_set_error (cr, CAIRO_STATUS_NULL_POINTER); |
3734 | return; |
- | |
3735 | } |
- | |
3736 | 3545 | return; |
|
3737 | status = _cairo_gstate_glyph_path (cr->gstate, |
3546 | } |
3738 | glyphs, num_glyphs, |
3547 | |
Line 3739... | Line 3548... | ||
3739 | cr->path); |
3548 | status = cr->backend->glyph_path (cr, glyphs, num_glyphs); |
Line 3746... | Line 3555... | ||
3746 | * @cr: a cairo context |
3555 | * @cr: a cairo context |
3747 | * |
3556 | * |
3748 | * Gets the current compositing operator for a cairo context. |
3557 | * Gets the current compositing operator for a cairo context. |
3749 | * |
3558 | * |
3750 | * Return value: the current compositing operator. |
3559 | * Return value: the current compositing operator. |
- | 3560 | * |
|
- | 3561 | * Since: 1.0 |
|
3751 | **/ |
3562 | **/ |
3752 | cairo_operator_t |
3563 | cairo_operator_t |
3753 | cairo_get_operator (cairo_t *cr) |
3564 | cairo_get_operator (cairo_t *cr) |
3754 | { |
3565 | { |
3755 | if (unlikely (cr->status)) |
3566 | if (unlikely (cr->status)) |
3756 | return CAIRO_GSTATE_OPERATOR_DEFAULT; |
3567 | return CAIRO_GSTATE_OPERATOR_DEFAULT; |
Line 3757... | Line 3568... | ||
3757 | 3568 | ||
- | 3569 | return cr->backend->get_operator (cr); |
|
- | 3570 | } |
|
- | 3571 | ||
- | 3572 | #if 0 |
|
- | 3573 | /** |
|
- | 3574 | * cairo_get_opacity: |
|
- | 3575 | * @cr: a cairo context |
|
- | 3576 | * |
|
- | 3577 | * Gets the current compositing opacity for a cairo context. |
|
- | 3578 | * |
|
- | 3579 | * Return value: the current compositing opacity. |
|
- | 3580 | * |
|
- | 3581 | * Since: TBD |
|
- | 3582 | **/ |
|
- | 3583 | double |
|
- | 3584 | cairo_get_opacity (cairo_t *cr) |
|
- | 3585 | { |
|
- | 3586 | if (unlikely (cr->status)) |
|
- | 3587 | return 1.; |
|
- | 3588 | ||
3758 | return _cairo_gstate_get_operator (cr->gstate); |
3589 | return cr->backend->get_opacity (cr); |
- | 3590 | } |
|
Line 3759... | Line 3591... | ||
3759 | } |
3591 | #endif |
3760 | 3592 | ||
3761 | /** |
3593 | /** |
3762 | * cairo_get_tolerance: |
3594 | * cairo_get_tolerance: |
3763 | * @cr: a cairo context |
3595 | * @cr: a cairo context |
3764 | * |
3596 | * |
3765 | * Gets the current tolerance value, as set by cairo_set_tolerance(). |
3597 | * Gets the current tolerance value, as set by cairo_set_tolerance(). |
- | 3598 | * |
|
- | 3599 | * Return value: the current tolerance value. |
|
3766 | * |
3600 | * |
3767 | * Return value: the current tolerance value. |
3601 | * Since: 1.0 |
3768 | **/ |
3602 | **/ |
3769 | double |
3603 | double |
3770 | cairo_get_tolerance (cairo_t *cr) |
3604 | cairo_get_tolerance (cairo_t *cr) |
3771 | { |
3605 | { |
Line 3772... | Line 3606... | ||
3772 | if (unlikely (cr->status)) |
3606 | if (unlikely (cr->status)) |
3773 | return CAIRO_GSTATE_TOLERANCE_DEFAULT; |
3607 | return CAIRO_GSTATE_TOLERANCE_DEFAULT; |
3774 | 3608 | ||
Line 3775... | Line 3609... | ||
3775 | return _cairo_gstate_get_tolerance (cr->gstate); |
3609 | return cr->backend->get_tolerance (cr); |
3776 | } |
3610 | } |
3777 | slim_hidden_def (cairo_get_tolerance); |
3611 | slim_hidden_def (cairo_get_tolerance); |
3778 | 3612 | ||
3779 | /** |
3613 | /** |
- | 3614 | * cairo_get_antialias: |
|
3780 | * cairo_get_antialias: |
3615 | * @cr: a cairo context |
3781 | * @cr: a cairo context |
3616 | * |
- | 3617 | * Gets the current shape antialiasing mode, as set by |
|
- | 3618 | * cairo_set_antialias(). |
|
3782 | * |
3619 | * |
3783 | * Gets the current shape antialiasing mode, as set by cairo_set_shape_antialias(). |
3620 | * Return value: the current shape antialiasing mode. |
3784 | * |
3621 | * |
3785 | * Return value: the current shape antialiasing mode. |
3622 | * Since: 1.0 |
3786 | **/ |
3623 | **/ |
3787 | cairo_antialias_t |
3624 | cairo_antialias_t |
Line 3788... | Line 3625... | ||
3788 | cairo_get_antialias (cairo_t *cr) |
3625 | cairo_get_antialias (cairo_t *cr) |
3789 | { |
3626 | { |
Line 3790... | Line 3627... | ||
3790 | if (unlikely (cr->status)) |
3627 | if (unlikely (cr->status)) |
3791 | return CAIRO_ANTIALIAS_DEFAULT; |
3628 | return CAIRO_ANTIALIAS_DEFAULT; |
3792 | 3629 | ||
Line 3808... | Line 3645... | ||
3808 | cairo_has_current_point (cairo_t *cr) |
3645 | cairo_has_current_point (cairo_t *cr) |
3809 | { |
3646 | { |
3810 | if (unlikely (cr->status)) |
3647 | if (unlikely (cr->status)) |
3811 | return FALSE; |
3648 | return FALSE; |
Line 3812... | Line 3649... | ||
3812 | 3649 | ||
3813 | return cr->path->has_current_point; |
3650 | return cr->backend->has_current_point (cr); |
Line 3814... | Line 3651... | ||
3814 | } |
3651 | } |
3815 | 3652 | ||
3816 | /** |
3653 | /** |
Line 3840... | Line 3677... | ||
3840 | * otherwise change current path: |
3677 | * otherwise change current path: |
3841 | * cairo_show_text(). |
3678 | * cairo_show_text(). |
3842 | * |
3679 | * |
3843 | * Some functions unset the current path and as a result, current point: |
3680 | * Some functions unset the current path and as a result, current point: |
3844 | * cairo_fill(), cairo_stroke(). |
3681 | * cairo_fill(), cairo_stroke(). |
- | 3682 | * |
|
- | 3683 | * Since: 1.0 |
|
3845 | **/ |
3684 | **/ |
3846 | void |
3685 | void |
3847 | cairo_get_current_point (cairo_t *cr, double *x_ret, double *y_ret) |
3686 | cairo_get_current_point (cairo_t *cr, double *x_ret, double *y_ret) |
3848 | { |
3687 | { |
3849 | cairo_fixed_t x_fixed, y_fixed; |
- | |
3850 | double x, y; |
3688 | double x, y; |
Line -... | Line 3689... | ||
- | 3689 | ||
3851 | 3690 | x = y = 0; |
|
3852 | if (cr->status == CAIRO_STATUS_SUCCESS && |
3691 | if (cr->status == CAIRO_STATUS_SUCCESS && |
3853 | _cairo_path_fixed_get_current_point (cr->path, &x_fixed, &y_fixed)) |
- | |
3854 | { |
- | |
3855 | x = _cairo_fixed_to_double (x_fixed); |
- | |
3856 | y = _cairo_fixed_to_double (y_fixed); |
- | |
3857 | _cairo_gstate_backend_to_user (cr->gstate, &x, &y); |
- | |
3858 | } |
- | |
3859 | else |
3692 | cr->backend->has_current_point (cr)) |
3860 | { |
- | |
3861 | x = 0.0; |
3693 | { |
3862 | y = 0.0; |
3694 | cr->backend->get_current_point (cr, &x, &y); |
Line 3863... | Line 3695... | ||
3863 | } |
3695 | } |
3864 | 3696 | ||
3865 | if (x_ret) |
3697 | if (x_ret) |
Line 3874... | Line 3706... | ||
3874 | * @cr: a cairo context |
3706 | * @cr: a cairo context |
3875 | * |
3707 | * |
3876 | * Gets the current fill rule, as set by cairo_set_fill_rule(). |
3708 | * Gets the current fill rule, as set by cairo_set_fill_rule(). |
3877 | * |
3709 | * |
3878 | * Return value: the current fill rule. |
3710 | * Return value: the current fill rule. |
- | 3711 | * |
|
- | 3712 | * Since: 1.0 |
|
3879 | **/ |
3713 | **/ |
3880 | cairo_fill_rule_t |
3714 | cairo_fill_rule_t |
3881 | cairo_get_fill_rule (cairo_t *cr) |
3715 | cairo_get_fill_rule (cairo_t *cr) |
3882 | { |
3716 | { |
3883 | if (unlikely (cr->status)) |
3717 | if (unlikely (cr->status)) |
3884 | return CAIRO_GSTATE_FILL_RULE_DEFAULT; |
3718 | return CAIRO_GSTATE_FILL_RULE_DEFAULT; |
Line 3885... | Line 3719... | ||
3885 | 3719 | ||
3886 | return _cairo_gstate_get_fill_rule (cr->gstate); |
3720 | return cr->backend->get_fill_rule (cr); |
Line 3887... | Line 3721... | ||
3887 | } |
3721 | } |
3888 | 3722 | ||
3889 | /** |
3723 | /** |
Line 3894... | Line 3728... | ||
3894 | * cairo_set_line_width(). Note that the value is unchanged even if |
3728 | * cairo_set_line_width(). Note that the value is unchanged even if |
3895 | * the CTM has changed between the calls to cairo_set_line_width() and |
3729 | * the CTM has changed between the calls to cairo_set_line_width() and |
3896 | * cairo_get_line_width(). |
3730 | * cairo_get_line_width(). |
3897 | * |
3731 | * |
3898 | * Return value: the current line width. |
3732 | * Return value: the current line width. |
- | 3733 | * |
|
- | 3734 | * Since: 1.0 |
|
3899 | **/ |
3735 | **/ |
3900 | double |
3736 | double |
3901 | cairo_get_line_width (cairo_t *cr) |
3737 | cairo_get_line_width (cairo_t *cr) |
3902 | { |
3738 | { |
3903 | if (unlikely (cr->status)) |
3739 | if (unlikely (cr->status)) |
3904 | return CAIRO_GSTATE_LINE_WIDTH_DEFAULT; |
3740 | return CAIRO_GSTATE_LINE_WIDTH_DEFAULT; |
Line 3905... | Line 3741... | ||
3905 | 3741 | ||
3906 | return _cairo_gstate_get_line_width (cr->gstate); |
3742 | return cr->backend->get_line_width (cr); |
3907 | } |
3743 | } |
Line 3908... | Line 3744... | ||
3908 | slim_hidden_def (cairo_get_line_width); |
3744 | slim_hidden_def (cairo_get_line_width); |
3909 | 3745 | ||
3910 | /** |
3746 | /** |
3911 | * cairo_get_line_cap: |
3747 | * cairo_get_line_cap: |
3912 | * @cr: a cairo context |
3748 | * @cr: a cairo context |
3913 | * |
3749 | * |
3914 | * Gets the current line cap style, as set by cairo_set_line_cap(). |
3750 | * Gets the current line cap style, as set by cairo_set_line_cap(). |
- | 3751 | * |
|
- | 3752 | * Return value: the current line cap style. |
|
3915 | * |
3753 | * |
3916 | * Return value: the current line cap style. |
3754 | * Since: 1.0 |
3917 | **/ |
3755 | **/ |
3918 | cairo_line_cap_t |
3756 | cairo_line_cap_t |
3919 | cairo_get_line_cap (cairo_t *cr) |
3757 | cairo_get_line_cap (cairo_t *cr) |
3920 | { |
3758 | { |
Line 3921... | Line 3759... | ||
3921 | if (unlikely (cr->status)) |
3759 | if (unlikely (cr->status)) |
3922 | return CAIRO_GSTATE_LINE_CAP_DEFAULT; |
3760 | return CAIRO_GSTATE_LINE_CAP_DEFAULT; |
Line 3923... | Line 3761... | ||
3923 | 3761 | ||
3924 | return _cairo_gstate_get_line_cap (cr->gstate); |
3762 | return cr->backend->get_line_cap (cr); |
3925 | } |
3763 | } |
3926 | 3764 | ||
3927 | /** |
3765 | /** |
3928 | * cairo_get_line_join: |
3766 | * cairo_get_line_join: |
3929 | * @cr: a cairo context |
3767 | * @cr: a cairo context |
- | 3768 | * |
|
- | 3769 | * Gets the current line join style, as set by cairo_set_line_join(). |
|
3930 | * |
3770 | * |
3931 | * Gets the current line join style, as set by cairo_set_line_join(). |
3771 | * Return value: the current line join style. |
3932 | * |
3772 | * |
3933 | * Return value: the current line join style. |
3773 | * Since: 1.0 |
3934 | **/ |
3774 | **/ |
3935 | cairo_line_join_t |
3775 | cairo_line_join_t |
Line 3936... | Line 3776... | ||
3936 | cairo_get_line_join (cairo_t *cr) |
3776 | cairo_get_line_join (cairo_t *cr) |
3937 | { |
3777 | { |
Line 3938... | Line 3778... | ||
3938 | if (unlikely (cr->status)) |
3778 | if (unlikely (cr->status)) |
3939 | return CAIRO_GSTATE_LINE_JOIN_DEFAULT; |
3779 | return CAIRO_GSTATE_LINE_JOIN_DEFAULT; |
3940 | 3780 | ||
3941 | return _cairo_gstate_get_line_join (cr->gstate); |
3781 | return cr->backend->get_line_join (cr); |
3942 | } |
3782 | } |
3943 | 3783 | ||
3944 | /** |
3784 | /** |
- | 3785 | * cairo_get_miter_limit: |
|
- | 3786 | * @cr: a cairo context |
|
3945 | * cairo_get_miter_limit: |
3787 | * |
3946 | * @cr: a cairo context |
3788 | * Gets the current miter limit, as set by cairo_set_miter_limit(). |
3947 | * |
3789 | * |
3948 | * Gets the current miter limit, as set by cairo_set_miter_limit(). |
3790 | * Return value: the current miter limit. |
3949 | * |
3791 | * |
3950 | * Return value: the current miter limit. |
3792 | * Since: 1.0 |
Line 3951... | Line 3793... | ||
3951 | **/ |
3793 | **/ |
3952 | double |
3794 | double |
Line 3953... | Line 3795... | ||
3953 | cairo_get_miter_limit (cairo_t *cr) |
3795 | cairo_get_miter_limit (cairo_t *cr) |
3954 | { |
3796 | { |
3955 | if (unlikely (cr->status)) |
3797 | if (unlikely (cr->status)) |
3956 | return CAIRO_GSTATE_MITER_LIMIT_DEFAULT; |
3798 | return CAIRO_GSTATE_MITER_LIMIT_DEFAULT; |
3957 | 3799 | ||
3958 | return _cairo_gstate_get_miter_limit (cr->gstate); |
3800 | return cr->backend->get_miter_limit (cr); |
- | 3801 | } |
|
- | 3802 | ||
3959 | } |
3803 | /** |
3960 | 3804 | * cairo_get_matrix: |
|
3961 | /** |
3805 | * @cr: a cairo context |
3962 | * cairo_get_matrix: |
3806 | * @matrix: return value for the matrix |
3963 | * @cr: a cairo context |
3807 | * |
3964 | * @matrix: return value for the matrix |
3808 | * Stores the current transformation matrix (CTM) into @matrix. |
3965 | * |
3809 | * |
3966 | * Stores the current transformation matrix (CTM) into @matrix. |
3810 | * Since: 1.0 |
Line 3967... | Line 3811... | ||
3967 | **/ |
3811 | **/ |
3968 | void |
3812 | void |
3969 | cairo_get_matrix (cairo_t *cr, cairo_matrix_t *matrix) |
3813 | cairo_get_matrix (cairo_t *cr, cairo_matrix_t *matrix) |
Line 3970... | Line 3814... | ||
3970 | { |
3814 | { |
3971 | if (unlikely (cr->status)) { |
3815 | if (unlikely (cr->status)) { |
Line 3990... | Line 3834... | ||
3990 | * A nil surface is indicated by cairo_surface_status() |
3834 | * A nil surface is indicated by cairo_surface_status() |
3991 | * |
3835 | * |
3992 | * |
3836 | * |
3993 | * Return value: the target surface. This object is owned by cairo. To |
3837 | * Return value: the target surface. This object is owned by cairo. To |
3994 | * keep a reference to it, you must call cairo_surface_reference(). |
3838 | * keep a reference to it, you must call cairo_surface_reference(). |
- | 3839 | * |
|
- | 3840 | * Since: 1.0 |
|
3995 | **/ |
3841 | **/ |
3996 | cairo_surface_t * |
3842 | cairo_surface_t * |
3997 | cairo_get_target (cairo_t *cr) |
3843 | cairo_get_target (cairo_t *cr) |
3998 | { |
3844 | { |
3999 | if (unlikely (cr->status)) |
3845 | if (unlikely (cr->status)) |
4000 | return _cairo_surface_create_in_error (cr->status); |
3846 | return _cairo_surface_create_in_error (cr->status); |
Line 4001... | Line 3847... | ||
4001 | 3847 | ||
4002 | return _cairo_gstate_get_original_target (cr->gstate); |
3848 | return cr->backend->get_original_target (cr); |
4003 | } |
3849 | } |
Line 4004... | Line 3850... | ||
4004 | slim_hidden_def (cairo_get_target); |
3850 | slim_hidden_def (cairo_get_target); |
4005 | 3851 | ||
Line 4027... | Line 3873... | ||
4027 | cairo_get_group_target (cairo_t *cr) |
3873 | cairo_get_group_target (cairo_t *cr) |
4028 | { |
3874 | { |
4029 | if (unlikely (cr->status)) |
3875 | if (unlikely (cr->status)) |
4030 | return _cairo_surface_create_in_error (cr->status); |
3876 | return _cairo_surface_create_in_error (cr->status); |
Line 4031... | Line 3877... | ||
4031 | 3877 | ||
4032 | return _cairo_gstate_get_target (cr->gstate); |
3878 | return cr->backend->get_current_target (cr); |
Line 4033... | Line 3879... | ||
4033 | } |
3879 | } |
4034 | 3880 | ||
4035 | /** |
3881 | /** |
Line 4055... | Line 3901... | ||
4055 | * |
3901 | * |
4056 | * |
3902 | * |
4057 | * Return value: the copy of the current path. The caller owns the |
3903 | * Return value: the copy of the current path. The caller owns the |
4058 | * returned object and should call cairo_path_destroy() when finished |
3904 | * returned object and should call cairo_path_destroy() when finished |
4059 | * with it. |
3905 | * with it. |
- | 3906 | * |
|
- | 3907 | * Since: 1.0 |
|
4060 | **/ |
3908 | **/ |
4061 | cairo_path_t * |
3909 | cairo_path_t * |
4062 | cairo_copy_path (cairo_t *cr) |
3910 | cairo_copy_path (cairo_t *cr) |
4063 | { |
3911 | { |
4064 | if (unlikely (cr->status)) |
3912 | if (unlikely (cr->status)) |
4065 | return _cairo_path_create_in_error (cr->status); |
3913 | return _cairo_path_create_in_error (cr->status); |
Line 4066... | Line 3914... | ||
4066 | 3914 | ||
4067 | return _cairo_path_create (cr->path, cr->gstate); |
3915 | return cr->backend->copy_path (cr); |
Line 4068... | Line 3916... | ||
4068 | } |
3916 | } |
4069 | 3917 | ||
4070 | /** |
3918 | /** |
Line 4097... | Line 3945... | ||
4097 | * |
3945 | * |
4098 | * |
3946 | * |
4099 | * Return value: the copy of the current path. The caller owns the |
3947 | * Return value: the copy of the current path. The caller owns the |
4100 | * returned object and should call cairo_path_destroy() when finished |
3948 | * returned object and should call cairo_path_destroy() when finished |
4101 | * with it. |
3949 | * with it. |
- | 3950 | * |
|
- | 3951 | * Since: 1.0 |
|
4102 | **/ |
3952 | **/ |
4103 | cairo_path_t * |
3953 | cairo_path_t * |
4104 | cairo_copy_path_flat (cairo_t *cr) |
3954 | cairo_copy_path_flat (cairo_t *cr) |
4105 | { |
3955 | { |
4106 | if (unlikely (cr->status)) |
3956 | if (unlikely (cr->status)) |
4107 | return _cairo_path_create_in_error (cr->status); |
3957 | return _cairo_path_create_in_error (cr->status); |
Line 4108... | Line 3958... | ||
4108 | 3958 | ||
4109 | return _cairo_path_create_flat (cr->path, cr->gstate); |
3959 | return cr->backend->copy_path_flat (cr); |
Line 4110... | Line 3960... | ||
4110 | } |
3960 | } |
4111 | 3961 | ||
4112 | /** |
3962 | /** |
Line 4118... | Line 3968... | ||
4118 | * return value from one of cairo_copy_path() or |
3968 | * return value from one of cairo_copy_path() or |
4119 | * cairo_copy_path_flat() or it may be constructed manually. See |
3969 | * cairo_copy_path_flat() or it may be constructed manually. See |
4120 | * #cairo_path_t for details on how the path data structure should be |
3970 | * #cairo_path_t for details on how the path data structure should be |
4121 | * initialized, and note that |
3971 | * initialized, and note that |
4122 | * initialized to %CAIRO_STATUS_SUCCESS. |
3972 | * initialized to %CAIRO_STATUS_SUCCESS. |
- | 3973 | * |
|
- | 3974 | * Since: 1.0 |
|
4123 | **/ |
3975 | **/ |
4124 | void |
3976 | void |
4125 | cairo_append_path (cairo_t *cr, |
3977 | cairo_append_path (cairo_t *cr, |
4126 | const cairo_path_t *path) |
3978 | const cairo_path_t *path) |
4127 | { |
3979 | { |
4128 | cairo_status_t status; |
3980 | cairo_status_t status; |
Line 4129... | Line 3981... | ||
4129 | 3981 | ||
4130 | if (unlikely (cr->status)) |
3982 | if (unlikely (cr->status)) |
Line 4131... | Line 3983... | ||
4131 | return; |
3983 | return; |
4132 | 3984 | ||
4133 | if (path == NULL) { |
3985 | if (unlikely (path == NULL)) { |
4134 | _cairo_set_error (cr, CAIRO_STATUS_NULL_POINTER); |
3986 | _cairo_set_error (cr, CAIRO_STATUS_NULL_POINTER); |
Line 4135... | Line 3987... | ||
4135 | return; |
3987 | return; |
4136 | } |
3988 | } |
4137 | 3989 | ||
4138 | if (path->status) { |
3990 | if (unlikely (path->status)) { |
4139 | if (path->status > CAIRO_STATUS_SUCCESS && |
3991 | if (path->status > CAIRO_STATUS_SUCCESS && |
4140 | path->status <= CAIRO_STATUS_LAST_STATUS) |
3992 | path->status <= CAIRO_STATUS_LAST_STATUS) |
Line 4145... | Line 3997... | ||
4145 | } |
3997 | } |
Line 4146... | Line 3998... | ||
4146 | 3998 | ||
4147 | if (path->num_data == 0) |
3999 | if (path->num_data == 0) |
Line 4148... | Line 4000... | ||
4148 | return; |
4000 | return; |
4149 | 4001 | ||
4150 | if (path->data == NULL) { |
4002 | if (unlikely (path->data == NULL)) { |
4151 | _cairo_set_error (cr, CAIRO_STATUS_NULL_POINTER); |
4003 | _cairo_set_error (cr, CAIRO_STATUS_NULL_POINTER); |
Line 4152... | Line 4004... | ||
4152 | return; |
4004 | return; |
4153 | } |
4005 | } |
4154 | 4006 | ||
4155 | status = _cairo_path_append_to_context (path, cr); |
4007 | status = cr->backend->append_path (cr, path); |
Line 4156... | Line 4008... | ||
4156 | if (unlikely (status)) |
4008 | if (unlikely (status)) |
Line 4162... | Line 4014... | ||
4162 | * @cr: a cairo context |
4014 | * @cr: a cairo context |
4163 | * |
4015 | * |
4164 | * Checks whether an error has previously occurred for this context. |
4016 | * Checks whether an error has previously occurred for this context. |
4165 | * |
4017 | * |
4166 | * Returns: the current status of this context, see #cairo_status_t |
4018 | * Returns: the current status of this context, see #cairo_status_t |
- | 4019 | * |
|
- | 4020 | * Since: 1.0 |
|
4167 | **/ |
4021 | **/ |
4168 | cairo_status_t |
4022 | cairo_status_t |
4169 | cairo_status (cairo_t *cr) |
4023 | cairo_status (cairo_t *cr) |
4170 | { |
4024 | { |
4171 | return cr->status; |
4025 | return cr->status; |