1
/* -*- Mode: c; tab-width: 8; c-basic-offset: 4; indent-tabs-mode: t; -*- */
2
/* cairo - a vector graphics library with display and print output
3
 *
4
 * Copyright © 2002 University of Southern California
5
 * Copyright © 2005 Red Hat, Inc.
6
 *
7
 * This library is free software; you can redistribute it and/or
8
 * modify it either under the terms of the GNU Lesser General Public
9
 * License version 2.1 as published by the Free Software Foundation
10
 * (the "LGPL") or, at your option, under the terms of the Mozilla
11
 * Public License Version 1.1 (the "MPL"). If you do not alter this
12
 * notice, a recipient may use your version of this file under either
13
 * the MPL or the LGPL.
14
 *
15
 * You should have received a copy of the LGPL along with this library
16
 * in the file COPYING-LGPL-2.1; if not, write to the Free Software
17
 * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
18
 * You should have received a copy of the MPL along with this library
19
 * in the file COPYING-MPL-1.1
20
 *
21
 * The contents of this file are subject to the Mozilla Public License
22
 * Version 1.1 (the "License"); you may not use this file except in
23
 * compliance with the License. You may obtain a copy of the License at
24
 * http://www.mozilla.org/MPL/
25
 *
26
 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
27
 * OF ANY KIND, either express or implied. See the LGPL or the MPL for
28
 * the specific language governing rights and limitations.
29
 *
30
 * The Original Code is the cairo graphics library.
31
 *
32
 * The Initial Developer of the Original Code is University of Southern
33
 * California.
34
 *
35
 * Contributor(s):
36
 *	Carl D. Worth <cworth@cworth.org>
37
 */
38

            
39
/*
40
 * These definitions are solely for use by the implementation of cairo
41
 * and constitute no kind of standard.  If you need any of these
42
 * functions, please drop me a note.  Either the library needs new
43
 * functionality, or there's a way to do what you need using the
44
 * existing published interfaces. cworth@cworth.org
45
 */
46

            
47
#ifndef _CAIROINT_H_
48
#define _CAIROINT_H_
49

            
50
#include "config.h"
51

            
52
#include <assert.h>
53
#include <stdlib.h>
54
#include <string.h>
55
#include <stdarg.h>
56
#include <stddef.h>
57

            
58
#ifdef _MSC_VER
59
#define _USE_MATH_DEFINES
60
#endif
61
#include <math.h>
62
#include <limits.h>
63
#include <stdio.h>
64

            
65
#include "cairo.h"
66
#include <pixman.h>
67

            
68
#include "cairo-compiler-private.h"
69
#include "cairo-error-private.h"
70

            
71
#if CAIRO_HAS_PDF_SURFACE    || \
72
    CAIRO_HAS_PS_SURFACE     || \
73
    CAIRO_HAS_SCRIPT_SURFACE
74
#define CAIRO_HAS_DEFLATE_STREAM 1
75
#endif
76

            
77
#if CAIRO_HAS_PS_SURFACE  || \
78
    CAIRO_HAS_PDF_SURFACE || \
79
    CAIRO_HAS_SVG_SURFACE || \
80
    CAIRO_HAS_WIN32_SURFACE
81
#define CAIRO_HAS_FONT_SUBSET 1
82
#endif
83

            
84
#if CAIRO_HAS_PS_SURFACE  || \
85
    CAIRO_HAS_PDF_SURFACE || \
86
    CAIRO_HAS_FONT_SUBSET
87
#define CAIRO_HAS_PDF_OPERATORS 1
88
#endif
89

            
90
CAIRO_BEGIN_DECLS
91

            
92
#undef MIN
93
#define MIN(a, b) ((a) < (b) ? (a) : (b))
94

            
95
#undef MAX
96
#define MAX(a, b) ((a) > (b) ? (a) : (b))
97

            
98
#if _XOPEN_SOURCE >= 600 || defined (_ISOC99_SOURCE)
99
#define ISFINITE(x) isfinite (x)
100
#else
101
#define ISFINITE(x) ((x) * (x) >= 0.) /* check for NaNs */
102
#endif
103

            
104
#ifndef FALSE
105
#define FALSE 0
106
#endif
107

            
108
#ifndef TRUE
109
#define TRUE 1
110
#endif
111

            
112
#ifndef M_PI
113
#define M_PI 3.14159265358979323846
114
#endif
115

            
116
#ifndef M_SQRT2
117
#define M_SQRT2 1.41421356237309504880
118
#endif
119

            
120
#ifndef M_SQRT1_2
121
#define M_SQRT1_2 0.707106781186547524400844362104849039
122
#endif
123

            
124
#undef  ARRAY_LENGTH
125
#define ARRAY_LENGTH(__array) ((int) (sizeof (__array) / sizeof (__array[0])))
126

            
127
#undef STRINGIFY
128
#undef STRINGIFY_ARG
129
#define STRINGIFY(macro_or_string)    STRINGIFY_ARG (macro_or_string)
130
#define STRINGIFY_ARG(contents)       #contents
131

            
132
#if defined (__GNUC__)
133
#define cairo_container_of(ptr, type, member) ({ \
134
    const __typeof__ (((type *) 0)->member) *mptr__ = (ptr); \
135
    (type *) ((char *) mptr__ - offsetof (type, member)); \
136
})
137
#else
138
#define cairo_container_of(ptr, type, member) \
139
    ((type *)((char *) (ptr) - (char *) &((type *)0)->member))
140
#endif
141

            
142

            
143
#define ASSERT_NOT_REACHED		\
144
do {					\
145
    assert (!"reached");		\
146
} while (0)
147
#define COMPILE_TIME_ASSERT1(condition, line)		\
148
    typedef int compile_time_assertion_at_line_##line##_failed [(condition)?1:-1]
149
#define COMPILE_TIME_ASSERT0(condition, line)	COMPILE_TIME_ASSERT1(condition, line)
150
#define COMPILE_TIME_ASSERT(condition)		COMPILE_TIME_ASSERT0(condition, __LINE__)
151

            
152
#define CAIRO_ALPHA_IS_CLEAR(alpha) ((alpha) <= ((double)0x00ff / (double)0xffff))
153
#define CAIRO_ALPHA_SHORT_IS_CLEAR(alpha) ((alpha) <= 0x00ff)
154

            
155
#define CAIRO_ALPHA_IS_OPAQUE(alpha) ((alpha) >= ((double)0xff00 / (double)0xffff))
156
#define CAIRO_ALPHA_SHORT_IS_OPAQUE(alpha) ((alpha) >= 0xff00)
157
#define CAIRO_ALPHA_IS_ZERO(alpha) ((alpha) <= 0.0)
158

            
159
#define CAIRO_COLOR_IS_CLEAR(color) CAIRO_ALPHA_SHORT_IS_CLEAR ((color)->alpha_short)
160
#define CAIRO_COLOR_IS_OPAQUE(color) CAIRO_ALPHA_SHORT_IS_OPAQUE ((color)->alpha_short)
161

            
162
/* Reverse the bits in a byte with 7 operations (no 64-bit):
163
 * Devised by Sean Anderson, July 13, 2001.
164
 * Source: http://graphics.stanford.edu/~seander/bithacks.html#ReverseByteWith32Bits
165
 */
166
#define CAIRO_BITSWAP8(c) ((((c) * 0x0802LU & 0x22110LU) | ((c) * 0x8020LU & 0x88440LU)) * 0x10101LU >> 16)
167

            
168
/* Return the number of 1 bits in mask.
169
 *
170
 * GCC 3.4 supports a "population count" builtin, which on many targets is
171
 * implemented with a single instruction. There is a fallback definition
172
 * in libgcc in case a target does not have one, which should be just as
173
 * good as the open-coded solution below, (which is "HACKMEM 169").
174
 */
175
static inline int cairo_const
176
412
_cairo_popcount (uint32_t mask)
177
{
178
#if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)
179
412
    return __builtin_popcount (mask);
180
#else
181
    register int y;
182

            
183
    y = (mask >> 1) &033333333333;
184
    y = mask - y - ((y >>1) & 033333333333);
185
    return (((y + (y >> 3)) & 030707070707) % 077);
186
#endif
187
}
188

            
189
static cairo_always_inline cairo_bool_t
190
_cairo_is_little_endian (void)
191
{
192
    static const int i = 1;
193
3
    return *((char *) &i) == 0x01;
194
}
195

            
196
#ifdef WORDS_BIGENDIAN
197
#define CAIRO_BITSWAP8_IF_LITTLE_ENDIAN(c) (c)
198
#else
199
#define CAIRO_BITSWAP8_IF_LITTLE_ENDIAN(c) CAIRO_BITSWAP8(c)
200
#endif
201

            
202
#ifdef WORDS_BIGENDIAN
203

            
204
#define cpu_to_be16(v) (v)
205
#define be16_to_cpu(v) (v)
206
#define cpu_to_be32(v) (v)
207
#define be32_to_cpu(v) (v)
208

            
209
#else
210

            
211
static inline uint16_t cairo_const
212
cpu_to_be16(uint16_t v)
213
{
214
    return (v << 8) | (v >> 8);
215
}
216

            
217
static inline uint16_t cairo_const
218
be16_to_cpu(uint16_t v)
219
{
220
    return cpu_to_be16 (v);
221
}
222

            
223
static inline uint32_t cairo_const
224
cpu_to_be32(uint32_t v)
225
{
226
    return (v >> 24) | ((v >> 8) & 0xff00) | ((v << 8) & 0xff0000) | (v << 24);
227
}
228

            
229
static inline uint32_t cairo_const
230
be32_to_cpu(uint32_t v)
231
{
232
    return cpu_to_be32 (v);
233
}
234

            
235
#endif
236

            
237
/* Unaligned big endian access
238
 */
