tizen 2.3.1 release
[framework/graphics/cairo.git] / src / cairoint.h
1 /* cairo - a vector graphics library with display and print output
2  *
3  * Copyright © 2002 University of Southern California
4  * Copyright © 2005 Red Hat, Inc.
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it either under the terms of the GNU Lesser General Public
8  * License version 2.1 as published by the Free Software Foundation
9  * (the "LGPL") or, at your option, under the terms of the Mozilla
10  * Public License Version 1.1 (the "MPL"). If you do not alter this
11  * notice, a recipient may use your version of this file under either
12  * the MPL or the LGPL.
13  *
14  * You should have received a copy of the LGPL along with this library
15  * in the file COPYING-LGPL-2.1; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
17  * You should have received a copy of the MPL along with this library
18  * in the file COPYING-MPL-1.1
19  *
20  * The contents of this file are subject to the Mozilla Public License
21  * Version 1.1 (the "License"); you may not use this file except in
22  * compliance with the License. You may obtain a copy of the License at
23  * http://www.mozilla.org/MPL/
24  *
25  * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
26  * OF ANY KIND, either express or implied. See the LGPL or the MPL for
27  * the specific language governing rights and limitations.
28  *
29  * The Original Code is the cairo graphics library.
30  *
31  * The Initial Developer of the Original Code is University of Southern
32  * California.
33  *
34  * Contributor(s):
35  *      Carl D. Worth <cworth@cworth.org>
36  */
37
38 /*
39  * These definitions are solely for use by the implementation of cairo
40  * and constitute no kind of standard.  If you need any of these
41  * functions, please drop me a note.  Either the library needs new
42  * functionality, or there's a way to do what you need using the
43  * existing published interfaces. cworth@cworth.org
44  */
45
46 #ifndef _CAIROINT_H_
47 #define _CAIROINT_H_
48
49 #if HAVE_CONFIG_H
50 #include "config.h"
51 #endif
52
53 #ifdef _MSC_VER
54 #define cairo_public __declspec(dllexport)
55 #endif
56
57 #include <assert.h>
58 #include <stdlib.h>
59 #include <string.h>
60 #include <stdarg.h>
61 #include <stddef.h>
62
63 #ifdef _MSC_VER
64 #define _USE_MATH_DEFINES
65 #endif
66 #include <math.h>
67 #include <limits.h>
68 #include <stdio.h>
69
70 #include "cairo.h"
71 #include <pixman.h>
72
73 #include "cairo-compiler-private.h"
74 #include "cairo-error-private.h"
75
76 #if CAIRO_HAS_PDF_SURFACE    || \
77     CAIRO_HAS_PS_SURFACE     || \
78     CAIRO_HAS_SCRIPT_SURFACE || \
79     CAIRO_HAS_XML_SURFACE
80 #define CAIRO_HAS_DEFLATE_STREAM 1
81 #endif
82
83 #if CAIRO_HAS_PS_SURFACE  || \
84     CAIRO_HAS_PDF_SURFACE || \
85     CAIRO_HAS_SVG_SURFACE || \
86     CAIRO_HAS_WIN32_SURFACE
87 #define CAIRO_HAS_FONT_SUBSET 1
88 #endif
89
90 #if CAIRO_HAS_PS_SURFACE  || \
91     CAIRO_HAS_PDF_SURFACE || \
92     CAIRO_HAS_FONT_SUBSET
93 #define CAIRO_HAS_PDF_OPERATORS 1
94 #endif
95
96 CAIRO_BEGIN_DECLS
97
98 #if _WIN32 && !_WIN32_WCE /* Permissions on WinCE? No worries! */
99 cairo_private FILE *
100 _cairo_win32_tmpfile (void);
101 #define tmpfile() _cairo_win32_tmpfile()
102 #endif
103
104 #undef MIN
105 #define MIN(a, b) ((a) < (b) ? (a) : (b))
106
107 #undef MAX
108 #define MAX(a, b) ((a) > (b) ? (a) : (b))
109
110 #ifndef FALSE
111 #define FALSE 0
112 #endif
113
114 #ifndef TRUE
115 #define TRUE 1
116 #endif
117
118 #ifndef M_PI
119 #define M_PI 3.14159265358979323846
120 #endif
121
122 #ifndef M_SQRT2
123 #define M_SQRT2 1.41421356237309504880
124 #endif
125
126 #ifndef M_SQRT1_2
127 #define M_SQRT1_2 0.707106781186547524400844362104849039
128 #endif
129
130 #undef  ARRAY_LENGTH
131 #define ARRAY_LENGTH(__array) ((int) (sizeof (__array) / sizeof (__array[0])))
132
133 #undef STRINGIFY
134 #undef STRINGIFY_ARG
135 #define STRINGIFY(macro_or_string)    STRINGIFY_ARG (macro_or_string)
136 #define STRINGIFY_ARG(contents)       #contents
137
138 #if defined (__GNUC__)
139 #define cairo_container_of(ptr, type, member) ({ \
140     const __typeof__ (((type *) 0)->member) *mptr__ = (ptr); \
141     (type *) ((char *) mptr__ - offsetof (type, member)); \
142 })
143 #else
144 #define cairo_container_of(ptr, type, member) \
145     ((type *)((char *) (ptr) - (char *) &((type *)0)->member))
146 #endif
147
148
149 #define ASSERT_NOT_REACHED              \
150 do {                                    \
151     assert (!"reached");                \
152 } while (0)
153 #define COMPILE_TIME_ASSERT1(condition, line)           \
154     typedef int compile_time_assertion_at_line_##line##_failed [(condition)?1:-1]
155 #define COMPILE_TIME_ASSERT0(condition, line)   COMPILE_TIME_ASSERT1(condition, line)
156 #define COMPILE_TIME_ASSERT(condition)          COMPILE_TIME_ASSERT0(condition, __LINE__)
157
158 #define CAIRO_ALPHA_IS_CLEAR(alpha) ((alpha) <= ((double)0x00ff / (double)0xffff))
159 #define CAIRO_ALPHA_SHORT_IS_CLEAR(alpha) ((alpha) <= 0x00ff)
160
161 #define CAIRO_ALPHA_IS_OPAQUE(alpha) ((alpha) >= ((double)0xff00 / (double)0xffff))
162 #define CAIRO_ALPHA_SHORT_IS_OPAQUE(alpha) ((alpha) >= 0xff00)
163 #define CAIRO_ALPHA_IS_ZERO(alpha) ((alpha) <= 0.0)
164
165 #define CAIRO_COLOR_IS_CLEAR(color) CAIRO_ALPHA_SHORT_IS_CLEAR ((color)->alpha_short)
166 #define CAIRO_COLOR_IS_OPAQUE(color) CAIRO_ALPHA_SHORT_IS_OPAQUE ((color)->alpha_short)
167
168 /* Reverse the bits in a byte with 7 operations (no 64-bit):
169  * Devised by Sean Anderson, July 13, 2001.
170  * Source: http://graphics.stanford.edu/~seander/bithacks.html#ReverseByteWith32Bits
171  */
172 #define CAIRO_BITSWAP8(c) ((((c) * 0x0802LU & 0x22110LU) | ((c) * 0x8020LU & 0x88440LU)) * 0x10101LU >> 16)
173
174 /* Return the number of 1 bits in mask.
175  *
176  * GCC 3.4 supports a "population count" builtin, which on many targets is
177  * implemented with a single instruction. There is a fallback definition
178  * in libgcc in case a target does not have one, which should be just as
179  * good as the open-coded solution below, (which is "HACKMEM 169").
180  */
181 static inline int cairo_const
182 _cairo_popcount (uint32_t mask)
183 {
184 #if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)
185     return __builtin_popcount (mask);
186 #else
187     register int y;
188
189     y = (mask >> 1) &033333333333;
190     y = mask - y - ((y >>1) & 033333333333);
191     return (((y + (y >> 3)) & 030707070707) % 077);
192 #endif
193 }
194
195 static cairo_always_inline cairo_bool_t
196 _cairo_is_little_endian (void)
197 {
198     static const int i = 1;
199     return *((char *) &i) == 0x01;
200 }
201
202 #ifdef WORDS_BIGENDIAN
203 #define CAIRO_BITSWAP8_IF_LITTLE_ENDIAN(c) (c)
204 #else
205 #define CAIRO_BITSWAP8_IF_LITTLE_ENDIAN(c) CAIRO_BITSWAP8(c)
206 #endif
207
208 #ifdef WORDS_BIGENDIAN
209
210 #define cpu_to_be16(v) (v)
211 #define be16_to_cpu(v) (v)
212 #define cpu_to_be32(v) (v)
213 #define be32_to_cpu(v) (v)
214
215 #else
216
217 static inline uint16_t cairo_const
218 cpu_to_be16(uint16_t v)
219 {
220     return (v << 8) | (v >> 8);
221 }
222
223 static inline uint16_t cairo_const
224 be16_to_cpu(uint16_t v)
225 {
226     return cpu_to_be16 (v);
227 }
228
229 static inline uint32_t cairo_const
230 cpu_to_be32(uint32_t v)
231 {
232     return (cpu_to_be16 (v) << 16) | cpu_to_be16 (v >> 16);
233 }
234
235 static inline uint32_t cairo_const
236 be32_to_cpu(uint32_t v)
237 {
238     return cpu_to_be32 (v);
239 }
240
241 #endif
242
243
244 /* The glibc versions of ispace() and isdigit() are slow in UTF-8 locales.
245  */
246
247 static inline int cairo_const
248 _cairo_isspace (int c)
249 {
250     return (c == 0x20 || (c >= 0x09 && c <= 0x0d));
251 }
252
253 static inline int cairo_const
254 _cairo_isdigit (int c)
255 {
256     return (c >= '0' && c <= '9');
257 }
258
259 #include "cairo-types-private.h"
260 #include "cairo-cache-private.h"
261 #include "cairo-reference-count-private.h"
262 #include "cairo-spans-private.h"
263 #include "cairo-surface-private.h"
264
265 cairo_private void
266 _cairo_box_from_doubles (cairo_box_t *box,
267                          double *x1, double *y1,
268                          double *x2, double *y2);
269
270 cairo_private void
271 _cairo_box_to_doubles (const cairo_box_t *box,
272                        double *x1, double *y1,
273                        double *x2, double *y2);
274
275 cairo_private void
276 _cairo_box_from_rectangle (cairo_box_t                 *box,
277                            const cairo_rectangle_int_t *rectangle);
278
279 cairo_private void
280 _cairo_box_round_to_rectangle (const cairo_box_t     *box,
281                                cairo_rectangle_int_t *rectangle);
282
283 cairo_private void
284 _cairo_box_add_curve_to (cairo_box_t         *extents,
285                          const cairo_point_t *a,
286                          const cairo_point_t *b,
287                          const cairo_point_t *c,
288                          const cairo_point_t *d);
289
290 cairo_private void
291 _cairo_boxes_get_extents (const cairo_box_t *boxes,
292                           int num_boxes,
293                           cairo_box_t *extents);
294
295 cairo_private extern const cairo_rectangle_int_t _cairo_empty_rectangle;
296 cairo_private extern const cairo_rectangle_int_t _cairo_unbounded_rectangle;
297
298 static inline void
299 _cairo_unbounded_rectangle_init (cairo_rectangle_int_t *rect)
300 {
301     *rect = _cairo_unbounded_rectangle;
302 }
303
304 cairo_private_no_warn cairo_bool_t
305 _cairo_rectangle_intersect (cairo_rectangle_int_t *dst,
306                             const cairo_rectangle_int_t *src);
307
308 cairo_private_no_warn cairo_bool_t
309 _cairo_rectangle_exact_intersect (cairo_rectangle_t *dst,
310                                   const cairo_rectangle_t *src);
311
312 static inline cairo_bool_t
313 _cairo_rectangle_intersects (const cairo_rectangle_int_t *dst,
314                              const cairo_rectangle_int_t *src)
315 {
316     return !(src->x >= dst->x + (int) dst->width ||
317              src->x + (int) src->width <= dst->x ||
318              src->y >= dst->y + (int) dst->height ||
319              src->y + (int) src->height <= dst->y);
320 }
321
322 static inline cairo_bool_t
323 _cairo_rectangle_contains_rectangle (const cairo_rectangle_int_t *a,
324                                      const cairo_rectangle_int_t *b)
325 {
326     return (a->x <= b->x &&
327             a->x + (int) a->width >= b->x + (int) b->width &&
328             a->y <= b->y &&
329             a->y + (int) a->height >= b->y + (int) b->height);
330 }
331
332 cairo_private void
333 _cairo_rectangle_int_from_double (cairo_rectangle_int_t *recti,
334                                   const cairo_rectangle_t *rectf);
335
336 /* Extends the dst rectangle to also contain src.
337  * If one of the rectangles is empty, the result is undefined
338  */
339 cairo_private void
340 _cairo_rectangle_union (cairo_rectangle_int_t *dst,
341                         const cairo_rectangle_int_t *src);
342
343 cairo_private cairo_bool_t
344 _cairo_box_intersects_line_segment (const cairo_box_t *box,
345                                     cairo_line_t *line) cairo_pure;
346
347 cairo_private cairo_bool_t
348 _cairo_spline_intersects (const cairo_point_t *a,
349                           const cairo_point_t *b,
350                           const cairo_point_t *c,
351                           const cairo_point_t *d,
352                           const cairo_box_t *box) cairo_pure;
353
354 typedef struct {
355     const cairo_user_data_key_t *key;
356     void *user_data;
357     cairo_destroy_func_t destroy;
358 } cairo_user_data_slot_t;
359
360 cairo_private void
361 _cairo_user_data_array_init (cairo_user_data_array_t *array);
362
363 cairo_private void
364 _cairo_user_data_array_fini (cairo_user_data_array_t *array);
365
366 cairo_private void *
367 _cairo_user_data_array_get_data (cairo_user_data_array_t     *array,
368                                  const cairo_user_data_key_t *key);
369
370 cairo_private cairo_status_t
371 _cairo_user_data_array_set_data (cairo_user_data_array_t     *array,
372                                  const cairo_user_data_key_t *key,
373                                  void                        *user_data,
374                                  cairo_destroy_func_t         destroy);
375
376 cairo_private cairo_status_t
377 _cairo_user_data_array_copy (cairo_user_data_array_t            *dst,
378                              const cairo_user_data_array_t      *src);
379
380 cairo_private void
381 _cairo_user_data_array_foreach (cairo_user_data_array_t     *array,
382                                 void (*func) (const void *key,
383                                               void *elt,
384                                               void *closure),
385                                 void *closure);
386
387 #define _CAIRO_HASH_INIT_VALUE 5381
388
389 cairo_private unsigned long
390 _cairo_hash_string (const char *c);
391
392 cairo_private unsigned long
393 _cairo_hash_bytes (unsigned long hash,
394                    const void *bytes,
395                    unsigned int length);
396
397 #define _cairo_scaled_glyph_index(g) ((g)->hash_entry.hash)
398 #define _cairo_scaled_glyph_set_index(g, i)  ((g)->hash_entry.hash = (i))
399
400 #include "cairo-scaled-font-private.h"
401
402 struct _cairo_font_face {
403     /* hash_entry must be first */
404     cairo_hash_entry_t hash_entry;
405     cairo_status_t status;
406     cairo_reference_count_t ref_count;
407     cairo_user_data_array_t user_data;
408     const cairo_font_face_backend_t *backend;
409 };
410
411 cairo_private void
412 _cairo_default_context_reset_static_data (void);
413
414 cairo_private void
415 _cairo_toy_font_face_reset_static_data (void);
416
417 cairo_private void
418 _cairo_ft_font_reset_static_data (void);
419
420 cairo_private void
421 _cairo_win32_font_reset_static_data (void);
422
423 #if CAIRO_HAS_COGL_SURFACE
424 void
425 _cairo_cogl_context_reset_static_data (void);
426 #endif
427
428 /* the font backend interface */
429
430 struct _cairo_unscaled_font_backend {
431     void (*destroy)                 (void                            *unscaled_font);
432 };
433
434 /* #cairo_toy_font_face_t - simple family/slant/weight font faces used for
435  * the built-in font API
436  */
437
438 typedef struct _cairo_toy_font_face {
439     cairo_font_face_t base;
440     const char *family;
441     cairo_bool_t owns_family;
442     cairo_font_slant_t slant;
443     cairo_font_weight_t weight;
444
445     cairo_font_face_t *impl_face; /* The non-toy font face this actually uses */
446 } cairo_toy_font_face_t;
447
448 typedef enum _cairo_scaled_glyph_info {
449     CAIRO_SCALED_GLYPH_INFO_METRICS      = (1 << 0),
450     CAIRO_SCALED_GLYPH_INFO_SURFACE      = (1 << 1),
451     CAIRO_SCALED_GLYPH_INFO_PATH         = (1 << 2),
452     CAIRO_SCALED_GLYPH_INFO_RECORDING_SURFACE = (1 << 3)
453 } cairo_scaled_glyph_info_t;
454
455 typedef struct _cairo_scaled_font_subset {
456     cairo_scaled_font_t *scaled_font;
457     unsigned int font_id;
458     unsigned int subset_id;
459
460     /* Index of glyphs array is subset_glyph_index.
461      * Value of glyphs array is scaled_font_glyph_index.
462      */
463     unsigned long *glyphs;
464     char          **utf8;
465     char          **glyph_names;
466     int           *to_latin_char;
467     unsigned long *latin_to_subset_glyph_index;
468     unsigned int num_glyphs;
469     cairo_bool_t is_composite;
470     cairo_bool_t is_scaled;
471     cairo_bool_t is_latin;
472 } cairo_scaled_font_subset_t;
473
474 struct _cairo_scaled_font_backend {
475     cairo_font_type_t type;
476
477     void
478     (*fini)             (void                   *scaled_font);
479
480     cairo_warn cairo_int_status_t
481     (*scaled_glyph_init)        (void                        *scaled_font,
482                                  cairo_scaled_glyph_t        *scaled_glyph,
483                                  cairo_scaled_glyph_info_t    info);
484
485     /* A backend only needs to implement this or ucs4_to_index(), not
486      * both. This allows the backend to do something more sophisticated
487      * then just converting characters one by one.
488      */
489     cairo_warn cairo_int_status_t
490     (*text_to_glyphs) (void                       *scaled_font,
491                        double                      x,
492                        double                      y,
493                        const char                 *utf8,
494                        int                         utf8_len,
495                        cairo_glyph_t             **glyphs,
496                        int                        *num_glyphs,
497                        cairo_text_cluster_t      **clusters,
498                        int                        *num_clusters,
499                        cairo_text_cluster_flags_t *cluster_flags);
500
501     unsigned long
502     (*ucs4_to_index)            (void                        *scaled_font,
503                                  uint32_t                     ucs4);
504
505     /* Read data from a sfnt font table.
506      * @scaled_font: font
507      * @tag: 4 byte table name specifying the table to read.
508      * @offset: offset into the table
509      * @buffer: buffer to write data into. Caller must ensure there is sufficient space.
510      *          If NULL, return the size of the table in @length.
511      * @length: If @buffer is NULL, the size of the table will be returned in @length.
512      *          If @buffer is not null, @length specifies the number of bytes to read.
513      *
514      * If less than @length bytes are available to read this function
515      * returns CAIRO_INT_STATUS_UNSUPPORTED. Note that requesting more
516      * bytes than are available in the table may continue reading data
517      * from the following table and return success. If this is
518      * undesirable the caller should first query the table size. If an
519      * error occurs the output value of @length is undefined.
520      *
521      * Returns CAIRO_INT_STATUS_UNSUPPORTED if not a sfnt style font or table not found.
522      */
523     cairo_warn cairo_int_status_t
524     (*load_truetype_table)(void                 *scaled_font,
525                            unsigned long         tag,
526                            long                  offset,
527                            unsigned char        *buffer,
528                            unsigned long        *length);
529
530     /* ucs4 is set to -1 if the unicode character could not be found
531      * for the glyph */
532     cairo_warn cairo_int_status_t
533     (*index_to_ucs4)(void                       *scaled_font,
534                      unsigned long               index,
535                      uint32_t                   *ucs4);
536
537     cairo_warn cairo_bool_t
538     (*is_synthetic)(void                       *scaled_font);
539
540     /* For type 1 fonts, return the glyph name for a given glyph index.
541      * A glyph index and list of glyph names in the Type 1 fonts is provided.
542      * The function returns the index of the glyph in the list of glyph names.
543      * @scaled_font: font
544      * @glyph_names: the names of each glyph in the Type 1 font in the
545      *   order they appear in the CharStrings array
546      * @num_glyph_names: the number of names in the glyph_names array
547      * @glyph_index: the given glyph index
548      * @glyph_array_index: (index into glyph_names) the glyph name corresponding
549      *  to the glyph_index
550      */
551
552     cairo_warn cairo_int_status_t
553     (*index_to_glyph_name)(void                 *scaled_font,
554                            char                **glyph_names,
555                            int                   num_glyph_names,
556                            unsigned long         glyph_index,
557                            unsigned long        *glyph_array_index);
558
559     /* Read data from a PostScript font.
560      * @scaled_font: font
561      * @offset: offset into the table
562      * @buffer: buffer to write data into. Caller must ensure there is sufficient space.
563      *          If NULL, return the size of the table in @length.
564      * @length: If @buffer is NULL, the size of the table will be returned in @length.
565      *          If @buffer is not null, @length specifies the number of bytes to read.
566      *
567      * If less than @length bytes are available to read this function
568      * returns CAIRO_INT_STATUS_UNSUPPORTED. If an error occurs the
569      * output value of @length is undefined.
570      *
571      * Returns CAIRO_INT_STATUS_UNSUPPORTED if not a Type 1 font.
572      */
573     cairo_warn cairo_int_status_t
574     (*load_type1_data)    (void                 *scaled_font,
575                            long                  offset,
576                            unsigned char        *buffer,
577                            unsigned long        *length);
578 };
579
580 struct _cairo_font_face_backend {
581     cairo_font_type_t   type;
582
583     cairo_warn cairo_status_t
584     (*create_for_toy)  (cairo_toy_font_face_t   *toy_face,
585                         cairo_font_face_t      **font_face);
586
587     /* The destroy() function is allowed to resurrect the font face
588      * by re-referencing. This is needed for the FreeType backend.
589      */
590     void
591     (*destroy)     (void                        *font_face);
592
593     cairo_warn cairo_status_t
594     (*scaled_font_create) (void                         *font_face,
595                            const cairo_matrix_t         *font_matrix,
596                            const cairo_matrix_t         *ctm,
597                            const cairo_font_options_t   *options,
598                            cairo_scaled_font_t         **scaled_font);
599
600     cairo_font_face_t *
601     (*get_implementation) (void                         *font_face,
602                            const cairo_matrix_t         *font_matrix,
603                            const cairo_matrix_t         *ctm,
604                            const cairo_font_options_t   *options);
605 };
606
607 extern const cairo_private struct _cairo_font_face_backend _cairo_user_font_face_backend;
608
609 /* concrete font backends */
610 #if CAIRO_HAS_FT_FONT
611
612 extern const cairo_private struct _cairo_font_face_backend _cairo_ft_font_face_backend;
613
614 #endif
615
616 #if CAIRO_HAS_WIN32_FONT
617
618 extern const cairo_private struct _cairo_font_face_backend _cairo_win32_font_face_backend;
619
620 #endif
621
622 #if CAIRO_HAS_QUARTZ_FONT
623
624 extern const cairo_private struct _cairo_font_face_backend _cairo_quartz_font_face_backend;
625
626 #endif
627
628 #define CAIRO_EXTEND_SURFACE_DEFAULT CAIRO_EXTEND_NONE
629 #define CAIRO_EXTEND_GRADIENT_DEFAULT CAIRO_EXTEND_PAD
630 #define CAIRO_FILTER_DEFAULT CAIRO_FILTER_GOOD
631
632 extern const cairo_private cairo_solid_pattern_t _cairo_pattern_clear;
633 extern const cairo_private cairo_solid_pattern_t _cairo_pattern_black;
634 extern const cairo_private cairo_solid_pattern_t _cairo_pattern_white;
635
636 struct _cairo_surface_attributes {
637     cairo_matrix_t matrix;
638     cairo_extend_t extend;
639     cairo_filter_t filter;
640     cairo_bool_t has_component_alpha;
641     int            x_offset;
642     int            y_offset;
643     void           *extra;
644 };
645
646 #define CAIRO_FONT_SLANT_DEFAULT   CAIRO_FONT_SLANT_NORMAL
647 #define CAIRO_FONT_WEIGHT_DEFAULT  CAIRO_FONT_WEIGHT_NORMAL
648
649 #define CAIRO_WIN32_FONT_FAMILY_DEFAULT "Arial"
650 #define CAIRO_QUARTZ_FONT_FAMILY_DEFAULT  "Helvetica"
651 #define CAIRO_FT_FONT_FAMILY_DEFAULT     ""
652 #define CAIRO_USER_FONT_FAMILY_DEFAULT     "@cairo:"
653
654 #if   CAIRO_HAS_WIN32_FONT
655
656 #define CAIRO_FONT_FAMILY_DEFAULT CAIRO_WIN32_FONT_FAMILY_DEFAULT
657 #define CAIRO_FONT_FACE_BACKEND_DEFAULT &_cairo_win32_font_face_backend
658
659 #elif CAIRO_HAS_QUARTZ_FONT
660
661 #define CAIRO_FONT_FAMILY_DEFAULT CAIRO_QUARTZ_FONT_FAMILY_DEFAULT
662 #define CAIRO_FONT_FACE_BACKEND_DEFAULT &_cairo_quartz_font_face_backend
663
664 #elif CAIRO_HAS_FT_FONT
665
666 #define CAIRO_FONT_FAMILY_DEFAULT CAIRO_FT_FONT_FAMILY_DEFAULT
667 #define CAIRO_FONT_FACE_BACKEND_DEFAULT &_cairo_ft_font_face_backend
668
669 #else
670
671 #define CAIRO_FONT_FAMILY_DEFAULT CAIRO_FT_FONT_FAMILY_DEFAULT
672 #define CAIRO_FONT_FACE_BACKEND_DEFAULT &_cairo_user_font_face_backend
673
674 #endif
675
676 #define CAIRO_GSTATE_OPERATOR_DEFAULT   CAIRO_OPERATOR_OVER
677 #define CAIRO_GSTATE_TOLERANCE_DEFAULT  0.1
678 #define CAIRO_GSTATE_FILL_RULE_DEFAULT  CAIRO_FILL_RULE_WINDING
679 #define CAIRO_GSTATE_LINE_WIDTH_DEFAULT 2.0
680 #define CAIRO_GSTATE_LINE_CAP_DEFAULT   CAIRO_LINE_CAP_BUTT
681 #define CAIRO_GSTATE_LINE_JOIN_DEFAULT  CAIRO_LINE_JOIN_MITER
682 #define CAIRO_GSTATE_MITER_LIMIT_DEFAULT        10.0
683 #define CAIRO_GSTATE_DEFAULT_FONT_SIZE  10.0
684
685 #define CAIRO_SURFACE_RESOLUTION_DEFAULT 72.0
686 #define CAIRO_SURFACE_FALLBACK_RESOLUTION_DEFAULT 300.0
687
688 typedef struct _cairo_stroke_face {
689     cairo_point_t ccw;
690     cairo_point_t point;
691     cairo_point_t cw;
692     cairo_slope_t dev_vector;
693     cairo_point_double_t dev_slope;
694     cairo_point_double_t usr_vector;
695     double length;
696 } cairo_stroke_face_t;
697
698 /* cairo.c */
699
700 static inline double cairo_const
701 _cairo_restrict_value (double value, double min, double max)
702 {
703     if (value < min)
704         return min;
705     else if (value > max)
706         return max;
707     else
708         return value;
709 }
710
711 /* C99 round() rounds to the nearest integral value with halfway cases rounded
712  * away from 0. _cairo_round rounds halfway cases toward positive infinity.
713  * This matches the rounding behaviour of _cairo_lround. */
714 static inline double cairo_const
715 _cairo_round (double r)
716 {
717     return floor (r + .5);
718 }
719
720 #if DISABLE_SOME_FLOATING_POINT
721 cairo_private int
722 _cairo_lround (double d) cairo_const;
723 #else
724 static inline int cairo_const
725 _cairo_lround (double r)
726 {
727     return _cairo_round (r);
728 }
729 #endif
730
731 cairo_private uint16_t
732 _cairo_half_from_float (float f) cairo_const;
733
734 cairo_private cairo_bool_t
735 _cairo_operator_bounded_by_mask (cairo_operator_t op) cairo_const;
736
737 cairo_private cairo_bool_t
738 _cairo_operator_bounded_by_source (cairo_operator_t op) cairo_const;
739
740 enum {
741     CAIRO_OPERATOR_BOUND_BY_MASK = 1 << 1,
742     CAIRO_OPERATOR_BOUND_BY_SOURCE = 1 << 2,
743 };
744
745 cairo_private uint32_t
746 _cairo_operator_bounded_by_either (cairo_operator_t op) cairo_const;
747 /* cairo-color.c */
748 cairo_private const cairo_color_t *
749 _cairo_stock_color (cairo_stock_t stock) cairo_pure;
750
751 #define CAIRO_COLOR_WHITE       _cairo_stock_color (CAIRO_STOCK_WHITE)
752 #define CAIRO_COLOR_BLACK       _cairo_stock_color (CAIRO_STOCK_BLACK)
753 #define CAIRO_COLOR_TRANSPARENT _cairo_stock_color (CAIRO_STOCK_TRANSPARENT)
754
755 cairo_private uint16_t
756 _cairo_color_double_to_short (double d) cairo_const;
757
758 cairo_private void
759 _cairo_color_init_rgba (cairo_color_t *color,
760                         double red, double green, double blue,
761                         double alpha);
762
763 cairo_private void
764 _cairo_color_multiply_alpha (cairo_color_t *color,
765                              double         alpha);
766
767 cairo_private void
768 _cairo_color_get_rgba (cairo_color_t *color,
769                        double        *red,
770                        double        *green,
771                        double        *blue,
772                        double        *alpha);
773
774 cairo_private void
775 _cairo_color_get_rgba_premultiplied (cairo_color_t *color,
776                                      double        *red,
777                                      double        *green,
778                                      double        *blue,
779                                      double        *alpha);
780
781 cairo_private cairo_bool_t
782 _cairo_color_equal (const cairo_color_t *color_a,
783                     const cairo_color_t *color_b) cairo_pure;
784
785 cairo_private cairo_bool_t
786 _cairo_color_stop_equal (const cairo_color_stop_t *color_a,
787                          const cairo_color_stop_t *color_b) cairo_pure;
788
789 cairo_private cairo_content_t
790 _cairo_color_get_content (const cairo_color_t *color) cairo_pure;
791
792 /* cairo-font-face.c */
793
794 extern const cairo_private cairo_font_face_t _cairo_font_face_nil;
795
796 cairo_private void
797 _cairo_font_face_init (cairo_font_face_t               *font_face,
798                        const cairo_font_face_backend_t *backend);
799
800 cairo_private cairo_status_t
801 _cairo_font_face_set_error (cairo_font_face_t *font_face,
802                             cairo_status_t     status);
803
804 cairo_private void
805 _cairo_unscaled_font_init (cairo_unscaled_font_t               *font,
806                            const cairo_unscaled_font_backend_t *backend);
807
808 cairo_private_no_warn cairo_unscaled_font_t *
809 _cairo_unscaled_font_reference (cairo_unscaled_font_t *font);
810
811 cairo_private void
812 _cairo_unscaled_font_destroy (cairo_unscaled_font_t *font);
813
814 /* cairo-font-face-twin.c */
815
816 cairo_private cairo_font_face_t *
817 _cairo_font_face_twin_create_fallback (void);
818
819 cairo_private cairo_status_t
820 _cairo_font_face_twin_create_for_toy (cairo_toy_font_face_t   *toy_face,
821                                       cairo_font_face_t      **font_face);
822
823 /* cairo-font-face-twin-data.c */
824
825 extern const cairo_private int8_t _cairo_twin_outlines[];
826 extern const cairo_private uint16_t _cairo_twin_charmap[128];
827
828 /* cairo-font-options.c */
829
830 cairo_private void
831 _cairo_font_options_init_default (cairo_font_options_t *options);
832
833 cairo_private void
834 _cairo_font_options_init_copy (cairo_font_options_t             *options,
835                                const cairo_font_options_t       *other);
836
837 cairo_private void
838 _cairo_font_options_set_lcd_filter (cairo_font_options_t   *options,
839                                    cairo_lcd_filter_t  lcd_filter);
840
841 cairo_private cairo_lcd_filter_t
842 _cairo_font_options_get_lcd_filter (const cairo_font_options_t *options);
843
844 cairo_private void
845 _cairo_font_options_set_round_glyph_positions (cairo_font_options_t   *options,
846                                                cairo_round_glyph_positions_t  round);
847
848 cairo_private cairo_round_glyph_positions_t
849 _cairo_font_options_get_round_glyph_positions (const cairo_font_options_t *options);
850
851 /* cairo-hull.c */
852 cairo_private cairo_status_t
853 _cairo_hull_compute (cairo_pen_vertex_t *vertices, int *num_vertices);
854
855 /* cairo-lzw.c */
856 cairo_private unsigned char *
857 _cairo_lzw_compress (unsigned char *data, unsigned long *size_in_out);
858
859 /* cairo-misc.c */
860 cairo_private cairo_status_t
861 _cairo_validate_text_clusters (const char                  *utf8,
862                                int                          utf8_len,
863                                const cairo_glyph_t         *glyphs,
864                                int                          num_glyphs,
865                                const cairo_text_cluster_t  *clusters,
866                                int                          num_clusters,
867                                cairo_text_cluster_flags_t   cluster_flags);
868
869 cairo_private cairo_status_t
870 _cairo_intern_string (const char **str_inout, int len);
871
872 cairo_private void
873 _cairo_intern_string_reset_static_data (void);
874
875 /* cairo-path-fixed.c */
876 cairo_private cairo_path_fixed_t *
877 _cairo_path_fixed_create (void);
878
879 cairo_private void
880 _cairo_path_fixed_init (cairo_path_fixed_t *path);
881
882 cairo_private cairo_status_t
883 _cairo_path_fixed_init_copy (cairo_path_fixed_t *path,
884                              const cairo_path_fixed_t *other);
885
886 cairo_private void
887 _cairo_path_fixed_fini (cairo_path_fixed_t *path);
888
889 cairo_private void
890 _cairo_path_fixed_destroy (cairo_path_fixed_t *path);
891
892 cairo_private cairo_status_t
893 _cairo_path_fixed_move_to (cairo_path_fixed_t  *path,
894                            cairo_fixed_t        x,
895                            cairo_fixed_t        y);
896
897 cairo_private void
898 _cairo_path_fixed_new_sub_path (cairo_path_fixed_t *path);
899
900 cairo_private cairo_status_t
901 _cairo_path_fixed_rel_move_to (cairo_path_fixed_t *path,
902                                cairo_fixed_t       dx,
903                                cairo_fixed_t       dy);
904
905 cairo_private cairo_status_t
906 _cairo_path_fixed_line_to (cairo_path_fixed_t *path,
907                            cairo_fixed_t        x,
908                            cairo_fixed_t        y);
909
910 cairo_private cairo_status_t
911 _cairo_path_fixed_rel_line_to (cairo_path_fixed_t *path,
912                                cairo_fixed_t       dx,
913                                cairo_fixed_t       dy);
914
915 cairo_private cairo_status_t
916 _cairo_path_fixed_curve_to (cairo_path_fixed_t  *path,
917                             cairo_fixed_t x0, cairo_fixed_t y0,
918                             cairo_fixed_t x1, cairo_fixed_t y1,
919                             cairo_fixed_t x2, cairo_fixed_t y2);
920
921 cairo_private cairo_status_t
922 _cairo_path_fixed_rel_curve_to (cairo_path_fixed_t *path,
923                                 cairo_fixed_t dx0, cairo_fixed_t dy0,
924                                 cairo_fixed_t dx1, cairo_fixed_t dy1,
925                                 cairo_fixed_t dx2, cairo_fixed_t dy2);
926
927 cairo_private cairo_status_t
928 _cairo_path_fixed_close_path (cairo_path_fixed_t *path);
929
930 cairo_private cairo_bool_t
931 _cairo_path_fixed_get_current_point (cairo_path_fixed_t *path,
932                                      cairo_fixed_t      *x,
933                                      cairo_fixed_t      *y);
934
935 typedef cairo_status_t
936 (cairo_path_fixed_move_to_func_t) (void          *closure,
937                                    const cairo_point_t *point);
938
939 typedef cairo_status_t
940 (cairo_path_fixed_line_to_func_t) (void          *closure,
941                                    const cairo_point_t *point);
942
943 typedef cairo_status_t
944 (cairo_path_fixed_curve_to_func_t) (void          *closure,
945                                     const cairo_point_t *p0,
946                                     const cairo_point_t *p1,
947                                     const cairo_point_t *p2);
948
949 typedef cairo_status_t
950 (cairo_path_fixed_close_path_func_t) (void *closure);
951
952 cairo_private cairo_status_t
953 _cairo_path_fixed_interpret (const cairo_path_fixed_t     *path,
954                        cairo_path_fixed_move_to_func_t    *move_to,
955                        cairo_path_fixed_line_to_func_t    *line_to,
956                        cairo_path_fixed_curve_to_func_t   *curve_to,
957                        cairo_path_fixed_close_path_func_t *close_path,
958                        void                               *closure);
959
960 cairo_private cairo_status_t
961 _cairo_path_fixed_interpret_flat (const cairo_path_fixed_t *path,
962                        cairo_path_fixed_move_to_func_t    *move_to,
963                        cairo_path_fixed_line_to_func_t    *line_to,
964                        cairo_path_fixed_close_path_func_t *close_path,
965                        void                               *closure,
966                        double                             tolerance);
967
968
969 cairo_private cairo_bool_t
970 _cairo_path_bounder_extents (const cairo_path_fixed_t *path,
971                              cairo_box_t *box);
972
973 cairo_private cairo_bool_t
974 _cairo_path_fixed_extents (const cairo_path_fixed_t *path,
975                            cairo_box_t *box);
976
977 cairo_private void
978 _cairo_path_fixed_approximate_clip_extents (const cairo_path_fixed_t    *path,
979                                             cairo_rectangle_int_t *extents);
980
981 cairo_private void
982 _cairo_path_fixed_approximate_fill_extents (const cairo_path_fixed_t *path,
983                                             cairo_rectangle_int_t *extents);
984
985 cairo_private void
986 _cairo_path_fixed_approximate_fill_exact_extents (const cairo_path_fixed_t *path,
987                                                   cairo_rectangle_t *extents);
988
989 cairo_private void
990 _cairo_path_fixed_fill_extents (const cairo_path_fixed_t        *path,
991                                 cairo_fill_rule_t        fill_rule,
992                                 double                   tolerance,
993                                 cairo_rectangle_int_t   *extents);
994
995 cairo_private void
996 _cairo_path_fixed_fill_exact_extents (const cairo_path_fixed_t  *path,
997                                       cairo_fill_rule_t  fill_rule,
998                                       double                     tolerance,
999                                       cairo_rectangle_t *extents);
1000
1001 cairo_private void
1002 _cairo_path_fixed_approximate_stroke_extents (const cairo_path_fixed_t *path,
1003                                               const cairo_stroke_style_t *style,
1004                                               const cairo_matrix_t *ctm,
1005                                               cairo_rectangle_int_t *extents);
1006
1007 cairo_private void
1008 _cairo_path_fixed_approximate_stroke_exact_extents (const cairo_path_fixed_t *path,
1009                                                     const cairo_stroke_style_t *style,
1010                                                     const cairo_matrix_t *ctm,
1011                                                     cairo_rectangle_t *extents);
1012
1013 cairo_private cairo_status_t
1014 _cairo_path_fixed_stroke_extents (const cairo_path_fixed_t *path,
1015                                   const cairo_stroke_style_t *style,
1016                                   const cairo_matrix_t *ctm,
1017                                   const cairo_matrix_t *ctm_inverse,
1018                                   double tolerance,
1019                                   cairo_rectangle_int_t *extents);
1020
1021 cairo_private cairo_status_t
1022 _cairo_path_fixed_stroke_exact_extents (const cairo_path_fixed_t *path,
1023                                         const cairo_stroke_style_t *style,
1024                                         const cairo_matrix_t *ctm,
1025                                         const cairo_matrix_t *ctm_inverse,
1026                                         double tolerance,
1027                                         cairo_rectangle_t *extents);
1028
1029 cairo_private void
1030 _cairo_path_fixed_transform (cairo_path_fixed_t *path,
1031                              const cairo_matrix_t       *matrix);
1032
1033 cairo_private cairo_bool_t
1034 _cairo_path_fixed_is_single_arc (const cairo_path_fixed_t *path);
1035
1036 cairo_private cairo_bool_t
1037 _cairo_path_fixed_is_single_line (const cairo_path_fixed_t *path);
1038
1039 cairo_private cairo_bool_t
1040 _cairo_path_fixed_is_box (const cairo_path_fixed_t *path,
1041                           cairo_box_t *box);
1042
1043 cairo_private cairo_bool_t
1044 _cairo_path_fixed_is_rectangle (const cairo_path_fixed_t *path,
1045                                 cairo_box_t        *box);
1046
1047 /* cairo-path-in-fill.c */
1048 cairo_private cairo_bool_t
1049 _cairo_path_fixed_in_fill (const cairo_path_fixed_t     *path,
1050                            cairo_fill_rule_t     fill_rule,
1051                            double                tolerance,
1052                            double                x,
1053                            double                y);
1054
1055 /* cairo-path-fill.c */
1056 cairo_private cairo_status_t
1057 _cairo_path_fixed_fill_to_polygon (const cairo_path_fixed_t *path,
1058                                    double              tolerance,
1059                                    cairo_polygon_t      *polygon);
1060
1061 cairo_private cairo_status_t
1062 _cairo_path_fixed_fill_rectilinear_to_polygon (const cairo_path_fixed_t *path,
1063                                                cairo_antialias_t antialias,
1064                                                cairo_polygon_t *polygon);
1065
1066 cairo_private cairo_status_t
1067 _cairo_path_fixed_fill_rectilinear_to_boxes (const cairo_path_fixed_t *path,
1068                                              cairo_fill_rule_t fill_rule,
1069                                              cairo_antialias_t antialias,
1070                                              cairo_boxes_t *boxes);
1071
1072 cairo_private cairo_region_t *
1073 _cairo_path_fixed_fill_rectilinear_to_region (const cairo_path_fixed_t  *path,
1074                                               cairo_fill_rule_t  fill_rule,
1075                                               const cairo_rectangle_int_t *extents);
1076
1077 cairo_private cairo_status_t
1078 _cairo_path_fixed_fill_to_traps (const cairo_path_fixed_t   *path,
1079                                  cairo_fill_rule_t           fill_rule,
1080                                  double                      tolerance,
1081                                  cairo_traps_t              *traps);
1082
1083 /* cairo-path-stroke.c */
1084 cairo_private cairo_status_t
1085 _cairo_path_fixed_stroke_to_polygon (const cairo_path_fixed_t   *path,
1086                                      const cairo_stroke_style_t *stroke_style,
1087                                      const cairo_matrix_t       *ctm,
1088                                      const cairo_matrix_t       *ctm_inverse,
1089                                      double              tolerance,
1090                                      cairo_polygon_t    *polygon);
1091
1092 cairo_private cairo_int_status_t
1093 _cairo_path_fixed_stroke_to_tristrip (const cairo_path_fixed_t  *path,
1094                                       const cairo_stroke_style_t*style,
1095                                       const cairo_matrix_t      *ctm,
1096                                       const cairo_matrix_t      *ctm_inverse,
1097                                       double                     tolerance,
1098                                       cairo_tristrip_t           *strip);
1099
1100 cairo_private cairo_status_t
1101 _cairo_path_fixed_stroke_dashed_to_polygon (const cairo_path_fixed_t    *path,
1102                                             const cairo_stroke_style_t  *stroke_style,
1103                                             const cairo_matrix_t        *ctm,
1104                                             const cairo_matrix_t        *ctm_inverse,
1105                                             double               tolerance,
1106                                             cairo_polygon_t     *polygon);
1107
1108 cairo_private cairo_int_status_t
1109 _cairo_path_fixed_stroke_rectilinear_to_boxes (const cairo_path_fixed_t *path,
1110                                                const cairo_stroke_style_t       *stroke_style,
1111                                                const cairo_matrix_t     *ctm,
1112                                                cairo_antialias_t         antialias,
1113                                                cairo_boxes_t            *boxes);
1114
1115 cairo_private cairo_int_status_t
1116 _cairo_path_fixed_stroke_to_traps (const cairo_path_fixed_t     *path,
1117                                    const cairo_stroke_style_t   *stroke_style,
1118                                    const cairo_matrix_t *ctm,
1119                                    const cairo_matrix_t *ctm_inverse,
1120                                    double                tolerance,
1121                                    cairo_traps_t        *traps);
1122
1123 cairo_private cairo_int_status_t
1124 _cairo_path_fixed_stroke_polygon_to_traps (const cairo_path_fixed_t     *path,
1125                                            const cairo_stroke_style_t   *stroke_style,
1126                                            const cairo_matrix_t *ctm,
1127                                            const cairo_matrix_t *ctm_inverse,
1128                                            double                tolerance,
1129                                            cairo_traps_t        *traps);
1130
1131 cairo_private cairo_status_t
1132 _cairo_path_fixed_stroke_to_shaper (cairo_path_fixed_t  *path,
1133                                    const cairo_stroke_style_t   *stroke_style,
1134                                    const cairo_matrix_t *ctm,
1135                                    const cairo_matrix_t *ctm_inverse,
1136                                    double                tolerance,
1137                                    cairo_status_t (*add_triangle) (void *closure,
1138                                                                    const cairo_point_t triangle[3]),
1139                                    cairo_status_t (*add_triangle_fan) (void *closure,
1140                                                                        const cairo_point_t *midpt,
1141                                                                        const cairo_point_t *points,
1142                                                                        int npoints),
1143                                    cairo_status_t (*add_quad) (void *closure,
1144                                                                const cairo_point_t quad[4]),
1145                                    void *closure);
1146
1147 /* cairo-scaled-font.c */
1148
1149 cairo_private void
1150 _cairo_scaled_font_freeze_cache (cairo_scaled_font_t *scaled_font);
1151
1152 cairo_private void
1153 _cairo_scaled_font_thaw_cache (cairo_scaled_font_t *scaled_font);
1154
1155 cairo_private void
1156 _cairo_scaled_font_reset_cache (cairo_scaled_font_t *scaled_font);
1157
1158 cairo_private cairo_status_t
1159 _cairo_scaled_font_set_error (cairo_scaled_font_t *scaled_font,
1160                               cairo_status_t status);
1161
1162 cairo_private cairo_scaled_font_t *
1163 _cairo_scaled_font_create_in_error (cairo_status_t status);
1164
1165 cairo_private void
1166 _cairo_scaled_font_reset_static_data (void);
1167
1168 cairo_private cairo_status_t
1169 _cairo_scaled_font_register_placeholder_and_unlock_font_map (cairo_scaled_font_t *scaled_font);
1170
1171 cairo_private void
1172 _cairo_scaled_font_unregister_placeholder_and_lock_font_map (cairo_scaled_font_t *scaled_font);
1173
1174 cairo_private cairo_status_t
1175 _cairo_scaled_font_init (cairo_scaled_font_t               *scaled_font,
1176                          cairo_font_face_t                 *font_face,
1177                          const cairo_matrix_t              *font_matrix,
1178                          const cairo_matrix_t              *ctm,
1179                          const cairo_font_options_t        *options,
1180                          const cairo_scaled_font_backend_t *backend);
1181
1182 cairo_private cairo_status_t
1183 _cairo_scaled_font_set_metrics (cairo_scaled_font_t         *scaled_font,
1184                                 cairo_font_extents_t        *fs_metrics);
1185
1186 /* This should only be called on an error path by a scaled_font constructor */
1187 cairo_private void
1188 _cairo_scaled_font_fini (cairo_scaled_font_t *scaled_font);
1189
1190 cairo_private cairo_status_t
1191 _cairo_scaled_font_font_extents (cairo_scaled_font_t  *scaled_font,
1192                                  cairo_font_extents_t *extents);
1193
1194 cairo_private cairo_status_t
1195 _cairo_scaled_font_glyph_device_extents (cairo_scaled_font_t     *scaled_font,
1196                                          const cairo_glyph_t     *glyphs,
1197                                          int                      num_glyphs,
1198                                          cairo_rectangle_int_t   *extents,
1199                                          cairo_bool_t            *overlap);
1200
1201 cairo_private cairo_bool_t
1202 _cairo_scaled_font_glyph_approximate_extents (cairo_scaled_font_t        *scaled_font,
1203                                               const cairo_glyph_t        *glyphs,
1204                                               int                      num_glyphs,
1205                                               cairo_rectangle_int_t   *extents);
1206
1207 cairo_private cairo_status_t
1208 _cairo_scaled_font_show_glyphs (cairo_scaled_font_t *scaled_font,
1209                                 cairo_operator_t     op,
1210                                 const cairo_pattern_t *source,
1211                                 cairo_surface_t     *surface,
1212                                 int                  source_x,
1213                                 int                  source_y,
1214                                 int                  dest_x,
1215                                 int                  dest_y,
1216                                 unsigned int         width,
1217                                 unsigned int         height,
1218                                 cairo_glyph_t       *glyphs,
1219                                 int                  num_glyphs,
1220                                 cairo_region_t      *clip_region);
1221
1222 cairo_private cairo_status_t
1223 _cairo_scaled_font_glyph_path (cairo_scaled_font_t *scaled_font,
1224                                const cairo_glyph_t *glyphs,
1225                                int                  num_glyphs,
1226                                cairo_path_fixed_t  *path);
1227
1228 cairo_private void
1229 _cairo_scaled_glyph_set_metrics (cairo_scaled_glyph_t *scaled_glyph,
1230                                  cairo_scaled_font_t *scaled_font,
1231                                  cairo_text_extents_t *fs_metrics);
1232
1233 cairo_private void
1234 _cairo_scaled_glyph_set_surface (cairo_scaled_glyph_t *scaled_glyph,
1235                                  cairo_scaled_font_t *scaled_font,
1236                                  cairo_image_surface_t *surface);
1237
1238 cairo_private void
1239 _cairo_scaled_glyph_set_path (cairo_scaled_glyph_t *scaled_glyph,
1240                               cairo_scaled_font_t *scaled_font,
1241                               cairo_path_fixed_t *path);
1242
1243 cairo_private void
1244 _cairo_scaled_glyph_set_recording_surface (cairo_scaled_glyph_t *scaled_glyph,
1245                                            cairo_scaled_font_t *scaled_font,
1246                                            cairo_surface_t *recording_surface);
1247
1248 cairo_private cairo_int_status_t
1249 _cairo_scaled_glyph_lookup (cairo_scaled_font_t *scaled_font,
1250                             unsigned long index,
1251                             cairo_scaled_glyph_info_t info,
1252                             cairo_scaled_glyph_t **scaled_glyph_ret);
1253
1254 cairo_private double
1255 _cairo_scaled_font_get_max_scale (cairo_scaled_font_t *scaled_font);
1256
1257 cairo_private void
1258 _cairo_scaled_font_map_destroy (void);
1259
1260 /* cairo-stroke-style.c */
1261
1262 cairo_private void
1263 _cairo_stroke_style_init (cairo_stroke_style_t *style);
1264
1265 cairo_private cairo_status_t
1266 _cairo_stroke_style_init_copy (cairo_stroke_style_t *style,
1267                                const cairo_stroke_style_t *other);
1268
1269 cairo_private void
1270 _cairo_stroke_style_fini (cairo_stroke_style_t *style);
1271
1272 cairo_private void
1273 _cairo_stroke_style_max_distance_from_path (const cairo_stroke_style_t *style,
1274                                             const cairo_path_fixed_t *path,
1275                                             const cairo_matrix_t *ctm,
1276                                             double *dx, double *dy);
1277 cairo_private void
1278 _cairo_stroke_style_max_line_distance_from_path (const cairo_stroke_style_t *style,
1279                                                  const cairo_path_fixed_t *path,
1280                                                  const cairo_matrix_t *ctm,
1281                                                  double *dx, double *dy);
1282
1283 cairo_private void
1284 _cairo_stroke_style_max_join_distance_from_path (const cairo_stroke_style_t *style,
1285                                                  const cairo_path_fixed_t *path,
1286                                                  const cairo_matrix_t *ctm,
1287                                                  double *dx, double *dy);
1288
1289 cairo_private double
1290 _cairo_stroke_style_dash_period (const cairo_stroke_style_t *style);
1291
1292 cairo_private double
1293 _cairo_stroke_style_dash_stroked (const cairo_stroke_style_t *style);
1294
1295 cairo_private cairo_bool_t
1296 _cairo_stroke_style_dash_can_approximate (const cairo_stroke_style_t *style,
1297                                           const cairo_matrix_t *ctm,
1298                                           double tolerance);
1299
1300 cairo_private void
1301 _cairo_stroke_style_dash_approximate (const cairo_stroke_style_t *style,
1302                                       const cairo_matrix_t *ctm,
1303                                       double tolerance,
1304                                       double *dash_offset,
1305                                       double *dashes,
1306                                       unsigned int *num_dashes);
1307
1308
1309 /* cairo-surface.c */
1310
1311 cairo_private cairo_status_t
1312 _cairo_surface_copy_mime_data (cairo_surface_t *dst,
1313                                cairo_surface_t *src);
1314
1315 cairo_private_no_warn cairo_int_status_t
1316 _cairo_surface_set_error (cairo_surface_t       *surface,
1317                           cairo_int_status_t     status);
1318
1319 cairo_private void
1320 _cairo_surface_set_resolution (cairo_surface_t *surface,
1321                                double x_res,
1322                                double y_res);
1323
1324 cairo_private cairo_surface_t *
1325 _cairo_surface_create_similar_scratch (cairo_surface_t *other,
1326                                        cairo_content_t  content,
1327                                        int              width,
1328                                        int              height);
1329
1330 cairo_private cairo_surface_t *
1331 _cairo_surface_create_for_rectangle_int (cairo_surface_t *target,
1332                                          const cairo_rectangle_int_t *extents);
1333
1334 cairo_private cairo_surface_t *
1335 _cairo_surface_create_similar_solid (cairo_surface_t        *other,
1336                                      cairo_content_t         content,
1337                                      int                     width,
1338                                      int                     height,
1339                                      const cairo_color_t    *color);
1340
1341 cairo_private void
1342 _cairo_surface_init (cairo_surface_t                    *surface,
1343                      const cairo_surface_backend_t      *backend,
1344                      cairo_device_t                     *device,
1345                      cairo_content_t                     content);
1346
1347 cairo_private void
1348 _cairo_surface_set_font_options (cairo_surface_t       *surface,
1349                                  cairo_font_options_t  *options);
1350
1351 cairo_private cairo_status_t
1352 _cairo_surface_paint (cairo_surface_t   *surface,
1353                       cairo_operator_t   op,
1354                       const cairo_pattern_t *source,
1355                       const cairo_clip_t            *clip);
1356
1357 cairo_private cairo_image_surface_t *
1358 _cairo_surface_map_to_image (cairo_surface_t  *surface,
1359                              const cairo_rectangle_int_t *extents);
1360
1361 cairo_private cairo_int_status_t
1362 _cairo_surface_unmap_image (cairo_surface_t       *surface,
1363                             cairo_image_surface_t *image);
1364
1365 cairo_private cairo_status_t
1366 _cairo_surface_mask (cairo_surface_t    *surface,
1367                      cairo_operator_t    op,
1368                      const cairo_pattern_t      *source,
1369                      const cairo_pattern_t      *mask,
1370                      const cairo_clip_t         *clip);
1371
1372 cairo_private cairo_status_t
1373 _cairo_surface_fill_stroke (cairo_surface_t         *surface,
1374                             cairo_operator_t         fill_op,
1375                             const cairo_pattern_t   *fill_source,
1376                             cairo_fill_rule_t        fill_rule,
1377                             double                   fill_tolerance,
1378                             cairo_antialias_t        fill_antialias,
1379                             cairo_path_fixed_t      *path,
1380                             cairo_operator_t         stroke_op,
1381                             const cairo_pattern_t   *stroke_source,
1382                             const cairo_stroke_style_t    *stroke_style,
1383                             const cairo_matrix_t            *stroke_ctm,
1384                             const cairo_matrix_t            *stroke_ctm_inverse,
1385                             double                   stroke_tolerance,
1386                             cairo_antialias_t        stroke_antialias,
1387                             const cairo_clip_t      *clip);
1388
1389 cairo_private cairo_status_t
1390 _cairo_surface_stroke (cairo_surface_t          *surface,
1391                        cairo_operator_t          op,
1392                        const cairo_pattern_t    *source,
1393                        const cairo_path_fixed_t *path,
1394                        const cairo_stroke_style_t       *style,
1395                        const cairo_matrix_t             *ctm,
1396                        const cairo_matrix_t             *ctm_inverse,
1397                        double                    tolerance,
1398                        cairo_antialias_t         antialias,
1399                        const cairo_clip_t               *clip);
1400
1401 cairo_private cairo_status_t
1402 _cairo_surface_fill (cairo_surface_t    *surface,
1403                      cairo_operator_t    op,
1404                      const cairo_pattern_t *source,
1405                      const cairo_path_fixed_t   *path,
1406                      cairo_fill_rule_t   fill_rule,
1407                      double              tolerance,
1408                      cairo_antialias_t   antialias,
1409                      const cairo_clip_t *clip);
1410
1411 cairo_private cairo_status_t
1412 _cairo_surface_show_text_glyphs (cairo_surface_t            *surface,
1413                                  cairo_operator_t            op,
1414                                  const cairo_pattern_t      *source,
1415                                  const char                 *utf8,
1416                                  int                         utf8_len,
1417                                  cairo_glyph_t              *glyphs,
1418                                  int                         num_glyphs,
1419                                  const cairo_text_cluster_t *clusters,
1420                                  int                         num_clusters,
1421                                  cairo_text_cluster_flags_t  cluster_flags,
1422                                  cairo_scaled_font_t        *scaled_font,
1423                                  const cairo_clip_t                 *clip);
1424
1425 cairo_private cairo_status_t
1426 _cairo_surface_acquire_source_image (cairo_surface_t         *surface,
1427                                      cairo_image_surface_t  **image_out,
1428                                      void                   **image_extra);
1429
1430 cairo_private void
1431 _cairo_surface_release_source_image (cairo_surface_t        *surface,
1432                                      cairo_image_surface_t  *image,
1433                                      void                   *image_extra);
1434
1435 cairo_private cairo_surface_t *
1436 _cairo_surface_snapshot (cairo_surface_t *surface);
1437
1438 cairo_private void
1439 _cairo_surface_attach_snapshot (cairo_surface_t *surface,
1440                                 cairo_surface_t *snapshot,
1441                                 cairo_surface_func_t detach_func);
1442
1443 cairo_private cairo_surface_t *
1444 _cairo_surface_has_snapshot (cairo_surface_t *surface,
1445                              const cairo_surface_backend_t *backend);
1446
1447 cairo_private void
1448 _cairo_surface_detach_snapshot (cairo_surface_t *snapshot);
1449
1450 cairo_private cairo_status_t
1451 _cairo_surface_begin_modification (cairo_surface_t *surface);
1452
1453 cairo_private_no_warn cairo_bool_t
1454 _cairo_surface_get_extents (cairo_surface_t         *surface,
1455                             cairo_rectangle_int_t   *extents);
1456
1457 cairo_private void
1458 _cairo_surface_set_device_scale (cairo_surface_t *surface,
1459                                  double           sx,
1460                                  double           sy);
1461
1462 cairo_private cairo_bool_t
1463 _cairo_surface_has_device_transform (cairo_surface_t *surface) cairo_pure;
1464
1465 cairo_private void
1466 _cairo_surface_release_device_reference (cairo_surface_t *surface);
1467
1468 /* cairo-image-surface.c */
1469
1470 /* XXX: In cairo 1.2.0 we added a new %CAIRO_FORMAT_RGB16_565 but
1471  * neglected to adjust this macro. The net effect is that it's
1472  * impossible to externally create an image surface with this
1473  * format. This is perhaps a good thing since we also neglected to fix
1474  * up things like cairo_surface_write_to_png() for the new format
1475  * (-Wswitch-enum will tell you where). Is it obvious that format was
1476  * added in haste?
1477  *
1478  * The reason for the new format was to allow the xlib backend to be
1479  * used on X servers with a 565 visual. So the new format did its job
1480  * for that, even without being considered "valid" for the sake of
1481  * things like cairo_image_surface_create().
1482  *
1483  * Since 1.2.0 we ran into the same situtation with X servers with BGR
1484  * visuals. This time we invented #cairo_internal_format_t instead,
1485  * (see it for more discussion).
1486  *
1487  * The punchline is that %CAIRO_FORMAT_VALID must not conside any
1488  * internal format to be valid. Also we need to decide if the
1489  * RGB16_565 should be moved to instead be an internal format. If so,
1490  * this macro need not change for it. (We probably will need to leave
1491  * an RGB16_565 value in the header files for the sake of code that
1492  * might have that value in it.)
1493  *
1494  * If we do decide to start fully supporting RGB16_565 as an external
1495  * format, then %CAIRO_FORMAT_VALID needs to be adjusted to include
1496  * it. But that should not happen before all necessary code is fixed
1497  * to support it (at least cairo_surface_write_to_png() and a few spots
1498  * in cairo-xlib-surface.c--again see -Wswitch-enum).
1499  */
1500 #define CAIRO_FORMAT_VALID(format) ((format) >= CAIRO_FORMAT_ARGB32 &&          \
1501                                     (format) <= CAIRO_FORMAT_RGB30)
1502
1503 /* pixman-required stride alignment in bytes. */
1504 #define CAIRO_STRIDE_ALIGNMENT (sizeof (uint32_t))
1505 #define CAIRO_STRIDE_FOR_WIDTH_BPP(w,bpp) \
1506    ((((bpp)*(w)+7)/8 + CAIRO_STRIDE_ALIGNMENT-1) & -CAIRO_STRIDE_ALIGNMENT)
1507
1508 #define CAIRO_CONTENT_VALID(content) ((content) &&                               \
1509                                       (((content) & ~(CAIRO_CONTENT_COLOR |      \
1510                                                       CAIRO_CONTENT_ALPHA |      \
1511                                                       CAIRO_CONTENT_COLOR_ALPHA))\
1512                                        == 0))
1513
1514 cairo_private int
1515 _cairo_format_bits_per_pixel (cairo_format_t format) cairo_const;
1516
1517 cairo_private cairo_format_t
1518 _cairo_format_from_content (cairo_content_t content) cairo_const;
1519
1520 cairo_private cairo_format_t
1521 _cairo_format_from_pixman_format (pixman_format_code_t pixman_format);
1522
1523 cairo_private cairo_content_t
1524 _cairo_content_from_format (cairo_format_t format) cairo_const;
1525
1526 cairo_private cairo_content_t
1527 _cairo_content_from_pixman_format (pixman_format_code_t pixman_format);
1528
1529 cairo_private cairo_surface_t *
1530 _cairo_image_surface_create_for_pixman_image (pixman_image_t            *pixman_image,
1531                                               pixman_format_code_t       pixman_format);
1532
1533 cairo_private pixman_format_code_t
1534 _cairo_format_to_pixman_format_code (cairo_format_t format);
1535
1536 cairo_private cairo_bool_t
1537 _pixman_format_from_masks (cairo_format_masks_t *masks,
1538                            pixman_format_code_t *format_ret);
1539
1540 cairo_private cairo_bool_t
1541 _pixman_format_to_masks (pixman_format_code_t    pixman_format,
1542                          cairo_format_masks_t   *masks);
1543
1544 cairo_private void
1545 _cairo_image_scaled_glyph_fini (cairo_scaled_font_t *scaled_font,
1546                                 cairo_scaled_glyph_t *scaled_glyph);
1547
1548 cairo_private void
1549 _cairo_image_reset_static_data (void);
1550
1551 cairo_private cairo_surface_t *
1552 _cairo_image_surface_create_with_pixman_format (unsigned char           *data,
1553                                                 pixman_format_code_t     pixman_format,
1554                                                 int                      width,
1555                                                 int                      height,
1556                                                 int                      stride);
1557
1558 cairo_private cairo_surface_t *
1559 _cairo_image_surface_create_with_content (cairo_content_t       content,
1560                                           int                   width,
1561                                           int                   height);
1562
1563 cairo_private void
1564 _cairo_image_surface_assume_ownership_of_data (cairo_image_surface_t *surface);
1565
1566 cairo_private cairo_image_surface_t *
1567 _cairo_image_surface_coerce (cairo_image_surface_t      *surface);
1568
1569 cairo_private cairo_image_surface_t *
1570 _cairo_image_surface_coerce_to_format (cairo_image_surface_t    *surface,
1571                                        cairo_format_t            format);
1572
1573 cairo_private cairo_image_transparency_t
1574 _cairo_image_analyze_transparency (cairo_image_surface_t      *image);
1575
1576 cairo_private cairo_image_color_t
1577 _cairo_image_analyze_color (cairo_image_surface_t      *image);
1578
1579 /* cairo-pen.c */
1580 cairo_private int
1581 _cairo_pen_vertices_needed (double          tolerance,
1582                             double          radius,
1583                             const cairo_matrix_t  *matrix);
1584
1585 cairo_private cairo_status_t
1586 _cairo_pen_init (cairo_pen_t    *pen,
1587                  double          radius,
1588                  double          tolerance,
1589                  const cairo_matrix_t   *ctm);
1590
1591 cairo_private void
1592 _cairo_pen_init_empty (cairo_pen_t *pen);
1593
1594 cairo_private cairo_status_t
1595 _cairo_pen_init_copy (cairo_pen_t *pen, const cairo_pen_t *other);
1596
1597 cairo_private void
1598 _cairo_pen_fini (cairo_pen_t *pen);
1599
1600 cairo_private cairo_status_t
1601 _cairo_pen_add_points (cairo_pen_t *pen, cairo_point_t *point, int num_points);
1602
1603 cairo_private int
1604 _cairo_pen_find_active_cw_vertex_index (const cairo_pen_t *pen,
1605                                         const cairo_slope_t *slope);
1606
1607 cairo_private int
1608 _cairo_pen_find_active_ccw_vertex_index (const cairo_pen_t *pen,
1609                                          const cairo_slope_t *slope);
1610
1611 cairo_private void
1612 _cairo_pen_find_active_cw_vertices (const cairo_pen_t *pen,
1613                                      const cairo_slope_t *in,
1614                                      const cairo_slope_t *out,
1615                                      int *start, int *stop);
1616
1617 cairo_private void
1618 _cairo_pen_find_active_ccw_vertices (const cairo_pen_t *pen,
1619                                      const cairo_slope_t *in,
1620                                      const cairo_slope_t *out,
1621                                      int *start, int *stop);
1622
1623 /* cairo-polygon.c */
1624 cairo_private void
1625 _cairo_polygon_init (cairo_polygon_t   *polygon,
1626                      const cairo_box_t *boxes,
1627                      int                num_boxes);
1628
1629 cairo_private void
1630 _cairo_polygon_init_with_clip (cairo_polygon_t *polygon,
1631                                const cairo_clip_t *clip);
1632
1633 cairo_private cairo_status_t
1634 _cairo_polygon_init_boxes (cairo_polygon_t *polygon,
1635                            const cairo_boxes_t *boxes);
1636
1637 cairo_private cairo_status_t
1638 _cairo_polygon_init_box_array (cairo_polygon_t *polygon,
1639                                cairo_box_t *boxes,
1640                                int num_boxes);
1641
1642 cairo_private void
1643 _cairo_polygon_limit (cairo_polygon_t *polygon,
1644                      const cairo_box_t *limits,
1645                      int num_limits);
1646
1647 cairo_private void
1648 _cairo_polygon_limit_to_clip (cairo_polygon_t *polygon,
1649                               const cairo_clip_t *clip);
1650
1651 cairo_private void
1652 _cairo_polygon_fini (cairo_polygon_t *polygon);
1653
1654 cairo_private cairo_status_t
1655 _cairo_polygon_add_line (cairo_polygon_t *polygon,
1656                          const cairo_line_t *line,
1657                          int top, int bottom,
1658                          int dir);
1659
1660 cairo_private cairo_status_t
1661 _cairo_polygon_add_external_edge (void *polygon,
1662                                   const cairo_point_t *p1,
1663                                   const cairo_point_t *p2);
1664
1665 cairo_private cairo_status_t
1666 _cairo_polygon_add_contour (cairo_polygon_t *polygon,
1667                             const cairo_contour_t *contour);
1668
1669 cairo_private void
1670 _cairo_polygon_translate (cairo_polygon_t *polygon, int dx, int dy);
1671
1672 cairo_private cairo_status_t
1673 _cairo_polygon_reduce (cairo_polygon_t *polygon,
1674                        cairo_fill_rule_t fill_rule);
1675
1676 cairo_private cairo_status_t
1677 _cairo_polygon_intersect (cairo_polygon_t *a, int winding_a,
1678                           cairo_polygon_t *b, int winding_b);
1679
1680 cairo_private cairo_status_t
1681 _cairo_polygon_intersect_with_boxes (cairo_polygon_t *polygon,
1682                                      cairo_fill_rule_t *winding,
1683                                      cairo_box_t *boxes,
1684                                      int num_boxes);
1685
1686 static inline cairo_bool_t
1687 _cairo_polygon_is_empty (const cairo_polygon_t *polygon)
1688 {
1689     return
1690         polygon->num_edges == 0 ||
1691         polygon->extents.p2.x <= polygon->extents.p1.x;
1692 }
1693
1694 #define _cairo_polygon_status(P) ((cairo_polygon_t *) (P))->status
1695
1696 /* cairo-spline.c */
1697 cairo_private cairo_bool_t
1698 _cairo_spline_init (cairo_spline_t *spline,
1699                     cairo_spline_add_point_func_t add_point_func,
1700                     void *closure,
1701                     const cairo_point_t *a, const cairo_point_t *b,
1702                     const cairo_point_t *c, const cairo_point_t *d);
1703
1704 cairo_private cairo_status_t
1705 _cairo_spline_decompose (cairo_spline_t *spline, double tolerance);
1706
1707 cairo_private cairo_status_t
1708 _cairo_spline_bound (cairo_spline_add_point_func_t add_point_func,
1709                      void *closure,
1710                      const cairo_point_t *p0, const cairo_point_t *p1,
1711                      const cairo_point_t *p2, const cairo_point_t *p3);
1712
1713 /* cairo-matrix.c */
1714 cairo_private void
1715 _cairo_matrix_get_affine (const cairo_matrix_t *matrix,
1716                           double *xx, double *yx,
1717                           double *xy, double *yy,
1718                           double *x0, double *y0);
1719
1720 cairo_private void
1721 _cairo_matrix_transform_bounding_box (const cairo_matrix_t *matrix,
1722                                       double *x1, double *y1,
1723                                       double *x2, double *y2,
1724                                       cairo_bool_t *is_tight);
1725
1726 cairo_private void
1727 _cairo_matrix_transform_bounding_box_fixed (const cairo_matrix_t *matrix,
1728                                             cairo_box_t          *bbox,
1729                                             cairo_bool_t         *is_tight);
1730
1731 cairo_private cairo_bool_t
1732 _cairo_matrix_is_invertible (const cairo_matrix_t *matrix) cairo_pure;
1733
1734 cairo_private cairo_bool_t
1735 _cairo_matrix_is_scale_0 (const cairo_matrix_t *matrix) cairo_pure;
1736
1737 cairo_private double
1738 _cairo_matrix_compute_determinant (const cairo_matrix_t *matrix) cairo_pure;
1739
1740 cairo_private cairo_status_t
1741 _cairo_matrix_compute_basis_scale_factors (const cairo_matrix_t *matrix,
1742                                            double *sx, double *sy, int x_major);
1743
1744 static inline cairo_bool_t
1745 _cairo_matrix_is_identity (const cairo_matrix_t *matrix)
1746 {
1747     return (matrix->xx == 1.0 && matrix->yx == 0.0 &&
1748             matrix->xy == 0.0 && matrix->yy == 1.0 &&
1749             matrix->x0 == 0.0 && matrix->y0 == 0.0);
1750 }
1751
1752 static inline cairo_bool_t
1753 _cairo_matrix_is_translation (const cairo_matrix_t *matrix)
1754 {
1755     return (matrix->xx == 1.0 && matrix->yx == 0.0 &&
1756             matrix->xy == 0.0 && matrix->yy == 1.0);
1757 }
1758
1759 static inline cairo_bool_t
1760 _cairo_matrix_is_scale (const cairo_matrix_t *matrix)
1761 {
1762     return matrix->yx == 0.0 && matrix->xy == 0.0;
1763 }
1764
1765 cairo_private cairo_bool_t
1766 _cairo_matrix_is_integer_translation(const cairo_matrix_t *matrix,
1767                                      int *itx, int *ity);
1768
1769 cairo_private cairo_bool_t
1770 _cairo_matrix_has_unity_scale (const cairo_matrix_t *matrix);
1771
1772 cairo_private cairo_bool_t
1773 _cairo_matrix_is_pixel_exact (const cairo_matrix_t *matrix) cairo_pure;
1774
1775 cairo_private double
1776 _cairo_matrix_transformed_circle_major_axis (const cairo_matrix_t *matrix,
1777                                              double radius) cairo_pure;
1778
1779 cairo_private cairo_bool_t
1780 _cairo_matrix_is_pixman_translation (const cairo_matrix_t     *matrix,
1781                                      cairo_filter_t            filter,
1782                                      int                      *out_x_offset,
1783                                      int                      *out_y_offset);
1784
1785 cairo_private cairo_status_t
1786 _cairo_matrix_to_pixman_matrix_offset (const cairo_matrix_t     *matrix,
1787                                        cairo_filter_t            filter,
1788                                        double                    xc,
1789                                        double                    yc,
1790                                        pixman_transform_t       *out_transform,
1791                                        int                      *out_x_offset,
1792                                        int                      *out_y_offset);
1793
1794 cairo_private cairo_status_t
1795 _cairo_bentley_ottmann_tessellate_rectilinear_polygon (cairo_traps_t     *traps,
1796                                                        const cairo_polygon_t *polygon,
1797                                                        cairo_fill_rule_t          fill_rule);
1798
1799 cairo_private cairo_status_t
1800 _cairo_bentley_ottmann_tessellate_polygon (cairo_traps_t         *traps,
1801                                            const cairo_polygon_t *polygon,
1802                                            cairo_fill_rule_t      fill_rule);
1803
1804 cairo_private cairo_status_t
1805 _cairo_bentley_ottmann_tessellate_traps (cairo_traps_t *traps,
1806                                          cairo_fill_rule_t fill_rule);
1807
1808 cairo_private cairo_status_t
1809 _cairo_bentley_ottmann_tessellate_rectangular_traps (cairo_traps_t *traps,
1810                                                      cairo_fill_rule_t fill_rule);
1811
1812 cairo_private cairo_status_t
1813 _cairo_bentley_ottmann_tessellate_boxes (const cairo_boxes_t *in,
1814                                          cairo_fill_rule_t fill_rule,
1815                                          cairo_boxes_t *out);
1816
1817 cairo_private cairo_status_t
1818 _cairo_bentley_ottmann_tessellate_rectilinear_traps (cairo_traps_t *traps,
1819                                                      cairo_fill_rule_t fill_rule);
1820
1821 cairo_private cairo_status_t
1822 _cairo_bentley_ottmann_tessellate_rectilinear_polygon_to_boxes (const cairo_polygon_t *polygon,
1823                                                                 cairo_fill_rule_t fill_rule,
1824                                                                 cairo_boxes_t *boxes);
1825
1826 cairo_private void
1827 _cairo_trapezoid_array_translate_and_scale (cairo_trapezoid_t *offset_traps,
1828                                             cairo_trapezoid_t *src_traps,
1829                                             int num_traps,
1830                                             double tx, double ty,
1831                                             double sx, double sy);
1832
1833 #if CAIRO_HAS_DRM_SURFACE
1834
1835 cairo_private void
1836 _cairo_drm_device_reset_static_data (void);
1837
1838 #endif
1839
1840 cairo_private void
1841 _cairo_clip_reset_static_data (void);
1842
1843 cairo_private void
1844 _cairo_pattern_reset_static_data (void);
1845
1846 /* cairo-unicode.c */
1847
1848 cairo_private int
1849 _cairo_utf8_get_char_validated (const char *p,
1850                                 uint32_t   *unicode);
1851
1852 cairo_private cairo_status_t
1853 _cairo_utf8_to_ucs4 (const char *str,
1854                      int         len,
1855                      uint32_t  **result,
1856                      int        *items_written);
1857
1858 cairo_private int
1859 _cairo_ucs4_to_utf8 (uint32_t    unicode,
1860                      char       *utf8);
1861
1862 #if CAIRO_HAS_WIN32_FONT || CAIRO_HAS_QUARTZ_FONT || CAIRO_HAS_PDF_OPERATORS
1863 # define CAIRO_HAS_UTF8_TO_UTF16 1
1864 #endif
1865 #if CAIRO_HAS_UTF8_TO_UTF16
1866 cairo_private cairo_status_t
1867 _cairo_utf8_to_utf16 (const char *str,
1868                       int         len,
1869                       uint16_t  **result,
1870                       int        *items_written);
1871 #endif
1872
1873 cairo_private void
1874 _cairo_matrix_multiply (cairo_matrix_t *r,
1875                         const cairo_matrix_t *a,
1876                         const cairo_matrix_t *b);
1877
1878 /* cairo-observer.c */
1879
1880 cairo_private void
1881 _cairo_observers_notify (cairo_list_t *observers, void *arg);
1882
1883 /* Avoid unnecessary PLT entries.  */
1884 slim_hidden_proto (cairo_clip_preserve);
1885 slim_hidden_proto (cairo_close_path);
1886 slim_hidden_proto (cairo_create);
1887 slim_hidden_proto (cairo_curve_to);
1888 slim_hidden_proto (cairo_destroy);
1889 slim_hidden_proto (cairo_fill_preserve);
1890 slim_hidden_proto (cairo_font_face_destroy);
1891 slim_hidden_proto (cairo_font_face_get_user_data);
1892 slim_hidden_proto_no_warn (cairo_font_face_reference);
1893 slim_hidden_proto (cairo_font_face_set_user_data);
1894 slim_hidden_proto (cairo_font_options_equal);
1895 slim_hidden_proto (cairo_font_options_hash);
1896 slim_hidden_proto (cairo_font_options_merge);
1897 slim_hidden_proto (cairo_font_options_set_antialias);
1898 slim_hidden_proto (cairo_font_options_set_font_color);
1899 slim_hidden_proto (cairo_font_options_set_hint_metrics);
1900 slim_hidden_proto (cairo_font_options_set_hint_style);
1901 slim_hidden_proto (cairo_font_options_set_subpixel_order);
1902 slim_hidden_proto (cairo_font_options_status);
1903 slim_hidden_proto (cairo_format_stride_for_width);
1904 slim_hidden_proto (cairo_get_current_point);
1905 slim_hidden_proto (cairo_get_line_width);
1906 slim_hidden_proto (cairo_get_matrix);
1907 slim_hidden_proto (cairo_get_scaled_font);
1908 slim_hidden_proto (cairo_get_target);
1909 slim_hidden_proto (cairo_get_tolerance);
1910 slim_hidden_proto (cairo_glyph_allocate);
1911 slim_hidden_proto (cairo_glyph_free);
1912 slim_hidden_proto (cairo_image_surface_create);
1913 slim_hidden_proto (cairo_image_surface_create_for_data);
1914 slim_hidden_proto (cairo_image_surface_get_data);
1915 slim_hidden_proto (cairo_image_surface_get_format);
1916 slim_hidden_proto (cairo_image_surface_get_height);
1917 slim_hidden_proto (cairo_image_surface_get_stride);
1918 slim_hidden_proto (cairo_image_surface_get_width);
1919 slim_hidden_proto (cairo_line_to);
1920 slim_hidden_proto (cairo_mask);
1921 slim_hidden_proto (cairo_matrix_init);
1922 slim_hidden_proto (cairo_matrix_init_identity);
1923 slim_hidden_proto (cairo_matrix_init_rotate);
1924 slim_hidden_proto (cairo_matrix_init_scale);
1925 slim_hidden_proto (cairo_matrix_init_translate);
1926 slim_hidden_proto (cairo_matrix_invert);
1927 slim_hidden_proto (cairo_matrix_multiply);
1928 slim_hidden_proto (cairo_matrix_scale);
1929 slim_hidden_proto (cairo_matrix_transform_distance);
1930 slim_hidden_proto (cairo_matrix_transform_point);
1931 slim_hidden_proto (cairo_matrix_translate);
1932 slim_hidden_proto (cairo_move_to);
1933 slim_hidden_proto (cairo_new_path);
1934 slim_hidden_proto (cairo_paint);
1935 slim_hidden_proto (cairo_pattern_add_color_stop_rgba);
1936 slim_hidden_proto (cairo_pattern_create_for_surface);
1937 slim_hidden_proto (cairo_pattern_create_rgb);
1938 slim_hidden_proto (cairo_pattern_create_rgba);
1939 slim_hidden_proto (cairo_pattern_destroy);
1940 slim_hidden_proto (cairo_pattern_get_extend);
1941 slim_hidden_proto (cairo_mesh_pattern_curve_to);
1942 slim_hidden_proto (cairo_mesh_pattern_get_control_point);
1943 slim_hidden_proto (cairo_mesh_pattern_get_corner_color_rgba);
1944 slim_hidden_proto (cairo_mesh_pattern_get_patch_count);
1945 slim_hidden_proto (cairo_mesh_pattern_get_path);
1946 slim_hidden_proto (cairo_mesh_pattern_line_to);
1947 slim_hidden_proto (cairo_mesh_pattern_move_to);
1948 slim_hidden_proto (cairo_mesh_pattern_set_corner_color_rgba);
1949 slim_hidden_proto_no_warn (cairo_pattern_reference);
1950 slim_hidden_proto (cairo_pattern_set_matrix);
1951 slim_hidden_proto (cairo_pop_group);
1952 slim_hidden_proto (cairo_push_group_with_content);
1953 slim_hidden_proto_no_warn (cairo_path_destroy);
1954 slim_hidden_proto (cairo_recording_surface_create);
1955 slim_hidden_proto (cairo_rel_line_to);
1956 slim_hidden_proto (cairo_restore);
1957 slim_hidden_proto (cairo_save);
1958 slim_hidden_proto (cairo_scale);
1959 slim_hidden_proto (cairo_scaled_font_create);
1960 slim_hidden_proto (cairo_scaled_font_destroy);
1961 slim_hidden_proto (cairo_scaled_font_extents);
1962 slim_hidden_proto (cairo_scaled_font_get_ctm);
1963 slim_hidden_proto (cairo_scaled_font_get_font_face);
1964 slim_hidden_proto (cairo_scaled_font_get_font_matrix);
1965 slim_hidden_proto (cairo_scaled_font_get_font_options);
1966 slim_hidden_proto (cairo_scaled_font_glyph_extents);
1967 slim_hidden_proto_no_warn (cairo_scaled_font_reference);
1968 slim_hidden_proto (cairo_scaled_font_status);
1969 slim_hidden_proto (cairo_scaled_font_get_user_data);
1970 slim_hidden_proto (cairo_scaled_font_set_user_data);
1971 slim_hidden_proto (cairo_scaled_font_text_to_glyphs);
1972 slim_hidden_proto (cairo_set_font_matrix);
1973 slim_hidden_proto (cairo_set_font_options);
1974 slim_hidden_proto (cairo_set_font_size);
1975 slim_hidden_proto (cairo_set_line_cap);
1976 slim_hidden_proto (cairo_set_line_join);
1977 slim_hidden_proto (cairo_set_line_width);
1978 slim_hidden_proto (cairo_set_matrix);
1979 slim_hidden_proto (cairo_set_operator);
1980 slim_hidden_proto (cairo_set_source);
1981 slim_hidden_proto (cairo_set_source_rgb);
1982 slim_hidden_proto (cairo_set_source_surface);
1983 slim_hidden_proto (cairo_set_tolerance);
1984 slim_hidden_proto (cairo_status);
1985 slim_hidden_proto (cairo_stroke);
1986 slim_hidden_proto (cairo_stroke_preserve);
1987 slim_hidden_proto (cairo_surface_copy_page);
1988 slim_hidden_proto (cairo_surface_create_similar_image);
1989 slim_hidden_proto (cairo_surface_destroy);
1990 slim_hidden_proto (cairo_surface_finish);
1991 slim_hidden_proto (cairo_surface_flush);
1992 slim_hidden_proto (cairo_surface_get_device_offset);
1993 slim_hidden_proto (cairo_surface_get_font_options);
1994 slim_hidden_proto (cairo_surface_get_mime_data);
1995 slim_hidden_proto (cairo_surface_has_show_text_glyphs);
1996 slim_hidden_proto (cairo_surface_mark_dirty);
1997 slim_hidden_proto (cairo_surface_mark_dirty_rectangle);
1998 slim_hidden_proto_no_warn (cairo_surface_reference);
1999 slim_hidden_proto (cairo_surface_set_device_offset);
2000 slim_hidden_proto (cairo_surface_set_fallback_resolution);
2001 slim_hidden_proto (cairo_surface_set_mime_data);
2002 slim_hidden_proto (cairo_surface_show_page);
2003 slim_hidden_proto (cairo_surface_status);
2004 slim_hidden_proto (cairo_surface_supports_mime_type);
2005 slim_hidden_proto (cairo_text_cluster_allocate);
2006 slim_hidden_proto (cairo_text_cluster_free);
2007 slim_hidden_proto (cairo_toy_font_face_create);
2008 slim_hidden_proto (cairo_toy_font_face_get_slant);
2009 slim_hidden_proto (cairo_toy_font_face_get_weight);
2010 slim_hidden_proto (cairo_translate);
2011 slim_hidden_proto (cairo_transform);
2012 slim_hidden_proto (cairo_user_font_face_create);
2013 slim_hidden_proto (cairo_user_font_face_set_init_func);
2014 slim_hidden_proto (cairo_user_font_face_set_render_glyph_func);
2015 slim_hidden_proto (cairo_user_font_face_set_unicode_to_glyph_func);
2016 slim_hidden_proto (cairo_device_to_user);
2017 slim_hidden_proto (cairo_user_to_device);
2018 slim_hidden_proto (cairo_user_to_device_distance);
2019 slim_hidden_proto (cairo_version_string);
2020 slim_hidden_proto (cairo_region_create);
2021 slim_hidden_proto (cairo_region_create_rectangle);
2022 slim_hidden_proto (cairo_region_create_rectangles);
2023 slim_hidden_proto (cairo_region_copy);
2024 slim_hidden_proto (cairo_region_reference);
2025 slim_hidden_proto (cairo_region_destroy);
2026 slim_hidden_proto (cairo_region_equal);
2027 slim_hidden_proto (cairo_region_status);
2028 slim_hidden_proto (cairo_region_get_extents);
2029 slim_hidden_proto (cairo_region_num_rectangles);
2030 slim_hidden_proto (cairo_region_get_rectangle);
2031 slim_hidden_proto (cairo_region_is_empty);
2032 slim_hidden_proto (cairo_region_contains_rectangle);
2033 slim_hidden_proto (cairo_region_contains_point);
2034 slim_hidden_proto (cairo_region_translate);
2035 slim_hidden_proto (cairo_region_subtract);
2036 slim_hidden_proto (cairo_region_subtract_rectangle);
2037 slim_hidden_proto (cairo_region_intersect);
2038 slim_hidden_proto (cairo_region_intersect_rectangle);
2039 slim_hidden_proto (cairo_region_union);
2040 slim_hidden_proto (cairo_region_union_rectangle);
2041 slim_hidden_proto (cairo_region_xor);
2042 slim_hidden_proto (cairo_region_xor_rectangle);
2043
2044 slim_hidden_proto (cairo_set_shadow);
2045 slim_hidden_proto (cairo_set_shadow_offset);
2046 slim_hidden_proto (cairo_set_shadow_rgba);
2047 slim_hidden_proto (cairo_set_shadow_rgb);
2048 slim_hidden_proto (cairo_set_shadow_blur);
2049 slim_hidden_proto (cairo_set_draw_shadow_only);
2050 slim_hidden_proto (cairo_shadow_enable_cache);
2051 slim_hidden_proto (cairo_set_path_is_inset_shadow_with_spread);
2052 #if CAIRO_HAS_PNG_FUNCTIONS
2053
2054 slim_hidden_proto (cairo_surface_write_to_png_stream);
2055
2056 #endif
2057
2058 cairo_private_no_warn cairo_filter_t
2059 _cairo_pattern_analyze_filter (const cairo_pattern_t    *pattern,
2060                                double                   *pad_out);
2061
2062 CAIRO_END_DECLS
2063
2064 #include "cairo-mutex-private.h"
2065 #include "cairo-fixed-private.h"
2066 #include "cairo-wideint-private.h"
2067 #include "cairo-malloc-private.h"
2068 #include "cairo-hash-private.h"
2069
2070 #if HAVE_VALGRIND
2071 #include <memcheck.h>
2072
2073 #define VG(x) x
2074
2075 cairo_private void
2076 _cairo_debug_check_image_surface_is_defined (const cairo_surface_t *surface);
2077
2078 #else
2079
2080 #define VG(x)
2081 #define _cairo_debug_check_image_surface_is_defined(X)
2082
2083 #endif
2084
2085 cairo_private void
2086 _cairo_debug_print_path (FILE *stream, cairo_path_fixed_t *path);
2087
2088 cairo_private void
2089 _cairo_debug_print_polygon (FILE *stream, cairo_polygon_t *polygon);
2090
2091 cairo_private void
2092 _cairo_debug_print_traps (FILE *file, const cairo_traps_t *traps);
2093
2094 cairo_private void
2095 _cairo_debug_print_clip (FILE *stream, const cairo_clip_t *clip);
2096
2097 #if 0
2098 #define TRACE(x) fprintf (stderr, "%s: ", __FILE__), fprintf x
2099 #define TRACE_(x) x
2100 #else
2101 #define TRACE(x)
2102 #define TRACE_(x)
2103 #endif
2104
2105 #endif