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
4 * Copyright © 2002 University of Southern California
5 * Copyright © 2005 Red Hat, Inc.
6 * Copyright © 2011 Intel Corporation
8 * This library is free software; you can redistribute it and/or
9 * modify it either under the terms of the GNU Lesser General Public
10 * License version 2.1 as published by the Free Software Foundation
11 * (the "LGPL") or, at your option, under the terms of the Mozilla
12 * Public License Version 1.1 (the "MPL"). If you do not alter this
13 * notice, a recipient may use your version of this file under either
14 * the MPL or the LGPL.
16 * You should have received a copy of the LGPL along with this library
17 * in the file COPYING-LGPL-2.1; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
19 * You should have received a copy of the MPL along with this library
20 * in the file COPYING-MPL-1.1
22 * The contents of this file are subject to the Mozilla Public License
23 * Version 1.1 (the "License"); you may not use this file except in
24 * compliance with the License. You may obtain a copy of the License at
25 * http://www.mozilla.org/MPL/
27 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
28 * OF ANY KIND, either express or implied. See the LGPL or the MPL for
29 * the specific language governing rights and limitations.
31 * The Original Code is the cairo graphics library.
33 * The Initial Developer of the Original Code is University of Southern
37 * Carl D. Worth <cworth@cworth.org>
38 * Chris Wilson <chris@chris-wilson.co.uk>
42 #include "cairo-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"
52 #include "cairo-ttrace.h"
57 * @Short_Description: The cairo drawing context
58 * @See_Also: #cairo_surface_t
60 * #cairo_t is the main object used when drawing with cairo. To
61 * draw with cairo, you create a #cairo_t, set the target surface,
62 * and drawing options for the #cairo_t, create shapes with
63 * functions like cairo_move_to() and cairo_line_to(), and then
64 * draw shapes with cairo_stroke() or cairo_fill().
66 * #cairo_t<!-- -->'s can be pushed to a stack via cairo_save().
67 * They may then safely be changed, without losing the current state.
68 * Use cairo_restore() to restore to the saved state.
74 * @Short_Description: Rendering text and glyphs
75 * @See_Also: #cairo_font_face_t, #cairo_scaled_font_t, cairo_text_path(),
78 * The functions with <emphasis>text</emphasis> in their name form cairo's
79 * <firstterm>toy</firstterm> text API. The toy API takes UTF-8 encoded
80 * text and is limited in its functionality to rendering simple
81 * left-to-right text with no advanced features. That means for example
82 * that most complex scripts like Hebrew, Arabic, and Indic scripts are
83 * out of question. No kerning or correct positioning of diacritical marks
84 * either. The font selection is pretty limited too and doesn't handle the
85 * case that the selected font does not cover the characters in the text.
86 * This set of functions are really that, a toy text API, for testing and
87 * demonstration purposes. Any serious application should avoid them.
89 * The functions with <emphasis>glyphs</emphasis> in their name form cairo's
90 * <firstterm>low-level</firstterm> text API. The low-level API relies on
91 * the user to convert text to a set of glyph indexes and positions. This
92 * is a very hard problem and is best handled by external libraries, like
93 * the pangocairo that is part of the Pango text layout and rendering library.
94 * Pango is available from <ulink
95 * url="http://www.pango.org/">http://www.pango.org/</ulink>.
99 * SECTION:cairo-transforms
100 * @Title: Transformations
101 * @Short_Description: Manipulating the current transformation matrix
102 * @See_Also: #cairo_matrix_t
104 * The current transformation matrix, <firstterm>ctm</firstterm>, is a
105 * two-dimensional affine transformation that maps all coordinates and other
106 * drawing instruments from the <firstterm>user space</firstterm> into the
107 * surface's canonical coordinate system, also known as the <firstterm>device
111 #define DEFINE_NIL_CONTEXT(status) \
113 CAIRO_REFERENCE_COUNT_INVALID, /* ref_count */ \
114 status, /* status */ \
115 { 0, 0, 0, NULL }, /* user_data */ \
119 static const cairo_t _cairo_nil[] = {
120 DEFINE_NIL_CONTEXT (CAIRO_STATUS_NO_MEMORY),
121 DEFINE_NIL_CONTEXT (CAIRO_STATUS_INVALID_RESTORE),
122 DEFINE_NIL_CONTEXT (CAIRO_STATUS_INVALID_POP_GROUP),
123 DEFINE_NIL_CONTEXT (CAIRO_STATUS_NO_CURRENT_POINT),
124 DEFINE_NIL_CONTEXT (CAIRO_STATUS_INVALID_MATRIX),
125 DEFINE_NIL_CONTEXT (CAIRO_STATUS_INVALID_STATUS),
126 DEFINE_NIL_CONTEXT (CAIRO_STATUS_NULL_POINTER),
127 DEFINE_NIL_CONTEXT (CAIRO_STATUS_INVALID_STRING),
128 DEFINE_NIL_CONTEXT (CAIRO_STATUS_INVALID_PATH_DATA),
129 DEFINE_NIL_CONTEXT (CAIRO_STATUS_READ_ERROR),
130 DEFINE_NIL_CONTEXT (CAIRO_STATUS_WRITE_ERROR),
131 DEFINE_NIL_CONTEXT (CAIRO_STATUS_SURFACE_FINISHED),
132 DEFINE_NIL_CONTEXT (CAIRO_STATUS_SURFACE_TYPE_MISMATCH),
133 DEFINE_NIL_CONTEXT (CAIRO_STATUS_PATTERN_TYPE_MISMATCH),
134 DEFINE_NIL_CONTEXT (CAIRO_STATUS_INVALID_CONTENT),
135 DEFINE_NIL_CONTEXT (CAIRO_STATUS_INVALID_FORMAT),
136 DEFINE_NIL_CONTEXT (CAIRO_STATUS_INVALID_VISUAL),
137 DEFINE_NIL_CONTEXT (CAIRO_STATUS_FILE_NOT_FOUND),
138 DEFINE_NIL_CONTEXT (CAIRO_STATUS_INVALID_DASH),
139 DEFINE_NIL_CONTEXT (CAIRO_STATUS_INVALID_DSC_COMMENT),
140 DEFINE_NIL_CONTEXT (CAIRO_STATUS_INVALID_INDEX),
141 DEFINE_NIL_CONTEXT (CAIRO_STATUS_CLIP_NOT_REPRESENTABLE),
142 DEFINE_NIL_CONTEXT (CAIRO_STATUS_TEMP_FILE_ERROR),
143 DEFINE_NIL_CONTEXT (CAIRO_STATUS_INVALID_STRIDE),
144 DEFINE_NIL_CONTEXT (CAIRO_STATUS_FONT_TYPE_MISMATCH),
145 DEFINE_NIL_CONTEXT (CAIRO_STATUS_USER_FONT_IMMUTABLE),
146 DEFINE_NIL_CONTEXT (CAIRO_STATUS_USER_FONT_ERROR),
147 DEFINE_NIL_CONTEXT (CAIRO_STATUS_NEGATIVE_COUNT),
148 DEFINE_NIL_CONTEXT (CAIRO_STATUS_INVALID_CLUSTERS),
149 DEFINE_NIL_CONTEXT (CAIRO_STATUS_INVALID_SLANT),
150 DEFINE_NIL_CONTEXT (CAIRO_STATUS_INVALID_WEIGHT),
151 DEFINE_NIL_CONTEXT (CAIRO_STATUS_INVALID_SIZE),
152 DEFINE_NIL_CONTEXT (CAIRO_STATUS_USER_FONT_NOT_IMPLEMENTED),
153 DEFINE_NIL_CONTEXT (CAIRO_STATUS_DEVICE_TYPE_MISMATCH),
154 DEFINE_NIL_CONTEXT (CAIRO_STATUS_DEVICE_ERROR),
155 DEFINE_NIL_CONTEXT (CAIRO_STATUS_INVALID_MESH_CONSTRUCTION),
156 DEFINE_NIL_CONTEXT (CAIRO_STATUS_DEVICE_FINISHED),
157 DEFINE_NIL_CONTEXT (CAIRO_STATUS_JBIG2_GLOBAL_MISSING)
160 COMPILE_TIME_ASSERT (ARRAY_LENGTH (_cairo_nil) == CAIRO_STATUS_LAST_STATUS - 1);
164 * @cr: a cairo context
165 * @status: a status value indicating an error
167 * Atomically sets cr->status to @status and calls _cairo_error;
168 * Does nothing if status is %CAIRO_STATUS_SUCCESS.
170 * All assignments of an error status to cr->status should happen
171 * through _cairo_set_error(). Note that due to the nature of the atomic
172 * operation, it is not safe to call this function on the nil objects.
174 * The purpose of this function is to allow the user to set a
175 * breakpoint in _cairo_error() to generate a stack trace for when the
176 * user causes cairo to detect an error.
179 _cairo_set_error (cairo_t *cr, cairo_status_t status)
181 /* Don't overwrite an existing error. This preserves the first
182 * error, which is the most significant. */
183 _cairo_status_set_error (&cr->status, _cairo_error (status));
187 _cairo_create_in_error (cairo_status_t status)
191 assert (status != CAIRO_STATUS_SUCCESS);
193 cr = (cairo_t *) &_cairo_nil[status - CAIRO_STATUS_NO_MEMORY];
194 assert (status == cr->status);
201 * @target: target surface for the context
203 * Creates a new #cairo_t with all graphics state parameters set to
204 * default values and with @target as a target surface. The target
205 * surface should be constructed with a backend-specific function such
206 * as cairo_image_surface_create() (or any other
207 * <function>cairo_<emphasis>backend</emphasis>_surface_create(<!-- -->)</function>
210 * This function references @target, so you can immediately
211 * call cairo_surface_destroy() on it if you don't need to
212 * maintain a separate reference to it.
214 * Return value: a newly allocated #cairo_t with a reference
215 * count of 1. The initial reference count should be released
216 * with cairo_destroy() when you are done using the #cairo_t.
217 * This function never returns %NULL. If memory cannot be
218 * allocated, a special #cairo_t object will be returned on
219 * which cairo_status() returns %CAIRO_STATUS_NO_MEMORY. If
220 * you attempt to target a surface which does not support
221 * writing (such as #cairo_mime_surface_t) then a
222 * %CAIRO_STATUS_WRITE_ERROR will be raised. You can use this
223 * object normally, but no drawing will be done.
228 cairo_create (cairo_surface_t *target)
230 CAIRO_TRACE_BEGIN (__func__);
231 if (unlikely (target == NULL)) {
232 CAIRO_TRACE_END (__func__);
233 return _cairo_create_in_error (_cairo_error (CAIRO_STATUS_NULL_POINTER));
235 if (unlikely (target->status)) {
236 CAIRO_TRACE_END (__func__);
237 return _cairo_create_in_error (target->status);
239 if (unlikely (target->finished)) {
240 CAIRO_TRACE_END (__func__);
241 return _cairo_create_in_error (_cairo_error (CAIRO_STATUS_SURFACE_FINISHED));
244 if (target->backend->create_context == NULL) {
245 CAIRO_TRACE_END (__func__);
246 return _cairo_create_in_error (_cairo_error (CAIRO_STATUS_WRITE_ERROR));
249 cairo_t *cr = target->backend->create_context (target);
250 CAIRO_TRACE_END (__func__);
254 slim_hidden_def (cairo_create);
257 _cairo_init (cairo_t *cr,
258 const cairo_backend_t *backend)
260 CAIRO_REFERENCE_COUNT_INIT (&cr->ref_count, 1);
261 cr->status = CAIRO_STATUS_SUCCESS;
262 _cairo_user_data_array_init (&cr->user_data);
264 cr->backend = backend;
271 * Increases the reference count on @cr by one. This prevents
272 * @cr from being destroyed until a matching call to cairo_destroy()
275 * The number of references to a #cairo_t can be get using
276 * cairo_get_reference_count().
278 * Return value: the referenced #cairo_t.
283 cairo_reference (cairo_t *cr)
285 if (cr == NULL || CAIRO_REFERENCE_COUNT_IS_INVALID (&cr->ref_count))
288 assert (CAIRO_REFERENCE_COUNT_HAS_REFERENCE (&cr->ref_count));
290 _cairo_reference_count_inc (&cr->ref_count);
296 _cairo_fini (cairo_t *cr)
298 _cairo_user_data_array_fini (&cr->user_data);
305 * Decreases the reference count on @cr by one. If the result
306 * is zero, then @cr and all associated resources are freed.
307 * See cairo_reference().
312 cairo_destroy (cairo_t *cr)
314 CAIRO_TRACE_BEGIN (__func__);
315 if (cr == NULL || CAIRO_REFERENCE_COUNT_IS_INVALID (&cr->ref_count)) {
316 CAIRO_TRACE_END (__func__);
320 assert (CAIRO_REFERENCE_COUNT_HAS_REFERENCE (&cr->ref_count));
322 if (! _cairo_reference_count_dec_and_test (&cr->ref_count)) {
323 CAIRO_TRACE_END (__func__);
327 cr->backend->destroy (cr);
328 CAIRO_TRACE_END (__func__);
330 slim_hidden_def (cairo_destroy);
333 * cairo_get_user_data:
335 * @key: the address of the #cairo_user_data_key_t the user data was
338 * Return user data previously attached to @cr using the specified
339 * key. If no user data has been attached with the given key this
340 * function returns %NULL.
342 * Return value: the user data previously attached or %NULL.
347 cairo_get_user_data (cairo_t *cr,
348 const cairo_user_data_key_t *key)
350 return _cairo_user_data_array_get_data (&cr->user_data, key);
354 * cairo_set_user_data:
356 * @key: the address of a #cairo_user_data_key_t to attach the user data to
357 * @user_data: the user data to attach to the #cairo_t
358 * @destroy: a #cairo_destroy_func_t which will be called when the
359 * #cairo_t is destroyed or when new user data is attached using the
362 * Attach user data to @cr. To remove user data from a surface,
363 * call this function with the key that was used to set it and %NULL
366 * Return value: %CAIRO_STATUS_SUCCESS or %CAIRO_STATUS_NO_MEMORY if a
367 * slot could not be allocated for the user data.
372 cairo_set_user_data (cairo_t *cr,
373 const cairo_user_data_key_t *key,
375 cairo_destroy_func_t destroy)
377 if (CAIRO_REFERENCE_COUNT_IS_INVALID (&cr->ref_count))
380 return _cairo_user_data_array_set_data (&cr->user_data,
381 key, user_data, destroy);
385 * cairo_get_reference_count:
388 * Returns the current reference count of @cr.
390 * Return value: the current reference count of @cr. If the
391 * object is a nil object, 0 will be returned.
396 cairo_get_reference_count (cairo_t *cr)
398 if (cr == NULL || CAIRO_REFERENCE_COUNT_IS_INVALID (&cr->ref_count))
401 return CAIRO_REFERENCE_COUNT_GET_VALUE (&cr->ref_count);
408 * Makes a copy of the current state of @cr and saves it
409 * on an internal stack of saved states for @cr. When
410 * cairo_restore() is called, @cr will be restored to
411 * the saved state. Multiple calls to cairo_save() and
412 * cairo_restore() can be nested; each call to cairo_restore()
413 * restores the state from the matching paired cairo_save().
415 * It isn't necessary to clear all saved states before
416 * a #cairo_t is freed. If the reference count of a #cairo_t
417 * drops to zero in response to a call to cairo_destroy(),
418 * any saved states will be freed along with the #cairo_t.
423 cairo_save (cairo_t *cr)
425 CAIRO_TRACE_BEGIN (__func__);
426 cairo_status_t status;
428 if (unlikely (cr->status)) {
429 CAIRO_TRACE_END (__func__);
433 status = cr->backend->save (cr);
434 if (unlikely (status))
435 _cairo_set_error (cr, status);
437 CAIRO_TRACE_END (__func__);
439 slim_hidden_def(cairo_save);
445 * Restores @cr to the state saved by a preceding call to
446 * cairo_save() and removes that state from the stack of
452 cairo_restore (cairo_t *cr)
454 CAIRO_TRACE_BEGIN (__func__);
455 cairo_status_t status;
457 if (unlikely (cr->status)) {
458 CAIRO_TRACE_END (__func__);
462 status = cr->backend->restore (cr);
463 if (unlikely (status))
464 _cairo_set_error (cr, status);
466 CAIRO_TRACE_END (__func__);
468 slim_hidden_def(cairo_restore);
472 * @cr: a cairo context
474 * Temporarily redirects drawing to an intermediate surface known as a
475 * group. The redirection lasts until the group is completed by a call
476 * to cairo_pop_group() or cairo_pop_group_to_source(). These calls
477 * provide the result of any drawing to the group as a pattern,
478 * (either as an explicit object, or set as the source pattern).
480 * This group functionality can be convenient for performing
481 * intermediate compositing. One common use of a group is to render
482 * objects as opaque within the group, (so that they occlude each
483 * other), and then blend the result with translucence onto the
486 * Groups can be nested arbitrarily deep by making balanced calls to
487 * cairo_push_group()/cairo_pop_group(). Each call pushes/pops the new
488 * target group onto/from a stack.
490 * The cairo_push_group() function calls cairo_save() so that any
491 * changes to the graphics state will not be visible outside the
492 * group, (the pop_group functions call cairo_restore()).
494 * By default the intermediate group will have a content type of
495 * %CAIRO_CONTENT_COLOR_ALPHA. Other content types can be chosen for
496 * the group by using cairo_push_group_with_content() instead.
498 * As an example, here is how one might fill and stroke a path with
499 * translucence, but without any portion of the fill being visible
502 * <informalexample><programlisting>
503 * cairo_push_group (cr);
504 * cairo_set_source (cr, fill_pattern);
505 * cairo_fill_preserve (cr);
506 * cairo_set_source (cr, stroke_pattern);
508 * cairo_pop_group_to_source (cr);
509 * cairo_paint_with_alpha (cr, alpha);
510 * </programlisting></informalexample>
515 cairo_push_group (cairo_t *cr)
517 cairo_push_group_with_content (cr, CAIRO_CONTENT_COLOR_ALPHA);
521 * cairo_push_group_with_content:
522 * @cr: a cairo context
523 * @content: a #cairo_content_t indicating the type of group that
526 * Temporarily redirects drawing to an intermediate surface known as a
527 * group. The redirection lasts until the group is completed by a call
528 * to cairo_pop_group() or cairo_pop_group_to_source(). These calls
529 * provide the result of any drawing to the group as a pattern,
530 * (either as an explicit object, or set as the source pattern).
532 * The group will have a content type of @content. The ability to
533 * control this content type is the only distinction between this
534 * function and cairo_push_group() which you should see for a more
535 * detailed description of group rendering.
540 cairo_push_group_with_content (cairo_t *cr, cairo_content_t content)
542 cairo_status_t status;
544 if (unlikely (cr->status))
547 status = cr->backend->push_group (cr, content);
548 if (unlikely (status))
549 _cairo_set_error (cr, status);
551 slim_hidden_def(cairo_push_group_with_content);
555 * @cr: a cairo context
557 * Terminates the redirection begun by a call to cairo_push_group() or
558 * cairo_push_group_with_content() and returns a new pattern
559 * containing the results of all drawing operations performed to the
562 * The cairo_pop_group() function calls cairo_restore(), (balancing a
563 * call to cairo_save() by the push_group function), so that any
564 * changes to the graphics state will not be visible outside the
567 * Return value: a newly created (surface) pattern containing the
568 * results of all drawing operations performed to the group. The
569 * caller owns the returned object and should call
570 * cairo_pattern_destroy() when finished with it.
575 cairo_pop_group (cairo_t *cr)
577 cairo_pattern_t *group_pattern;
579 if (unlikely (cr->status))
580 return _cairo_pattern_create_in_error (cr->status);
582 group_pattern = cr->backend->pop_group (cr);
583 if (unlikely (group_pattern->status))
584 _cairo_set_error (cr, group_pattern->status);
586 return group_pattern;
588 slim_hidden_def(cairo_pop_group);
591 * cairo_pop_group_to_source:
592 * @cr: a cairo context
594 * Terminates the redirection begun by a call to cairo_push_group() or
595 * cairo_push_group_with_content() and installs the resulting pattern
596 * as the source pattern in the given cairo context.
598 * The behavior of this function is equivalent to the sequence of
601 * <informalexample><programlisting>
602 * cairo_pattern_t *group = cairo_pop_group (cr);
603 * cairo_set_source (cr, group);
604 * cairo_pattern_destroy (group);
605 * </programlisting></informalexample>
607 * but is more convenient as their is no need for a variable to store
608 * the short-lived pointer to the pattern.
610 * The cairo_pop_group() function calls cairo_restore(), (balancing a
611 * call to cairo_save() by the push_group function), so that any
612 * changes to the graphics state will not be visible outside the
618 cairo_pop_group_to_source (cairo_t *cr)
620 cairo_pattern_t *group_pattern;
622 group_pattern = cairo_pop_group (cr);
623 cairo_set_source (cr, group_pattern);
624 cairo_pattern_destroy (group_pattern);
628 * cairo_set_operator:
630 * @op: a compositing operator, specified as a #cairo_operator_t
632 * Sets the compositing operator to be used for all drawing
633 * operations. See #cairo_operator_t for details on the semantics of
634 * each available compositing operator.
636 * The default operator is %CAIRO_OPERATOR_OVER.
641 cairo_set_operator (cairo_t *cr, cairo_operator_t op)
643 cairo_status_t status;
645 if (unlikely (cr->status))
648 status = cr->backend->set_operator (cr, op);
649 if (unlikely (status))
650 _cairo_set_error (cr, status);
652 slim_hidden_def (cairo_set_operator);
659 * @opacity: the level of opacity to use when compositing
661 * Sets the compositing opacity to be used for all drawing
662 * operations. The effect is to fade out the operations
663 * using the alpha value.
665 * The default opacity is 1.
670 cairo_set_opacity (cairo_t *cr, double opacity)
672 cairo_status_t status;
674 if (unlikely (cr->status))
677 status = cr->backend->set_opacity (cr, opacity);
678 if (unlikely (status))
679 _cairo_set_error (cr, status);
684 * cairo_set_source_rgb:
685 * @cr: a cairo context
686 * @red: red component of color
687 * @green: green component of color
688 * @blue: blue component of color
690 * Sets the source pattern within @cr to an opaque color. This opaque
691 * color will then be used for any subsequent drawing operation until
692 * a new source pattern is set.
694 * The color components are floating point numbers in the range 0 to
695 * 1. If the values passed in are outside that range, they will be
698 * The default source pattern is opaque black, (that is, it is
699 * equivalent to cairo_set_source_rgb(cr, 0.0, 0.0, 0.0)).
704 cairo_set_source_rgb (cairo_t *cr, double red, double green, double blue)
706 CAIRO_TRACE_BEGIN (__func__);
707 cairo_status_t status;
709 if (unlikely (cr->status)) {
710 CAIRO_TRACE_END (__func__);
714 status = cr->backend->set_source_rgba (cr, red, green, blue, 1.);
715 if (unlikely (status))
716 _cairo_set_error (cr, status);
718 CAIRO_TRACE_END (__func__);
720 slim_hidden_def (cairo_set_source_rgb);
723 * cairo_set_source_rgba:
724 * @cr: a cairo context
725 * @red: red component of color
726 * @green: green component of color
727 * @blue: blue component of color
728 * @alpha: alpha component of color
730 * Sets the source pattern within @cr to a translucent color. This
731 * color will then be used for any subsequent drawing operation until
732 * a new source pattern is set.
734 * The color and alpha components are floating point numbers in the
735 * range 0 to 1. If the values passed in are outside that range, they
738 * The default source pattern is opaque black, (that is, it is
739 * equivalent to cairo_set_source_rgba(cr, 0.0, 0.0, 0.0, 1.0)).
744 cairo_set_source_rgba (cairo_t *cr,
745 double red, double green, double blue,
748 cairo_status_t status;
750 if (unlikely (cr->status))
753 status = cr->backend->set_source_rgba (cr, red, green, blue, alpha);
754 if (unlikely (status))
755 _cairo_set_error (cr, status);
759 * cairo_set_source_surface:
760 * @cr: a cairo context
761 * @surface: a surface to be used to set the source pattern
762 * @x: User-space X coordinate for surface origin
763 * @y: User-space Y coordinate for surface origin
765 * This is a convenience function for creating a pattern from @surface
766 * and setting it as the source in @cr with cairo_set_source().
768 * The @x and @y parameters give the user-space coordinate at which
769 * the surface origin should appear. (The surface origin is its
770 * upper-left corner before any transformation has been applied.) The
771 * @x and @y parameters are negated and then set as translation values
772 * in the pattern matrix.
774 * Other than the initial translation pattern matrix, as described
775 * above, all other pattern attributes, (such as its extend mode), are
776 * set to the default values as in cairo_pattern_create_for_surface().
777 * The resulting pattern can be queried with cairo_get_source() so
778 * that these attributes can be modified if desired, (eg. to create a
779 * repeating pattern with cairo_pattern_set_extend()).
784 cairo_set_source_surface (cairo_t *cr,
785 cairo_surface_t *surface,
789 CAIRO_TRACE_BEGIN (__func__);
790 cairo_status_t status;
792 if (unlikely (cr->status)) {
793 CAIRO_TRACE_END (__func__);
797 if (unlikely (surface == NULL)) {
798 _cairo_set_error (cr, CAIRO_STATUS_NULL_POINTER);
799 CAIRO_TRACE_END (__func__);
803 status = cr->backend->set_source_surface (cr, surface, x, y);
804 if (unlikely (status))
805 _cairo_set_error (cr, status);
807 CAIRO_TRACE_END (__func__);
809 slim_hidden_def (cairo_set_source_surface);
813 * @cr: a cairo context
814 * @source: a #cairo_pattern_t to be used as the source for
815 * subsequent drawing operations.
817 * Sets the source pattern within @cr to @source. This pattern
818 * will then be used for any subsequent drawing operation until a new
819 * source pattern is set.
821 * Note: The pattern's transformation matrix will be locked to the
822 * user space in effect at the time of cairo_set_source(). This means
823 * that further modifications of the current transformation matrix
824 * will not affect the source pattern. See cairo_pattern_set_matrix().
826 * The default source pattern is a solid pattern that is opaque black,
827 * (that is, it is equivalent to cairo_set_source_rgb(cr, 0.0, 0.0,
833 cairo_set_source (cairo_t *cr, cairo_pattern_t *source)
835 cairo_status_t status;
837 if (unlikely (cr->status))
840 if (unlikely (source == NULL)) {
841 _cairo_set_error (cr, CAIRO_STATUS_NULL_POINTER);
845 if (unlikely (source->status)) {
846 _cairo_set_error (cr, source->status);
850 status = cr->backend->set_source (cr, source);
851 if (unlikely (status))
852 _cairo_set_error (cr, status);
854 slim_hidden_def (cairo_set_source);
858 * @cr: a cairo context
860 * Gets the current source pattern for @cr.
862 * Return value: the current source pattern. This object is owned by
863 * cairo. To keep a reference to it, you must call
864 * cairo_pattern_reference().
869 cairo_get_source (cairo_t *cr)
871 if (unlikely (cr->status))
872 return _cairo_pattern_create_in_error (cr->status);
874 return cr->backend->get_source (cr);
878 * cairo_set_tolerance:
880 * @tolerance: the tolerance, in device units (typically pixels)
882 * Sets the tolerance used when converting paths into trapezoids.
883 * Curved segments of the path will be subdivided until the maximum
884 * deviation between the original path and the polygonal approximation
885 * is less than @tolerance. The default value is 0.1. A larger
886 * value will give better performance, a smaller value, better
887 * appearance. (Reducing the value from the default value of 0.1
888 * is unlikely to improve appearance significantly.) The accuracy of paths
889 * within Cairo is limited by the precision of its internal arithmetic, and
890 * the prescribed @tolerance is restricted to the smallest
891 * representable internal value.
896 cairo_set_tolerance (cairo_t *cr, double tolerance)
898 cairo_status_t status;
900 if (unlikely (cr->status))
903 status = cr->backend->set_tolerance (cr, tolerance);
904 if (unlikely (status))
905 _cairo_set_error (cr, status);
907 slim_hidden_def (cairo_set_tolerance);
910 * cairo_set_antialias:
912 * @antialias: the new antialiasing mode
914 * Set the antialiasing mode of the rasterizer used for drawing shapes.
915 * This value is a hint, and a particular backend may or may not support
916 * a particular value. At the current time, no backend supports
917 * %CAIRO_ANTIALIAS_SUBPIXEL when drawing shapes.
919 * Note that this option does not affect text rendering, instead see
920 * cairo_font_options_set_antialias().
925 cairo_set_antialias (cairo_t *cr, cairo_antialias_t antialias)
927 cairo_status_t status;
929 if (unlikely (cr->status))
932 status = cr->backend->set_antialias (cr, antialias);
933 if (unlikely (status))
934 _cairo_set_error (cr, status);
938 * cairo_set_fill_rule:
940 * @fill_rule: a fill rule, specified as a #cairo_fill_rule_t
942 * Set the current fill rule within the cairo context. The fill rule
943 * is used to determine which regions are inside or outside a complex
944 * (potentially self-intersecting) path. The current fill rule affects
945 * both cairo_fill() and cairo_clip(). See #cairo_fill_rule_t for details
946 * on the semantics of each available fill rule.
948 * The default fill rule is %CAIRO_FILL_RULE_WINDING.
953 cairo_set_fill_rule (cairo_t *cr, cairo_fill_rule_t fill_rule)
955 cairo_status_t status;
957 if (unlikely (cr->status))
960 status = cr->backend->set_fill_rule (cr, fill_rule);
961 if (unlikely (status))
962 _cairo_set_error (cr, status);
966 * cairo_set_line_width:
968 * @width: a line width
970 * Sets the current line width within the cairo context. The line
971 * width value specifies the diameter of a pen that is circular in
972 * user space, (though device-space pen may be an ellipse in general
973 * due to scaling/shear/rotation of the CTM).
975 * Note: When the description above refers to user space and CTM it
976 * refers to the user space and CTM in effect at the time of the
977 * stroking operation, not the user space and CTM in effect at the
978 * time of the call to cairo_set_line_width(). The simplest usage
979 * makes both of these spaces identical. That is, if there is no
980 * change to the CTM between a call to cairo_set_line_width() and the
981 * stroking operation, then one can just pass user-space values to
982 * cairo_set_line_width() and ignore this note.
984 * As with the other stroke parameters, the current line width is
985 * examined by cairo_stroke(), cairo_stroke_extents(), and
986 * cairo_stroke_to_path(), but does not have any effect during path
989 * The default line width value is 2.0.
994 cairo_set_line_width (cairo_t *cr, double width)
996 cairo_status_t status;
998 if (unlikely (cr->status))
1004 status = cr->backend->set_line_width (cr, width);
1005 if (unlikely (status))
1006 _cairo_set_error (cr, status);
1008 slim_hidden_def (cairo_set_line_width);
1011 * cairo_set_line_cap:
1012 * @cr: a cairo context
1013 * @line_cap: a line cap style
1015 * Sets the current line cap style within the cairo context. See
1016 * #cairo_line_cap_t for details about how the available line cap
1019 * As with the other stroke parameters, the current line cap style is
1020 * examined by cairo_stroke(), cairo_stroke_extents(), and
1021 * cairo_stroke_to_path(), but does not have any effect during path
1024 * The default line cap style is %CAIRO_LINE_CAP_BUTT.
1029 cairo_set_line_cap (cairo_t *cr, cairo_line_cap_t line_cap)
1031 cairo_status_t status;
1033 if (unlikely (cr->status))
1036 status = cr->backend->set_line_cap (cr, line_cap);
1037 if (unlikely (status))
1038 _cairo_set_error (cr, status);
1040 slim_hidden_def (cairo_set_line_cap);
1043 * cairo_set_line_join:
1044 * @cr: a cairo context
1045 * @line_join: a line join style
1047 * Sets the current line join style within the cairo context. See
1048 * #cairo_line_join_t for details about how the available line join
1051 * As with the other stroke parameters, the current line join style is
1052 * examined by cairo_stroke(), cairo_stroke_extents(), and
1053 * cairo_stroke_to_path(), but does not have any effect during path
1056 * The default line join style is %CAIRO_LINE_JOIN_MITER.
1061 cairo_set_line_join (cairo_t *cr, cairo_line_join_t line_join)
1063 cairo_status_t status;
1065 if (unlikely (cr->status))
1068 status = cr->backend->set_line_join (cr, line_join);
1069 if (unlikely (status))
1070 _cairo_set_error (cr, status);
1072 slim_hidden_def (cairo_set_line_join);
1076 * @cr: a cairo context
1077 * @dashes: an array specifying alternate lengths of on and off stroke portions
1078 * @num_dashes: the length of the dashes array
1079 * @offset: an offset into the dash pattern at which the stroke should start
1081 * Sets the dash pattern to be used by cairo_stroke(). A dash pattern
1082 * is specified by @dashes, an array of positive values. Each value
1083 * provides the length of alternate "on" and "off" portions of the
1084 * stroke. The @offset specifies an offset into the pattern at which
1085 * the stroke begins.
1087 * Each "on" segment will have caps applied as if the segment were a
1088 * separate sub-path. In particular, it is valid to use an "on" length
1089 * of 0.0 with %CAIRO_LINE_CAP_ROUND or %CAIRO_LINE_CAP_SQUARE in order
1090 * to distributed dots or squares along a path.
1092 * Note: The length values are in user-space units as evaluated at the
1093 * time of stroking. This is not necessarily the same as the user
1094 * space at the time of cairo_set_dash().
1096 * If @num_dashes is 0 dashing is disabled.
1098 * If @num_dashes is 1 a symmetric pattern is assumed with alternating
1099 * on and off portions of the size specified by the single value in
1102 * If any value in @dashes is negative, or if all values are 0, then
1103 * @cr will be put into an error state with a status of
1104 * %CAIRO_STATUS_INVALID_DASH.
1109 cairo_set_dash (cairo_t *cr,
1110 const double *dashes,
1114 cairo_status_t status;
1116 if (unlikely (cr->status))
1119 status = cr->backend->set_dash (cr, dashes, num_dashes, offset);
1120 if (unlikely (status))
1121 _cairo_set_error (cr, status);
1125 * cairo_get_dash_count:
1128 * This function returns the length of the dash array in @cr (0 if dashing
1129 * is not currently in effect).
1131 * See also cairo_set_dash() and cairo_get_dash().
1133 * Return value: the length of the dash array, or 0 if no dash array set.
1138 cairo_get_dash_count (cairo_t *cr)
1142 if (unlikely (cr->status))
1145 cr->backend->get_dash (cr, NULL, &num_dashes, NULL);
1153 * @dashes: return value for the dash array, or %NULL
1154 * @offset: return value for the current dash offset, or %NULL
1156 * Gets the current dash array. If not %NULL, @dashes should be big
1157 * enough to hold at least the number of values returned by
1158 * cairo_get_dash_count().
1163 cairo_get_dash (cairo_t *cr,
1167 if (unlikely (cr->status))
1170 cr->backend->get_dash (cr, dashes, NULL, offset);
1174 * cairo_set_miter_limit:
1175 * @cr: a cairo context
1176 * @limit: miter limit to set
1178 * Sets the current miter limit within the cairo context.
1180 * If the current line join style is set to %CAIRO_LINE_JOIN_MITER
1181 * (see cairo_set_line_join()), the miter limit is used to determine
1182 * whether the lines should be joined with a bevel instead of a miter.
1183 * Cairo divides the length of the miter by the line width.
1184 * If the result is greater than the miter limit, the style is
1185 * converted to a bevel.
1187 * As with the other stroke parameters, the current line miter limit is
1188 * examined by cairo_stroke(), cairo_stroke_extents(), and
1189 * cairo_stroke_to_path(), but does not have any effect during path
1192 * The default miter limit value is 10.0, which will convert joins
1193 * with interior angles less than 11 degrees to bevels instead of
1194 * miters. For reference, a miter limit of 2.0 makes the miter cutoff
1195 * at 60 degrees, and a miter limit of 1.414 makes the cutoff at 90
1198 * A miter limit for a desired angle can be computed as: miter limit =
1204 cairo_set_miter_limit (cairo_t *cr, double limit)
1206 cairo_status_t status;
1208 if (unlikely (cr->status))
1211 status = cr->backend->set_miter_limit (cr, limit);
1212 if (unlikely (status))
1213 _cairo_set_error (cr, status);
1218 * @cr: a cairo context
1219 * @tx: amount to translate in the X direction
1220 * @ty: amount to translate in the Y direction
1222 * Modifies the current transformation matrix (CTM) by translating the
1223 * user-space origin by (@tx, @ty). This offset is interpreted as a
1224 * user-space coordinate according to the CTM in place before the new
1225 * call to cairo_translate(). In other words, the translation of the
1226 * user-space origin takes place after any existing transformation.
1231 cairo_translate (cairo_t *cr, double tx, double ty)
1233 CAIRO_TRACE_BEGIN (__func__);
1234 cairo_status_t status;
1236 if (unlikely (cr->status)) {
1237 CAIRO_TRACE_END (__func__);
1241 status = cr->backend->translate (cr, tx, ty);
1242 if (unlikely (status))
1243 _cairo_set_error (cr, status);
1245 CAIRO_TRACE_END (__func__);
1247 slim_hidden_def (cairo_translate);
1251 * @cr: a cairo context
1252 * @sx: scale factor for the X dimension
1253 * @sy: scale factor for the Y dimension
1255 * Modifies the current transformation matrix (CTM) by scaling the X
1256 * and Y user-space axes by @sx and @sy respectively. The scaling of
1257 * the axes takes place after any existing transformation of user
1263 cairo_scale (cairo_t *cr, double sx, double sy)
1265 CAIRO_TRACE_BEGIN (__func__);
1266 cairo_status_t status;
1268 if (unlikely (cr->status)) {
1269 CAIRO_TRACE_END (__func__);
1273 status = cr->backend->scale (cr, sx, sy);
1274 if (unlikely (status))
1275 _cairo_set_error (cr, status);
1277 CAIRO_TRACE_END (__func__);
1279 slim_hidden_def (cairo_scale);
1283 * @cr: a cairo context
1284 * @angle: angle (in radians) by which the user-space axes will be
1287 * Modifies the current transformation matrix (CTM) by rotating the
1288 * user-space axes by @angle radians. The rotation of the axes takes
1289 * places after any existing transformation of user space. The
1290 * rotation direction for positive angles is from the positive X axis
1291 * toward the positive Y axis.
1296 cairo_rotate (cairo_t *cr, double angle)
1298 CAIRO_TRACE_BEGIN (__func__);
1299 cairo_status_t status;
1301 if (unlikely (cr->status)) {
1302 CAIRO_TRACE_END (__func__);
1306 status = cr->backend->rotate (cr, angle);
1307 if (unlikely (status))
1308 _cairo_set_error (cr, status);
1310 CAIRO_TRACE_END (__func__);
1315 * @cr: a cairo context
1316 * @matrix: a transformation to be applied to the user-space axes
1318 * Modifies the current transformation matrix (CTM) by applying
1319 * @matrix as an additional transformation. The new transformation of
1320 * user space takes place after any existing transformation.
1325 cairo_transform (cairo_t *cr,
1326 const cairo_matrix_t *matrix)
1328 cairo_status_t status;
1330 if (unlikely (cr->status))
1333 status = cr->backend->transform (cr, matrix);
1334 if (unlikely (status))
1335 _cairo_set_error (cr, status);
1337 slim_hidden_def (cairo_transform);
1341 * @cr: a cairo context
1342 * @matrix: a transformation matrix from user space to device space
1344 * Modifies the current transformation matrix (CTM) by setting it
1350 cairo_set_matrix (cairo_t *cr,
1351 const cairo_matrix_t *matrix)
1353 cairo_status_t status;
1355 if (unlikely (cr->status))
1358 status = cr->backend->set_matrix (cr, matrix);
1359 if (unlikely (status))
1360 _cairo_set_error (cr, status);
1362 slim_hidden_def (cairo_set_matrix);
1365 * cairo_identity_matrix:
1366 * @cr: a cairo context
1368 * Resets the current transformation matrix (CTM) by setting it equal
1369 * to the identity matrix. That is, the user-space and device-space
1370 * axes will be aligned and one user-space unit will transform to one
1371 * device-space unit.
1376 cairo_identity_matrix (cairo_t *cr)
1378 cairo_status_t status;
1380 if (unlikely (cr->status))
1383 status = cr->backend->set_identity_matrix (cr);
1384 if (unlikely (status))
1385 _cairo_set_error (cr, status);
1389 * cairo_user_to_device:
1390 * @cr: a cairo context
1391 * @x: X value of coordinate (in/out parameter)
1392 * @y: Y value of coordinate (in/out parameter)
1394 * Transform a coordinate from user space to device space by
1395 * multiplying the given point by the current transformation matrix
1401 cairo_user_to_device (cairo_t *cr, double *x, double *y)
1403 CAIRO_TRACE_BEGIN (__func__);
1404 if (unlikely (cr->status)) {
1405 CAIRO_TRACE_END (__func__);
1409 cr->backend->user_to_device (cr, x, y);
1410 CAIRO_TRACE_END (__func__);
1412 slim_hidden_def (cairo_user_to_device);
1415 * cairo_user_to_device_distance:
1416 * @cr: a cairo context
1417 * @dx: X component of a distance vector (in/out parameter)
1418 * @dy: Y component of a distance vector (in/out parameter)
1420 * Transform a distance vector from user space to device space. This
1421 * function is similar to cairo_user_to_device() except that the
1422 * translation components of the CTM will be ignored when transforming
1428 cairo_user_to_device_distance (cairo_t *cr, double *dx, double *dy)
1430 CAIRO_TRACE_BEGIN (__func__);
1431 if (unlikely (cr->status)) {
1432 CAIRO_TRACE_END (__func__);
1436 cr->backend->user_to_device_distance (cr, dx, dy);
1437 CAIRO_TRACE_END (__func__);
1439 slim_hidden_def (cairo_user_to_device_distance);
1442 * cairo_device_to_user:
1444 * @x: X value of coordinate (in/out parameter)
1445 * @y: Y value of coordinate (in/out parameter)
1447 * Transform a coordinate from device space to user space by
1448 * multiplying the given point by the inverse of the current
1449 * transformation matrix (CTM).
1454 cairo_device_to_user (cairo_t *cr, double *x, double *y)
1456 CAIRO_TRACE_BEGIN (__func__);
1457 if (unlikely (cr->status)) {
1458 CAIRO_TRACE_END (__func__);
1462 cr->backend->device_to_user (cr, x, y);
1463 CAIRO_TRACE_END (__func__);
1465 slim_hidden_def (cairo_device_to_user);
1468 * cairo_device_to_user_distance:
1469 * @cr: a cairo context
1470 * @dx: X component of a distance vector (in/out parameter)
1471 * @dy: Y component of a distance vector (in/out parameter)
1473 * Transform a distance vector from device space to user space. This
1474 * function is similar to cairo_device_to_user() except that the
1475 * translation components of the inverse CTM will be ignored when
1476 * transforming (@dx,@dy).
1481 cairo_device_to_user_distance (cairo_t *cr, double *dx, double *dy)
1483 if (unlikely (cr->status))
1486 cr->backend->device_to_user_distance (cr, dx, dy);
1491 * @cr: a cairo context
1493 * Clears the current path. After this call there will be no path and
1499 cairo_new_path (cairo_t *cr)
1501 cairo_status_t status;
1503 if (unlikely (cr->status))
1506 status = cr->backend->new_path (cr);
1507 if (unlikely (status))
1508 _cairo_set_error (cr, status);
1510 slim_hidden_def(cairo_new_path);
1513 * cairo_new_sub_path:
1514 * @cr: a cairo context
1516 * Begin a new sub-path. Note that the existing path is not
1517 * affected. After this call there will be no current point.
1519 * In many cases, this call is not needed since new sub-paths are
1520 * frequently started with cairo_move_to().
1522 * A call to cairo_new_sub_path() is particularly useful when
1523 * beginning a new sub-path with one of the cairo_arc() calls. This
1524 * makes things easier as it is no longer necessary to manually
1525 * compute the arc's initial coordinates for a call to
1531 cairo_new_sub_path (cairo_t *cr)
1533 cairo_status_t status;
1535 if (unlikely (cr->status))
1538 status = cr->backend->new_sub_path (cr);
1539 if (unlikely (status))
1540 _cairo_set_error (cr, status);
1545 * @cr: a cairo context
1546 * @x: the X coordinate of the new position
1547 * @y: the Y coordinate of the new position
1549 * Begin a new sub-path. After this call the current point will be (@x,
1555 cairo_move_to (cairo_t *cr, double x, double y)
1557 cairo_status_t status;
1559 if (unlikely (cr->status))
1562 status = cr->backend->move_to (cr, x, y);
1563 if (unlikely (status))
1564 _cairo_set_error (cr, status);
1566 slim_hidden_def(cairo_move_to);
1571 * @cr: a cairo context
1572 * @x: the X coordinate of the end of the new line
1573 * @y: the Y coordinate of the end of the new line
1575 * Adds a line to the path from the current point to position (@x, @y)
1576 * in user-space coordinates. After this call the current point
1579 * If there is no current point before the call to cairo_line_to()
1580 * this function will behave as cairo_move_to(@cr, @x, @y).
1585 cairo_line_to (cairo_t *cr, double x, double y)
1587 cairo_status_t status;
1589 if (unlikely (cr->status))
1592 status = cr->backend->line_to (cr, x, y);
1593 if (unlikely (status))
1594 _cairo_set_error (cr, status);
1596 slim_hidden_def (cairo_line_to);
1600 * @cr: a cairo context
1601 * @x1: the X coordinate of the first control point
1602 * @y1: the Y coordinate of the first control point
1603 * @x2: the X coordinate of the second control point
1604 * @y2: the Y coordinate of the second control point
1605 * @x3: the X coordinate of the end of the curve
1606 * @y3: the Y coordinate of the end of the curve
1608 * Adds a cubic Bézier spline to the path from the current point to
1609 * position (@x3, @y3) in user-space coordinates, using (@x1, @y1) and
1610 * (@x2, @y2) as the control points. After this call the current point
1611 * will be (@x3, @y3).
1613 * If there is no current point before the call to cairo_curve_to()
1614 * this function will behave as if preceded by a call to
1615 * cairo_move_to(@cr, @x1, @y1).
1620 cairo_curve_to (cairo_t *cr,
1621 double x1, double y1,
1622 double x2, double y2,
1623 double x3, double y3)
1625 cairo_status_t status;
1627 if (unlikely (cr->status))
1630 status = cr->backend->curve_to (cr,
1634 if (unlikely (status))
1635 _cairo_set_error (cr, status);
1637 slim_hidden_def (cairo_curve_to);
1641 * @cr: a cairo context
1642 * @xc: X position of the center of the arc
1643 * @yc: Y position of the center of the arc
1644 * @radius: the radius of the arc
1645 * @angle1: the start angle, in radians
1646 * @angle2: the end angle, in radians
1648 * Adds a circular arc of the given @radius to the current path. The
1649 * arc is centered at (@xc, @yc), begins at @angle1 and proceeds in
1650 * the direction of increasing angles to end at @angle2. If @angle2 is
1651 * less than @angle1 it will be progressively increased by
1652 * <literal>2*M_PI</literal> until it is greater than @angle1.
1654 * If there is a current point, an initial line segment will be added
1655 * to the path to connect the current point to the beginning of the
1656 * arc. If this initial line is undesired, it can be avoided by
1657 * calling cairo_new_sub_path() before calling cairo_arc().
1659 * Angles are measured in radians. An angle of 0.0 is in the direction
1660 * of the positive X axis (in user space). An angle of
1661 * <literal>M_PI/2.0</literal> radians (90 degrees) is in the
1662 * direction of the positive Y axis (in user space). Angles increase
1663 * in the direction from the positive X axis toward the positive Y
1664 * axis. So with the default transformation matrix, angles increase in
1665 * a clockwise direction.
1667 * (To convert from degrees to radians, use <literal>degrees * (M_PI /
1670 * This function gives the arc in the direction of increasing angles;
1671 * see cairo_arc_negative() to get the arc in the direction of
1672 * decreasing angles.
1674 * The arc is circular in user space. To achieve an elliptical arc,
1675 * you can scale the current transformation matrix by different
1676 * amounts in the X and Y directions. For example, to draw an ellipse
1677 * in the box given by @x, @y, @width, @height:
1679 * <informalexample><programlisting>
1681 * cairo_translate (cr, x + width / 2., y + height / 2.);
1682 * cairo_scale (cr, width / 2., height / 2.);
1683 * cairo_arc (cr, 0., 0., 1., 0., 2 * M_PI);
1684 * cairo_restore (cr);
1685 * </programlisting></informalexample>
1690 cairo_arc (cairo_t *cr,
1691 double xc, double yc,
1693 double angle1, double angle2)
1695 CAIRO_TRACE_BEGIN (__func__);
1696 cairo_status_t status;
1698 if (unlikely (cr->status)) {
1699 CAIRO_TRACE_END (__func__);
1703 if (angle2 < angle1) {
1704 /* increase angle2 by multiples of full circle until it
1705 * satisfies angle2 >= angle1 */
1706 angle2 = fmod (angle2 - angle1, 2 * M_PI);
1711 status = cr->backend->arc (cr, xc, yc, radius, angle1, angle2, TRUE);
1712 if (unlikely (status))
1713 _cairo_set_error (cr, status);
1715 CAIRO_TRACE_END (__func__);
1719 * cairo_arc_negative:
1720 * @cr: a cairo context
1721 * @xc: X position of the center of the arc
1722 * @yc: Y position of the center of the arc
1723 * @radius: the radius of the arc
1724 * @angle1: the start angle, in radians
1725 * @angle2: the end angle, in radians
1727 * Adds a circular arc of the given @radius to the current path. The
1728 * arc is centered at (@xc, @yc), begins at @angle1 and proceeds in
1729 * the direction of decreasing angles to end at @angle2. If @angle2 is
1730 * greater than @angle1 it will be progressively decreased by
1731 * <literal>2*M_PI</literal> until it is less than @angle1.
1733 * See cairo_arc() for more details. This function differs only in the
1734 * direction of the arc between the two angles.
1739 cairo_arc_negative (cairo_t *cr,
1740 double xc, double yc,
1742 double angle1, double angle2)
1744 CAIRO_TRACE_BEGIN (__func__);
1745 cairo_status_t status;
1747 if (unlikely (cr->status)) {
1748 CAIRO_TRACE_END (__func__);
1752 if (angle2 > angle1) {
1753 /* decrease angle2 by multiples of full circle until it
1754 * satisfies angle2 <= angle1 */
1755 angle2 = fmod (angle2 - angle1, 2 * M_PI);
1761 status = cr->backend->arc (cr, xc, yc, radius, angle1, angle2, FALSE);
1762 if (unlikely (status))
1763 _cairo_set_error (cr, status);
1764 CAIRO_TRACE_END (__func__);
1769 cairo_arc_to (cairo_t *cr,
1770 double x1, double y1,
1771 double x2, double y2,
1774 cairo_status_t status;
1776 if (unlikely (cr->status))
1779 status = cr->backend->arc_to (cr, x1, y1, x2, y2, radius);
1780 if (unlikely (status))
1781 _cairo_set_error (cr, status);
1785 cairo_rel_arc_to (cairo_t *cr,
1786 double dx1, double dy1,
1787 double dx2, double dy2,
1790 cairo_status_t status;
1792 if (unlikely (cr->status))
1795 status = cr->backend->rel_arc_to (cr, dx1, dy1, dx2, dy2, radius);
1796 if (unlikely (status))
1797 _cairo_set_error (cr, status);
1802 * cairo_rel_move_to:
1803 * @cr: a cairo context
1807 * Begin a new sub-path. After this call the current point will offset
1810 * Given a current point of (x, y), cairo_rel_move_to(@cr, @dx, @dy)
1811 * is logically equivalent to cairo_move_to(@cr, x + @dx, y + @dy).
1813 * It is an error to call this function with no current point. Doing
1814 * so will cause @cr to shutdown with a status of
1815 * %CAIRO_STATUS_NO_CURRENT_POINT.
1820 cairo_rel_move_to (cairo_t *cr, double dx, double dy)
1822 cairo_status_t status;
1824 if (unlikely (cr->status))
1827 status = cr->backend->rel_move_to (cr, dx, dy);
1828 if (unlikely (status))
1829 _cairo_set_error (cr, status);
1833 * cairo_rel_line_to:
1834 * @cr: a cairo context
1835 * @dx: the X offset to the end of the new line
1836 * @dy: the Y offset to the end of the new line
1838 * Relative-coordinate version of cairo_line_to(). Adds a line to the
1839 * path from the current point to a point that is offset from the
1840 * current point by (@dx, @dy) in user space. After this call the
1841 * current point will be offset by (@dx, @dy).
1843 * Given a current point of (x, y), cairo_rel_line_to(@cr, @dx, @dy)
1844 * is logically equivalent to cairo_line_to(@cr, x + @dx, y + @dy).
1846 * It is an error to call this function with no current point. Doing
1847 * so will cause @cr to shutdown with a status of
1848 * %CAIRO_STATUS_NO_CURRENT_POINT.
1853 cairo_rel_line_to (cairo_t *cr, double dx, double dy)
1855 cairo_status_t status;
1857 if (unlikely (cr->status))
1860 status = cr->backend->rel_line_to (cr, dx, dy);
1861 if (unlikely (status))
1862 _cairo_set_error (cr, status);
1864 slim_hidden_def(cairo_rel_line_to);
1867 * cairo_rel_curve_to:
1868 * @cr: a cairo context
1869 * @dx1: the X offset to the first control point
1870 * @dy1: the Y offset to the first control point
1871 * @dx2: the X offset to the second control point
1872 * @dy2: the Y offset to the second control point
1873 * @dx3: the X offset to the end of the curve
1874 * @dy3: the Y offset to the end of the curve
1876 * Relative-coordinate version of cairo_curve_to(). All offsets are
1877 * relative to the current point. Adds a cubic Bézier spline to the
1878 * path from the current point to a point offset from the current
1879 * point by (@dx3, @dy3), using points offset by (@dx1, @dy1) and
1880 * (@dx2, @dy2) as the control points. After this call the current
1881 * point will be offset by (@dx3, @dy3).
1883 * Given a current point of (x, y), cairo_rel_curve_to(@cr, @dx1,
1884 * @dy1, @dx2, @dy2, @dx3, @dy3) is logically equivalent to
1885 * cairo_curve_to(@cr, x+@dx1, y+@dy1, x+@dx2, y+@dy2, x+@dx3, y+@dy3).
1887 * It is an error to call this function with no current point. Doing
1888 * so will cause @cr to shutdown with a status of
1889 * %CAIRO_STATUS_NO_CURRENT_POINT.
1894 cairo_rel_curve_to (cairo_t *cr,
1895 double dx1, double dy1,
1896 double dx2, double dy2,
1897 double dx3, double dy3)
1899 cairo_status_t status;
1901 if (unlikely (cr->status))
1904 status = cr->backend->rel_curve_to (cr,
1908 if (unlikely (status))
1909 _cairo_set_error (cr, status);
1914 * @cr: a cairo context
1915 * @x: the X coordinate of the top left corner of the rectangle
1916 * @y: the Y coordinate to the top left corner of the rectangle
1917 * @width: the width of the rectangle
1918 * @height: the height of the rectangle
1920 * Adds a closed sub-path rectangle of the given size to the current
1921 * path at position (@x, @y) in user-space coordinates.
1923 * This function is logically equivalent to:
1924 * <informalexample><programlisting>
1925 * cairo_move_to (cr, x, y);
1926 * cairo_rel_line_to (cr, width, 0);
1927 * cairo_rel_line_to (cr, 0, height);
1928 * cairo_rel_line_to (cr, -width, 0);
1929 * cairo_close_path (cr);
1930 * </programlisting></informalexample>
1935 cairo_rectangle (cairo_t *cr,
1937 double width, double height)
1939 CAIRO_TRACE_BEGIN (__func__);
1940 cairo_status_t status;
1942 if (unlikely (cr->status)) {
1943 CAIRO_TRACE_END (__func__);
1947 status = cr->backend->rectangle (cr, x, y, width, height);
1948 if (unlikely (status))
1949 _cairo_set_error (cr, status);
1951 CAIRO_TRACE_END (__func__);
1955 * cairo_rounded_rectangle:
1956 * @cr: a cairo context
1957 * @x: the X coordinate of the top left corner of the rectangle
1958 * @y: the Y coordinate to the top left corner of the rectangle
1959 * @width: the width of the rectangle
1960 * @height: the height of the rectangle
1961 * @r_top_left: top left corner radius
1962 * @r_top_right: top right corner radius
1963 * @r_bottom_left: bottom left corner radius
1964 * @r_bottom_left: top left corner radius
1966 * Adds a closed sub-path roundedrectangle of the given size to the current
1967 * path at position (@x, @y) in user-space coordinates.
1969 * This function is logically equivalent to:
1970 * <informalexample><programlisting>
1971 * cairo_move_to (cr, x, y + r_top_left)
1972 * cairo_rel_curve_to (cr, ....)
1973 * cairo_rel_line_to (cr, ....)
1974 * cairo_rel_curve_to (cr, ....)
1975 * cairo_line_to (cr, ....)
1976 * cairo_rel_curve_to (cr, ....)
1977 * cairo_close_path (cr)
1978 * </programlisting></informalexample>
1983 cairo_rounded_rectangle (cairo_t *cr,
1985 double width, double height,
1986 double r_top_left, double r_top_right,
1987 double r_bottom_left, double r_bottom_right)
1989 CAIRO_TRACE_BEGIN (__func__);
1990 cairo_status_t status;
1992 if (unlikely (cr->status)) {
1993 CAIRO_TRACE_END (__func__);
1997 status = cr->backend->rounded_rectangle (cr, x, y, width, height,
1998 r_top_left, r_top_right,
1999 r_bottom_left, r_bottom_right);
2000 if (unlikely (status))
2001 _cairo_set_error (cr, status);
2003 CAIRO_TRACE_END (__func__);
2009 cairo_stroke_to_path (cairo_t *cr)
2011 cairo_status_t status;
2013 if (unlikely (cr->status))
2016 /* The code in _cairo_recording_surface_get_path has a poorman's stroke_to_path */
2018 status = _cairo_gstate_stroke_path (cr->gstate);
2019 if (unlikely (status))
2020 _cairo_set_error (cr, status);
2026 * @cr: a cairo context
2028 * Adds a line segment to the path from the current point to the
2029 * beginning of the current sub-path, (the most recent point passed to
2030 * cairo_move_to()), and closes this sub-path. After this call the
2031 * current point will be at the joined endpoint of the sub-path.
2033 * The behavior of cairo_close_path() is distinct from simply calling
2034 * cairo_line_to() with the equivalent coordinate in the case of
2035 * stroking. When a closed sub-path is stroked, there are no caps on
2036 * the ends of the sub-path. Instead, there is a line join connecting
2037 * the final and initial segments of the sub-path.
2039 * If there is no current point before the call to cairo_close_path(),
2040 * this function will have no effect.
2042 * Note: As of cairo version 1.2.4 any call to cairo_close_path() will
2043 * place an explicit MOVE_TO element into the path immediately after
2044 * the CLOSE_PATH element, (which can be seen in cairo_copy_path() for
2045 * example). This can simplify path processing in some cases as it may
2046 * not be necessary to save the "last move_to point" during processing
2047 * as the MOVE_TO immediately after the CLOSE_PATH will provide that
2053 cairo_close_path (cairo_t *cr)
2055 cairo_status_t status;
2057 if (unlikely (cr->status))
2060 status = cr->backend->close_path (cr);
2061 if (unlikely (status))
2062 _cairo_set_error (cr, status);
2064 slim_hidden_def(cairo_close_path);
2067 * cairo_path_extents:
2068 * @cr: a cairo context
2069 * @x1: left of the resulting extents
2070 * @y1: top of the resulting extents
2071 * @x2: right of the resulting extents
2072 * @y2: bottom of the resulting extents
2074 * Computes a bounding box in user-space coordinates covering the
2075 * points on the current path. If the current path is empty, returns
2076 * an empty rectangle ((0,0), (0,0)). Stroke parameters, fill rule,
2077 * surface dimensions and clipping are not taken into account.
2079 * Contrast with cairo_fill_extents() and cairo_stroke_extents() which
2080 * return the extents of only the area that would be "inked" by
2081 * the corresponding drawing operations.
2083 * The result of cairo_path_extents() is defined as equivalent to the
2084 * limit of cairo_stroke_extents() with %CAIRO_LINE_CAP_ROUND as the
2085 * line width approaches 0.0, (but never reaching the empty-rectangle
2086 * returned by cairo_stroke_extents() for a line width of 0.0).
2088 * Specifically, this means that zero-area sub-paths such as
2089 * cairo_move_to();cairo_line_to() segments, (even degenerate cases
2090 * where the coordinates to both calls are identical), will be
2091 * considered as contributing to the extents. However, a lone
2092 * cairo_move_to() will not contribute to the results of
2093 * cairo_path_extents().
2098 cairo_path_extents (cairo_t *cr,
2099 double *x1, double *y1, double *x2, double *y2)
2101 if (unlikely (cr->status)) {
2114 cr->backend->path_extents (cr, x1, y1, x2, y2);
2119 * @cr: a cairo context
2121 * A drawing operator that paints the current source everywhere within
2122 * the current clip region.
2127 cairo_paint (cairo_t *cr)
2129 CAIRO_TRACE_BEGIN (__func__);
2130 cairo_status_t status;
2132 if (unlikely (cr->status)) {
2133 CAIRO_TRACE_END (__func__);
2137 status = cr->backend->paint (cr);
2138 if (unlikely (status))
2139 _cairo_set_error (cr, status);
2141 CAIRO_TRACE_END (__func__);
2143 slim_hidden_def (cairo_paint);
2146 * cairo_paint_with_alpha:
2147 * @cr: a cairo context
2148 * @alpha: alpha value, between 0 (transparent) and 1 (opaque)
2150 * A drawing operator that paints the current source everywhere within
2151 * the current clip region using a mask of constant alpha value
2152 * @alpha. The effect is similar to cairo_paint(), but the drawing
2153 * is faded out using the alpha value.
2158 cairo_paint_with_alpha (cairo_t *cr,
2161 CAIRO_TRACE_BEGIN (__func__);
2162 cairo_status_t status;
2164 if (unlikely (cr->status)) {
2165 CAIRO_TRACE_END (__func__);
2169 status = cr->backend->paint_with_alpha (cr, alpha);
2170 if (unlikely (status))
2171 _cairo_set_error (cr, status);
2173 CAIRO_TRACE_END (__func__);
2178 * @cr: a cairo context
2179 * @pattern: a #cairo_pattern_t
2181 * A drawing operator that paints the current source
2182 * using the alpha channel of @pattern as a mask. (Opaque
2183 * areas of @pattern are painted with the source, transparent
2184 * areas are not painted.)
2189 cairo_mask (cairo_t *cr,
2190 cairo_pattern_t *pattern)
2192 CAIRO_TRACE_BEGIN (__func__);
2193 cairo_status_t status;
2195 if (unlikely (cr->status)) {
2196 CAIRO_TRACE_END (__func__);
2200 if (unlikely (pattern == NULL)) {
2201 _cairo_set_error (cr, CAIRO_STATUS_NULL_POINTER);
2202 CAIRO_TRACE_END (__func__);
2206 if (unlikely (pattern->status)) {
2207 _cairo_set_error (cr, pattern->status);
2208 CAIRO_TRACE_END (__func__);
2212 status = cr->backend->mask (cr, pattern);
2213 if (unlikely (status))
2214 _cairo_set_error (cr, status);
2216 CAIRO_TRACE_END (__func__);
2218 slim_hidden_def (cairo_mask);
2221 * cairo_mask_surface:
2222 * @cr: a cairo context
2223 * @surface: a #cairo_surface_t
2224 * @surface_x: X coordinate at which to place the origin of @surface
2225 * @surface_y: Y coordinate at which to place the origin of @surface
2227 * A drawing operator that paints the current source
2228 * using the alpha channel of @surface as a mask. (Opaque
2229 * areas of @surface are painted with the source, transparent
2230 * areas are not painted.)
2235 cairo_mask_surface (cairo_t *cr,
2236 cairo_surface_t *surface,
2240 CAIRO_TRACE_BEGIN (__func__);
2241 cairo_pattern_t *pattern;
2242 cairo_matrix_t matrix;
2244 if (unlikely (cr->status)) {
2245 CAIRO_TRACE_END (__func__);
2249 pattern = cairo_pattern_create_for_surface (surface);
2251 cairo_matrix_init_translate (&matrix, - surface_x, - surface_y);
2252 cairo_pattern_set_matrix (pattern, &matrix);
2254 cairo_mask (cr, pattern);
2256 cairo_pattern_destroy (pattern);
2257 CAIRO_TRACE_END (__func__);
2262 * @cr: a cairo context
2264 * A drawing operator that strokes the current path according to the
2265 * current line width, line join, line cap, and dash settings. After
2266 * cairo_stroke(), the current path will be cleared from the cairo
2267 * context. See cairo_set_line_width(), cairo_set_line_join(),
2268 * cairo_set_line_cap(), cairo_set_dash(), and
2269 * cairo_stroke_preserve().
2271 * Note: Degenerate segments and sub-paths are treated specially and
2272 * provide a useful result. These can result in two different
2275 * 1. Zero-length "on" segments set in cairo_set_dash(). If the cap
2276 * style is %CAIRO_LINE_CAP_ROUND or %CAIRO_LINE_CAP_SQUARE then these
2277 * segments will be drawn as circular dots or squares respectively. In
2278 * the case of %CAIRO_LINE_CAP_SQUARE, the orientation of the squares
2279 * is determined by the direction of the underlying path.
2281 * 2. A sub-path created by cairo_move_to() followed by either a
2282 * cairo_close_path() or one or more calls to cairo_line_to() to the
2283 * same coordinate as the cairo_move_to(). If the cap style is
2284 * %CAIRO_LINE_CAP_ROUND then these sub-paths will be drawn as circular
2285 * dots. Note that in the case of %CAIRO_LINE_CAP_SQUARE a degenerate
2286 * sub-path will not be drawn at all, (since the correct orientation
2287 * is indeterminate).
2289 * In no case will a cap style of %CAIRO_LINE_CAP_BUTT cause anything
2290 * to be drawn in the case of either degenerate segments or sub-paths.
2295 cairo_stroke (cairo_t *cr)
2297 CAIRO_TRACE_BEGIN (__func__);
2298 cairo_status_t status;
2300 if (unlikely (cr->status)) {
2301 CAIRO_TRACE_END (__func__);
2305 status = cr->backend->stroke (cr);
2306 if (unlikely (status))
2307 _cairo_set_error (cr, status);
2309 CAIRO_TRACE_END (__func__);
2311 slim_hidden_def(cairo_stroke);
2314 * cairo_stroke_preserve:
2315 * @cr: a cairo context
2317 * A drawing operator that strokes the current path according to the
2318 * current line width, line join, line cap, and dash settings. Unlike
2319 * cairo_stroke(), cairo_stroke_preserve() preserves the path within the
2322 * See cairo_set_line_width(), cairo_set_line_join(),
2323 * cairo_set_line_cap(), cairo_set_dash(), and
2324 * cairo_stroke_preserve().
2329 cairo_stroke_preserve (cairo_t *cr)
2331 CAIRO_TRACE_BEGIN (__func__);
2332 cairo_status_t status;
2334 if (unlikely (cr->status)) {
2335 CAIRO_TRACE_END (__func__);
2339 status = cr->backend->stroke_preserve (cr);
2340 if (unlikely (status))
2341 _cairo_set_error (cr, status);
2343 CAIRO_TRACE_END (__func__);
2345 slim_hidden_def(cairo_stroke_preserve);
2349 * @cr: a cairo context
2351 * A drawing operator that fills the current path according to the
2352 * current fill rule, (each sub-path is implicitly closed before being
2353 * filled). After cairo_fill(), the current path will be cleared from
2354 * the cairo context. See cairo_set_fill_rule() and
2355 * cairo_fill_preserve().
2360 cairo_fill (cairo_t *cr)
2362 CAIRO_TRACE_BEGIN (__func__);
2363 cairo_status_t status;
2365 if (unlikely (cr->status)) {
2366 CAIRO_TRACE_END (__func__);
2370 status = cr->backend->fill (cr);
2371 if (unlikely (status))
2372 _cairo_set_error (cr, status);
2374 CAIRO_TRACE_END (__func__);
2378 * cairo_fill_preserve:
2379 * @cr: a cairo context
2381 * A drawing operator that fills the current path according to the
2382 * current fill rule, (each sub-path is implicitly closed before being
2383 * filled). Unlike cairo_fill(), cairo_fill_preserve() preserves the
2384 * path within the cairo context.
2386 * See cairo_set_fill_rule() and cairo_fill().
2391 cairo_fill_preserve (cairo_t *cr)
2393 CAIRO_TRACE_BEGIN (__func__);
2394 cairo_status_t status;
2396 if (unlikely (cr->status)) {
2397 CAIRO_TRACE_END (__func__);
2401 status = cr->backend->fill_preserve (cr);
2402 if (unlikely (status))
2403 _cairo_set_error (cr, status);
2405 CAIRO_TRACE_END (__func__);
2407 slim_hidden_def(cairo_fill_preserve);
2411 * @cr: a cairo context
2413 * Emits the current page for backends that support multiple pages, but
2414 * doesn't clear it, so, the contents of the current page will be retained
2415 * for the next page too. Use cairo_show_page() if you want to get an
2416 * empty page after the emission.
2418 * This is a convenience function that simply calls
2419 * cairo_surface_copy_page() on @cr's target.
2424 cairo_copy_page (cairo_t *cr)
2426 cairo_status_t status;
2428 if (unlikely (cr->status))
2431 status = cr->backend->copy_page (cr);
2432 if (unlikely (status))
2433 _cairo_set_error (cr, status);
2438 * @cr: a cairo context
2440 * Emits and clears the current page for backends that support multiple
2441 * pages. Use cairo_copy_page() if you don't want to clear the page.
2443 * This is a convenience function that simply calls
2444 * cairo_surface_show_page() on @cr's target.
2449 cairo_show_page (cairo_t *cr)
2451 cairo_status_t status;
2453 if (unlikely (cr->status))
2456 status = cr->backend->show_page (cr);
2457 if (unlikely (status))
2458 _cairo_set_error (cr, status);
2463 * @cr: a cairo context
2464 * @x: X coordinate of the point to test
2465 * @y: Y coordinate of the point to test
2467 * Tests whether the given point is inside the area that would be
2468 * affected by a cairo_stroke() operation given the current path and
2469 * stroking parameters. Surface dimensions and clipping are not taken
2472 * See cairo_stroke(), cairo_set_line_width(), cairo_set_line_join(),
2473 * cairo_set_line_cap(), cairo_set_dash(), and
2474 * cairo_stroke_preserve().
2476 * Return value: A non-zero value if the point is inside, or zero if
2482 cairo_in_stroke (cairo_t *cr, double x, double y)
2484 cairo_status_t status;
2485 cairo_bool_t inside = FALSE;
2487 if (unlikely (cr->status))
2490 status = cr->backend->in_stroke (cr, x, y, &inside);
2491 if (unlikely (status))
2492 _cairo_set_error (cr, status);
2499 * @cr: a cairo context
2500 * @x: X coordinate of the point to test
2501 * @y: Y coordinate of the point to test
2503 * Tests whether the given point is inside the area that would be
2504 * affected by a cairo_fill() operation given the current path and
2505 * filling parameters. Surface dimensions and clipping are not taken
2508 * See cairo_fill(), cairo_set_fill_rule() and cairo_fill_preserve().
2510 * Return value: A non-zero value if the point is inside, or zero if
2516 cairo_in_fill (cairo_t *cr, double x, double y)
2518 cairo_status_t status;
2519 cairo_bool_t inside = FALSE;
2521 if (unlikely (cr->status))
2524 status = cr->backend->in_fill (cr, x, y, &inside);
2525 if (unlikely (status))
2526 _cairo_set_error (cr, status);
2532 * cairo_stroke_extents:
2533 * @cr: a cairo context
2534 * @x1: left of the resulting extents
2535 * @y1: top of the resulting extents
2536 * @x2: right of the resulting extents
2537 * @y2: bottom of the resulting extents
2539 * Computes a bounding box in user coordinates covering the area that
2540 * would be affected, (the "inked" area), by a cairo_stroke()
2541 * operation given the current path and stroke parameters.
2542 * If the current path is empty, returns an empty rectangle ((0,0), (0,0)).
2543 * Surface dimensions and clipping are not taken into account.
2545 * Note that if the line width is set to exactly zero, then
2546 * cairo_stroke_extents() will return an empty rectangle. Contrast with
2547 * cairo_path_extents() which can be used to compute the non-empty
2548 * bounds as the line width approaches zero.
2550 * Note that cairo_stroke_extents() must necessarily do more work to
2551 * compute the precise inked areas in light of the stroke parameters,
2552 * so cairo_path_extents() may be more desirable for sake of
2553 * performance if non-inked path extents are desired.
2555 * See cairo_stroke(), cairo_set_line_width(), cairo_set_line_join(),
2556 * cairo_set_line_cap(), cairo_set_dash(), and
2557 * cairo_stroke_preserve().
2562 cairo_stroke_extents (cairo_t *cr,
2563 double *x1, double *y1, double *x2, double *y2)
2565 CAIRO_TRACE_BEGIN (__func__);
2566 cairo_status_t status;
2568 if (unlikely (cr->status)) {
2578 CAIRO_TRACE_END (__func__);
2582 status = cr->backend->stroke_extents (cr, x1, y1, x2, y2);
2583 if (unlikely (status))
2584 _cairo_set_error (cr, status);
2586 CAIRO_TRACE_END (__func__);
2590 * cairo_fill_extents:
2591 * @cr: a cairo context
2592 * @x1: left of the resulting extents
2593 * @y1: top of the resulting extents
2594 * @x2: right of the resulting extents
2595 * @y2: bottom of the resulting extents
2597 * Computes a bounding box in user coordinates covering the area that
2598 * would be affected, (the "inked" area), by a cairo_fill() operation
2599 * given the current path and fill parameters. If the current path is
2600 * empty, returns an empty rectangle ((0,0), (0,0)). Surface
2601 * dimensions and clipping are not taken into account.
2603 * Contrast with cairo_path_extents(), which is similar, but returns
2604 * non-zero extents for some paths with no inked area, (such as a
2605 * simple line segment).
2607 * Note that cairo_fill_extents() must necessarily do more work to
2608 * compute the precise inked areas in light of the fill rule, so
2609 * cairo_path_extents() may be more desirable for sake of performance
2610 * if the non-inked path extents are desired.
2612 * See cairo_fill(), cairo_set_fill_rule() and cairo_fill_preserve().
2617 cairo_fill_extents (cairo_t *cr,
2618 double *x1, double *y1, double *x2, double *y2)
2620 CAIRO_TRACE_BEGIN (__func__);
2621 cairo_status_t status;
2623 if (unlikely (cr->status)) {
2633 CAIRO_TRACE_END (__func__);
2637 status = cr->backend->fill_extents (cr, x1, y1, x2, y2);
2638 if (unlikely (status))
2639 _cairo_set_error (cr, status);
2641 CAIRO_TRACE_END (__func__);
2646 * @cr: a cairo context
2648 * Establishes a new clip region by intersecting the current clip
2649 * region with the current path as it would be filled by cairo_fill()
2650 * and according to the current fill rule (see cairo_set_fill_rule()).
2652 * After cairo_clip(), the current path will be cleared from the cairo
2655 * The current clip region affects all drawing operations by
2656 * effectively masking out any changes to the surface that are outside
2657 * the current clip region.
2659 * Calling cairo_clip() can only make the clip region smaller, never
2660 * larger. But the current clip is part of the graphics state, so a
2661 * temporary restriction of the clip region can be achieved by
2662 * calling cairo_clip() within a cairo_save()/cairo_restore()
2663 * pair. The only other means of increasing the size of the clip
2664 * region is cairo_reset_clip().
2669 cairo_clip (cairo_t *cr)
2671 cairo_status_t status;
2673 if (unlikely (cr->status))
2676 status = cr->backend->clip (cr);
2677 if (unlikely (status))
2678 _cairo_set_error (cr, status);
2682 * cairo_clip_preserve:
2683 * @cr: a cairo context
2685 * Establishes a new clip region by intersecting the current clip
2686 * region with the current path as it would be filled by cairo_fill()
2687 * and according to the current fill rule (see cairo_set_fill_rule()).
2689 * Unlike cairo_clip(), cairo_clip_preserve() preserves the path within
2690 * the cairo context.
2692 * The current clip region affects all drawing operations by
2693 * effectively masking out any changes to the surface that are outside
2694 * the current clip region.
2696 * Calling cairo_clip_preserve() can only make the clip region smaller, never
2697 * larger. But the current clip is part of the graphics state, so a
2698 * temporary restriction of the clip region can be achieved by
2699 * calling cairo_clip_preserve() within a cairo_save()/cairo_restore()
2700 * pair. The only other means of increasing the size of the clip
2701 * region is cairo_reset_clip().
2706 cairo_clip_preserve (cairo_t *cr)
2708 cairo_status_t status;
2710 if (unlikely (cr->status))
2713 status = cr->backend->clip_preserve (cr);
2714 if (unlikely (status))
2715 _cairo_set_error (cr, status);
2717 slim_hidden_def(cairo_clip_preserve);
2721 * @cr: a cairo context
2723 * Reset the current clip region to its original, unrestricted
2724 * state. That is, set the clip region to an infinitely large shape
2725 * containing the target surface. Equivalently, if infinity is too
2726 * hard to grasp, one can imagine the clip region being reset to the
2727 * exact bounds of the target surface.
2729 * Note that code meant to be reusable should not call
2730 * cairo_reset_clip() as it will cause results unexpected by
2731 * higher-level code which calls cairo_clip(). Consider using
2732 * cairo_save() and cairo_restore() around cairo_clip() as a more
2733 * robust means of temporarily restricting the clip region.
2738 cairo_reset_clip (cairo_t *cr)
2740 cairo_status_t status;
2742 if (unlikely (cr->status))
2745 status = cr->backend->reset_clip (cr);
2746 if (unlikely (status))
2747 _cairo_set_error (cr, status);
2751 * cairo_clip_extents:
2752 * @cr: a cairo context
2753 * @x1: left of the resulting extents
2754 * @y1: top of the resulting extents
2755 * @x2: right of the resulting extents
2756 * @y2: bottom of the resulting extents
2758 * Computes a bounding box in user coordinates covering the area inside the
2764 cairo_clip_extents (cairo_t *cr,
2765 double *x1, double *y1,
2766 double *x2, double *y2)
2768 CAIRO_TRACE_BEGIN (__func__);
2769 cairo_status_t status;
2780 if (unlikely (cr->status)) {
2781 CAIRO_TRACE_END (__func__);
2785 status = cr->backend->clip_extents (cr, x1, y1, x2, y2);
2786 if (unlikely (status))
2787 _cairo_set_error (cr, status);
2789 CAIRO_TRACE_END (__func__);
2794 * @cr: a cairo context
2795 * @x: X coordinate of the point to test
2796 * @y: Y coordinate of the point to test
2798 * Tests whether the given point is inside the area that would be
2799 * visible through the current clip, i.e. the area that would be filled by
2800 * a cairo_paint() operation.
2802 * See cairo_clip(), and cairo_clip_preserve().
2804 * Return value: A non-zero value if the point is inside, or zero if
2810 cairo_in_clip (cairo_t *cr, double x, double y)
2812 cairo_status_t status;
2813 cairo_bool_t inside = FALSE;
2815 if (unlikely (cr->status))
2818 status = cr->backend->in_clip (cr, x, y, &inside);
2819 if (unlikely (status))
2820 _cairo_set_error (cr, status);
2826 * cairo_copy_clip_rectangle_list:
2827 * @cr: a cairo context
2829 * Gets the current clip region as a list of rectangles in user coordinates.
2830 * Never returns %NULL.
2832 * The status in the list may be %CAIRO_STATUS_CLIP_NOT_REPRESENTABLE to
2833 * indicate that the clip region cannot be represented as a list of
2834 * user-space rectangles. The status may have other values to indicate
2837 * Returns: the current clip region as a list of rectangles in user coordinates,
2838 * which should be destroyed using cairo_rectangle_list_destroy().
2842 cairo_rectangle_list_t *
2843 cairo_copy_clip_rectangle_list (cairo_t *cr)
2845 if (unlikely (cr->status))
2846 return _cairo_rectangle_list_create_in_error (cr->status);
2848 return cr->backend->clip_copy_rectangle_list (cr);
2852 * cairo_select_font_face:
2854 * @family: a font family name, encoded in UTF-8
2855 * @slant: the slant for the font
2856 * @weight: the weight for the font
2858 * Note: The cairo_select_font_face() function call is part of what
2859 * the cairo designers call the "toy" text API. It is convenient for
2860 * short demos and simple programs, but it is not expected to be
2861 * adequate for serious text-using applications.
2863 * Selects a family and style of font from a simplified description as
2864 * a family name, slant and weight. Cairo provides no operation to
2865 * list available family names on the system (this is a "toy",
2866 * remember), but the standard CSS2 generic family names, ("serif",
2867 * "sans-serif", "cursive", "fantasy", "monospace"), are likely to
2870 * If @family starts with the string "@cairo:", or if no native font
2871 * backends are compiled in, cairo will use an internal font family.
2872 * The internal font family recognizes many modifiers in the @family
2873 * string, most notably, it recognizes the string "monospace". That is,
2874 * the family name "@cairo:monospace" will use the monospace version of
2875 * the internal font family.
2877 * For "real" font selection, see the font-backend-specific
2878 * font_face_create functions for the font backend you are using. (For
2879 * example, if you are using the freetype-based cairo-ft font backend,
2880 * see cairo_ft_font_face_create_for_ft_face() or
2881 * cairo_ft_font_face_create_for_pattern().) The resulting font face
2882 * could then be used with cairo_scaled_font_create() and
2883 * cairo_set_scaled_font().
2885 * Similarly, when using the "real" font support, you can call
2886 * directly into the underlying font system, (such as fontconfig or
2887 * freetype), for operations such as listing available fonts, etc.
2889 * It is expected that most applications will need to use a more
2890 * comprehensive font handling and text layout library, (for example,
2891 * pango), in conjunction with cairo.
2893 * If text is drawn without a call to cairo_select_font_face(), (nor
2894 * cairo_set_font_face() nor cairo_set_scaled_font()), the default
2895 * family is platform-specific, but is essentially "sans-serif".
2896 * Default slant is %CAIRO_FONT_SLANT_NORMAL, and default weight is
2897 * %CAIRO_FONT_WEIGHT_NORMAL.
2899 * This function is equivalent to a call to cairo_toy_font_face_create()
2900 * followed by cairo_set_font_face().
2905 cairo_select_font_face (cairo_t *cr,
2907 cairo_font_slant_t slant,
2908 cairo_font_weight_t weight)
2910 cairo_font_face_t *font_face;
2911 cairo_status_t status;
2913 if (unlikely (cr->status))
2916 font_face = cairo_toy_font_face_create (family, slant, weight);
2917 if (unlikely (font_face->status)) {
2918 _cairo_set_error (cr, font_face->status);
2922 status = cr->backend->set_font_face (cr, font_face);
2923 cairo_font_face_destroy (font_face);
2925 if (unlikely (status))
2926 _cairo_set_error (cr, status);
2930 * cairo_font_extents:
2932 * @extents: a #cairo_font_extents_t object into which the results
2935 * Gets the font extents for the currently selected font.
2940 cairo_font_extents (cairo_t *cr,
2941 cairo_font_extents_t *extents)
2943 cairo_status_t status;
2945 extents->ascent = 0.0;
2946 extents->descent = 0.0;
2947 extents->height = 0.0;
2948 extents->max_x_advance = 0.0;
2949 extents->max_y_advance = 0.0;
2951 if (unlikely (cr->status))
2954 status = cr->backend->font_extents (cr, extents);
2955 if (unlikely (status))
2956 _cairo_set_error (cr, status);
2960 * cairo_set_font_face:
2962 * @font_face: a #cairo_font_face_t, or %NULL to restore to the default font
2964 * Replaces the current #cairo_font_face_t object in the #cairo_t with
2965 * @font_face. The replaced font face in the #cairo_t will be
2966 * destroyed if there are no other references to it.
2971 cairo_set_font_face (cairo_t *cr,
2972 cairo_font_face_t *font_face)
2974 cairo_status_t status;
2976 if (unlikely (cr->status))
2979 status = cr->backend->set_font_face (cr, font_face);
2980 if (unlikely (status))
2981 _cairo_set_error (cr, status);
2985 * cairo_get_font_face:
2988 * Gets the current font face for a #cairo_t.
2990 * Return value: the current font face. This object is owned by
2991 * cairo. To keep a reference to it, you must call
2992 * cairo_font_face_reference().
2994 * This function never returns %NULL. If memory cannot be allocated, a
2995 * special "nil" #cairo_font_face_t object will be returned on which
2996 * cairo_font_face_status() returns %CAIRO_STATUS_NO_MEMORY. Using
2997 * this nil object will cause its error state to propagate to other
2998 * objects it is passed to, (for example, calling
2999 * cairo_set_font_face() with a nil font will trigger an error that
3000 * will shutdown the #cairo_t object).
3005 cairo_get_font_face (cairo_t *cr)
3007 if (unlikely (cr->status))
3008 return (cairo_font_face_t*) &_cairo_font_face_nil;
3010 return cr->backend->get_font_face (cr);
3014 * cairo_set_font_size:
3016 * @size: the new font size, in user space units
3018 * Sets the current font matrix to a scale by a factor of @size, replacing
3019 * any font matrix previously set with cairo_set_font_size() or
3020 * cairo_set_font_matrix(). This results in a font size of @size user space
3021 * units. (More precisely, this matrix will result in the font's
3022 * em-square being a @size by @size square in user space.)
3024 * If text is drawn without a call to cairo_set_font_size(), (nor
3025 * cairo_set_font_matrix() nor cairo_set_scaled_font()), the default
3026 * font size is 10.0.
3031 cairo_set_font_size (cairo_t *cr, double size)
3033 cairo_status_t status;
3035 if (unlikely (cr->status))
3038 status = cr->backend->set_font_size (cr, size);
3039 if (unlikely (status))
3040 _cairo_set_error (cr, status);
3042 slim_hidden_def (cairo_set_font_size);
3045 * cairo_set_font_matrix:
3047 * @matrix: a #cairo_matrix_t describing a transform to be applied to
3050 * Sets the current font matrix to @matrix. The font matrix gives a
3051 * transformation from the design space of the font (in this space,
3052 * the em-square is 1 unit by 1 unit) to user space. Normally, a
3053 * simple scale is used (see cairo_set_font_size()), but a more
3054 * complex font matrix can be used to shear the font
3055 * or stretch it unequally along the two axes
3060 cairo_set_font_matrix (cairo_t *cr,
3061 const cairo_matrix_t *matrix)
3063 cairo_status_t status;
3065 if (unlikely (cr->status))
3068 status = cr->backend->set_font_matrix (cr, matrix);
3069 if (unlikely (status))
3070 _cairo_set_error (cr, status);
3072 slim_hidden_def (cairo_set_font_matrix);
3075 * cairo_get_font_matrix:
3077 * @matrix: return value for the matrix
3079 * Stores the current font matrix into @matrix. See
3080 * cairo_set_font_matrix().
3085 cairo_get_font_matrix (cairo_t *cr, cairo_matrix_t *matrix)
3087 if (unlikely (cr->status)) {
3088 cairo_matrix_init_identity (matrix);
3092 cr->backend->get_font_matrix (cr, matrix);
3096 * cairo_set_font_options:
3098 * @options: font options to use
3100 * Sets a set of custom font rendering options for the #cairo_t.
3101 * Rendering options are derived by merging these options with the
3102 * options derived from underlying surface; if the value in @options
3103 * has a default value (like %CAIRO_ANTIALIAS_DEFAULT), then the value
3104 * from the surface is used.
3109 cairo_set_font_options (cairo_t *cr,
3110 const cairo_font_options_t *options)
3112 cairo_status_t status;
3114 if (unlikely (cr->status))
3117 status = cairo_font_options_status ((cairo_font_options_t *) options);
3118 if (unlikely (status)) {
3119 _cairo_set_error (cr, status);
3123 status = cr->backend->set_font_options (cr, options);
3124 if (unlikely (status))
3125 _cairo_set_error (cr, status);
3127 slim_hidden_def (cairo_set_font_options);
3130 * cairo_get_font_options:
3132 * @options: a #cairo_font_options_t object into which to store
3133 * the retrieved options. All existing values are overwritten
3135 * Retrieves font rendering options set via #cairo_set_font_options.
3136 * Note that the returned options do not include any options derived
3137 * from the underlying surface; they are literally the options
3138 * passed to cairo_set_font_options().
3143 cairo_get_font_options (cairo_t *cr,
3144 cairo_font_options_t *options)
3146 /* check that we aren't trying to overwrite the nil object */
3147 if (cairo_font_options_status (options))
3150 if (unlikely (cr->status)) {
3151 _cairo_font_options_init_default (options);
3155 cr->backend->get_font_options (cr, options);
3159 * cairo_set_scaled_font:
3161 * @scaled_font: a #cairo_scaled_font_t
3163 * Replaces the current font face, font matrix, and font options in
3164 * the #cairo_t with those of the #cairo_scaled_font_t. Except for
3165 * some translation, the current CTM of the #cairo_t should be the
3166 * same as that of the #cairo_scaled_font_t, which can be accessed
3167 * using cairo_scaled_font_get_ctm().
3172 cairo_set_scaled_font (cairo_t *cr,
3173 const cairo_scaled_font_t *scaled_font)
3175 cairo_status_t status;
3177 if (unlikely (cr->status))
3180 if ((scaled_font == NULL)) {
3181 _cairo_set_error (cr, _cairo_error (CAIRO_STATUS_NULL_POINTER));
3185 status = scaled_font->status;
3186 if (unlikely (status)) {
3187 _cairo_set_error (cr, status);
3191 status = cr->backend->set_scaled_font (cr, (cairo_scaled_font_t *) scaled_font);
3192 if (unlikely (status))
3193 _cairo_set_error (cr, status);
3197 * cairo_get_scaled_font:
3200 * Gets the current scaled font for a #cairo_t.
3202 * Return value: the current scaled font. This object is owned by
3203 * cairo. To keep a reference to it, you must call
3204 * cairo_scaled_font_reference().
3206 * This function never returns %NULL. If memory cannot be allocated, a
3207 * special "nil" #cairo_scaled_font_t object will be returned on which
3208 * cairo_scaled_font_status() returns %CAIRO_STATUS_NO_MEMORY. Using
3209 * this nil object will cause its error state to propagate to other
3210 * objects it is passed to, (for example, calling
3211 * cairo_set_scaled_font() with a nil font will trigger an error that
3212 * will shutdown the #cairo_t object).
3216 cairo_scaled_font_t *
3217 cairo_get_scaled_font (cairo_t *cr)
3219 if (unlikely (cr->status))
3220 return _cairo_scaled_font_create_in_error (cr->status);
3222 return cr->backend->get_scaled_font (cr);
3224 slim_hidden_def (cairo_get_scaled_font);
3227 * cairo_text_extents:
3229 * @utf8: a NUL-terminated string of text encoded in UTF-8, or %NULL
3230 * @extents: a #cairo_text_extents_t object into which the results
3233 * Gets the extents for a string of text. The extents describe a
3234 * user-space rectangle that encloses the "inked" portion of the text,
3235 * (as it would be drawn by cairo_show_text()). Additionally, the
3236 * x_advance and y_advance values indicate the amount by which the
3237 * current point would be advanced by cairo_show_text().
3239 * Note that whitespace characters do not directly contribute to the
3240 * size of the rectangle (extents.width and extents.height). They do
3241 * contribute indirectly by changing the position of non-whitespace
3242 * characters. In particular, trailing whitespace characters are
3243 * likely to not affect the size of the rectangle, though they will
3244 * affect the x_advance and y_advance values.
3249 cairo_text_extents (cairo_t *cr,
3251 cairo_text_extents_t *extents)
3253 cairo_status_t status;
3254 cairo_scaled_font_t *scaled_font;
3255 cairo_glyph_t *glyphs = NULL;
3259 extents->x_bearing = 0.0;
3260 extents->y_bearing = 0.0;
3261 extents->width = 0.0;
3262 extents->height = 0.0;
3263 extents->x_advance = 0.0;
3264 extents->y_advance = 0.0;
3266 if (unlikely (cr->status))
3272 scaled_font = cairo_get_scaled_font (cr);
3273 if (unlikely (scaled_font->status)) {
3274 _cairo_set_error (cr, scaled_font->status);
3278 cairo_get_current_point (cr, &x, &y);
3279 status = cairo_scaled_font_text_to_glyphs (scaled_font,
3282 &glyphs, &num_glyphs,
3285 if (likely (status == CAIRO_STATUS_SUCCESS)) {
3286 status = cr->backend->glyph_extents (cr,
3290 cairo_glyph_free (glyphs);
3292 if (unlikely (status))
3293 _cairo_set_error (cr, status);
3297 * cairo_glyph_extents:
3299 * @glyphs: an array of #cairo_glyph_t objects
3300 * @num_glyphs: the number of elements in @glyphs
3301 * @extents: a #cairo_text_extents_t object into which the results
3304 * Gets the extents for an array of glyphs. The extents describe a
3305 * user-space rectangle that encloses the "inked" portion of the
3306 * glyphs, (as they would be drawn by cairo_show_glyphs()).
3307 * Additionally, the x_advance and y_advance values indicate the
3308 * amount by which the current point would be advanced by
3309 * cairo_show_glyphs().
3311 * Note that whitespace glyphs do not contribute to the size of the
3312 * rectangle (extents.width and extents.height).
3317 cairo_glyph_extents (cairo_t *cr,
3318 const cairo_glyph_t *glyphs,
3320 cairo_text_extents_t *extents)
3322 cairo_status_t status;
3324 extents->x_bearing = 0.0;
3325 extents->y_bearing = 0.0;
3326 extents->width = 0.0;
3327 extents->height = 0.0;
3328 extents->x_advance = 0.0;
3329 extents->y_advance = 0.0;
3331 if (unlikely (cr->status))
3334 if (num_glyphs == 0)
3337 if (unlikely (num_glyphs < 0)) {
3338 _cairo_set_error (cr, CAIRO_STATUS_NEGATIVE_COUNT);
3342 if (unlikely (glyphs == NULL)) {
3343 _cairo_set_error (cr, CAIRO_STATUS_NULL_POINTER);
3347 status = cr->backend->glyph_extents (cr, glyphs, num_glyphs, extents);
3348 if (unlikely (status))
3349 _cairo_set_error (cr, status);
3354 * @cr: a cairo context
3355 * @utf8: a NUL-terminated string of text encoded in UTF-8, or %NULL
3357 * A drawing operator that generates the shape from a string of UTF-8
3358 * characters, rendered according to the current font_face, font_size
3359 * (font_matrix), and font_options.
3361 * This function first computes a set of glyphs for the string of
3362 * text. The first glyph is placed so that its origin is at the
3363 * current point. The origin of each subsequent glyph is offset from
3364 * that of the previous glyph by the advance values of the previous
3367 * After this call the current point is moved to the origin of where
3368 * the next glyph would be placed in this same progression. That is,
3369 * the current point will be at the origin of the final glyph offset
3370 * by its advance values. This allows for easy display of a single
3371 * logical string with multiple calls to cairo_show_text().
3373 * Note: The cairo_show_text() function call is part of what the cairo
3374 * designers call the "toy" text API. It is convenient for short demos
3375 * and simple programs, but it is not expected to be adequate for
3376 * serious text-using applications. See cairo_show_glyphs() for the
3377 * "real" text display API in cairo.
3382 cairo_show_text (cairo_t *cr, const char *utf8)
3384 CAIRO_TRACE_BEGIN (__func__);
3385 cairo_text_extents_t extents;
3386 cairo_status_t status;
3387 cairo_glyph_t *glyphs, *last_glyph;
3388 cairo_text_cluster_t *clusters;
3389 int utf8_len, num_glyphs, num_clusters;
3390 cairo_text_cluster_flags_t cluster_flags;
3392 cairo_bool_t has_show_text_glyphs;
3393 cairo_glyph_t stack_glyphs[CAIRO_STACK_ARRAY_LENGTH (cairo_glyph_t)];
3394 cairo_text_cluster_t stack_clusters[CAIRO_STACK_ARRAY_LENGTH (cairo_text_cluster_t)];
3395 cairo_scaled_font_t *scaled_font;
3396 cairo_glyph_text_info_t info, *i;
3398 if (unlikely (cr->status)) {
3399 CAIRO_TRACE_END (__func__);
3404 CAIRO_TRACE_END (__func__);
3408 scaled_font = cairo_get_scaled_font (cr);
3409 if (unlikely (scaled_font->status)) {
3410 _cairo_set_error (cr, scaled_font->status);
3411 CAIRO_TRACE_END (__func__);
3415 utf8_len = strlen (utf8);
3417 has_show_text_glyphs =
3418 cairo_surface_has_show_text_glyphs (cairo_get_target (cr));
3420 glyphs = stack_glyphs;
3421 num_glyphs = ARRAY_LENGTH (stack_glyphs);
3423 if (has_show_text_glyphs) {
3424 clusters = stack_clusters;
3425 num_clusters = ARRAY_LENGTH (stack_clusters);
3431 cairo_get_current_point (cr, &x, &y);
3432 status = cairo_scaled_font_text_to_glyphs (scaled_font,
3435 &glyphs, &num_glyphs,
3436 has_show_text_glyphs ? &clusters : NULL, &num_clusters,
3438 if (unlikely (status))
3441 if (num_glyphs == 0) {
3442 CAIRO_TRACE_END (__func__);
3447 if (has_show_text_glyphs) {
3449 info.utf8_len = utf8_len;
3450 info.clusters = clusters;
3451 info.num_clusters = num_clusters;
3452 info.cluster_flags = cluster_flags;
3456 status = cr->backend->glyphs (cr, glyphs, num_glyphs, i);
3457 if (unlikely (status))
3460 last_glyph = &glyphs[num_glyphs - 1];
3461 status = cr->backend->glyph_extents (cr, last_glyph, 1, &extents);
3462 if (unlikely (status))
3465 x = last_glyph->x + extents.x_advance;
3466 y = last_glyph->y + extents.y_advance;
3467 cr->backend->move_to (cr, x, y);
3470 if (glyphs != stack_glyphs)
3471 cairo_glyph_free (glyphs);
3472 if (clusters != stack_clusters)
3473 cairo_text_cluster_free (clusters);
3475 if (unlikely (status))
3476 _cairo_set_error (cr, status);
3478 CAIRO_TRACE_END (__func__);
3482 * cairo_show_glyphs:
3483 * @cr: a cairo context
3484 * @glyphs: array of glyphs to show
3485 * @num_glyphs: number of glyphs to show
3487 * A drawing operator that generates the shape from an array of glyphs,
3488 * rendered according to the current font face, font size
3489 * (font matrix), and font options.
3494 cairo_show_glyphs (cairo_t *cr, const cairo_glyph_t *glyphs, int num_glyphs)
3496 CAIRO_TRACE_BEGIN (__func__);
3497 cairo_status_t status;
3499 if (unlikely (cr->status)) {
3500 CAIRO_TRACE_END (__func__);
3504 if (num_glyphs == 0) {
3505 CAIRO_TRACE_END (__func__);
3509 if (num_glyphs < 0) {
3510 _cairo_set_error (cr, CAIRO_STATUS_NEGATIVE_COUNT);
3511 CAIRO_TRACE_END (__func__);
3515 if (glyphs == NULL) {
3516 _cairo_set_error (cr, CAIRO_STATUS_NULL_POINTER);
3517 CAIRO_TRACE_END (__func__);
3521 status = cr->backend->glyphs (cr, glyphs, num_glyphs, NULL);
3522 if (unlikely (status))
3523 _cairo_set_error (cr, status);
3525 CAIRO_TRACE_END (__func__);
3529 * cairo_show_text_glyphs:
3530 * @cr: a cairo context
3531 * @utf8: a string of text encoded in UTF-8
3532 * @utf8_len: length of @utf8 in bytes, or -1 if it is NUL-terminated
3533 * @glyphs: array of glyphs to show
3534 * @num_glyphs: number of glyphs to show
3535 * @clusters: array of cluster mapping information
3536 * @num_clusters: number of clusters in the mapping
3537 * @cluster_flags: cluster mapping flags
3539 * This operation has rendering effects similar to cairo_show_glyphs()
3540 * but, if the target surface supports it, uses the provided text and
3541 * cluster mapping to embed the text for the glyphs shown in the output.
3542 * If the target does not support the extended attributes, this function
3543 * acts like the basic cairo_show_glyphs() as if it had been passed
3544 * @glyphs and @num_glyphs.
3546 * The mapping between @utf8 and @glyphs is provided by an array of
3547 * <firstterm>clusters</firstterm>. Each cluster covers a number of
3548 * text bytes and glyphs, and neighboring clusters cover neighboring
3549 * areas of @utf8 and @glyphs. The clusters should collectively cover @utf8
3550 * and @glyphs in entirety.
3552 * The first cluster always covers bytes from the beginning of @utf8.
3553 * If @cluster_flags do not have the %CAIRO_TEXT_CLUSTER_FLAG_BACKWARD
3554 * set, the first cluster also covers the beginning
3555 * of @glyphs, otherwise it covers the end of the @glyphs array and
3556 * following clusters move backward.
3558 * See #cairo_text_cluster_t for constraints on valid clusters.
3563 cairo_show_text_glyphs (cairo_t *cr,
3566 const cairo_glyph_t *glyphs,
3568 const cairo_text_cluster_t *clusters,
3570 cairo_text_cluster_flags_t cluster_flags)
3572 CAIRO_TRACE_BEGIN (__func__);
3573 cairo_status_t status;
3575 if (unlikely (cr->status)) {
3576 CAIRO_TRACE_END (__func__);
3580 /* A slew of sanity checks */
3582 /* Special case for NULL and -1 */
3583 if (utf8 == NULL && utf8_len == -1)
3586 /* No NULLs for non-zeros */
3587 if ((num_glyphs && glyphs == NULL) ||
3588 (utf8_len && utf8 == NULL) ||
3589 (num_clusters && clusters == NULL)) {
3590 _cairo_set_error (cr, CAIRO_STATUS_NULL_POINTER);
3591 CAIRO_TRACE_END (__func__);
3595 /* A -1 for utf8_len means NUL-terminated */
3597 utf8_len = strlen (utf8);
3599 /* Apart from that, no negatives */
3600 if (num_glyphs < 0 || utf8_len < 0 || num_clusters < 0) {
3601 _cairo_set_error (cr, CAIRO_STATUS_NEGATIVE_COUNT);
3602 CAIRO_TRACE_END (__func__);
3606 if (num_glyphs == 0 && utf8_len == 0) {
3607 CAIRO_TRACE_END (__func__);
3612 /* Make sure clusters cover the entire glyphs and utf8 arrays,
3613 * and that cluster boundaries are UTF-8 boundaries. */
3614 status = _cairo_validate_text_clusters (utf8, utf8_len,
3616 clusters, num_clusters, cluster_flags);
3617 if (status == CAIRO_STATUS_INVALID_CLUSTERS) {
3618 /* Either got invalid UTF-8 text, or cluster mapping is bad.
3619 * Differentiate those. */
3621 cairo_status_t status2;
3623 status2 = _cairo_utf8_to_ucs4 (utf8, utf8_len, NULL, NULL);
3627 cairo_glyph_text_info_t info;
3630 info.utf8_len = utf8_len;
3631 info.clusters = clusters;
3632 info.num_clusters = num_clusters;
3633 info.cluster_flags = cluster_flags;
3635 status = cr->backend->glyphs (cr, glyphs, num_glyphs, &info);
3638 status = cr->backend->glyphs (cr, glyphs, num_glyphs, NULL);
3640 if (unlikely (status))
3641 _cairo_set_error (cr, status);
3643 CAIRO_TRACE_END (__func__);
3648 * @cr: a cairo context
3649 * @utf8: a NUL-terminated string of text encoded in UTF-8, or %NULL
3651 * Adds closed paths for text to the current path. The generated
3652 * path if filled, achieves an effect similar to that of
3653 * cairo_show_text().
3655 * Text conversion and positioning is done similar to cairo_show_text().
3657 * Like cairo_show_text(), After this call the current point is
3658 * moved to the origin of where the next glyph would be placed in
3659 * this same progression. That is, the current point will be at
3660 * the origin of the final glyph offset by its advance values.
3661 * This allows for chaining multiple calls to to cairo_text_path()
3662 * without having to set current point in between.
3664 * Note: The cairo_text_path() function call is part of what the cairo
3665 * designers call the "toy" text API. It is convenient for short demos
3666 * and simple programs, but it is not expected to be adequate for
3667 * serious text-using applications. See cairo_glyph_path() for the
3668 * "real" text path API in cairo.
3673 cairo_text_path (cairo_t *cr, const char *utf8)
3675 CAIRO_TRACE_BEGIN (__func__);
3676 cairo_status_t status;
3677 cairo_text_extents_t extents;
3678 cairo_glyph_t stack_glyphs[CAIRO_STACK_ARRAY_LENGTH (cairo_glyph_t)];
3679 cairo_glyph_t *glyphs, *last_glyph;
3680 cairo_scaled_font_t *scaled_font;
3684 if (unlikely (cr->status)) {
3685 CAIRO_TRACE_END (__func__);
3690 CAIRO_TRACE_END (__func__);
3695 glyphs = stack_glyphs;
3696 num_glyphs = ARRAY_LENGTH (stack_glyphs);
3698 scaled_font = cairo_get_scaled_font (cr);
3699 if (unlikely (scaled_font->status)) {
3700 _cairo_set_error (cr, scaled_font->status);
3701 CAIRO_TRACE_END (__func__);
3705 cairo_get_current_point (cr, &x, &y);
3706 status = cairo_scaled_font_text_to_glyphs (scaled_font,
3709 &glyphs, &num_glyphs,
3712 if (num_glyphs == 0) {
3713 CAIRO_TRACE_END (__func__);
3717 status = cr->backend->glyph_path (cr, glyphs, num_glyphs);
3719 if (unlikely (status))
3722 last_glyph = &glyphs[num_glyphs - 1];
3723 status = cr->backend->glyph_extents (cr, last_glyph, 1, &extents);
3725 if (unlikely (status))
3728 x = last_glyph->x + extents.x_advance;
3729 y = last_glyph->y + extents.y_advance;
3730 cr->backend->move_to (cr, x, y);
3733 if (glyphs != stack_glyphs)
3734 cairo_glyph_free (glyphs);
3736 if (unlikely (status))
3737 _cairo_set_error (cr, status);
3739 CAIRO_TRACE_END (__func__);
3744 * @cr: a cairo context
3745 * @glyphs: array of glyphs to show
3746 * @num_glyphs: number of glyphs to show
3748 * Adds closed paths for the glyphs to the current path. The generated
3749 * path if filled, achieves an effect similar to that of
3750 * cairo_show_glyphs().
3755 cairo_glyph_path (cairo_t *cr, const cairo_glyph_t *glyphs, int num_glyphs)
3757 CAIRO_TRACE_BEGIN (__func__);
3758 cairo_status_t status;
3760 if (unlikely (cr->status)) {
3761 CAIRO_TRACE_END (__func__);
3765 if (num_glyphs == 0) {
3766 CAIRO_TRACE_END (__func__);
3770 if (unlikely (num_glyphs < 0)) {
3771 _cairo_set_error (cr, CAIRO_STATUS_NEGATIVE_COUNT);
3772 CAIRO_TRACE_END (__func__);
3776 if (unlikely (glyphs == NULL)) {
3777 _cairo_set_error (cr, CAIRO_STATUS_NULL_POINTER);
3778 CAIRO_TRACE_END (__func__);
3782 status = cr->backend->glyph_path (cr, glyphs, num_glyphs);
3783 if (unlikely (status))
3784 _cairo_set_error (cr, status);
3786 CAIRO_TRACE_END (__func__);
3790 * cairo_get_operator:
3791 * @cr: a cairo context
3793 * Gets the current compositing operator for a cairo context.
3795 * Return value: the current compositing operator.
3800 cairo_get_operator (cairo_t *cr)
3802 if (unlikely (cr->status))
3803 return CAIRO_GSTATE_OPERATOR_DEFAULT;
3805 return cr->backend->get_operator (cr);
3810 * cairo_get_opacity:
3811 * @cr: a cairo context
3813 * Gets the current compositing opacity for a cairo context.
3815 * Return value: the current compositing opacity.
3820 cairo_get_opacity (cairo_t *cr)
3822 if (unlikely (cr->status))
3825 return cr->backend->get_opacity (cr);
3830 * cairo_get_tolerance:
3831 * @cr: a cairo context
3833 * Gets the current tolerance value, as set by cairo_set_tolerance().
3835 * Return value: the current tolerance value.
3840 cairo_get_tolerance (cairo_t *cr)
3842 if (unlikely (cr->status))
3843 return CAIRO_GSTATE_TOLERANCE_DEFAULT;
3845 return cr->backend->get_tolerance (cr);
3847 slim_hidden_def (cairo_get_tolerance);
3850 * cairo_get_antialias:
3851 * @cr: a cairo context
3853 * Gets the current shape antialiasing mode, as set by
3854 * cairo_set_antialias().
3856 * Return value: the current shape antialiasing mode.
3861 cairo_get_antialias (cairo_t *cr)
3863 if (unlikely (cr->status))
3864 return CAIRO_ANTIALIAS_DEFAULT;
3866 return cr->backend->get_antialias (cr);
3870 * cairo_has_current_point:
3871 * @cr: a cairo context
3873 * Returns whether a current point is defined on the current path.
3874 * See cairo_get_current_point() for details on the current point.
3876 * Return value: whether a current point is defined.
3881 cairo_has_current_point (cairo_t *cr)
3883 if (unlikely (cr->status))
3886 return cr->backend->has_current_point (cr);
3890 * cairo_get_current_point:
3891 * @cr: a cairo context
3892 * @x: return value for X coordinate of the current point
3893 * @y: return value for Y coordinate of the current point
3895 * Gets the current point of the current path, which is
3896 * conceptually the final point reached by the path so far.
3898 * The current point is returned in the user-space coordinate
3899 * system. If there is no defined current point or if @cr is in an
3900 * error status, @x and @y will both be set to 0.0. It is possible to
3901 * check this in advance with cairo_has_current_point().
3903 * Most path construction functions alter the current point. See the
3904 * following for details on how they affect the current point:
3905 * cairo_new_path(), cairo_new_sub_path(),
3906 * cairo_append_path(), cairo_close_path(),
3907 * cairo_move_to(), cairo_line_to(), cairo_curve_to(),
3908 * cairo_rel_move_to(), cairo_rel_line_to(), cairo_rel_curve_to(),
3909 * cairo_arc(), cairo_arc_negative(), cairo_rectangle(),
3910 * cairo_text_path(), cairo_glyph_path(), cairo_stroke_to_path().
3912 * Some functions use and alter the current point but do not
3913 * otherwise change current path:
3914 * cairo_show_text().
3916 * Some functions unset the current path and as a result, current point:
3917 * cairo_fill(), cairo_stroke().
3922 cairo_get_current_point (cairo_t *cr, double *x_ret, double *y_ret)
3927 if (cr->status == CAIRO_STATUS_SUCCESS &&
3928 cr->backend->has_current_point (cr))
3930 cr->backend->get_current_point (cr, &x, &y);
3938 slim_hidden_def(cairo_get_current_point);
3941 * cairo_get_fill_rule:
3942 * @cr: a cairo context
3944 * Gets the current fill rule, as set by cairo_set_fill_rule().
3946 * Return value: the current fill rule.
3951 cairo_get_fill_rule (cairo_t *cr)
3953 if (unlikely (cr->status))
3954 return CAIRO_GSTATE_FILL_RULE_DEFAULT;
3956 return cr->backend->get_fill_rule (cr);
3960 * cairo_get_line_width:
3961 * @cr: a cairo context
3963 * This function returns the current line width value exactly as set by
3964 * cairo_set_line_width(). Note that the value is unchanged even if
3965 * the CTM has changed between the calls to cairo_set_line_width() and
3966 * cairo_get_line_width().
3968 * Return value: the current line width.
3973 cairo_get_line_width (cairo_t *cr)
3975 if (unlikely (cr->status))
3976 return CAIRO_GSTATE_LINE_WIDTH_DEFAULT;
3978 return cr->backend->get_line_width (cr);
3980 slim_hidden_def (cairo_get_line_width);
3983 * cairo_get_line_cap:
3984 * @cr: a cairo context
3986 * Gets the current line cap style, as set by cairo_set_line_cap().
3988 * Return value: the current line cap style.
3993 cairo_get_line_cap (cairo_t *cr)
3995 if (unlikely (cr->status))
3996 return CAIRO_GSTATE_LINE_CAP_DEFAULT;
3998 return cr->backend->get_line_cap (cr);
4002 * cairo_get_line_join:
4003 * @cr: a cairo context
4005 * Gets the current line join style, as set by cairo_set_line_join().
4007 * Return value: the current line join style.
4012 cairo_get_line_join (cairo_t *cr)
4014 if (unlikely (cr->status))
4015 return CAIRO_GSTATE_LINE_JOIN_DEFAULT;
4017 return cr->backend->get_line_join (cr);
4021 * cairo_get_miter_limit:
4022 * @cr: a cairo context
4024 * Gets the current miter limit, as set by cairo_set_miter_limit().
4026 * Return value: the current miter limit.
4031 cairo_get_miter_limit (cairo_t *cr)
4033 if (unlikely (cr->status))
4034 return CAIRO_GSTATE_MITER_LIMIT_DEFAULT;
4036 return cr->backend->get_miter_limit (cr);
4041 * @cr: a cairo context
4042 * @matrix: return value for the matrix
4044 * Stores the current transformation matrix (CTM) into @matrix.
4049 cairo_get_matrix (cairo_t *cr, cairo_matrix_t *matrix)
4051 if (unlikely (cr->status)) {
4052 cairo_matrix_init_identity (matrix);
4056 cr->backend->get_matrix (cr, matrix);
4058 slim_hidden_def (cairo_get_matrix);
4062 * @cr: a cairo context
4064 * Gets the target surface for the cairo context as passed to
4067 * This function will always return a valid pointer, but the result
4068 * can be a "nil" surface if @cr is already in an error state,
4069 * (ie. cairo_status() <literal>!=</literal> %CAIRO_STATUS_SUCCESS).
4070 * A nil surface is indicated by cairo_surface_status()
4071 * <literal>!=</literal> %CAIRO_STATUS_SUCCESS.
4073 * Return value: the target surface. This object is owned by cairo. To
4074 * keep a reference to it, you must call cairo_surface_reference().
4079 cairo_get_target (cairo_t *cr)
4081 if (unlikely (cr->status))
4082 return _cairo_surface_create_in_error (cr->status);
4084 return cr->backend->get_original_target (cr);
4086 slim_hidden_def (cairo_get_target);
4089 * cairo_get_group_target:
4090 * @cr: a cairo context
4092 * Gets the current destination surface for the context. This is either
4093 * the original target surface as passed to cairo_create() or the target
4094 * surface for the current group as started by the most recent call to
4095 * cairo_push_group() or cairo_push_group_with_content().
4097 * This function will always return a valid pointer, but the result
4098 * can be a "nil" surface if @cr is already in an error state,
4099 * (ie. cairo_status() <literal>!=</literal> %CAIRO_STATUS_SUCCESS).
4100 * A nil surface is indicated by cairo_surface_status()
4101 * <literal>!=</literal> %CAIRO_STATUS_SUCCESS.
4103 * Return value: the target surface. This object is owned by cairo. To
4104 * keep a reference to it, you must call cairo_surface_reference().
4109 cairo_get_group_target (cairo_t *cr)
4111 if (unlikely (cr->status))
4112 return _cairo_surface_create_in_error (cr->status);
4114 return cr->backend->get_current_target (cr);
4119 * @cr: a cairo context
4121 * Creates a copy of the current path and returns it to the user as a
4122 * #cairo_path_t. See #cairo_path_data_t for hints on how to iterate
4123 * over the returned data structure.
4125 * This function will always return a valid pointer, but the result
4126 * will have no data (<literal>data==%NULL</literal> and
4127 * <literal>num_data==0</literal>), if either of the following
4131 * <listitem>If there is insufficient memory to copy the path. In this
4132 * case <literal>path->status</literal> will be set to
4133 * %CAIRO_STATUS_NO_MEMORY.</listitem>
4134 * <listitem>If @cr is already in an error state. In this case
4135 * <literal>path->status</literal> will contain the same status that
4136 * would be returned by cairo_status().</listitem>
4139 * Return value: the copy of the current path. The caller owns the
4140 * returned object and should call cairo_path_destroy() when finished
4146 cairo_copy_path (cairo_t *cr)
4148 if (unlikely (cr->status))
4149 return _cairo_path_create_in_error (cr->status);
4151 return cr->backend->copy_path (cr);
4155 * cairo_copy_path_flat:
4156 * @cr: a cairo context
4158 * Gets a flattened copy of the current path and returns it to the
4159 * user as a #cairo_path_t. See #cairo_path_data_t for hints on
4160 * how to iterate over the returned data structure.
4162 * This function is like cairo_copy_path() except that any curves
4163 * in the path will be approximated with piecewise-linear
4164 * approximations, (accurate to within the current tolerance
4165 * value). That is, the result is guaranteed to not have any elements
4166 * of type %CAIRO_PATH_CURVE_TO which will instead be replaced by a
4167 * series of %CAIRO_PATH_LINE_TO elements.
4169 * This function will always return a valid pointer, but the result
4170 * will have no data (<literal>data==%NULL</literal> and
4171 * <literal>num_data==0</literal>), if either of the following
4175 * <listitem>If there is insufficient memory to copy the path. In this
4176 * case <literal>path->status</literal> will be set to
4177 * %CAIRO_STATUS_NO_MEMORY.</listitem>
4178 * <listitem>If @cr is already in an error state. In this case
4179 * <literal>path->status</literal> will contain the same status that
4180 * would be returned by cairo_status().</listitem>
4183 * Return value: the copy of the current path. The caller owns the
4184 * returned object and should call cairo_path_destroy() when finished
4190 cairo_copy_path_flat (cairo_t *cr)
4192 if (unlikely (cr->status))
4193 return _cairo_path_create_in_error (cr->status);
4195 return cr->backend->copy_path_flat (cr);
4199 * cairo_append_path:
4200 * @cr: a cairo context
4201 * @path: path to be appended
4203 * Append the @path onto the current path. The @path may be either the
4204 * return value from one of cairo_copy_path() or
4205 * cairo_copy_path_flat() or it may be constructed manually. See
4206 * #cairo_path_t for details on how the path data structure should be
4207 * initialized, and note that <literal>path->status</literal> must be
4208 * initialized to %CAIRO_STATUS_SUCCESS.
4213 cairo_append_path (cairo_t *cr,
4214 const cairo_path_t *path)
4216 cairo_status_t status;
4218 if (unlikely (cr->status))
4221 if (unlikely (path == NULL)) {
4222 _cairo_set_error (cr, CAIRO_STATUS_NULL_POINTER);
4226 if (unlikely (path->status)) {
4227 if (path->status > CAIRO_STATUS_SUCCESS &&
4228 path->status <= CAIRO_STATUS_LAST_STATUS)
4229 _cairo_set_error (cr, path->status);
4231 _cairo_set_error (cr, CAIRO_STATUS_INVALID_STATUS);
4235 if (path->num_data == 0)
4238 if (unlikely (path->data == NULL)) {
4239 _cairo_set_error (cr, CAIRO_STATUS_NULL_POINTER);
4243 status = cr->backend->append_path (cr, path);
4244 if (unlikely (status))
4245 _cairo_set_error (cr, status);
4250 * @cr: a cairo context
4252 * Checks whether an error has previously occurred for this context.
4254 * Returns: the current status of this context, see #cairo_status_t
4259 cairo_status (cairo_t *cr)
4263 slim_hidden_def (cairo_status);
4266 cairo_set_shadow (cairo_t *cr, cairo_shadow_type_t shadow)
4268 cairo_status_t status;
4270 if (unlikely (cr->status))
4273 status = cr->backend->set_shadow (cr, shadow);
4274 if (unlikely (status))
4275 _cairo_set_error (cr, status);
4277 slim_hidden_def (cairo_set_shadow);
4280 cairo_set_shadow_offset (cairo_t *cr, double x_offset, double y_offset)
4282 cairo_status_t status;
4284 if (unlikely (cr->status))
4287 status = cr->backend->set_shadow_offset (cr, x_offset, y_offset);
4288 if (unlikely (status))
4289 _cairo_set_error (cr, status);
4291 slim_hidden_def (cairo_set_shadow_offset);
4294 cairo_set_shadow_rgb (cairo_t *cr, double red, double green, double blue)
4296 cairo_status_t status;
4298 if (unlikely (cr->status))
4301 status = cr->backend->set_shadow_rgba (cr, red, green, blue, 1.0);
4302 if (unlikely (status))
4303 _cairo_set_error (cr, status);
4305 slim_hidden_def (cairo_set_shadow_rgb);
4308 cairo_set_shadow_rgba (cairo_t *cr, double red, double green,
4309 double blue, double alpha)
4311 cairo_status_t status;
4313 if (unlikely (cr->status))
4316 status = cr->backend->set_shadow_rgba (cr, red, green, blue, alpha);
4317 if (unlikely (status))
4318 _cairo_set_error (cr, status);
4320 slim_hidden_def (cairo_set_shadow_rgba);
4323 cairo_set_shadow_blur (cairo_t *cr, double x_blur, double y_blur)
4325 cairo_status_t status;
4327 if (unlikely (cr->status))
4330 status = cr->backend->set_shadow_blur (cr, x_blur, y_blur);
4331 if (unlikely (status))
4332 _cairo_set_error (cr, status);
4334 slim_hidden_def (cairo_set_shadow_blur);
4337 cairo_set_draw_shadow_only (cairo_t *cr, cairo_bool_t draw_shadow_only)
4339 if (unlikely (cr->status))
4342 cr->backend->set_draw_shadow_only (cr, draw_shadow_only);
4344 slim_hidden_def (cairo_set_draw_shadow_only);
4347 cairo_shadow_enable_cache (cairo_t *cr, cairo_bool_t enable)
4349 if (unlikely (cr->status))
4352 cr->backend->shadow_enable_cache (cr, enable);
4354 slim_hidden_def (cairo_shadow_enable_cache);
4357 cairo_set_path_is_inset_shadow_with_spread (cairo_t *cr,
4358 cairo_bool_t is_spread_path)
4360 if (unlikely (cr->status))
4362 cr->backend->set_path_is_inset_shadow_with_spread (cr, is_spread_path);}
4363 slim_hidden_def (cairo_set_path_is_inset_shadow_with_spread);