239

            
240
static inline uint16_t get_unaligned_be16 (const unsigned char *p)
241
{
242
    return p[0] << 8 | p[1];
243
}
244

            
245
static inline uint32_t get_unaligned_be32 (const unsigned char *p)
246
{
247
    return (uint32_t)p[0] << 24 | p[1] << 16 | p[2] << 8 | p[3];
248
}
249

            
250
static inline void put_unaligned_be16 (uint16_t v, unsigned char *p)
251
{
252
    p[0] = (v >> 8) & 0xff;
253
    p[1] = v & 0xff;
254
}
255

            
256
static inline void put_unaligned_be32 (uint32_t v, unsigned char *p)
257
{
258
    p[0] = (v >> 24) & 0xff;
259
    p[1] = (v >> 16) & 0xff;
260
    p[2] = (v >> 8)  & 0xff;
261
    p[3] = v & 0xff;
262
}
263

            
264
#include "cairo-ctype-inline.h"
265
#include "cairo-types-private.h"
266
#include "cairo-cache-private.h"
267
#include "cairo-reference-count-private.h"
268
#include "cairo-spans-private.h"
269
#include "cairo-surface-private.h"
270

            
271
cairo_private void
272
_cairo_box_from_doubles (cairo_box_t *box,
273
			 double *x1, double *y1,
274
			 double *x2, double *y2);
275

            
276
cairo_private void
277
_cairo_box_to_doubles (const cairo_box_t *box,
278
		       double *x1, double *y1,
279
		       double *x2, double *y2);
280

            
281
cairo_private void
282
_cairo_box_from_rectangle (cairo_box_t                 *box,
283
			   const cairo_rectangle_int_t *rectangle);
284

            
285
cairo_private void
286
_cairo_box_round_to_rectangle (const cairo_box_t     *box,
287
			       cairo_rectangle_int_t *rectangle);
288

            
289
cairo_private void
290
_cairo_box_add_curve_to (cairo_box_t         *extents,
291
			 const cairo_point_t *a,
292
			 const cairo_point_t *b,
293
			 const cairo_point_t *c,
294
			 const cairo_point_t *d);
295

            
296
cairo_private void
297
_cairo_boxes_get_extents (const cairo_box_t *boxes,
298
			  int num_boxes,
299
			  cairo_box_t *extents);
300

            
301
cairo_private extern const cairo_rectangle_int_t _cairo_empty_rectangle;
302
cairo_private extern const cairo_rectangle_int_t _cairo_unbounded_rectangle;
303

            
304
static inline void
305
2213006
_cairo_unbounded_rectangle_init (cairo_rectangle_int_t *rect)
306
{
307
2213006
    *rect = _cairo_unbounded_rectangle;
308
2213006
}
309

            
310
cairo_private_no_warn cairo_bool_t
311
_cairo_rectangle_intersect (cairo_rectangle_int_t *dst,
312
			    const cairo_rectangle_int_t *src);
313

            
314
static inline cairo_bool_t
315
417930
_cairo_rectangle_intersects (const cairo_rectangle_int_t *dst,
316
			     const cairo_rectangle_int_t *src)
317
{
318
835860
    return !(src->x >= dst->x + dst->width  ||
319
417930
	     src->x + src->width <= dst->x  ||
320
417924
	     src->y >= dst->y + dst->height ||
321
417924
	     src->y + src->height <= dst->y);
322
}
323

            
324
static inline cairo_bool_t
325
1203214
_cairo_rectangle_contains_rectangle (const cairo_rectangle_int_t *a,
326
				     const cairo_rectangle_int_t *b)
327
{
328
2302901
    return (a->x <= b->x &&
329
1099687
	    a->x + a->width >= b->x + b->width &&
330
3391578
	    a->y <= b->y &&
331
1088677
	    a->y + a->height >= b->y + b->height);
332
}
333

            
334
cairo_private void
335
_cairo_rectangle_int_from_double (cairo_rectangle_int_t *recti,
336
				  const cairo_rectangle_t *rectf);
337

            
338
/* Extends the dst rectangle to also contain src.
339
 * If one of the rectangles is empty, the result is undefined
340
 */
341
cairo_private void
342
_cairo_rectangle_union (cairo_rectangle_int_t *dst,
343
			const cairo_rectangle_int_t *src);
344

            
345
cairo_private cairo_bool_t
346
_cairo_box_intersects_line_segment (const cairo_box_t *box,
347
	                            cairo_line_t *line) cairo_pure;
348

            
349
cairo_private cairo_bool_t
350
_cairo_spline_intersects (const cairo_point_t *a,
351
			  const cairo_point_t *b,
352
			  const cairo_point_t *c,
353
			  const cairo_point_t *d,
354
			  const cairo_box_t *box) cairo_pure;
355

            
356
typedef struct {
357
    const cairo_user_data_key_t *key;
358
    void *user_data;
359
    cairo_destroy_func_t destroy;
360
} cairo_user_data_slot_t;
361

            
362
cairo_private void
363
_cairo_user_data_array_init (cairo_user_data_array_t *array);
364

            
365
cairo_private void
366
_cairo_user_data_array_fini (cairo_user_data_array_t *array);
367

            
368
cairo_private void *
369
_cairo_user_data_array_get_data (cairo_user_data_array_t     *array,
370
				 const cairo_user_data_key_t *key);
371

            
372
cairo_private cairo_status_t
373
_cairo_user_data_array_set_data (cairo_user_data_array_t     *array,
374
				 const cairo_user_data_key_t *key,
375
				 void			     *user_data,
376
				 cairo_destroy_func_t	      destroy);
377

            
378
cairo_private cairo_status_t
379
_cairo_user_data_array_copy (cairo_user_data_array_t		*dst,
380
			     const cairo_user_data_array_t	*src);
381

            
382
cairo_private void
383
_cairo_user_data_array_foreach (cairo_user_data_array_t     *array,
384
				void (*func) (const void *key,
385
					      void *elt,
386
					      void *closure),
387
				void *closure);
388

            
389
#define _CAIRO_HASH_INIT_VALUE 5381
390

            
391
cairo_private uintptr_t
392
_cairo_hash_string (const char *c);
393

            
394
cairo_private uintptr_t
395
_cairo_hash_bytes (uintptr_t hash,
396
		   const void *bytes,
397
		   unsigned int length);
398

            
399
cairo_private uintptr_t
400
_cairo_hash_uintptr (uintptr_t hash,
401
                     uintptr_t u);
402

            
403
/* We use bits 24-27 to store phases for subpixel positions */
404
#define _cairo_scaled_glyph_index(g) ((unsigned long)((g)->hash_entry.hash & 0xffffff))
405
#define _cairo_scaled_glyph_xphase(g) (int)(((g)->hash_entry.hash >> 24) & 3)
406
#define _cairo_scaled_glyph_yphase(g) (int)(((g)->hash_entry.hash >> 26) & 3)
407
#define _cairo_scaled_glyph_set_index(g, i)  ((g)->hash_entry.hash = (i))
408

            
409
#include "cairo-scaled-font-private.h"
410

            
411
struct _cairo_font_face {
412
    /* hash_entry must be first */
413
    cairo_hash_entry_t hash_entry;
414
    cairo_status_t status;
415
    cairo_reference_count_t ref_count;
416
    cairo_user_data_array_t user_data;
417
    const cairo_font_face_backend_t *backend;
418
};
419

            
420
cairo_private void
421
_cairo_default_context_reset_static_data (void);
422

            
423
cairo_private void
424
_cairo_toy_font_face_reset_static_data (void);
425

            
426
cairo_private void
427
_cairo_ft_font_reset_static_data (void);
428

            
429
cairo_private void
430
_cairo_win32_font_reset_static_data (void);
431

            
432
/* the font backend interface */
433

            
434
struct _cairo_unscaled_font_backend {
435
    cairo_bool_t (*destroy) (void	*unscaled_font);
436
};
437

            
438
/* #cairo_toy_font_face_t - simple family/slant/weight font faces used for
439
 * the built-in font API
440
 */
