Subversion Repositories Kolibri OS

Rev

Blame | Last modification | View Log | RSS feed

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