441

            
442
typedef struct _cairo_toy_font_face {
443
    cairo_font_face_t base;
444
    const char *family;
445
    cairo_bool_t owns_family;
446
    cairo_font_slant_t slant;
447
    cairo_font_weight_t weight;
448

            
449
    cairo_font_face_t *impl_face; /* The non-toy font face this actually uses */
450
} cairo_toy_font_face_t;
451

            
452
typedef enum _cairo_scaled_glyph_info {
453
    CAIRO_SCALED_GLYPH_INFO_METRICS	 = (1 << 0),
454
    CAIRO_SCALED_GLYPH_INFO_SURFACE	 = (1 << 1),
455
    CAIRO_SCALED_GLYPH_INFO_PATH	 = (1 << 2),
456
    CAIRO_SCALED_GLYPH_INFO_RECORDING_SURFACE = (1 << 3),
457
    CAIRO_SCALED_GLYPH_INFO_COLOR_SURFACE = (1 << 4)
458
} cairo_scaled_glyph_info_t;
459

            
460
typedef struct _cairo_scaled_font_subset {
461
    cairo_scaled_font_t *scaled_font;
462
    unsigned int font_id;
463
    unsigned int subset_id;
464

            
465
    /* Index of glyphs array is subset_glyph_index.
466
     * Value of glyphs array is scaled_font_glyph_index.
467
     */
468
    unsigned long *glyphs;
469
    char          **utf8;
470
    char          **glyph_names;
471
    int           *to_latin_char;
472
    unsigned long *latin_to_subset_glyph_index;
473
    unsigned int num_glyphs;
474
    cairo_bool_t is_composite;
475
    cairo_bool_t is_scaled;
476
    cairo_bool_t is_latin;
477
} cairo_scaled_font_subset_t;
478

            
479
struct _cairo_scaled_font_backend {
480
    cairo_font_type_t type;
481

            
482
    void
483
    (*fini)		(void			*scaled_font);
484

            
485
    /*
486
     * Get the requested glyph info.
487
     * @scaled_font: a #cairo_scaled_font_t
488
     * @scaled_glyph: a #cairo_scaled_glyph_t the glyph
489
     * @info: a #cairo_scaled_glyph_info_t which information to retrieve
490
     *  %CAIRO_SCALED_GLYPH_INFO_METRICS - glyph metrics and bounding box
491
     *  %CAIRO_SCALED_GLYPH_INFO_SURFACE - surface holding glyph image
492
     *  %CAIRO_SCALED_GLYPH_INFO_PATH - path holding glyph outline in device space
493
     *  %CAIRO_SCALED_GLYPH_INFO_RECORDING_SURFACE - surface holding recording of glyph
494
     *  %CAIRO_SCALED_GLYPH_INFO_COLOR_SURFACE - surface holding color glyph image
495
     * @foreground_color - foreground color to use when rendering color fonts. Use NULL
496
     * if not requesting CAIRO_SCALED_GLYPH_INFO_COLOR_SURFACE or foreground color is unknown.
497
     */
498
    cairo_warn cairo_int_status_t
499
    (*scaled_glyph_init)	(void			     *scaled_font,
500
				 cairo_scaled_glyph_t	     *scaled_glyph,
501
				 cairo_scaled_glyph_info_t    info,
502
                                 const cairo_color_t         *foreground_color);
503

            
504
    /* A backend only needs to implement this or ucs4_to_index(), not
505
     * both. This allows the backend to do something more sophisticated
506
     * then just converting characters one by one.
507
     */
508
    cairo_warn cairo_int_status_t
509
    (*text_to_glyphs) (void                       *scaled_font,
510
		       double		           x,
511
		       double		           y,
512
		       const char	          *utf8,
513
		       int		           utf8_len,
514
		       cairo_glyph_t	         **glyphs,
515
		       int		          *num_glyphs,
516
		       cairo_text_cluster_t      **clusters,
517
		       int		          *num_clusters,
518
		       cairo_text_cluster_flags_t *cluster_flags);
519

            
520
    /* Get the glyph index for the given unicode code point.
521
     * @scaled_font: a #cairo_scaled_font_t
522
     * @ucs4: unicode code point
523
     * Returns glyph index or 0 if not found.
524
     */
525
    unsigned long
526
    (*ucs4_to_index)		(void			     *scaled_font,
527
				 uint32_t		      ucs4);
528

            
529
    /* Read data from a sfnt font table.
530
     * @scaled_font: font
531
     * @tag: 4 byte table name specifying the table to read.
532
     * @offset: offset into the table
533
     * @buffer: buffer to write data into. Caller must ensure there is sufficient space.
534
     *          If NULL, return the size of the table in @length.
535
     * @length: If @buffer is NULL, the size of the table will be returned in @length.
536
     *          If @buffer is not null, @length specifies the number of bytes to read.
537
     *
538
     * If less than @length bytes are available to read this function
539
     * returns CAIRO_INT_STATUS_UNSUPPORTED. Note that requesting more
540
     * bytes than are available in the table may continue reading data
541
     * from the following table and return success. If this is
542
     * undesirable the caller should first query the table size. If an
543
     * error occurs the output value of @length is undefined.
544
     *
545
     * Returns CAIRO_INT_STATUS_UNSUPPORTED if not a sfnt style font or table not found.
546
     */
547
    cairo_warn cairo_int_status_t
548
    (*load_truetype_table)(void		        *scaled_font,
549
                           unsigned long         tag,
550
                           long                  offset,
551
                           unsigned char        *buffer,
552
                           unsigned long        *length);
553

            
554
    /* ucs4 is set to -1 if the unicode character could not be found
555
     * for the glyph */
556
    cairo_warn cairo_int_status_t
557
    (*index_to_ucs4)(void                       *scaled_font,
558
		     unsigned long               index,
559
                     uint32_t                   *ucs4);
560

            
561
    /* Determine if this scaled font differs from the outlines in the font tables.
562
     * eg synthesized bold/italic or a non default variant of a variable font.
563
     * @scaled_font: font
564
     * @is_sythetic: returns TRUE if scaled font is synthetic
565
     * Returns cairo status
566
     */
567
    cairo_warn cairo_int_status_t
568
    (*is_synthetic)(void                       *scaled_font,
569
		    cairo_bool_t               *is_synthetic);
570

            
571
    /* For type 1 fonts, return the glyph name for a given glyph index.
572
     * A glyph index and list of glyph names in the Type 1 fonts is provided.
573
     * The function returns the index of the glyph in the list of glyph names.
574
     * @scaled_font: font
575
     * @glyph_names: the names of each glyph in the Type 1 font in the
576
     *   order they appear in the CharStrings array
577
     * @num_glyph_names: the number of names in the glyph_names array
578
     * @glyph_index: the given glyph index
579
     * @glyph_array_index: (index into glyph_names) the glyph name corresponding
580
     *  to the glyph_index
581
     */
582
    cairo_warn cairo_int_status_t
583
    (*index_to_glyph_name)(void                 *scaled_font,
584
			   char                **glyph_names,
585
			   int                   num_glyph_names,
586
			   unsigned long         glyph_index,
587
			   unsigned long        *glyph_array_index);
588

            
589
    /* Read data from a PostScript font.
590
     * @scaled_font: font
591
     * @offset: offset into the table
592
     * @buffer: buffer to write data into. Caller must ensure there is sufficient space.
593
     *          If NULL, return the size of the table in @length.
594
     * @length: If @buffer is NULL, the size of the table will be returned in @length.
595
     *          If @buffer is not null, @length specifies the number of bytes to read.
596
     *
597
     * If less than @length bytes are available to read this function
598
     * returns CAIRO_INT_STATUS_UNSUPPORTED. If an error occurs the
599
     * output value of @length is undefined.
600
     *
601
     * Returns CAIRO_INT_STATUS_UNSUPPORTED if not a Type 1 font.
602
     */
603
    cairo_warn cairo_int_status_t
604
    (*load_type1_data)    (void		        *scaled_font,
605
                           long                  offset,
606
                           unsigned char        *buffer,
607
                           unsigned long        *length);
608

            
609
    /* Check if font has any color glyphs.
610
     * @scaled_font: font
611
     * Returns TRUE if font contains any color glyphs
612
     */
613
    cairo_bool_t
614
    (*has_color_glyphs)   (void                 *scaled_font);
615
};
616

            
617
struct _cairo_font_face_backend {
618
    cairo_font_type_t	type;
619

            
620
    cairo_warn cairo_status_t
621
    (*create_for_toy)  (cairo_toy_font_face_t	*toy_face,
622
			cairo_font_face_t      **font_face);
623

            
624
    /* The destroy() function is allowed to resurrect the font face
625
     * by re-referencing. This is needed for the FreeType backend.
626
     */
627
    cairo_bool_t
628
    (*destroy)     (void			*font_face);
629

            
630
    cairo_warn cairo_status_t
631
    (*scaled_font_create) (void				*font_face,
632
			   const cairo_matrix_t		*font_matrix,
633
			   const cairo_matrix_t		*ctm,
634
			   const cairo_font_options_t	*options,
635
			   cairo_scaled_font_t	       **scaled_font);
636

            
637
    cairo_font_face_t *
638
    (*get_implementation) (void				*font_face,
639
			   const cairo_matrix_t		*font_matrix,
640
			   const cairo_matrix_t		*ctm,
641
			   const cairo_font_options_t	*options);
642
};
643

            
644
extern const cairo_private struct _cairo_font_face_backend _cairo_user_font_face_backend;
645

            
646
/* concrete font backends */
647
#if CAIRO_HAS_FT_FONT
648

            
649
extern const cairo_private struct _cairo_font_face_backend _cairo_ft_font_face_backend;
650

            
651
#endif
652

            
653
#if CAIRO_HAS_WIN32_FONT
654

            
655
extern const cairo_private struct _cairo_font_face_backend _cairo_win32_font_face_backend;
656

            
657
#endif
658

            
659
#if CAIRO_HAS_DWRITE_FONT
660

            
661
extern const cairo_private struct _cairo_font_face_backend _cairo_dwrite_font_face_backend;
662

            
663
#endif
664

            
665
#if CAIRO_HAS_QUARTZ_FONT
666

            
667
extern const cairo_private struct _cairo_font_face_backend _cairo_quartz_font_face_backend;
668

            
669
#endif
670

            
671
#define CAIRO_EXTEND_SURFACE_DEFAULT CAIRO_EXTEND_NONE
672
#define CAIRO_EXTEND_GRADIENT_DEFAULT CAIRO_EXTEND_PAD
673
#define CAIRO_FILTER_DEFAULT CAIRO_FILTER_GOOD
674

            
675
extern const cairo_private cairo_solid_pattern_t _cairo_pattern_clear;
676
extern const cairo_private cairo_solid_pattern_t _cairo_pattern_black;
677
extern const cairo_private cairo_solid_pattern_t _cairo_pattern_white;
678

            
679
struct _cairo_surface_attributes {
680
    cairo_matrix_t matrix;
681
    cairo_extend_t extend;
682
    cairo_filter_t filter;
683
    cairo_bool_t has_component_alpha;
684
    int		   x_offset;
685
    int		   y_offset;
686
    void	   *extra;
687
};
688

            
689
#define CAIRO_FONT_SLANT_DEFAULT   CAIRO_FONT_SLANT_NORMAL
690
#define CAIRO_FONT_WEIGHT_DEFAULT  CAIRO_FONT_WEIGHT_NORMAL
691

            
692
#define CAIRO_WIN32_FONT_FAMILY_DEFAULT "Arial"
693
#define CAIRO_DWRITE_FONT_FAMILY_DEFAULT "Arial"
694
#define CAIRO_QUARTZ_FONT_FAMILY_DEFAULT  "Helvetica"
695
#define CAIRO_FT_FONT_FAMILY_DEFAULT     ""
696
#define CAIRO_USER_FONT_FAMILY_DEFAULT     "@cairo:"
697

            
698
#if   CAIRO_HAS_DWRITE_FONT
699

            
700
#define CAIRO_FONT_FAMILY_DEFAULT CAIRO_DWRITE_FONT_FAMILY_DEFAULT
701
#define CAIRO_FONT_FACE_BACKEND_DEFAULT &_cairo_dwrite_font_face_backend
702

            
703
#elif CAIRO_HAS_WIN32_FONT
704

            
705
#define CAIRO_FONT_FAMILY_DEFAULT CAIRO_WIN32_FONT_FAMILY_DEFAULT
706
#define CAIRO_FONT_FACE_BACKEND_DEFAULT &_cairo_win32_font_face_backend
707

            
708
#elif CAIRO_HAS_QUARTZ_FONT
709

            
710
#define CAIRO_FONT_FAMILY_DEFAULT CAIRO_QUARTZ_FONT_FAMILY_DEFAULT
711
#define CAIRO_FONT_FACE_BACKEND_DEFAULT &_cairo_quartz_font_face_backend
712

            
713
#elif CAIRO_HAS_FT_FONT
714

            
715
#define CAIRO_FONT_FAMILY_DEFAULT CAIRO_FT_FONT_FAMILY_DEFAULT
716
#define CAIRO_FONT_FACE_BACKEND_DEFAULT &_cairo_ft_font_face_backend
717

            
718
#else
719

            
720
#define CAIRO_FONT_FAMILY_DEFAULT CAIRO_FT_FONT_FAMILY_DEFAULT
721
#define CAIRO_FONT_FACE_BACKEND_DEFAULT &_cairo_user_font_face_backend
722

            
723
#endif
724

            
725
#define CAIRO_GSTATE_OPERATOR_DEFAULT	CAIRO_OPERATOR_OVER
726
#define CAIRO_GSTATE_TOLERANCE_DEFAULT	0.1
727
#define CAIRO_GSTATE_FILL_RULE_DEFAULT	CAIRO_FILL_RULE_WINDING
728
#define CAIRO_GSTATE_LINE_WIDTH_DEFAULT	2.0
729
#define CAIRO_GSTATE_LINE_CAP_DEFAULT	CAIRO_LINE_CAP_BUTT
730
#define CAIRO_GSTATE_LINE_JOIN_DEFAULT	CAIRO_LINE_JOIN_MITER
731
#define CAIRO_GSTATE_MITER_LIMIT_DEFAULT	10.0
732
#define CAIRO_GSTATE_DEFAULT_FONT_SIZE  10.0
733

            
734
#define CAIRO_SURFACE_RESOLUTION_DEFAULT 72.0
735
#define CAIRO_SURFACE_FALLBACK_RESOLUTION_DEFAULT 300.0
736

            
737
typedef struct _cairo_stroke_face {
738
    cairo_point_t ccw;
739
    cairo_point_t point;
740
    cairo_point_t cw;
741
    cairo_slope_t dev_vector;
742
    cairo_point_double_t dev_slope;
743
    cairo_point_double_t usr_vector;
744
    double length;
745
} cairo_stroke_face_t;
746

            
747
/* cairo.c */
748

            
749
static inline double cairo_const
750
934391
_cairo_restrict_value (double value, double min, double max)
751
{
752
934391
    if (value < min)
753
	return min;
754
934391
    else if (value > max)
755
6
	return max;
756
    else
757
934385
	return value;
758
}
759

            
760
/* C99 round() rounds to the nearest integral value with halfway cases rounded
761
 * away from 0. _cairo_round rounds halfway cases toward positive infinity.
762
 * This matches the rounding behaviour of _cairo_lround. */
763
static inline double cairo_const
764
2010874
_cairo_round (double r)
765
{
766
2010874
    return floor (r + .5);
767
}
768

            
769
#if DISABLE_SOME_FLOATING_POINT
770
cairo_private int
771
_cairo_lround (double d) cairo_const;
772
#else
773
static inline int cairo_const
774
2010874
_cairo_lround (double r)
775
{
776
2010874
    return _cairo_round (r);
777
}
778
#endif
779

            
780
cairo_private uint16_t
781
_cairo_half_from_float (float f) cairo_const;
782

            
783
cairo_private cairo_bool_t
784
_cairo_operator_bounded_by_mask (cairo_operator_t op) cairo_const;
785

            
786
cairo_private cairo_bool_t
787
_cairo_operator_bounded_by_source (cairo_operator_t op) cairo_const;
788

            
789
enum {
790
    CAIRO_OPERATOR_BOUND_BY_MASK = 1 << 1,
791
    CAIRO_OPERATOR_BOUND_BY_SOURCE = 1 << 2,
792
};
793

            
794
cairo_private uint32_t
795
_cairo_operator_bounded_by_either (cairo_operator_t op) cairo_const;
796
/* cairo-color.c */
797
cairo_private const cairo_color_t *
798
_cairo_stock_color (cairo_stock_t stock) cairo_pure;
799

            
800
#define CAIRO_COLOR_WHITE       _cairo_stock_color (CAIRO_STOCK_WHITE)
801
#define CAIRO_COLOR_BLACK       _cairo_stock_color (CAIRO_STOCK_BLACK)
802
#define CAIRO_COLOR_TRANSPARENT _cairo_stock_color (CAIRO_STOCK_TRANSPARENT)
803

            
804
cairo_private uint16_t
805
_cairo_color_double_to_short (double d) cairo_const;
806

            
807
cairo_private void
808
_cairo_color_init_rgba (cairo_color_t *color,
809
			double red, double green, double blue,
810
			double alpha);
811

            
812
cairo_private void
813
_cairo_color_multiply_alpha (cairo_color_t *color,
814
			     double	    alpha);
815

            
816
cairo_private void
817
_cairo_color_get_rgba (cairo_color_t *color,
818
		       double	     *red,
819
		       double	     *green,
820
		       double	     *blue,
821
		       double	     *alpha);
822

            
823
cairo_private void
824
_cairo_color_get_rgba_premultiplied (cairo_color_t *color,
825
				     double	   *red,
826
				     double	   *green,
827
				     double	   *blue,
828
				     double	   *alpha);
829

            
830
cairo_private cairo_bool_t
831
_cairo_color_equal (const cairo_color_t *color_a,
832
                    const cairo_color_t *color_b) cairo_pure;
833

            
834
cairo_private cairo_bool_t
835
_cairo_color_stop_equal (const cairo_color_stop_t *color_a,
836
			 const cairo_color_stop_t *color_b) cairo_pure;
837

            
838
cairo_private cairo_content_t
839
_cairo_color_get_content (const cairo_color_t *color) cairo_pure;
840

            
841
/* cairo-font-face.c */
842

            
843
extern const cairo_private cairo_font_face_t _cairo_font_face_nil;
844
extern const cairo_private cairo_font_face_t _cairo_font_face_nil_file_not_found;
845

            
846
cairo_private void
847
_cairo_font_face_init (cairo_font_face_t               *font_face,
848
		       const cairo_font_face_backend_t *backend);
849

            
850
cairo_private cairo_bool_t
851
_cairo_font_face_destroy (void *abstract_face);
852

            
853
cairo_private cairo_status_t
854
_cairo_font_face_set_error (cairo_font_face_t *font_face,
855
	                    cairo_status_t     status);
856

            
857
cairo_private void
858
_cairo_unscaled_font_init (cairo_unscaled_font_t               *font,
859
			   const cairo_unscaled_font_backend_t *backend);
860

            
861
cairo_private_no_warn cairo_unscaled_font_t *
862
_cairo_unscaled_font_reference (cairo_unscaled_font_t *font);
863

            
864
cairo_private void
865
_cairo_unscaled_font_destroy (cairo_unscaled_font_t *font);
866

            
867
/* cairo-font-face-twin.c */
868

            
869
cairo_private cairo_font_face_t *
870
_cairo_font_face_twin_create_fallback (void);
871

            
872
cairo_private cairo_status_t
873
_cairo_font_face_twin_create_for_toy (cairo_toy_font_face_t   *toy_face,
874
				      cairo_font_face_t      **font_face);
875

            
876
/* cairo-font-face-twin-data.c */
877

            
878
extern const cairo_private int8_t _cairo_twin_outlines[];
879
extern const cairo_private uint16_t _cairo_twin_charmap[128];
880

            
881
/* cairo-font-options.c */
882

            
883
cairo_private void
884
_cairo_font_options_init_default (cairo_font_options_t *options);
885

            
886
cairo_private void
887
_cairo_font_options_init_copy (cairo_font_options_t		*options,
888
			       const cairo_font_options_t	*other);
889

            
890
cairo_private cairo_bool_t
891
_cairo_font_options_compare (const cairo_font_options_t	*a,
892
                             const cairo_font_options_t	*b);
893

            
894
cairo_private void
895
_cairo_font_options_fini (cairo_font_options_t *options);
896

            
897
cairo_private void
898
_cairo_font_options_set_lcd_filter (cairo_font_options_t   *options,
899
				   cairo_lcd_filter_t  lcd_filter);
900

            
901
cairo_private cairo_lcd_filter_t
902
_cairo_font_options_get_lcd_filter (const cairo_font_options_t *options);
903

            
904
cairo_private void
905
_cairo_font_options_set_round_glyph_positions (cairo_font_options_t   *options,
906
					       cairo_round_glyph_positions_t  round);
907

            
908
cairo_private cairo_round_glyph_positions_t
909
_cairo_font_options_get_round_glyph_positions (const cairo_font_options_t *options);
910

            
911
/* cairo-hull.c */
912
cairo_private cairo_status_t
913
_cairo_hull_compute (cairo_pen_vertex_t *vertices, int *num_vertices);
914

            
915
/* cairo-lzw.c */
916
cairo_private unsigned char *
917
_cairo_lzw_compress (unsigned char *data, unsigned long *size_in_out);
918

            
919
/* cairo-misc.c */
920
cairo_private cairo_status_t
921
_cairo_validate_text_clusters (const char		   *utf8,
922
			       int			    utf8_len,
923
			       const cairo_glyph_t	   *glyphs,
924
			       int			    num_glyphs,
925
			       const cairo_text_cluster_t  *clusters,
926
			       int			    num_clusters,
927
			       cairo_text_cluster_flags_t   cluster_flags);
928

            
929
cairo_private unsigned long
930
_cairo_string_hash (const char *str, int len);
931

            
932
cairo_private cairo_status_t
933
_cairo_intern_string (const char **str_inout, int len);
934

            
935
cairo_private void
936
_cairo_intern_string_reset_static_data (void);
937

            
938
cairo_private const char *
939
_cairo_get_locale_decimal_point (void);
940

            
941
cairo_private double
942
_cairo_strtod (const char *nptr, char **endptr);
943

            
944
#ifdef HAVE_STRNDUP
945
#define _cairo_strndup strndup
946
#else
947
cairo_private char *
948
_cairo_strndup (const char *s, size_t n);
949
#endif
950

            
951
/* cairo-path-fixed.c */
952
cairo_private cairo_path_fixed_t *
953
_cairo_path_fixed_create (void);
954

            
955
cairo_private void
956
_cairo_path_fixed_init (cairo_path_fixed_t *path);
957

            
958
cairo_private cairo_status_t
959
_cairo_path_fixed_init_copy (cairo_path_fixed_t *path,
960
			     const cairo_path_fixed_t *other);
961

            
962
cairo_private void
963
_cairo_path_fixed_fini (cairo_path_fixed_t *path);
964

            
965
cairo_private void
966
_cairo_path_fixed_destroy (cairo_path_fixed_t *path);
967

            
968
cairo_private cairo_status_t
969
_cairo_path_fixed_move_to (cairo_path_fixed_t  *path,
970
			   cairo_fixed_t	x,
971
			   cairo_fixed_t	y);
972

            
973
cairo_private void
974
_cairo_path_fixed_new_sub_path (cairo_path_fixed_t *path);
975

            
976
cairo_private cairo_status_t
977
_cairo_path_fixed_rel_move_to (cairo_path_fixed_t *path,
978
			       cairo_fixed_t	   dx,
979
			       cairo_fixed_t	   dy);
980

            
981
cairo_private cairo_status_t
982
_cairo_path_fixed_line_to (cairo_path_fixed_t *path,
983
			   cairo_fixed_t	x,
984
			   cairo_fixed_t	y);
985

            
986
cairo_private cairo_status_t
987
_cairo_path_fixed_rel_line_to (cairo_path_fixed_t *path,
988
			       cairo_fixed_t	   dx,
989
			       cairo_fixed_t	   dy);
990

            
991
cairo_private cairo_status_t
992
_cairo_path_fixed_curve_to (cairo_path_fixed_t	*path,
993
			    cairo_fixed_t x0, cairo_fixed_t y0,
994
			    cairo_fixed_t x1, cairo_fixed_t y1,
995
			    cairo_fixed_t x2, cairo_fixed_t y2);
996

            
997
cairo_private cairo_status_t
998
_cairo_path_fixed_rel_curve_to (cairo_path_fixed_t *path,
999
				cairo_fixed_t dx0, cairo_fixed_t dy0,
				cairo_fixed_t dx1, cairo_fixed_t dy1,
				cairo_fixed_t dx2, cairo_fixed_t dy2);
cairo_private cairo_status_t
_cairo_path_fixed_close_path (cairo_path_fixed_t *path);
cairo_private cairo_bool_t
_cairo_path_fixed_get_current_point (cairo_path_fixed_t *path,
				     cairo_fixed_t	*x,
				     cairo_fixed_t	*y);
typedef cairo_status_t
(cairo_path_fixed_move_to_func_t) (void		 *closure,
				   const cairo_point_t *point);
typedef cairo_status_t
(cairo_path_fixed_line_to_func_t) (void		 *closure,
				   const cairo_point_t *point);
typedef cairo_status_t
(cairo_path_fixed_curve_to_func_t) (void	  *closure,
				    const cairo_point_t *p0,
				    const cairo_point_t *p1,
				    const cairo_point_t *p2);
typedef cairo_status_t
(cairo_path_fixed_close_path_func_t) (void *closure);
cairo_private cairo_status_t
_cairo_path_fixed_interpret (const cairo_path_fixed_t	  *path,
		       cairo_path_fixed_move_to_func_t	  *move_to,
		       cairo_path_fixed_line_to_func_t	  *line_to,
		       cairo_path_fixed_curve_to_func_t	  *curve_to,
		       cairo_path_fixed_close_path_func_t *close_path,
		       void				  *closure);
cairo_private cairo_status_t
_cairo_path_fixed_interpret_flat (const cairo_path_fixed_t *path,
		       cairo_path_fixed_move_to_func_t	  *move_to,
		       cairo_path_fixed_line_to_func_t	  *line_to,
		       cairo_path_fixed_close_path_func_t *close_path,
		       void				  *closure,
		       double				  tolerance);
cairo_private cairo_bool_t
_cairo_path_bounder_extents (const cairo_path_fixed_t *path,
			     cairo_box_t *box);
cairo_private cairo_bool_t
_cairo_path_fixed_extents (const cairo_path_fixed_t *path,
			   cairo_box_t *box);
cairo_private void
_cairo_path_fixed_approximate_clip_extents (const cairo_path_fixed_t	*path,
					    cairo_rectangle_int_t *extents);
cairo_private void
_cairo_path_fixed_approximate_fill_extents (const cairo_path_fixed_t *path,
					    cairo_rectangle_int_t *extents);
cairo_private void
_cairo_path_fixed_fill_extents (const cairo_path_fixed_t	*path,
				cairo_fill_rule_t	 fill_rule,
				double			 tolerance,
				cairo_rectangle_int_t	*extents);
cairo_private void
_cairo_path_fixed_approximate_stroke_extents (const cairo_path_fixed_t *path,
					      const cairo_stroke_style_t *style,
					      const cairo_matrix_t *ctm,
					      cairo_bool_t vector,
					      cairo_rectangle_int_t *extents);
cairo_private cairo_status_t
_cairo_path_fixed_stroke_extents (const cairo_path_fixed_t *path,
				  const cairo_stroke_style_t *style,
				  const cairo_matrix_t *ctm,
				  const cairo_matrix_t *ctm_inverse,
				  double tolerance,
				  cairo_rectangle_int_t *extents);
cairo_private void
_cairo_path_fixed_transform (cairo_path_fixed_t	*path,
			     const cairo_matrix_t	*matrix);
cairo_private cairo_bool_t
_cairo_path_fixed_is_box (const cairo_path_fixed_t *path,
                          cairo_box_t *box);
cairo_private cairo_bool_t
_cairo_path_fixed_is_rectangle (const cairo_path_fixed_t *path,
				cairo_box_t        *box);
/* cairo-path-in-fill.c */
cairo_private cairo_bool_t
_cairo_path_fixed_in_fill (const cairo_path_fixed_t	*path,
			   cairo_fill_rule_t	 fill_rule,
			   double		 tolerance,
			   double		 x,
			   double		 y);
/* cairo-path-fill.c */
cairo_private cairo_status_t
_cairo_path_fixed_fill_to_polygon (const cairo_path_fixed_t *path,
				   double              tolerance,
				   cairo_polygon_t      *polygon);
cairo_private cairo_status_t
_cairo_path_fixed_fill_rectilinear_to_polygon (const cairo_path_fixed_t *path,
					       cairo_antialias_t antialias,
					       cairo_polygon_t *polygon);
cairo_private cairo_status_t
_cairo_path_fixed_fill_rectilinear_to_boxes (const cairo_path_fixed_t *path,
					     cairo_fill_rule_t fill_rule,
					     cairo_antialias_t antialias,
					     cairo_boxes_t *boxes);
cairo_private cairo_region_t *
_cairo_path_fixed_fill_rectilinear_to_region (const cairo_path_fixed_t	*path,
					      cairo_fill_rule_t	 fill_rule,
					      const cairo_rectangle_int_t *extents);
cairo_private cairo_status_t
_cairo_path_fixed_fill_to_traps (const cairo_path_fixed_t   *path,
				 cairo_fill_rule_t	     fill_rule,
				 double			     tolerance,
				 cairo_traps_t		    *traps);
/* cairo-path-stroke.c */
cairo_private cairo_status_t
_cairo_path_fixed_stroke_to_polygon (const cairo_path_fixed_t	*path,
				     const cairo_stroke_style_t	*stroke_style,
				     const cairo_matrix_t	*ctm,
				     const cairo_matrix_t	*ctm_inverse,
				     double		 tolerance,
				     cairo_polygon_t	*polygon);
cairo_private cairo_int_status_t
_cairo_path_fixed_stroke_to_tristrip (const cairo_path_fixed_t	*path,
				      const cairo_stroke_style_t*style,
				      const cairo_matrix_t	*ctm,
				      const cairo_matrix_t	*ctm_inverse,
				      double			 tolerance,
				      cairo_tristrip_t		 *strip);
cairo_private cairo_status_t
_cairo_path_fixed_stroke_dashed_to_polygon (const cairo_path_fixed_t	*path,
					    const cairo_stroke_style_t	*stroke_style,
					    const cairo_matrix_t	*ctm,
					    const cairo_matrix_t	*ctm_inverse,
					    double		 tolerance,
					    cairo_polygon_t	*polygon);
cairo_private cairo_int_status_t
_cairo_path_fixed_stroke_rectilinear_to_boxes (const cairo_path_fixed_t	*path,
					       const cairo_stroke_style_t	*stroke_style,
					       const cairo_matrix_t	*ctm,
					       cairo_antialias_t	 antialias,
					       cairo_boxes_t		*boxes);
cairo_private cairo_int_status_t
_cairo_path_fixed_stroke_to_traps (const cairo_path_fixed_t	*path,
				   const cairo_stroke_style_t	*stroke_style,
				   const cairo_matrix_t	*ctm,
				   const cairo_matrix_t	*ctm_inverse,
				   double		 tolerance,
				   cairo_traps_t	*traps);
cairo_private cairo_int_status_t
_cairo_path_fixed_stroke_polygon_to_traps (const cairo_path_fixed_t	*path,
					   const cairo_stroke_style_t	*stroke_style,
					   const cairo_matrix_t	*ctm,
					   const cairo_matrix_t	*ctm_inverse,
					   double		 tolerance,
					   cairo_traps_t	*traps);
cairo_private cairo_status_t
_cairo_path_fixed_stroke_to_shaper (cairo_path_fixed_t	*path,
				   const cairo_stroke_style_t	*stroke_style,
				   const cairo_matrix_t	*ctm,
				   const cairo_matrix_t	*ctm_inverse,
				   double		 tolerance,
				   cairo_status_t (*add_triangle) (void *closure,
								   const cairo_point_t triangle[3]),
				   cairo_status_t (*add_triangle_fan) (void *closure,
								       const cairo_point_t *midpt,
								       const cairo_point_t *points,
								       int npoints),
				   cairo_status_t (*add_quad) (void *closure,
							       const cairo_point_t quad[4]),
				   void *closure);
/* cairo-scaled-font.c */
cairo_private void
_cairo_scaled_font_freeze_cache (cairo_scaled_font_t *scaled_font);
cairo_private void
_cairo_scaled_font_thaw_cache (cairo_scaled_font_t *scaled_font);
cairo_private void
_cairo_scaled_font_reset_cache (cairo_scaled_font_t *scaled_font);
cairo_private cairo_status_t
_cairo_scaled_font_set_error (cairo_scaled_font_t *scaled_font,
			      cairo_status_t status);
cairo_private cairo_scaled_font_t *
_cairo_scaled_font_create_in_error (cairo_status_t status);
cairo_private void
_cairo_scaled_font_reset_static_data (void);
cairo_private cairo_status_t
_cairo_scaled_font_register_placeholder_and_unlock_font_map (cairo_scaled_font_t *scaled_font);
cairo_private void
_cairo_scaled_font_unregister_placeholder_and_lock_font_map (cairo_scaled_font_t *scaled_font);
cairo_private cairo_status_t
_cairo_scaled_font_init (cairo_scaled_font_t               *scaled_font,
			 cairo_font_face_t		   *font_face,
			 const cairo_matrix_t              *font_matrix,
			 const cairo_matrix_t              *ctm,
			 const cairo_font_options_t	   *options,
			 const cairo_scaled_font_backend_t *backend);
cairo_private cairo_status_t
_cairo_scaled_font_set_metrics (cairo_scaled_font_t	    *scaled_font,
				cairo_font_extents_t	    *fs_metrics);
/* This should only be called on an error path by a scaled_font constructor */
cairo_private void
_cairo_scaled_font_fini (cairo_scaled_font_t *scaled_font);
cairo_private cairo_status_t
_cairo_scaled_font_font_extents (cairo_scaled_font_t  *scaled_font,
				 cairo_font_extents_t *extents);
cairo_private cairo_status_t
_cairo_scaled_font_glyph_device_extents (cairo_scaled_font_t	 *scaled_font,
					 const cairo_glyph_t	 *glyphs,
					 int                      num_glyphs,
					 cairo_rectangle_int_t   *extents,
					 cairo_bool_t		 *overlap);
cairo_private cairo_bool_t
_cairo_scaled_font_glyph_approximate_extents (cairo_scaled_font_t	 *scaled_font,
					      const cairo_glyph_t	 *glyphs,
					      int                      num_glyphs,
					      cairo_rectangle_int_t   *extents);
cairo_private cairo_status_t
_cairo_scaled_font_show_glyphs (cairo_scaled_font_t *scaled_font,
				cairo_operator_t     op,
				const cairo_pattern_t *source,
				cairo_surface_t	    *surface,
				int		     source_x,
				int		     source_y,
				int		     dest_x,
				int		     dest_y,
				unsigned int	     width,
				unsigned int	     height,
				cairo_glyph_t	    *glyphs,
				int		     num_glyphs,
				cairo_region_t	    *clip_region);
cairo_private cairo_status_t
_cairo_scaled_font_glyph_path (cairo_scaled_font_t *scaled_font,
			       const cairo_glyph_t *glyphs,
			       int                  num_glyphs,
			       cairo_path_fixed_t  *path);
cairo_private void
_cairo_scaled_glyph_set_metrics (cairo_scaled_glyph_t *scaled_glyph,
				 cairo_scaled_font_t *scaled_font,
				 cairo_text_extents_t *fs_metrics);
cairo_private void
_cairo_scaled_glyph_set_surface (cairo_scaled_glyph_t *scaled_glyph,
				 cairo_scaled_font_t *scaled_font,
				 cairo_image_surface_t *surface);
cairo_private void
_cairo_scaled_glyph_set_path (cairo_scaled_glyph_t *scaled_glyph,
			      cairo_scaled_font_t *scaled_font,
			      cairo_path_fixed_t *path);
cairo_private void
_cairo_scaled_glyph_set_recording_surface (cairo_scaled_glyph_t *scaled_glyph,
                                           cairo_scaled_font_t *scaled_font,
                                           cairo_surface_t *recording_surface,
					   const cairo_color_t *foreground_color);
cairo_private void
_cairo_scaled_glyph_set_color_surface (cairo_scaled_glyph_t *scaled_glyph,
		                       cairo_scaled_font_t *scaled_font,
		                       cairo_image_surface_t *surface,
                                       const cairo_color_t *foreground_color);
cairo_private cairo_int_status_t
_cairo_scaled_glyph_lookup (cairo_scaled_font_t *scaled_font,
			    unsigned long index,
			    cairo_scaled_glyph_info_t info,
                            const cairo_color_t   *foreground_color,
			    cairo_scaled_glyph_t **scaled_glyph_ret);
cairo_private double
_cairo_scaled_font_get_max_scale (cairo_scaled_font_t *scaled_font);
cairo_private void
_cairo_scaled_font_map_destroy (void);
/* cairo-stroke-style.c */
cairo_private void
_cairo_stroke_style_init (cairo_stroke_style_t *style);
cairo_private cairo_status_t
_cairo_stroke_style_init_copy (cairo_stroke_style_t *style,
			       const cairo_stroke_style_t *other);
cairo_private void
_cairo_stroke_style_fini (cairo_stroke_style_t *style);
cairo_private void
_cairo_stroke_style_max_distance_from_path (const cairo_stroke_style_t *style,
					    const cairo_path_fixed_t *path,
                                            const cairo_matrix_t *ctm,
                                            double *dx, double *dy);
cairo_private void
_cairo_stroke_style_max_line_distance_from_path (const cairo_stroke_style_t *style,
						 const cairo_path_fixed_t *path,
						 const cairo_matrix_t *ctm,
						 double *dx, double *dy);
cairo_private void
_cairo_stroke_style_max_join_distance_from_path (const cairo_stroke_style_t *style,
						 const cairo_path_fixed_t *path,
						 const cairo_matrix_t *ctm,
						 double *dx, double *dy);
cairo_private double
_cairo_stroke_style_dash_period (const cairo_stroke_style_t *style);
cairo_private double
_cairo_stroke_style_dash_stroked (const cairo_stroke_style_t *style);
cairo_private cairo_bool_t
_cairo_stroke_style_dash_can_approximate (const cairo_stroke_style_t *style,
					  const cairo_matrix_t *ctm,
					  double tolerance);
cairo_private void
_cairo_stroke_style_dash_approximate (const cairo_stroke_style_t *style,
				      const cairo_matrix_t *ctm,
				      double tolerance,
				      double *dash_offset,
				      double *dashes,
				      unsigned int *num_dashes);
/* cairo-surface.c */
cairo_private cairo_bool_t
_cairo_surface_has_mime_image (cairo_surface_t *surface);
cairo_private cairo_status_t
_cairo_surface_copy_mime_data (cairo_surface_t *dst,
			       cairo_surface_t *src);
cairo_private_no_warn cairo_int_status_t
_cairo_surface_set_error (cairo_surface_t	*surface,
			  cairo_int_status_t	 status);
cairo_private void
_cairo_surface_set_resolution (cairo_surface_t *surface,
                               double x_res,
                               double y_res);
cairo_private cairo_surface_t *
_cairo_surface_create_for_rectangle_int (cairo_surface_t *target,
					 const cairo_rectangle_int_t *extents);
cairo_private cairo_surface_t *
_cairo_surface_create_scratch (cairo_surface_t	    *other,
			       cairo_content_t	     content,
			       int		     width,
			       int		     height,
			       const cairo_color_t  *color);
cairo_private void
_cairo_surface_init (cairo_surface_t			*surface,
		     const cairo_surface_backend_t	*backend,
		     cairo_device_t			*device,
		     cairo_content_t			 content,
		     cairo_bool_t                        is_vector);
cairo_private void
_cairo_surface_set_font_options (cairo_surface_t       *surface,
				 cairo_font_options_t  *options);
cairo_private cairo_status_t
_cairo_surface_paint (cairo_surface_t	*surface,
		      cairo_operator_t	 op,
		      const cairo_pattern_t *source,
		      const cairo_clip_t	    *clip);
cairo_private cairo_image_surface_t *
_cairo_surface_map_to_image (cairo_surface_t  *surface,
			     const cairo_rectangle_int_t *extents);
cairo_private_no_warn cairo_int_status_t
_cairo_surface_unmap_image (cairo_surface_t       *surface,
			    cairo_image_surface_t *image);
cairo_private cairo_status_t
_cairo_surface_mask (cairo_surface_t	*surface,
		     cairo_operator_t	 op,
		     const cairo_pattern_t	*source,
		     const cairo_pattern_t	*mask,
		     const cairo_clip_t		*clip);
cairo_private cairo_status_t
_cairo_surface_fill_stroke (cairo_surface_t	    *surface,
			    cairo_operator_t	     fill_op,
			    const cairo_pattern_t   *fill_source,
			    cairo_fill_rule_t	     fill_rule,
			    double		     fill_tolerance,
			    cairo_antialias_t	     fill_antialias,
			    cairo_path_fixed_t	    *path,
			    cairo_operator_t	     stroke_op,
			    const cairo_pattern_t   *stroke_source,
			    const cairo_stroke_style_t    *stroke_style,
			    const cairo_matrix_t	    *stroke_ctm,
			    const cairo_matrix_t	    *stroke_ctm_inverse,
			    double		     stroke_tolerance,
			    cairo_antialias_t	     stroke_antialias,
			    const cairo_clip_t	    *clip);
cairo_private cairo_status_t
_cairo_surface_stroke (cairo_surface_t		*surface,
		       cairo_operator_t		 op,
		       const cairo_pattern_t	*source,
		       const cairo_path_fixed_t	*path,
		       const cairo_stroke_style_t	*style,
		       const cairo_matrix_t		*ctm,
		       const cairo_matrix_t		*ctm_inverse,
		       double			 tolerance,
		       cairo_antialias_t	 antialias,
		       const cairo_clip_t		*clip);
cairo_private cairo_status_t
_cairo_surface_fill (cairo_surface_t	*surface,
		     cairo_operator_t	 op,
		     const cairo_pattern_t *source,
		     const cairo_path_fixed_t	*path,
		     cairo_fill_rule_t	 fill_rule,
		     double		 tolerance,
		     cairo_antialias_t	 antialias,
		     const cairo_clip_t	*clip);
cairo_private cairo_status_t
_cairo_surface_show_text_glyphs (cairo_surface_t	    *surface,
				 cairo_operator_t	     op,
				 const cairo_pattern_t	    *source,
				 const char		    *utf8,
				 int			     utf8_len,
				 cairo_glyph_t		    *glyphs,
				 int			     num_glyphs,
				 const cairo_text_cluster_t *clusters,
				 int			     num_clusters,
				 cairo_text_cluster_flags_t  cluster_flags,
				 cairo_scaled_font_t	    *scaled_font,
				 const cairo_clip_t		    *clip);
cairo_private cairo_status_t
_cairo_surface_tag (cairo_surface_t	        *surface,
		    cairo_bool_t                 begin,
		    const char                  *tag_name,
		    const char                  *attributes);
cairo_private cairo_bool_t
_cairo_surface_supports_color_glyph (cairo_surface_t       *surface,
				     cairo_scaled_font_t   *scaled_font,
				     unsigned long          glyph_index);
cairo_private cairo_status_t
_cairo_surface_acquire_source_image (cairo_surface_t         *surface,
				     cairo_image_surface_t  **image_out,
				     void                   **image_extra);
cairo_private void
_cairo_surface_release_source_image (cairo_surface_t        *surface,
				     cairo_image_surface_t  *image,
				     void                   *image_extra);
cairo_private cairo_surface_t *
_cairo_surface_snapshot (cairo_surface_t *surface);
cairo_private void
_cairo_surface_attach_snapshot (cairo_surface_t *surface,
				cairo_surface_t *snapshot,
				cairo_surface_func_t detach_func);
cairo_private cairo_surface_t *
_cairo_surface_has_snapshot (cairo_surface_t *surface,
			     const cairo_surface_backend_t *backend);
cairo_private void
_cairo_surface_detach_snapshot (cairo_surface_t *snapshot);
cairo_private cairo_status_t
_cairo_surface_begin_modification (cairo_surface_t *surface);
cairo_private_no_warn cairo_bool_t
_cairo_surface_get_extents (cairo_surface_t         *surface,
			    cairo_rectangle_int_t   *extents);
cairo_private cairo_bool_t
_cairo_surface_has_device_transform (cairo_surface_t *surface) cairo_pure;
cairo_private void
_cairo_surface_release_device_reference (cairo_surface_t *surface);
/* cairo-image-surface.c */
/* XXX: In cairo 1.2.0 we added a new %CAIRO_FORMAT_RGB16_565 but
 * neglected to adjust this macro. The net effect is that it's
 * impossible to externally create an image surface with this
 * format. This is perhaps a good thing since we also neglected to fix
 * up things like cairo_surface_write_to_png() for the new format
 * (-Wswitch-enum will tell you where). Is it obvious that format was
 * added in haste?
 *
 * The reason for the new format was to allow the xlib backend to be
 * used on X servers with a 565 visual. So the new format did its job
 * for that, even without being considered "valid" for the sake of
 * things like cairo_image_surface_create().
 *
 * Since 1.2.0 we ran into the same situation with X servers with BGR
 * visuals. This time we invented #cairo_internal_format_t instead,
 * (see it for more discussion).
 *
 * The punchline is that %CAIRO_FORMAT_VALID must not consider any
 * internal format to be valid. Also we need to decide if the
 * RGB16_565 should be moved to instead be an internal format. If so,
 * this macro need not change for it. (We probably will need to leave
 * an RGB16_565 value in the header files for the sake of code that
 * might have that value in it.)
 *
 * If we do decide to start fully supporting RGB16_565 as an external
 * format, then %CAIRO_FORMAT_VALID needs to be adjusted to include
 * it. But that should not happen before all necessary code is fixed
 * to support it (at least cairo_surface_write_to_png() and a few spots
 * in cairo-xlib-surface.c--again see -Wswitch-enum).
 */
#define CAIRO_FORMAT_VALID(format) ((format) >= CAIRO_FORMAT_ARGB32 &&		\
                                    (format) <= CAIRO_FORMAT_RGBA128F)
/* pixman-required stride alignment in bytes. */
#define CAIRO_STRIDE_ALIGNMENT (sizeof (uint32_t))
#define CAIRO_STRIDE_FOR_WIDTH_BPP(w,bpp) \
   ((((bpp)*(w)+7)/8 + CAIRO_STRIDE_ALIGNMENT-1) & -CAIRO_STRIDE_ALIGNMENT)
#define CAIRO_CONTENT_VALID(content) ((content) && 			         \
				      (((content) & ~(CAIRO_CONTENT_COLOR |      \
						      CAIRO_CONTENT_ALPHA |      \
						      CAIRO_CONTENT_COLOR_ALPHA))\
				       == 0))
cairo_private int
_cairo_format_bits_per_pixel (cairo_format_t format) cairo_const;
cairo_private cairo_format_t
_cairo_format_from_content (cairo_content_t content) cairo_const;
cairo_private cairo_format_t
_cairo_format_from_pixman_format (pixman_format_code_t pixman_format);
cairo_private cairo_content_t
_cairo_content_from_format (cairo_format_t format) cairo_const;
cairo_private cairo_content_t
_cairo_content_from_pixman_format (pixman_format_code_t pixman_format);
cairo_private cairo_surface_t *
_cairo_image_surface_create_for_pixman_image (pixman_image_t		*pixman_image,
					      pixman_format_code_t	 pixman_format);
cairo_private pixman_format_code_t
_cairo_format_to_pixman_format_code (cairo_format_t format);
cairo_private cairo_bool_t
_pixman_format_from_masks (cairo_format_masks_t *masks,
			   pixman_format_code_t *format_ret);
cairo_private cairo_bool_t
_pixman_format_to_masks (pixman_format_code_t	 pixman_format,
			 cairo_format_masks_t	*masks);
cairo_private void
_cairo_image_scaled_glyph_fini (cairo_scaled_font_t *scaled_font,
				cairo_scaled_glyph_t *scaled_glyph);
cairo_private void
_cairo_image_reset_static_data (void);
cairo_private void
_cairo_image_compositor_reset_static_data (void);
cairo_private cairo_surface_t *
_cairo_image_surface_create_with_pixman_format (unsigned char		*data,
						pixman_format_code_t	 pixman_format,
						int			 width,
						int			 height,
						int			 stride);
cairo_private cairo_surface_t *
_cairo_image_surface_create_with_content (cairo_content_t	content,
					  int			width,
					  int			height);
cairo_private void
_cairo_image_surface_assume_ownership_of_data (cairo_image_surface_t *surface);
cairo_private cairo_image_surface_t *
_cairo_image_surface_coerce (cairo_image_surface_t	*surface);
cairo_private cairo_image_surface_t *
_cairo_image_surface_coerce_to_format (cairo_image_surface_t	*surface,
			               cairo_format_t		 format);
cairo_private cairo_image_transparency_t
_cairo_image_analyze_transparency (cairo_image_surface_t      *image);
cairo_private cairo_image_color_t
_cairo_image_analyze_color (cairo_image_surface_t      *image);
/* cairo-pen.c */
cairo_private int
_cairo_pen_vertices_needed (double	    tolerance,
			    double	    radius,
			    const cairo_matrix_t  *matrix);
cairo_private cairo_status_t
_cairo_pen_init (cairo_pen_t	*pen,
		 double		 radius,
		 double		 tolerance,
		 const cairo_matrix_t	*ctm);
cairo_private void
_cairo_pen_init_empty (cairo_pen_t *pen);
cairo_private cairo_status_t
_cairo_pen_init_copy (cairo_pen_t *pen, const cairo_pen_t *other);
cairo_private void
_cairo_pen_fini (cairo_pen_t *pen);
cairo_private cairo_status_t
_cairo_pen_add_points (cairo_pen_t *pen, cairo_point_t *point, int num_points);
cairo_private int
_cairo_pen_find_active_cw_vertex_index (const cairo_pen_t *pen,
					const cairo_slope_t *slope);
cairo_private int
_cairo_pen_find_active_ccw_vertex_index (const cairo_pen_t *pen,
					 const cairo_slope_t *slope);
cairo_private void
_cairo_pen_find_active_cw_vertices (const cairo_pen_t *pen,
				     const cairo_slope_t *in,
				     const cairo_slope_t *out,
				     int *start, int *stop);
cairo_private void
_cairo_pen_find_active_ccw_vertices (const cairo_pen_t *pen,
				     const cairo_slope_t *in,
				     const cairo_slope_t *out,
				     int *start, int *stop);
/* cairo-polygon.c */
cairo_private void
_cairo_polygon_init (cairo_polygon_t   *polygon,
		     const cairo_box_t *boxes,
		     int		num_boxes);
cairo_private void
_cairo_polygon_init_with_clip (cairo_polygon_t *polygon,
			       const cairo_clip_t *clip);
cairo_private cairo_status_t
_cairo_polygon_init_boxes (cairo_polygon_t *polygon,
			   const cairo_boxes_t *boxes);
cairo_private cairo_status_t
_cairo_polygon_init_box_array (cairo_polygon_t *polygon,
			       cairo_box_t *boxes,
			       int num_boxes);
cairo_private void
_cairo_polygon_limit (cairo_polygon_t *polygon,
		     const cairo_box_t *limits,
		     int num_limits);
cairo_private void
_cairo_polygon_limit_to_clip (cairo_polygon_t *polygon,
			      const cairo_clip_t *clip);
cairo_private void
_cairo_polygon_fini (cairo_polygon_t *polygon);
cairo_private_no_warn cairo_status_t
_cairo_polygon_add_line (cairo_polygon_t *polygon,
			 const cairo_line_t *line,
			 int top, int bottom,
			 int dir);
cairo_private_no_warn cairo_status_t
_cairo_polygon_add_external_edge (void *polygon,
				  const cairo_point_t *p1,
				  const cairo_point_t *p2);
cairo_private_no_warn cairo_status_t
_cairo_polygon_add_contour (cairo_polygon_t *polygon,
			    const cairo_contour_t *contour);
cairo_private void
_cairo_polygon_translate (cairo_polygon_t *polygon, int dx, int dy);
cairo_private cairo_status_t
_cairo_polygon_reduce (cairo_polygon_t *polygon,
		       cairo_fill_rule_t fill_rule);
cairo_private cairo_status_t
_cairo_polygon_intersect (cairo_polygon_t *a, int winding_a,
			  cairo_polygon_t *b, int winding_b);
cairo_private cairo_status_t
_cairo_polygon_intersect_with_boxes (cairo_polygon_t *polygon,
				     cairo_fill_rule_t *winding,
				     cairo_box_t *boxes,
				     int num_boxes);
static inline cairo_bool_t
179480
_cairo_polygon_is_empty (const cairo_polygon_t *polygon)
{
    return
358939
	polygon->num_edges == 0 ||
179459
	polygon->extents.p2.x <= polygon->extents.p1.x;
}
#define _cairo_polygon_status(P) ((cairo_polygon_t *) (P))->status
/* cairo-spline.c */
cairo_private cairo_bool_t
_cairo_spline_init (cairo_spline_t *spline,
		    cairo_spline_add_point_func_t add_point_func,
		    void *closure,
		    const cairo_point_t *a, const cairo_point_t *b,
		    const cairo_point_t *c, const cairo_point_t *d);
cairo_private cairo_status_t
_cairo_spline_decompose (cairo_spline_t *spline, double tolerance);
cairo_private cairo_status_t
_cairo_spline_bound (cairo_spline_add_point_func_t add_point_func,
		     void *closure,
		     const cairo_point_t *p0, const cairo_point_t *p1,
		     const cairo_point_t *p2, const cairo_point_t *p3);
/* cairo-matrix.c */
cairo_private void
_cairo_matrix_get_affine (const cairo_matrix_t *matrix,
			  double *xx, double *yx,
			  double *xy, double *yy,
			  double *x0, double *y0);
cairo_private void
_cairo_matrix_transform_bounding_box (const cairo_matrix_t *matrix,
				      double *x1, double *y1,
				      double *x2, double *y2,
				      cairo_bool_t *is_tight);
cairo_private void
_cairo_matrix_transform_bounding_box_fixed (const cairo_matrix_t *matrix,
					    cairo_box_t          *bbox,
					    cairo_bool_t         *is_tight);
cairo_private cairo_bool_t
_cairo_matrix_is_invertible (const cairo_matrix_t *matrix) cairo_pure;
cairo_private cairo_bool_t
_cairo_matrix_is_scale_0 (const cairo_matrix_t *matrix) cairo_pure;
cairo_private double
_cairo_matrix_compute_determinant (const cairo_matrix_t *matrix) cairo_pure;
cairo_private cairo_status_t
_cairo_matrix_compute_basis_scale_factors (const cairo_matrix_t *matrix,
					   double *sx, double *sy, int x_major);
static inline cairo_bool_t
5778921
_cairo_matrix_is_identity (const cairo_matrix_t *matrix)
{
4425993
    return (matrix->xx == 1.0 && matrix->yx == 0.0 &&
4423842
	    matrix->xy == 0.0 && matrix->yy == 1.0 &&
10204914
	    matrix->x0 == 0.0 && matrix->y0 == 0.0);
}
static inline cairo_bool_t
572098
_cairo_matrix_is_translation (const cairo_matrix_t *matrix)
{
305400
    return (matrix->xx == 1.0 && matrix->yx == 0.0 &&
877498
	    matrix->xy == 0.0 && matrix->yy == 1.0);
}
static inline cairo_bool_t
2448
_cairo_matrix_is_scale (const cairo_matrix_t *matrix)
{
2448
    return matrix->yx == 0.0 && matrix->xy == 0.0;
}
cairo_private cairo_bool_t
_cairo_matrix_is_integer_translation(const cairo_matrix_t *matrix,
				     int *itx, int *ity);
cairo_private cairo_bool_t
_cairo_matrix_has_unity_scale (const cairo_matrix_t *matrix);
cairo_private cairo_bool_t
_cairo_matrix_is_pixel_exact (const cairo_matrix_t *matrix) cairo_pure;
cairo_private double
_cairo_matrix_transformed_circle_major_axis (const cairo_matrix_t *matrix,
					     double radius) cairo_pure;
cairo_private cairo_bool_t
_cairo_matrix_is_pixman_translation (const cairo_matrix_t     *matrix,
				     cairo_filter_t            filter,
				     int                      *out_x_offset,
				     int                      *out_y_offset);
cairo_private cairo_status_t
_cairo_matrix_to_pixman_matrix_offset (const cairo_matrix_t	*matrix,
				       cairo_filter_t            filter,
				       double                    xc,
				       double                    yc,
				       pixman_transform_t	*out_transform,
				       int                      *out_x_offset,
				       int                      *out_y_offset);
cairo_private void
_cairo_debug_print_matrix (FILE *file, const cairo_matrix_t *matrix);
cairo_private void
_cairo_debug_print_rect (FILE *file, const cairo_rectangle_int_t *rect);
cairo_private const char *
_cairo_debug_operator_to_string (cairo_operator_t op);
cairo_private const char *
_cairo_debug_status_to_string (cairo_int_status_t status);
cairo_private cairo_status_t
_cairo_bentley_ottmann_tessellate_rectilinear_polygon (cairo_traps_t	 *traps,
						       const cairo_polygon_t *polygon,
						       cairo_fill_rule_t	  fill_rule);
cairo_private cairo_status_t
_cairo_bentley_ottmann_tessellate_polygon (cairo_traps_t         *traps,
					   const cairo_polygon_t *polygon,
					   cairo_fill_rule_t      fill_rule);
cairo_private cairo_status_t
_cairo_bentley_ottmann_tessellate_traps (cairo_traps_t *traps,
					 cairo_fill_rule_t fill_rule);
cairo_private cairo_status_t
_cairo_bentley_ottmann_tessellate_rectangular_traps (cairo_traps_t *traps,
						     cairo_fill_rule_t fill_rule);
cairo_private cairo_status_t
_cairo_bentley_ottmann_tessellate_boxes (const cairo_boxes_t *in,
					 cairo_fill_rule_t fill_rule,
					 cairo_boxes_t *out);
cairo_private cairo_status_t
_cairo_bentley_ottmann_tessellate_rectilinear_traps (cairo_traps_t *traps,
						     cairo_fill_rule_t fill_rule);
cairo_private cairo_status_t
_cairo_bentley_ottmann_tessellate_rectilinear_polygon_to_boxes (const cairo_polygon_t *polygon,
								cairo_fill_rule_t fill_rule,
								cairo_boxes_t *boxes);
cairo_private void
_cairo_trapezoid_array_translate_and_scale (cairo_trapezoid_t *offset_traps,
					    cairo_trapezoid_t *src_traps,
					    int num_traps,
					    double tx, double ty,
					    double sx, double sy);
cairo_private void
_cairo_clip_reset_static_data (void);
cairo_private void
_cairo_pattern_reset_static_data (void);
/* cairo-unicode.c */
cairo_private int
_cairo_utf8_get_char_validated (const char *p,
				uint32_t   *unicode);
cairo_private cairo_status_t
_cairo_utf8_to_ucs4 (const char *str,
		     int	 len,
		     uint32_t  **result,
		     int	*items_written);
cairo_private int
_cairo_ucs4_to_utf8 (uint32_t    unicode,
		     char       *utf8);
cairo_private int
_cairo_ucs4_to_utf16 (uint32_t    unicode,
		      uint16_t   *utf16);
#if _WIN32 || CAIRO_HAS_WIN32_FONT || CAIRO_HAS_QUARTZ_FONT || CAIRO_HAS_PDF_OPERATORS
# define CAIRO_HAS_UTF8_TO_UTF16 1
#endif
#if CAIRO_HAS_UTF8_TO_UTF16
cairo_private cairo_status_t
_cairo_utf8_to_utf16 (const char *str,
		      int	  len,
		      uint16_t  **result,
		      int	 *items_written);
#endif
cairo_private void
_cairo_matrix_multiply (cairo_matrix_t *r,
			const cairo_matrix_t *a,
			const cairo_matrix_t *b);
/* cairo-observer.c */
cairo_private void
_cairo_observers_notify (cairo_list_t *observers, void *arg);
/* Open a file with a UTF-8 filename */
cairo_private cairo_status_t
_cairo_fopen (const char *filename, const char *mode, FILE **file_out);
cairo_private FILE *
_cairo_tmpfile (void);
#include "cairo-mutex-private.h"
#include "cairo-fixed-private.h"
#include "cairo-wideint-private.h"
#include "cairo-malloc-private.h"
#include "cairo-hash-private.h"
#if HAVE_VALGRIND
#include <memcheck.h>
#define VG(x) x
cairo_private void
_cairo_debug_check_image_surface_is_defined (const cairo_surface_t *surface);
#else
#define VG(x)
#define _cairo_debug_check_image_surface_is_defined(X)
#endif
cairo_private void
_cairo_debug_print_path (FILE *stream, const cairo_path_fixed_t *path);
cairo_private void
_cairo_debug_print_polygon (FILE *stream, cairo_polygon_t *polygon);
cairo_private void
_cairo_debug_print_traps (FILE *file, const cairo_traps_t *traps);
cairo_private void
_cairo_debug_print_clip (FILE *stream, const cairo_clip_t *clip);
#if 0
#define TRACE(x) fprintf (stderr, "%s: ", __FILE__), fprintf x
#define TRACE_(x) x
#else
#define TRACE(x)
#define TRACE_(x)
#endif
CAIRO_END_DECLS
#endif