Subversion Repositories Kolibri OS

Rev

Go to most recent revision | Blame | Last modification | View Log | Download | 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.  
  75. #if CAIRO_HAS_PS_SURFACE  || \
  76.     CAIRO_HAS_PDF_SURFACE || \
  77.     CAIRO_HAS_SVG_SURFACE || \
  78.     CAIRO_HAS_WIN32_SURFACE
  79. #define CAIRO_HAS_FONT_SUBSET 1
  80. #endif
  81.  
  82. #if CAIRO_HAS_PS_SURFACE || CAIRO_HAS_PDF_SURFACE || CAIRO_HAS_FONT_SUBSET
  83. #define CAIRO_HAS_PDF_OPERATORS 1
  84. #endif
  85.  
  86. CAIRO_BEGIN_DECLS
  87.  
  88. #if _WIN32 && !_WIN32_WCE /* Permissions on WinCE? No worries! */
  89. cairo_private FILE *
  90. _cairo_win32_tmpfile (void);
  91. #define tmpfile() _cairo_win32_tmpfile()
  92. #endif
  93.  
  94. #undef MIN
  95. #define MIN(a, b) ((a) < (b) ? (a) : (b))
  96.  
  97. #undef MAX
  98. #define MAX(a, b) ((a) > (b) ? (a) : (b))
  99.  
  100. #ifndef FALSE
  101. #define FALSE 0
  102. #endif
  103.  
  104. #ifndef TRUE
  105. #define TRUE 1
  106. #endif
  107.  
  108. #ifndef M_PI
  109. #define M_PI 3.14159265358979323846
  110. #endif
  111.  
  112. #ifndef M_SQRT2
  113. #define M_SQRT2 1.41421356237309504880
  114. #endif
  115.  
  116. #ifndef M_SQRT1_2
  117. #define M_SQRT1_2 0.707106781186547524400844362104849039
  118. #endif
  119.  
  120. #undef  ARRAY_LENGTH
  121. #define ARRAY_LENGTH(__array) ((int) (sizeof (__array) / sizeof (__array[0])))
  122.  
  123. #undef STRINGIFY
  124. #undef STRINGIFY_ARG
  125. #define STRINGIFY(macro_or_string)    STRINGIFY_ARG (macro_or_string)
  126. #define STRINGIFY_ARG(contents)       #contents
  127.  
  128. #if defined (__GNUC__)
  129. #define cairo_container_of(ptr, type, member) ({ \
  130.     const __typeof__ (((type *) 0)->member) *mptr__ = (ptr); \
  131.     (type *) ((char *) mptr__ - offsetof (type, member)); \
  132. })
  133. #else
  134. #define cairo_container_of(ptr, type, member) \
  135.     ((type *)((char *) (ptr) - (char *) &((type *)0)->member))
  136. #endif
  137.  
  138.  
  139. #define ASSERT_NOT_REACHED              \
  140. do {                                    \
  141.     assert (!"reached");                \
  142. } while (0)
  143. #define COMPILE_TIME_ASSERT1(condition, line)           \
  144.     typedef int compile_time_assertion_at_line_##line##_failed [(condition)?1:-1]
  145. #define COMPILE_TIME_ASSERT0(condition, line)   COMPILE_TIME_ASSERT1(condition, line)
  146. #define COMPILE_TIME_ASSERT(condition)          COMPILE_TIME_ASSERT0(condition, __LINE__)
  147.  
  148. #define CAIRO_ALPHA_IS_CLEAR(alpha) ((alpha) <= ((double)0x00ff / (double)0xffff))
  149. #define CAIRO_ALPHA_SHORT_IS_CLEAR(alpha) ((alpha) <= 0x00ff)
  150.  
  151. #define CAIRO_ALPHA_IS_OPAQUE(alpha) ((alpha) >= ((double)0xff00 / (double)0xffff))
  152. #define CAIRO_ALPHA_SHORT_IS_OPAQUE(alpha) ((alpha) >= 0xff00)
  153. #define CAIRO_ALPHA_IS_ZERO(alpha) ((alpha) <= 0.0)
  154.  
  155. #define CAIRO_COLOR_IS_CLEAR(color) CAIRO_ALPHA_SHORT_IS_CLEAR ((color)->alpha_short)
  156. #define CAIRO_COLOR_IS_OPAQUE(color) CAIRO_ALPHA_SHORT_IS_OPAQUE ((color)->alpha_short)
  157.  
  158. /* Reverse the bits in a byte with 7 operations (no 64-bit):
  159.  * Devised by Sean Anderson, July 13, 2001.
  160.  * Source: http://graphics.stanford.edu/~seander/bithacks.html#ReverseByteWith32Bits
  161.  */
  162. #define CAIRO_BITSWAP8(c) ((((c) * 0x0802LU & 0x22110LU) | ((c) * 0x8020LU & 0x88440LU)) * 0x10101LU >> 16)
  163.  
  164. /* Return the number of 1 bits in mask.
  165.  *
  166.  * GCC 3.4 supports a "population count" builtin, which on many targets is
  167.  * implemented with a single instruction. There is a fallback definition
  168.  * in libgcc in case a target does not have one, which should be just as
  169.  * good as the open-coded solution below, (which is "HACKMEM 169").
  170.  */
  171. static inline int cairo_const
  172. _cairo_popcount (uint32_t mask)
  173. {
  174. #if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)
  175.     return __builtin_popcount (mask);
  176. #else
  177.     register int y;
  178.  
  179.     y = (mask >> 1) &033333333333;
  180.     y = mask - y - ((y >>1) & 033333333333);
  181.     return (((y + (y >> 3)) & 030707070707) % 077);
  182. #endif
  183. }
  184.  
  185. #ifdef WORDS_BIGENDIAN
  186. #define CAIRO_BITSWAP8_IF_LITTLE_ENDIAN(c) (c)
  187. #else
  188. #define CAIRO_BITSWAP8_IF_LITTLE_ENDIAN(c) CAIRO_BITSWAP8(c)
  189. #endif
  190.  
  191. #ifdef WORDS_BIGENDIAN
  192.  
  193. #define cpu_to_be16(v) (v)
  194. #define be16_to_cpu(v) (v)
  195. #define cpu_to_be32(v) (v)
  196. #define be32_to_cpu(v) (v)
  197.  
  198. #else
  199.  
  200. static inline uint16_t cairo_const
  201. cpu_to_be16(uint16_t v)
  202. {
  203.     return (v << 8) | (v >> 8);
  204. }
  205.  
  206. static inline uint16_t cairo_const
  207. be16_to_cpu(uint16_t v)
  208. {
  209.     return cpu_to_be16 (v);
  210. }
  211.  
  212. static inline uint32_t cairo_const
  213. cpu_to_be32(uint32_t v)
  214. {
  215.     return (cpu_to_be16 (v) << 16) | cpu_to_be16 (v >> 16);
  216. }
  217.  
  218. static inline uint32_t cairo_const
  219. be32_to_cpu(uint32_t v)
  220. {
  221.     return cpu_to_be32 (v);
  222. }
  223.  
  224. #endif
  225.  
  226.  
  227. /* The glibc versions of ispace() and isdigit() are slow in UTF-8 locales.
  228.  */
  229.  
  230. static inline int cairo_const
  231. _cairo_isspace (int c)
  232. {
  233.     return (c == 0x20 || (c >= 0x09 && c <= 0x0d));
  234. }
  235.  
  236. static inline int cairo_const
  237. _cairo_isdigit (int c)
  238. {
  239.     return (c >= '0' && c <= '9');
  240. }
  241.  
  242. #include "cairo-types-private.h"
  243. #include "cairo-cache-private.h"
  244. #include "cairo-reference-count-private.h"
  245. #include "cairo-spans-private.h"
  246.  
  247. cairo_private void
  248. _cairo_box_from_doubles (cairo_box_t *box,
  249.                          double *x1, double *y1,
  250.                          double *x2, double *y2);
  251.  
  252. cairo_private void
  253. _cairo_box_to_doubles (const cairo_box_t *box,
  254.                        double *x1, double *y1,
  255.                        double *x2, double *y2);
  256.  
  257. cairo_private void
  258. _cairo_box_from_rectangle (cairo_box_t                 *box,
  259.                            const cairo_rectangle_int_t *rectangle);
  260.  
  261. cairo_private void
  262. _cairo_box_round_to_rectangle (const cairo_box_t     *box,
  263.                                cairo_rectangle_int_t *rectangle);
  264.  
  265. cairo_private void
  266. _cairo_boxes_get_extents (const cairo_box_t *boxes,
  267.                           int num_boxes,
  268.                           cairo_box_t *extents);
  269.  
  270. static inline void
  271. _cairo_unbounded_rectangle_init (cairo_rectangle_int_t *rect)
  272. {
  273.     rect->x = CAIRO_RECT_INT_MIN;
  274.     rect->y = CAIRO_RECT_INT_MIN;
  275.     rect->width = CAIRO_RECT_INT_MAX - CAIRO_RECT_INT_MIN;
  276.     rect->height = CAIRO_RECT_INT_MAX - CAIRO_RECT_INT_MIN;
  277. }
  278.  
  279. cairo_private cairo_bool_t
  280. _cairo_rectangle_intersect (cairo_rectangle_int_t *dst,
  281.                             const cairo_rectangle_int_t *src);
  282.  
  283. cairo_private cairo_bool_t
  284. _cairo_box_intersects_line_segment (cairo_box_t *box,
  285.                                     cairo_line_t *line) cairo_pure;
  286.  
  287. cairo_private cairo_bool_t
  288. _cairo_box_contains_point (cairo_box_t *box,
  289.                            const cairo_point_t *point) cairo_pure;
  290.  
  291. /* cairo-array.c structures and functions */
  292.  
  293. cairo_private void
  294. _cairo_array_init (cairo_array_t *array, int element_size);
  295.  
  296. cairo_private void
  297. _cairo_array_init_snapshot (cairo_array_t       *array,
  298.                             const cairo_array_t *other);
  299.  
  300. cairo_private void
  301. _cairo_array_fini (cairo_array_t *array);
  302.  
  303. cairo_private cairo_status_t
  304. _cairo_array_grow_by (cairo_array_t *array, unsigned int additional);
  305.  
  306. cairo_private void
  307. _cairo_array_truncate (cairo_array_t *array, unsigned int num_elements);
  308.  
  309. cairo_private cairo_status_t
  310. _cairo_array_append (cairo_array_t *array, const void *element);
  311.  
  312. cairo_private cairo_status_t
  313. _cairo_array_append_multiple (cairo_array_t     *array,
  314.                               const void        *elements,
  315.                               int                num_elements);
  316.  
  317. cairo_private cairo_status_t
  318. _cairo_array_allocate (cairo_array_t     *array,
  319.                        unsigned int       num_elements,
  320.                        void             **elements);
  321.  
  322. cairo_private void *
  323. _cairo_array_index (cairo_array_t *array, unsigned int index);
  324.  
  325. cairo_private void
  326. _cairo_array_copy_element (cairo_array_t *array, int index, void *dst);
  327.  
  328. cairo_private int
  329. _cairo_array_num_elements (cairo_array_t *array);
  330.  
  331. cairo_private int
  332. _cairo_array_size (cairo_array_t *array);
  333.  
  334. typedef struct {
  335.     const cairo_user_data_key_t *key;
  336.     void *user_data;
  337.     cairo_destroy_func_t destroy;
  338. } cairo_user_data_slot_t;
  339.  
  340. cairo_private void
  341. _cairo_user_data_array_init (cairo_user_data_array_t *array);
  342.  
  343. cairo_private void
  344. _cairo_user_data_array_fini (cairo_user_data_array_t *array);
  345.  
  346. cairo_private void *
  347. _cairo_user_data_array_get_data (cairo_user_data_array_t     *array,
  348.                                  const cairo_user_data_key_t *key);
  349.  
  350. cairo_private cairo_status_t
  351. _cairo_user_data_array_set_data (cairo_user_data_array_t     *array,
  352.                                  const cairo_user_data_key_t *key,
  353.                                  void                        *user_data,
  354.                                  cairo_destroy_func_t         destroy);
  355.  
  356. cairo_private cairo_status_t
  357. _cairo_user_data_array_copy (cairo_user_data_array_t    *dst,
  358.                              cairo_user_data_array_t    *src);
  359.  
  360. cairo_private void
  361. _cairo_user_data_array_foreach (cairo_user_data_array_t     *array,
  362.                                 void (*func) (const void *key,
  363.                                               void *elt,
  364.                                               void *closure),
  365.                                 void *closure);
  366.  
  367. #define _CAIRO_HASH_INIT_VALUE 5381
  368.  
  369. cairo_private unsigned long
  370. _cairo_hash_string (const char *c);
  371.  
  372. cairo_private unsigned long
  373. _cairo_hash_bytes (unsigned long hash,
  374.                    const void *bytes,
  375.                    unsigned int length);
  376.  
  377. #define _cairo_scaled_glyph_index(g) ((g)->hash_entry.hash)
  378. #define _cairo_scaled_glyph_set_index(g, i)  ((g)->hash_entry.hash = (i))
  379.  
  380. #include "cairo-scaled-font-private.h"
  381.  
  382. struct _cairo_font_face {
  383.     /* hash_entry must be first */
  384.     cairo_hash_entry_t hash_entry;
  385.     cairo_status_t status;
  386.     cairo_reference_count_t ref_count;
  387.     cairo_user_data_array_t user_data;
  388.     const cairo_font_face_backend_t *backend;
  389. };
  390.  
  391. cairo_private void
  392. _cairo_reset_static_data (void);
  393.  
  394. cairo_private void
  395. _cairo_toy_font_face_reset_static_data (void);
  396.  
  397. cairo_private void
  398. _cairo_ft_font_reset_static_data (void);
  399.  
  400. /* the font backend interface */
  401.  
  402. struct _cairo_unscaled_font_backend {
  403.     void (*destroy)                 (void                            *unscaled_font);
  404. };
  405.  
  406. /* #cairo_toy_font_face_t - simple family/slant/weight font faces used for
  407.  * the built-in font API
  408.  */
  409.  
  410. typedef struct _cairo_toy_font_face {
  411.     cairo_font_face_t base;
  412.     const char *family;
  413.     cairo_bool_t owns_family;
  414.     cairo_font_slant_t slant;
  415.     cairo_font_weight_t weight;
  416.  
  417.     cairo_font_face_t *impl_face; /* The non-toy font face this actually uses */
  418. } cairo_toy_font_face_t;
  419.  
  420. typedef enum _cairo_scaled_glyph_info {
  421.     CAIRO_SCALED_GLYPH_INFO_METRICS      = (1 << 0),
  422.     CAIRO_SCALED_GLYPH_INFO_SURFACE      = (1 << 1),
  423.     CAIRO_SCALED_GLYPH_INFO_PATH         = (1 << 2),
  424.     CAIRO_SCALED_GLYPH_INFO_RECORDING_SURFACE = (1 << 3)
  425. } cairo_scaled_glyph_info_t;
  426.  
  427. typedef struct _cairo_scaled_font_subset {
  428.     cairo_scaled_font_t *scaled_font;
  429.     unsigned int font_id;
  430.     unsigned int subset_id;
  431.  
  432.     /* Index of glyphs array is subset_glyph_index.
  433.      * Value of glyphs array is scaled_font_glyph_index.
  434.      */
  435.     unsigned long *glyphs;
  436.     unsigned long *to_unicode;
  437.     char          **utf8;
  438.     char          **glyph_names;
  439.     unsigned int num_glyphs;
  440.     cairo_bool_t is_composite;
  441.     cairo_bool_t is_scaled;
  442. } cairo_scaled_font_subset_t;
  443.  
  444. struct _cairo_scaled_font_backend {
  445.     cairo_font_type_t type;
  446.  
  447.     void
  448.     (*fini)             (void                   *scaled_font);
  449.  
  450.     cairo_warn cairo_int_status_t
  451.     (*scaled_glyph_init)        (void                        *scaled_font,
  452.                                  cairo_scaled_glyph_t        *scaled_glyph,
  453.                                  cairo_scaled_glyph_info_t    info);
  454.  
  455.     /* A backend only needs to implement this or ucs4_to_index(), not
  456.      * both. This allows the backend to do something more sophisticated
  457.      * then just converting characters one by one.
  458.      */
  459.     cairo_warn cairo_int_status_t
  460.     (*text_to_glyphs) (void                       *scaled_font,
  461.                        double                      x,
  462.                        double                      y,
  463.                        const char                 *utf8,
  464.                        int                         utf8_len,
  465.                        cairo_glyph_t             **glyphs,
  466.                        int                        *num_glyphs,
  467.                        cairo_text_cluster_t      **clusters,
  468.                        int                        *num_clusters,
  469.                        cairo_text_cluster_flags_t *cluster_flags);
  470.  
  471.     unsigned long
  472.     (*ucs4_to_index)            (void                        *scaled_font,
  473.                                  uint32_t                     ucs4);
  474.     cairo_warn cairo_int_status_t
  475.     (*show_glyphs)      (void                   *scaled_font,
  476.                          cairo_operator_t        op,
  477.                          const cairo_pattern_t  *pattern,
  478.                          cairo_surface_t        *surface,
  479.                          int                     source_x,
  480.                          int                     source_y,
  481.                          int                     dest_x,
  482.                          int                     dest_y,
  483.                          unsigned int            width,
  484.                          unsigned int            height,
  485.                          cairo_glyph_t          *glyphs,
  486.                          int                     num_glyphs,
  487.                          cairo_region_t         *clip_region,
  488.                          int                    *remaining_glyphs);
  489.  
  490.     cairo_warn cairo_int_status_t
  491.     (*load_truetype_table)(void                 *scaled_font,
  492.                            unsigned long         tag,
  493.                            long                  offset,
  494.                            unsigned char        *buffer,
  495.                            unsigned long        *length);
  496.  
  497.     /* ucs4 is set to -1 if the unicode character could not be found
  498.      * for the glyph */
  499.     cairo_warn cairo_int_status_t
  500.     (*index_to_ucs4)(void                       *scaled_font,
  501.                      unsigned long               index,
  502.                      uint32_t                   *ucs4);
  503. };
  504.  
  505. struct _cairo_font_face_backend {
  506.     cairo_font_type_t   type;
  507.  
  508.     cairo_warn cairo_status_t
  509.     (*create_for_toy)  (cairo_toy_font_face_t   *toy_face,
  510.                         cairo_font_face_t      **font_face);
  511.  
  512.     /* The destroy() function is allowed to resurrect the font face
  513.      * by re-referencing. This is needed for the FreeType backend.
  514.      */
  515.     void
  516.     (*destroy)     (void                        *font_face);
  517.  
  518.     cairo_warn cairo_status_t
  519.     (*scaled_font_create) (void                         *font_face,
  520.                            const cairo_matrix_t         *font_matrix,
  521.                            const cairo_matrix_t         *ctm,
  522.                            const cairo_font_options_t   *options,
  523.                            cairo_scaled_font_t         **scaled_font);
  524.  
  525.     cairo_font_face_t *
  526.     (*get_implementation) (void                         *font_face,
  527.                            const cairo_matrix_t         *font_matrix,
  528.                            const cairo_matrix_t         *ctm,
  529.                            const cairo_font_options_t   *options);
  530. };
  531.  
  532. extern const cairo_private struct _cairo_font_face_backend _cairo_user_font_face_backend;
  533.  
  534. /* concrete font backends */
  535. #if CAIRO_HAS_FT_FONT
  536.  
  537. extern const cairo_private struct _cairo_font_face_backend _cairo_ft_font_face_backend;
  538.  
  539. #endif
  540.  
  541. #if CAIRO_HAS_WIN32_FONT
  542.  
  543. extern const cairo_private struct _cairo_font_face_backend _cairo_win32_font_face_backend;
  544.  
  545. #endif
  546.  
  547. #if CAIRO_HAS_QUARTZ_FONT
  548.  
  549. extern const cairo_private struct _cairo_font_face_backend _cairo_quartz_font_face_backend;
  550.  
  551. #endif
  552.  
  553. struct _cairo_surface_backend {
  554.     cairo_surface_type_t type;
  555.  
  556.     cairo_surface_t *
  557.     (*create_similar)           (void                   *surface,
  558.                                  cairo_content_t         content,
  559.                                  int                     width,
  560.                                  int                     height);
  561.  
  562.     cairo_warn cairo_status_t
  563.     (*finish)                   (void                   *surface);
  564.  
  565.     cairo_warn cairo_status_t
  566.     (*acquire_source_image)     (void                    *abstract_surface,
  567.                                  cairo_image_surface_t  **image_out,
  568.                                  void                   **image_extra);
  569.  
  570.     void
  571.     (*release_source_image)     (void                   *abstract_surface,
  572.                                  cairo_image_surface_t  *image,
  573.                                  void                   *image_extra);
  574.  
  575.     cairo_warn cairo_status_t
  576.     (*acquire_dest_image)       (void                    *abstract_surface,
  577.                                  cairo_rectangle_int_t   *interest_rect,
  578.                                  cairo_image_surface_t  **image_out,
  579.                                  cairo_rectangle_int_t   *image_rect,
  580.                                  void                   **image_extra);
  581.  
  582.     void
  583.     (*release_dest_image)       (void                    *abstract_surface,
  584.                                  cairo_rectangle_int_t   *interest_rect,
  585.                                  cairo_image_surface_t   *image,
  586.                                  cairo_rectangle_int_t   *image_rect,
  587.                                  void                    *image_extra);
  588.  
  589.     /* Create a new surface (@clone_out) with the following
  590.      * characteristics:
  591.      *
  592.      * 1. It is as compatible as possible with @surface (in terms of
  593.      *    efficiency)
  594.      *
  595.      * 2. It has the same contents as @src within the given rectangle.
  596.      *
  597.      * 3. The offset of the similar surface with respect to the original
  598.      *    surface is returned in the clone_offset vector.
  599.      *    - if you clone the entire surface, this vector is zero.
  600.      *    - if you clone (src_x, src_y)x(w, h) the vector is (src_x, src_y);
  601.      */
  602.     cairo_warn cairo_status_t
  603.     (*clone_similar)            (void                   *surface,
  604.                                  cairo_surface_t        *src,
  605.                                  int                     src_x,
  606.                                  int                     src_y,
  607.                                  int                     width,
  608.                                  int                     height,
  609.                                  int                    *clone_offset_x,
  610.                                  int                    *clone_offset_y,
  611.                                  cairo_surface_t       **clone_out);
  612.  
  613.     /* XXX remove to a separate cairo_surface_compositor_t */
  614.     /* XXX: dst should be the first argument for consistency */
  615.     cairo_warn cairo_int_status_t
  616.     (*composite)                (cairo_operator_t        op,
  617.                                  const cairo_pattern_t  *src,
  618.                                  const cairo_pattern_t  *mask,
  619.                                  void                   *dst,
  620.                                  int                     src_x,
  621.                                  int                     src_y,
  622.                                  int                     mask_x,
  623.                                  int                     mask_y,
  624.                                  int                     dst_x,
  625.                                  int                     dst_y,
  626.                                  unsigned int            width,
  627.                                  unsigned int            height,
  628.                                  cairo_region_t         *clip_region);
  629.  
  630.     cairo_warn cairo_int_status_t
  631.     (*fill_rectangles)          (void                    *surface,
  632.                                  cairo_operator_t         op,
  633.                                  const cairo_color_t     *color,
  634.                                  cairo_rectangle_int_t   *rects,
  635.                                  int                      num_rects);
  636.  
  637.     /* XXX: dst should be the first argument for consistency */
  638.     cairo_warn cairo_int_status_t
  639.     (*composite_trapezoids)     (cairo_operator_t        op,
  640.                                  const cairo_pattern_t  *pattern,
  641.                                  void                   *dst,
  642.                                  cairo_antialias_t       antialias,
  643.                                  int                     src_x,
  644.                                  int                     src_y,
  645.                                  int                     dst_x,
  646.                                  int                     dst_y,
  647.                                  unsigned int            width,
  648.                                  unsigned int            height,
  649.                                  cairo_trapezoid_t      *traps,
  650.                                  int                     num_traps,
  651.                                  cairo_region_t         *region);
  652.  
  653.     cairo_warn cairo_span_renderer_t *
  654.     (*create_span_renderer)     (cairo_operator_t                        op,
  655.                                  const cairo_pattern_t                  *pattern,
  656.                                  void                                   *dst,
  657.                                  cairo_antialias_t                       antialias,
  658.                                  const cairo_composite_rectangles_t *rects,
  659.                                  cairo_region_t *clip_region);
  660.  
  661.     cairo_warn cairo_bool_t
  662.     (*check_span_renderer)      (cairo_operator_t                        op,
  663.                                  const cairo_pattern_t                  *pattern,
  664.                                  void                                   *dst,
  665.                                  cairo_antialias_t                       antialias);
  666.  
  667.     cairo_warn cairo_int_status_t
  668.     (*copy_page)                (void                   *surface);
  669.  
  670.     cairo_warn cairo_int_status_t
  671.     (*show_page)                (void                   *surface);
  672.  
  673.     /* Get the extents of the current surface. For many surface types
  674.      * this will be as simple as { x=0, y=0, width=surface->width,
  675.      * height=surface->height}.
  676.      *
  677.      * If this function is not implemented, or if it returns
  678.      * FALSE the surface is considered to be
  679.      * boundless and infinite bounds are used for it.
  680.      */
  681.     cairo_warn cairo_bool_t
  682.     (*get_extents)              (void                    *surface,
  683.                                  cairo_rectangle_int_t   *extents);
  684.  
  685.     /*
  686.      * This is an optional entry to let the surface manage its own glyph
  687.      * resources. If null, render against this surface, using image
  688.      * surfaces as glyphs.
  689.      */
  690.     cairo_warn cairo_int_status_t
  691.     (*old_show_glyphs)          (cairo_scaled_font_t            *font,
  692.                                  cairo_operator_t                op,
  693.                                  const cairo_pattern_t          *pattern,
  694.                                  void                           *surface,
  695.                                  int                             source_x,
  696.                                  int                             source_y,
  697.                                  int                             dest_x,
  698.                                  int                             dest_y,
  699.                                  unsigned int                    width,
  700.                                  unsigned int                    height,
  701.                                  cairo_glyph_t                  *glyphs,
  702.                                  int                             num_glyphs,
  703.                                  cairo_region_t                 *clip_region);
  704.  
  705.     void
  706.     (*get_font_options)         (void                  *surface,
  707.                                  cairo_font_options_t  *options);
  708.  
  709.     cairo_warn cairo_status_t
  710.     (*flush)                    (void                  *surface);
  711.  
  712.     cairo_warn cairo_status_t
  713.     (*mark_dirty_rectangle)     (void                  *surface,
  714.                                  int                    x,
  715.                                  int                    y,
  716.                                  int                    width,
  717.                                  int                    height);
  718.  
  719.     void
  720.     (*scaled_font_fini)         (cairo_scaled_font_t   *scaled_font);
  721.  
  722.     void
  723.     (*scaled_glyph_fini)        (cairo_scaled_glyph_t   *scaled_glyph,
  724.                                  cairo_scaled_font_t    *scaled_font);
  725.  
  726.     /* OK, I'm starting over somewhat by defining the 5 top-level
  727.      * drawing operators for the surface backend here with consistent
  728.      * naming and argument-order conventions. */
  729.     cairo_warn cairo_int_status_t
  730.     (*paint)                    (void                   *surface,
  731.                                  cairo_operator_t        op,
  732.                                  const cairo_pattern_t  *source,
  733.                                  cairo_clip_t           *clip);
  734.  
  735.     cairo_warn cairo_int_status_t
  736.     (*mask)                     (void                   *surface,
  737.                                  cairo_operator_t        op,
  738.                                  const cairo_pattern_t  *source,
  739.                                  const cairo_pattern_t  *mask,
  740.                                  cairo_clip_t           *clip);
  741.  
  742.     cairo_warn cairo_int_status_t
  743.     (*stroke)                   (void                   *surface,
  744.                                  cairo_operator_t        op,
  745.                                  const cairo_pattern_t  *source,
  746.                                  cairo_path_fixed_t     *path,
  747.                                  const cairo_stroke_style_t     *style,
  748.                                  const cairo_matrix_t   *ctm,
  749.                                  const cairo_matrix_t   *ctm_inverse,
  750.                                  double                  tolerance,
  751.                                  cairo_antialias_t       antialias,
  752.                                  cairo_clip_t           *clip);
  753.  
  754.     cairo_warn cairo_int_status_t
  755.     (*fill)                     (void                   *surface,
  756.                                  cairo_operator_t        op,
  757.                                  const cairo_pattern_t  *source,
  758.                                  cairo_path_fixed_t     *path,
  759.                                  cairo_fill_rule_t       fill_rule,
  760.                                  double                  tolerance,
  761.                                  cairo_antialias_t       antialias,
  762.                                  cairo_clip_t           *clip);
  763.  
  764.     cairo_warn cairo_int_status_t
  765.     (*show_glyphs)              (void                   *surface,
  766.                                  cairo_operator_t        op,
  767.                                  const cairo_pattern_t  *source,
  768.                                  cairo_glyph_t          *glyphs,
  769.                                  int                     num_glyphs,
  770.                                  cairo_scaled_font_t    *scaled_font,
  771.                                  cairo_clip_t           *clip,
  772.                                  int                    *remaining_glyphs);
  773.  
  774.     cairo_surface_t *
  775.     (*snapshot)                 (void                   *surface);
  776.  
  777.     cairo_bool_t
  778.     (*is_similar)               (void                   *surface_a,
  779.                                  void                   *surface_b);
  780.  
  781.     cairo_warn cairo_int_status_t
  782.     (*fill_stroke)              (void                   *surface,
  783.                                  cairo_operator_t        fill_op,
  784.                                  const cairo_pattern_t  *fill_source,
  785.                                  cairo_fill_rule_t       fill_rule,
  786.                                  double                  fill_tolerance,
  787.                                  cairo_antialias_t       fill_antialias,
  788.                                  cairo_path_fixed_t     *path,
  789.                                  cairo_operator_t        stroke_op,
  790.                                  const cairo_pattern_t  *stroke_source,
  791.                                  const cairo_stroke_style_t     *stroke_style,
  792.                                  const cairo_matrix_t   *stroke_ctm,
  793.                                  const cairo_matrix_t   *stroke_ctm_inverse,
  794.                                  double                  stroke_tolerance,
  795.                                  cairo_antialias_t       stroke_antialias,
  796.                                  cairo_clip_t           *clip);
  797.  
  798.     cairo_surface_t *
  799.     (*create_solid_pattern_surface)
  800.                                 (void                         *surface,
  801.                                  const cairo_solid_pattern_t  *solid_pattern);
  802.  
  803.     cairo_bool_t
  804.     (*can_repaint_solid_pattern_surface)
  805.                                 (void                         *surface,
  806.                                  const cairo_solid_pattern_t  *solid_pattern);
  807.  
  808.     cairo_bool_t
  809.     (*has_show_text_glyphs)     (void                       *surface);
  810.  
  811.     cairo_warn cairo_int_status_t
  812.     (*show_text_glyphs)         (void                       *surface,
  813.                                  cairo_operator_t            op,
  814.                                  const cairo_pattern_t      *source,
  815.                                  const char                 *utf8,
  816.                                  int                         utf8_len,
  817.                                  cairo_glyph_t              *glyphs,
  818.                                  int                         num_glyphs,
  819.                                  const cairo_text_cluster_t *clusters,
  820.                                  int                         num_clusters,
  821.                                  cairo_text_cluster_flags_t  cluster_flags,
  822.                                  cairo_scaled_font_t        *scaled_font,
  823.                                  cairo_clip_t               *clip);
  824. };
  825.  
  826. #include "cairo-surface-private.h"
  827.  
  828. struct _cairo_image_surface {
  829.     cairo_surface_t base;
  830.  
  831.     pixman_format_code_t pixman_format;
  832.     cairo_format_t format;
  833.     unsigned char *data;
  834.  
  835.     int width;
  836.     int height;
  837.     int stride;
  838.     int depth;
  839.  
  840.     pixman_image_t *pixman_image;
  841.  
  842.     unsigned owns_data : 1;
  843.     unsigned transparency : 2;
  844. };
  845.  
  846. extern const cairo_private cairo_surface_backend_t _cairo_image_surface_backend;
  847.  
  848. #define CAIRO_EXTEND_SURFACE_DEFAULT CAIRO_EXTEND_NONE
  849. #define CAIRO_EXTEND_GRADIENT_DEFAULT CAIRO_EXTEND_PAD
  850. #define CAIRO_FILTER_DEFAULT CAIRO_FILTER_GOOD
  851.  
  852. extern const cairo_private cairo_solid_pattern_t _cairo_pattern_clear;
  853. extern const cairo_private cairo_solid_pattern_t _cairo_pattern_black;
  854. extern const cairo_private cairo_solid_pattern_t _cairo_pattern_white;
  855.  
  856. typedef struct _cairo_surface_attributes {
  857.     cairo_matrix_t matrix;
  858.     cairo_extend_t extend;
  859.     cairo_filter_t filter;
  860.     cairo_bool_t has_component_alpha;
  861.     int            x_offset;
  862.     int            y_offset;
  863.     void           *extra;
  864. } cairo_surface_attributes_t;
  865.  
  866. typedef struct _cairo_traps {
  867.     cairo_status_t status;
  868.  
  869.     const cairo_box_t *limits;
  870.     int num_limits;
  871.  
  872.     unsigned int maybe_region : 1; /* hint: 0 implies that it cannot be */
  873.     unsigned int has_intersections : 1;
  874.     unsigned int is_rectilinear : 1;
  875.     unsigned int is_rectangular : 1;
  876.  
  877.     int num_traps;
  878.     int traps_size;
  879.     cairo_trapezoid_t *traps;
  880.     cairo_trapezoid_t  traps_embedded[16];
  881. } cairo_traps_t;
  882.  
  883. #define CAIRO_FONT_SLANT_DEFAULT   CAIRO_FONT_SLANT_NORMAL
  884. #define CAIRO_FONT_WEIGHT_DEFAULT  CAIRO_FONT_WEIGHT_NORMAL
  885.  
  886. #define CAIRO_WIN32_FONT_FAMILY_DEFAULT "Arial"
  887. #define CAIRO_QUARTZ_FONT_FAMILY_DEFAULT  "Helvetica"
  888. #define CAIRO_FT_FONT_FAMILY_DEFAULT     ""
  889. #define CAIRO_USER_FONT_FAMILY_DEFAULT     "@cairo:"
  890.  
  891. #if   CAIRO_HAS_WIN32_FONT
  892.  
  893. #define CAIRO_FONT_FAMILY_DEFAULT CAIRO_WIN32_FONT_FAMILY_DEFAULT
  894. #define CAIRO_FONT_FACE_BACKEND_DEFAULT &_cairo_win32_font_face_backend
  895.  
  896. #elif CAIRO_HAS_QUARTZ_FONT
  897.  
  898. #define CAIRO_FONT_FAMILY_DEFAULT CAIRO_QUARTZ_FONT_FAMILY_DEFAULT
  899. #define CAIRO_FONT_FACE_BACKEND_DEFAULT &_cairo_quartz_font_face_backend
  900.  
  901. #elif CAIRO_HAS_FT_FONT
  902.  
  903. #define CAIRO_FONT_FAMILY_DEFAULT CAIRO_FT_FONT_FAMILY_DEFAULT
  904. #define CAIRO_FONT_FACE_BACKEND_DEFAULT &_cairo_ft_font_face_backend
  905.  
  906. #else
  907.  
  908. #define CAIRO_FONT_FAMILY_DEFAULT CAIRO_FT_FONT_FAMILY_DEFAULT
  909. #define CAIRO_FONT_FACE_BACKEND_DEFAULT &_cairo_user_font_face_backend
  910.  
  911. #endif
  912.  
  913. #define CAIRO_GSTATE_OPERATOR_DEFAULT   CAIRO_OPERATOR_OVER
  914. #define CAIRO_GSTATE_TOLERANCE_DEFAULT  0.1
  915. #define CAIRO_GSTATE_FILL_RULE_DEFAULT  CAIRO_FILL_RULE_WINDING
  916. #define CAIRO_GSTATE_LINE_WIDTH_DEFAULT 2.0
  917. #define CAIRO_GSTATE_LINE_CAP_DEFAULT   CAIRO_LINE_CAP_BUTT
  918. #define CAIRO_GSTATE_LINE_JOIN_DEFAULT  CAIRO_LINE_JOIN_MITER
  919. #define CAIRO_GSTATE_MITER_LIMIT_DEFAULT        10.0
  920. #define CAIRO_GSTATE_DEFAULT_FONT_SIZE  10.0
  921.  
  922. #define CAIRO_SURFACE_RESOLUTION_DEFAULT 72.0
  923. #define CAIRO_SURFACE_FALLBACK_RESOLUTION_DEFAULT 300.0
  924.  
  925. typedef struct _cairo_stroke_face {
  926.     cairo_point_t ccw;
  927.     cairo_point_t point;
  928.     cairo_point_t cw;
  929.     cairo_slope_t dev_vector;
  930.     cairo_point_double_t usr_vector;
  931. } cairo_stroke_face_t;
  932.  
  933. /* cairo.c */
  934.  
  935. static inline double cairo_const
  936. _cairo_restrict_value (double value, double min, double max)
  937. {
  938.     if (value < min)
  939.         return min;
  940.     else if (value > max)
  941.         return max;
  942.     else
  943.         return value;
  944. }
  945.  
  946. /* C99 round() rounds to the nearest integral value with halfway cases rounded
  947.  * away from 0. _cairo_round rounds halfway cases toward negative infinity.
  948.  * This matches the rounding behaviour of _cairo_lround. */
  949. static inline double cairo_const
  950. _cairo_round (double r)
  951. {
  952.     return floor (r + .5);
  953. }
  954.  
  955. #if DISABLE_SOME_FLOATING_POINT
  956. cairo_private int
  957. _cairo_lround (double d) cairo_const;
  958. #else
  959. #define _cairo_lround lround
  960. #endif
  961.  
  962. cairo_private uint16_t
  963. _cairo_half_from_float (float f) cairo_const;
  964.  
  965. cairo_private cairo_bool_t
  966. _cairo_operator_bounded_by_mask (cairo_operator_t op) cairo_const;
  967.  
  968. cairo_private cairo_bool_t
  969. _cairo_operator_bounded_by_source (cairo_operator_t op) cairo_const;
  970.  
  971. enum {
  972.     CAIRO_OPERATOR_BOUND_BY_MASK = 1 << 1,
  973.     CAIRO_OPERATOR_BOUND_BY_SOURCE = 1 << 2,
  974. };
  975.  
  976. cairo_private uint32_t
  977. _cairo_operator_bounded_by_either (cairo_operator_t op) cairo_const;
  978. /* cairo-color.c */
  979. cairo_private const cairo_color_t *
  980. _cairo_stock_color (cairo_stock_t stock) cairo_pure;
  981.  
  982. #define CAIRO_COLOR_WHITE       _cairo_stock_color (CAIRO_STOCK_WHITE)
  983. #define CAIRO_COLOR_BLACK       _cairo_stock_color (CAIRO_STOCK_BLACK)
  984. #define CAIRO_COLOR_TRANSPARENT _cairo_stock_color (CAIRO_STOCK_TRANSPARENT)
  985.  
  986. cairo_private uint16_t
  987. _cairo_color_double_to_short (double d) cairo_const;
  988.  
  989. cairo_private void
  990. _cairo_color_init (cairo_color_t *color);
  991.  
  992. cairo_private void
  993. _cairo_color_init_rgb (cairo_color_t *color,
  994.                        double red, double green, double blue);
  995.  
  996. cairo_private void
  997. _cairo_color_init_rgba (cairo_color_t *color,
  998.                         double red, double green, double blue,
  999.                         double alpha);
  1000.  
  1001. cairo_private void
  1002. _cairo_color_multiply_alpha (cairo_color_t *color,
  1003.                              double         alpha);
  1004.  
  1005. cairo_private void
  1006. _cairo_color_get_rgba (cairo_color_t *color,
  1007.                        double        *red,
  1008.                        double        *green,
  1009.                        double        *blue,
  1010.                        double        *alpha);
  1011.  
  1012. cairo_private void
  1013. _cairo_color_get_rgba_premultiplied (cairo_color_t *color,
  1014.                                      double        *red,
  1015.                                      double        *green,
  1016.                                      double        *blue,
  1017.                                      double        *alpha);
  1018.  
  1019. cairo_private cairo_bool_t
  1020. _cairo_color_equal (const cairo_color_t *color_a,
  1021.                     const cairo_color_t *color_b) cairo_pure;
  1022.  
  1023. cairo_private cairo_bool_t
  1024. _cairo_color_stop_equal (const cairo_color_stop_t *color_a,
  1025.                          const cairo_color_stop_t *color_b) cairo_pure;
  1026.  
  1027. cairo_private cairo_content_t
  1028. _cairo_color_get_content (const cairo_color_t *color) cairo_pure;
  1029.  
  1030. /* cairo-font-face.c */
  1031.  
  1032. extern const cairo_private cairo_font_face_t _cairo_font_face_nil;
  1033.  
  1034. cairo_private void
  1035. _cairo_font_face_init (cairo_font_face_t               *font_face,
  1036.                        const cairo_font_face_backend_t *backend);
  1037.  
  1038. cairo_private cairo_status_t
  1039. _cairo_font_face_set_error (cairo_font_face_t *font_face,
  1040.                             cairo_status_t     status);
  1041.  
  1042. cairo_private void
  1043. _cairo_unscaled_font_init (cairo_unscaled_font_t               *font,
  1044.                            const cairo_unscaled_font_backend_t *backend);
  1045.  
  1046. cairo_private_no_warn cairo_unscaled_font_t *
  1047. _cairo_unscaled_font_reference (cairo_unscaled_font_t *font);
  1048.  
  1049. cairo_private void
  1050. _cairo_unscaled_font_destroy (cairo_unscaled_font_t *font);
  1051.  
  1052. /* cairo-font-face-twin.c */
  1053.  
  1054. cairo_private cairo_font_face_t *
  1055. _cairo_font_face_twin_create_fallback (void);
  1056.  
  1057. cairo_private cairo_status_t
  1058. _cairo_font_face_twin_create_for_toy (cairo_toy_font_face_t   *toy_face,
  1059.                                       cairo_font_face_t      **font_face);
  1060.  
  1061. /* cairo-font-face-twin-data.c */
  1062.  
  1063. extern const cairo_private int8_t _cairo_twin_outlines[];
  1064. extern const cairo_private uint16_t _cairo_twin_charmap[128];
  1065.  
  1066. /* cairo-font-options.c */
  1067.  
  1068. cairo_private void
  1069. _cairo_font_options_init_default (cairo_font_options_t *options);
  1070.  
  1071. cairo_private void
  1072. _cairo_font_options_init_copy (cairo_font_options_t             *options,
  1073.                                const cairo_font_options_t       *other);
  1074.  
  1075. cairo_private void
  1076. _cairo_font_options_set_lcd_filter (cairo_font_options_t   *options,
  1077.                                    cairo_lcd_filter_t  lcd_filter);
  1078.  
  1079. cairo_private cairo_lcd_filter_t
  1080. _cairo_font_options_get_lcd_filter (const cairo_font_options_t *options);
  1081.  
  1082. /* cairo-hull.c */
  1083. cairo_private cairo_status_t
  1084. _cairo_hull_compute (cairo_pen_vertex_t *vertices, int *num_vertices);
  1085.  
  1086. /* cairo-lzw.c */
  1087. cairo_private unsigned char *
  1088. _cairo_lzw_compress (unsigned char *data, unsigned long *size_in_out);
  1089.  
  1090. /* cairo-misc.c */
  1091. cairo_private cairo_status_t
  1092. _cairo_validate_text_clusters (const char                  *utf8,
  1093.                                int                          utf8_len,
  1094.                                const cairo_glyph_t         *glyphs,
  1095.                                int                          num_glyphs,
  1096.                                const cairo_text_cluster_t  *clusters,
  1097.                                int                          num_clusters,
  1098.                                cairo_text_cluster_flags_t   cluster_flags);
  1099.  
  1100. cairo_private cairo_status_t
  1101. _cairo_intern_string (const char **str_inout, int len);
  1102.  
  1103. cairo_private void
  1104. _cairo_intern_string_reset_static_data (void);
  1105.  
  1106. /* cairo-path-fixed.c */
  1107. cairo_private cairo_path_fixed_t *
  1108. _cairo_path_fixed_create (void);
  1109.  
  1110. cairo_private void
  1111. _cairo_path_fixed_init (cairo_path_fixed_t *path);
  1112.  
  1113. cairo_private cairo_status_t
  1114. _cairo_path_fixed_init_copy (cairo_path_fixed_t *path,
  1115.                              const cairo_path_fixed_t *other);
  1116.  
  1117. cairo_private cairo_bool_t
  1118. _cairo_path_fixed_is_equal (const cairo_path_fixed_t *path,
  1119.                             const cairo_path_fixed_t *other);
  1120.  
  1121. cairo_private void
  1122. _cairo_path_fixed_fini (cairo_path_fixed_t *path);
  1123.  
  1124. cairo_private void
  1125. _cairo_path_fixed_destroy (cairo_path_fixed_t *path);
  1126.  
  1127. cairo_private cairo_status_t
  1128. _cairo_path_fixed_move_to (cairo_path_fixed_t  *path,
  1129.                            cairo_fixed_t        x,
  1130.                            cairo_fixed_t        y);
  1131.  
  1132. cairo_private void
  1133. _cairo_path_fixed_new_sub_path (cairo_path_fixed_t *path);
  1134.  
  1135. cairo_private cairo_status_t
  1136. _cairo_path_fixed_rel_move_to (cairo_path_fixed_t *path,
  1137.                                cairo_fixed_t       dx,
  1138.                                cairo_fixed_t       dy);
  1139.  
  1140. cairo_private cairo_status_t
  1141. _cairo_path_fixed_line_to (cairo_path_fixed_t *path,
  1142.                            cairo_fixed_t        x,
  1143.                            cairo_fixed_t        y);
  1144.  
  1145. cairo_private cairo_status_t
  1146. _cairo_path_fixed_rel_line_to (cairo_path_fixed_t *path,
  1147.                                cairo_fixed_t       dx,
  1148.                                cairo_fixed_t       dy);
  1149.  
  1150. cairo_private cairo_status_t
  1151. _cairo_path_fixed_curve_to (cairo_path_fixed_t  *path,
  1152.                             cairo_fixed_t x0, cairo_fixed_t y0,
  1153.                             cairo_fixed_t x1, cairo_fixed_t y1,
  1154.                             cairo_fixed_t x2, cairo_fixed_t y2);
  1155.  
  1156. cairo_private cairo_status_t
  1157. _cairo_path_fixed_rel_curve_to (cairo_path_fixed_t *path,
  1158.                                 cairo_fixed_t dx0, cairo_fixed_t dy0,
  1159.                                 cairo_fixed_t dx1, cairo_fixed_t dy1,
  1160.                                 cairo_fixed_t dx2, cairo_fixed_t dy2);
  1161.  
  1162. cairo_private cairo_status_t
  1163. _cairo_path_fixed_close_path (cairo_path_fixed_t *path);
  1164.  
  1165. cairo_private cairo_bool_t
  1166. _cairo_path_fixed_get_current_point (cairo_path_fixed_t *path,
  1167.                                      cairo_fixed_t      *x,
  1168.                                      cairo_fixed_t      *y);
  1169.  
  1170. typedef cairo_status_t
  1171. (cairo_path_fixed_move_to_func_t) (void          *closure,
  1172.                                    const cairo_point_t *point);
  1173.  
  1174. typedef cairo_status_t
  1175. (cairo_path_fixed_line_to_func_t) (void          *closure,
  1176.                                    const cairo_point_t *point);
  1177.  
  1178. typedef cairo_status_t
  1179. (cairo_path_fixed_curve_to_func_t) (void          *closure,
  1180.                                     const cairo_point_t *p0,
  1181.                                     const cairo_point_t *p1,
  1182.                                     const cairo_point_t *p2);
  1183.  
  1184. typedef cairo_status_t
  1185. (cairo_path_fixed_close_path_func_t) (void *closure);
  1186.  
  1187. cairo_private cairo_status_t
  1188. _cairo_path_fixed_interpret (const cairo_path_fixed_t     *path,
  1189.                        cairo_direction_t                   dir,
  1190.                        cairo_path_fixed_move_to_func_t    *move_to,
  1191.                        cairo_path_fixed_line_to_func_t    *line_to,
  1192.                        cairo_path_fixed_curve_to_func_t   *curve_to,
  1193.                        cairo_path_fixed_close_path_func_t *close_path,
  1194.                        void                               *closure);
  1195.  
  1196. cairo_private cairo_status_t
  1197. _cairo_path_fixed_interpret_flat (const cairo_path_fixed_t *path,
  1198.                        cairo_direction_t                   dir,
  1199.                        cairo_path_fixed_move_to_func_t    *move_to,
  1200.                        cairo_path_fixed_line_to_func_t    *line_to,
  1201.                        cairo_path_fixed_close_path_func_t *close_path,
  1202.                        void                               *closure,
  1203.                        double                             tolerance);
  1204.  
  1205. cairo_private cairo_bool_t
  1206. _cairo_path_fixed_extents (const cairo_path_fixed_t *path,
  1207.                            cairo_box_t *box);
  1208.  
  1209. cairo_private void
  1210. _cairo_path_fixed_approximate_clip_extents (const cairo_path_fixed_t    *path,
  1211.                                             cairo_rectangle_int_t *extents);
  1212.  
  1213. cairo_private void
  1214. _cairo_path_fixed_approximate_fill_extents (const cairo_path_fixed_t *path,
  1215.                                             cairo_rectangle_int_t *extents);
  1216.  
  1217. cairo_private void
  1218. _cairo_path_fixed_fill_extents (const cairo_path_fixed_t        *path,
  1219.                                 cairo_fill_rule_t        fill_rule,
  1220.                                 double                   tolerance,
  1221.                                 cairo_rectangle_int_t   *extents);
  1222.  
  1223. cairo_private void
  1224. _cairo_path_fixed_approximate_stroke_extents (const cairo_path_fixed_t *path,
  1225.                                               const cairo_stroke_style_t *style,
  1226.                                               const cairo_matrix_t *ctm,
  1227.                                               cairo_rectangle_int_t *extents);
  1228.  
  1229. cairo_private cairo_status_t
  1230. _cairo_path_fixed_stroke_extents (const cairo_path_fixed_t *path,
  1231.                                   const cairo_stroke_style_t *style,
  1232.                                   const cairo_matrix_t *ctm,
  1233.                                   const cairo_matrix_t *ctm_inverse,
  1234.                                   double tolerance,
  1235.                                   cairo_rectangle_int_t *extents);
  1236.  
  1237. cairo_private void
  1238. _cairo_path_fixed_transform (cairo_path_fixed_t *path,
  1239.                              const cairo_matrix_t       *matrix);
  1240.  
  1241. cairo_private cairo_bool_t
  1242. _cairo_path_fixed_is_box (const cairo_path_fixed_t *path,
  1243.                           cairo_box_t *box);
  1244.  
  1245. cairo_private cairo_bool_t
  1246. _cairo_path_fixed_is_rectangle (const cairo_path_fixed_t *path,
  1247.                                 cairo_box_t        *box);
  1248.  
  1249. /* cairo-path-in-fill.c */
  1250. cairo_private cairo_bool_t
  1251. _cairo_path_fixed_in_fill (const cairo_path_fixed_t     *path,
  1252.                            cairo_fill_rule_t     fill_rule,
  1253.                            double                tolerance,
  1254.                            double                x,
  1255.                            double                y);
  1256.  
  1257. /* cairo-path-fill.c */
  1258. cairo_private cairo_status_t
  1259. _cairo_path_fixed_fill_to_polygon (const cairo_path_fixed_t *path,
  1260.                                    double              tolerance,
  1261.                                    cairo_polygon_t      *polygon);
  1262.  
  1263. cairo_private cairo_int_status_t
  1264. _cairo_path_fixed_fill_rectilinear_to_traps (const cairo_path_fixed_t *path,
  1265.                                              cairo_fill_rule_t fill_rule,
  1266.                                              cairo_traps_t *traps);
  1267.  
  1268. cairo_private cairo_status_t
  1269. _cairo_path_fixed_fill_rectilinear_to_boxes (const cairo_path_fixed_t *path,
  1270.                                              cairo_fill_rule_t fill_rule,
  1271.                                              cairo_boxes_t *boxes);
  1272.  
  1273. cairo_private cairo_region_t *
  1274. _cairo_path_fixed_fill_rectilinear_to_region (const cairo_path_fixed_t  *path,
  1275.                                               cairo_fill_rule_t  fill_rule,
  1276.                                               const cairo_rectangle_int_t *extents);
  1277.  
  1278. cairo_private cairo_status_t
  1279. _cairo_path_fixed_fill_to_traps (const cairo_path_fixed_t   *path,
  1280.                                  cairo_fill_rule_t           fill_rule,
  1281.                                  double                      tolerance,
  1282.                                  cairo_traps_t              *traps);
  1283.  
  1284. /* cairo-path-stroke.c */
  1285. cairo_private cairo_status_t
  1286. _cairo_path_fixed_stroke_to_polygon (const cairo_path_fixed_t   *path,
  1287.                                      const cairo_stroke_style_t *stroke_style,
  1288.                                      const cairo_matrix_t       *ctm,
  1289.                                      const cairo_matrix_t       *ctm_inverse,
  1290.                                      double              tolerance,
  1291.                                      cairo_polygon_t    *polygon);
  1292.  
  1293. cairo_private cairo_int_status_t
  1294. _cairo_path_fixed_stroke_rectilinear_to_traps (const cairo_path_fixed_t *path,
  1295.                                                const cairo_stroke_style_t       *stroke_style,
  1296.                                                const cairo_matrix_t     *ctm,
  1297.                                                cairo_traps_t            *traps);
  1298.  
  1299. cairo_private cairo_int_status_t
  1300. _cairo_path_fixed_stroke_rectilinear_to_boxes (const cairo_path_fixed_t *path,
  1301.                                                const cairo_stroke_style_t       *stroke_style,
  1302.                                                const cairo_matrix_t     *ctm,
  1303.                                                cairo_boxes_t            *boxes);
  1304.  
  1305. cairo_private cairo_status_t
  1306. _cairo_path_fixed_stroke_to_traps (const cairo_path_fixed_t     *path,
  1307.                                    const cairo_stroke_style_t   *stroke_style,
  1308.                                    const cairo_matrix_t *ctm,
  1309.                                    const cairo_matrix_t *ctm_inverse,
  1310.                                    double                tolerance,
  1311.                                    cairo_traps_t        *traps);
  1312.  
  1313. cairo_private cairo_status_t
  1314. _cairo_path_fixed_stroke_to_shaper (cairo_path_fixed_t  *path,
  1315.                                    const cairo_stroke_style_t   *stroke_style,
  1316.                                    const cairo_matrix_t *ctm,
  1317.                                    const cairo_matrix_t *ctm_inverse,
  1318.                                    double                tolerance,
  1319.                                    cairo_status_t (*add_triangle) (void *closure,
  1320.                                                                    const cairo_point_t triangle[3]),
  1321.                                    cairo_status_t (*add_triangle_fan) (void *closure,
  1322.                                                                        const cairo_point_t *midpt,
  1323.                                                                        const cairo_point_t *points,
  1324.                                                                        int npoints),
  1325.                                    cairo_status_t (*add_quad) (void *closure,
  1326.                                                                const cairo_point_t quad[4]),
  1327.                                    void *closure);
  1328.  
  1329. /* cairo-scaled-font.c */
  1330.  
  1331. cairo_private void
  1332. _cairo_scaled_font_freeze_cache (cairo_scaled_font_t *scaled_font);
  1333.  
  1334. cairo_private void
  1335. _cairo_scaled_font_thaw_cache (cairo_scaled_font_t *scaled_font);
  1336.  
  1337. cairo_private void
  1338. _cairo_scaled_font_reset_cache (cairo_scaled_font_t *scaled_font);
  1339.  
  1340. cairo_private cairo_status_t
  1341. _cairo_scaled_font_set_error (cairo_scaled_font_t *scaled_font,
  1342.                               cairo_status_t status);
  1343.  
  1344. cairo_private cairo_scaled_font_t *
  1345. _cairo_scaled_font_create_in_error (cairo_status_t status);
  1346.  
  1347. cairo_private void
  1348. _cairo_scaled_font_reset_static_data (void);
  1349.  
  1350. cairo_private cairo_status_t
  1351. _cairo_scaled_font_register_placeholder_and_unlock_font_map (cairo_scaled_font_t *scaled_font);
  1352.  
  1353. cairo_private void
  1354. _cairo_scaled_font_unregister_placeholder_and_lock_font_map (cairo_scaled_font_t *scaled_font);
  1355.  
  1356. cairo_private cairo_status_t
  1357. _cairo_scaled_font_init (cairo_scaled_font_t               *scaled_font,
  1358.                          cairo_font_face_t                 *font_face,
  1359.                          const cairo_matrix_t              *font_matrix,
  1360.                          const cairo_matrix_t              *ctm,
  1361.                          const cairo_font_options_t        *options,
  1362.                          const cairo_scaled_font_backend_t *backend);
  1363.  
  1364. cairo_private cairo_status_t
  1365. _cairo_scaled_font_set_metrics (cairo_scaled_font_t         *scaled_font,
  1366.                                 cairo_font_extents_t        *fs_metrics);
  1367.  
  1368. /* This should only be called on an error path by a scaled_font constructor */
  1369. cairo_private void
  1370. _cairo_scaled_font_fini (cairo_scaled_font_t *scaled_font);
  1371.  
  1372. cairo_private cairo_status_t
  1373. _cairo_scaled_font_font_extents (cairo_scaled_font_t  *scaled_font,
  1374.                                  cairo_font_extents_t *extents);
  1375.  
  1376. cairo_private cairo_status_t
  1377. _cairo_scaled_font_glyph_device_extents (cairo_scaled_font_t     *scaled_font,
  1378.                                          const cairo_glyph_t     *glyphs,
  1379.                                          int                      num_glyphs,
  1380.                                          cairo_rectangle_int_t   *extents,
  1381.                                          cairo_bool_t            *overlap);
  1382.  
  1383. cairo_private void
  1384. _cairo_scaled_font_glyph_approximate_extents (cairo_scaled_font_t        *scaled_font,
  1385.                                               const cairo_glyph_t        *glyphs,
  1386.                                               int                      num_glyphs,
  1387.                                               cairo_rectangle_int_t   *extents);
  1388.  
  1389. cairo_private cairo_status_t
  1390. _cairo_scaled_font_show_glyphs (cairo_scaled_font_t *scaled_font,
  1391.                                 cairo_operator_t     op,
  1392.                                 const cairo_pattern_t *source,
  1393.                                 cairo_surface_t     *surface,
  1394.                                 int                  source_x,
  1395.                                 int                  source_y,
  1396.                                 int                  dest_x,
  1397.                                 int                  dest_y,
  1398.                                 unsigned int         width,
  1399.                                 unsigned int         height,
  1400.                                 cairo_glyph_t       *glyphs,
  1401.                                 int                  num_glyphs,
  1402.                                 cairo_region_t      *clip_region);
  1403.  
  1404. cairo_private cairo_status_t
  1405. _cairo_scaled_font_glyph_path (cairo_scaled_font_t *scaled_font,
  1406.                                const cairo_glyph_t *glyphs,
  1407.                                int                  num_glyphs,
  1408.                                cairo_path_fixed_t  *path);
  1409.  
  1410. cairo_private void
  1411. _cairo_scaled_glyph_set_metrics (cairo_scaled_glyph_t *scaled_glyph,
  1412.                                  cairo_scaled_font_t *scaled_font,
  1413.                                  cairo_text_extents_t *fs_metrics);
  1414.  
  1415. cairo_private void
  1416. _cairo_scaled_glyph_set_surface (cairo_scaled_glyph_t *scaled_glyph,
  1417.                                  cairo_scaled_font_t *scaled_font,
  1418.                                  cairo_image_surface_t *surface);
  1419.  
  1420. cairo_private void
  1421. _cairo_scaled_glyph_set_path (cairo_scaled_glyph_t *scaled_glyph,
  1422.                               cairo_scaled_font_t *scaled_font,
  1423.                               cairo_path_fixed_t *path);
  1424.  
  1425. cairo_private void
  1426. _cairo_scaled_glyph_set_recording_surface (cairo_scaled_glyph_t *scaled_glyph,
  1427.                                            cairo_scaled_font_t *scaled_font,
  1428.                                            cairo_surface_t *recording_surface);
  1429.  
  1430. cairo_private cairo_int_status_t
  1431. _cairo_scaled_glyph_lookup (cairo_scaled_font_t *scaled_font,
  1432.                             unsigned long index,
  1433.                             cairo_scaled_glyph_info_t info,
  1434.                             cairo_scaled_glyph_t **scaled_glyph_ret);
  1435.  
  1436. cairo_private double
  1437. _cairo_scaled_font_get_max_scale (cairo_scaled_font_t *scaled_font);
  1438.  
  1439. cairo_private void
  1440. _cairo_scaled_font_map_destroy (void);
  1441.  
  1442. /* cairo-stroke-style.c */
  1443.  
  1444. cairo_private void
  1445. _cairo_stroke_style_init (cairo_stroke_style_t *style);
  1446.  
  1447. cairo_private cairo_status_t
  1448. _cairo_stroke_style_init_copy (cairo_stroke_style_t *style,
  1449.                                const cairo_stroke_style_t *other);
  1450.  
  1451. cairo_private void
  1452. _cairo_stroke_style_fini (cairo_stroke_style_t *style);
  1453.  
  1454. cairo_private void
  1455. _cairo_stroke_style_max_distance_from_path (const cairo_stroke_style_t *style,
  1456.                                             const cairo_matrix_t *ctm,
  1457.                                             double *dx, double *dy);
  1458.  
  1459. cairo_private double
  1460. _cairo_stroke_style_dash_period (const cairo_stroke_style_t *style);
  1461.  
  1462. cairo_private double
  1463. _cairo_stroke_style_dash_stroked (const cairo_stroke_style_t *style);
  1464.  
  1465. cairo_private cairo_bool_t
  1466. _cairo_stroke_style_dash_can_approximate (const cairo_stroke_style_t *style,
  1467.                                           const cairo_matrix_t *ctm,
  1468.                                           double tolerance);
  1469.  
  1470. cairo_private void
  1471. _cairo_stroke_style_dash_approximate (const cairo_stroke_style_t *style,
  1472.                                       const cairo_matrix_t *ctm,
  1473.                                       double tolerance,
  1474.                                       double *dash_offset,
  1475.                                       double *dashes,
  1476.                                       unsigned int *num_dashes);
  1477.  
  1478.  
  1479. /* cairo-surface.c */
  1480.  
  1481. cairo_private cairo_surface_t *
  1482. _cairo_surface_create_in_error (cairo_status_t status);
  1483.  
  1484. cairo_private cairo_status_t
  1485. _cairo_surface_copy_mime_data (cairo_surface_t *dst,
  1486.                                cairo_surface_t *src);
  1487.  
  1488. cairo_private cairo_status_t
  1489. _cairo_surface_set_error (cairo_surface_t       *surface,
  1490.                           cairo_status_t         status);
  1491.  
  1492. cairo_private void
  1493. _cairo_surface_set_resolution (cairo_surface_t *surface,
  1494.                                double x_res,
  1495.                                double y_res);
  1496.  
  1497. cairo_private cairo_surface_t *
  1498. _cairo_surface_create_similar_scratch (cairo_surface_t *other,
  1499.                                        cairo_content_t  content,
  1500.                                        int              width,
  1501.                                        int              height);
  1502.  
  1503. cairo_private cairo_surface_t *
  1504. _cairo_surface_create_similar_solid (cairo_surface_t        *other,
  1505.                                      cairo_content_t         content,
  1506.                                      int                     width,
  1507.                                      int                     height,
  1508.                                      const cairo_color_t    *color,
  1509.                                      cairo_bool_t            allow_fallback);
  1510.  
  1511. cairo_private cairo_surface_t *
  1512. _cairo_surface_create_solid_pattern_surface (cairo_surface_t       *other,
  1513.                                              const cairo_solid_pattern_t *solid_pattern);
  1514.  
  1515. cairo_private cairo_int_status_t
  1516. _cairo_surface_repaint_solid_pattern_surface (cairo_surface_t       *other,
  1517.                                               cairo_surface_t       *solid_surface,
  1518.                                               const cairo_solid_pattern_t *solid_pattern);
  1519.  
  1520. cairo_private void
  1521. _cairo_surface_init (cairo_surface_t                    *surface,
  1522.                      const cairo_surface_backend_t      *backend,
  1523.                      cairo_device_t                     *device,
  1524.                      cairo_content_t                     content);
  1525.  
  1526. cairo_private void
  1527. _cairo_surface_set_font_options (cairo_surface_t       *surface,
  1528.                                  cairo_font_options_t  *options);
  1529.  
  1530. cairo_private cairo_status_t
  1531. _cairo_surface_composite (cairo_operator_t      op,
  1532.                           const cairo_pattern_t *src,
  1533.                           const cairo_pattern_t *mask,
  1534.                           cairo_surface_t       *dst,
  1535.                           int                    src_x,
  1536.                           int                    src_y,
  1537.                           int                    mask_x,
  1538.                           int                    mask_y,
  1539.                           int                    dst_x,
  1540.                           int                    dst_y,
  1541.                           unsigned int           width,
  1542.                           unsigned int           height,
  1543.                           cairo_region_t        *clip_region);
  1544.  
  1545. cairo_private cairo_status_t
  1546. _cairo_surface_fill_rectangle (cairo_surface_t     *surface,
  1547.                                cairo_operator_t     op,
  1548.                                const cairo_color_t *color,
  1549.                                int                  x,
  1550.                                int                  y,
  1551.                                int                  width,
  1552.                                int                  height);
  1553.  
  1554. cairo_private cairo_status_t
  1555. _cairo_surface_fill_region (cairo_surface_t        *surface,
  1556.                             cairo_operator_t        op,
  1557.                             const cairo_color_t    *color,
  1558.                             cairo_region_t         *region);
  1559.  
  1560. cairo_private cairo_status_t
  1561. _cairo_surface_fill_rectangles (cairo_surface_t         *surface,
  1562.                                 cairo_operator_t         op,
  1563.                                 const cairo_color_t     *color,
  1564.                                 cairo_rectangle_int_t   *rects,
  1565.                                 int                      num_rects);
  1566.  
  1567. cairo_private cairo_status_t
  1568. _cairo_surface_paint (cairo_surface_t   *surface,
  1569.                       cairo_operator_t   op,
  1570.                       const cairo_pattern_t *source,
  1571.                       cairo_clip_t          *clip);
  1572.  
  1573. cairo_private cairo_status_t
  1574. _cairo_surface_mask (cairo_surface_t    *surface,
  1575.                      cairo_operator_t    op,
  1576.                      const cairo_pattern_t      *source,
  1577.                      const cairo_pattern_t      *mask,
  1578.                      cairo_clip_t               *clip);
  1579.  
  1580. cairo_private cairo_status_t
  1581. _cairo_surface_fill_stroke (cairo_surface_t         *surface,
  1582.                             cairo_operator_t         fill_op,
  1583.                             const cairo_pattern_t   *fill_source,
  1584.                             cairo_fill_rule_t        fill_rule,
  1585.                             double                   fill_tolerance,
  1586.                             cairo_antialias_t        fill_antialias,
  1587.                             cairo_path_fixed_t      *path,
  1588.                             cairo_operator_t         stroke_op,
  1589.                             const cairo_pattern_t   *stroke_source,
  1590.                             const cairo_stroke_style_t    *stroke_style,
  1591.                             const cairo_matrix_t            *stroke_ctm,
  1592.                             const cairo_matrix_t            *stroke_ctm_inverse,
  1593.                             double                   stroke_tolerance,
  1594.                             cairo_antialias_t        stroke_antialias,
  1595.                             cairo_clip_t            *clip);
  1596.  
  1597. cairo_private cairo_status_t
  1598. _cairo_surface_stroke (cairo_surface_t          *surface,
  1599.                        cairo_operator_t          op,
  1600.                        const cairo_pattern_t    *source,
  1601.                        cairo_path_fixed_t       *path,
  1602.                        const cairo_stroke_style_t       *style,
  1603.                        const cairo_matrix_t             *ctm,
  1604.                        const cairo_matrix_t             *ctm_inverse,
  1605.                        double                    tolerance,
  1606.                        cairo_antialias_t         antialias,
  1607.                        cairo_clip_t             *clip);
  1608.  
  1609. cairo_private cairo_status_t
  1610. _cairo_surface_fill (cairo_surface_t    *surface,
  1611.                      cairo_operator_t    op,
  1612.                      const cairo_pattern_t *source,
  1613.                      cairo_path_fixed_t *path,
  1614.                      cairo_fill_rule_t   fill_rule,
  1615.                      double              tolerance,
  1616.                      cairo_antialias_t   antialias,
  1617.                      cairo_clip_t       *clip);
  1618.  
  1619. cairo_private cairo_status_t
  1620. _cairo_surface_show_text_glyphs (cairo_surface_t            *surface,
  1621.                                  cairo_operator_t            op,
  1622.                                  const cairo_pattern_t      *source,
  1623.                                  const char                 *utf8,
  1624.                                  int                         utf8_len,
  1625.                                  cairo_glyph_t              *glyphs,
  1626.                                  int                         num_glyphs,
  1627.                                  const cairo_text_cluster_t *clusters,
  1628.                                  int                         num_clusters,
  1629.                                  cairo_text_cluster_flags_t  cluster_flags,
  1630.                                  cairo_scaled_font_t        *scaled_font,
  1631.                                  cairo_clip_t               *clip);
  1632.  
  1633. cairo_private cairo_status_t
  1634. _cairo_surface_paint_extents (cairo_surface_t *surface,
  1635.                               cairo_operator_t          op,
  1636.                               const cairo_pattern_t     *source,
  1637.                               cairo_clip_t              *clip,
  1638.                               cairo_rectangle_int_t     *extents);
  1639.  
  1640. cairo_private cairo_status_t
  1641. _cairo_surface_mask_extents (cairo_surface_t *surface,
  1642.                              cairo_operator_t            op,
  1643.                              const cairo_pattern_t      *source,
  1644.                              const cairo_pattern_t      *mask,
  1645.                              cairo_clip_t               *clip,
  1646.                              cairo_rectangle_int_t      *extents);
  1647.  
  1648. cairo_private cairo_status_t
  1649. _cairo_surface_stroke_extents (cairo_surface_t *surface,
  1650.                                cairo_operator_t op,
  1651.                                const cairo_pattern_t *source,
  1652.                                cairo_path_fixed_t       *path,
  1653.                                const cairo_stroke_style_t *style,
  1654.                                const cairo_matrix_t *ctm,
  1655.                                const cairo_matrix_t *ctm_inverse,
  1656.                                double tolerance,
  1657.                                cairo_antialias_t         antialias,
  1658.                                cairo_clip_t *clip,
  1659.                                cairo_rectangle_int_t *extents);
  1660.  
  1661. cairo_private cairo_status_t
  1662. _cairo_surface_fill_extents (cairo_surface_t            *surface,
  1663.                              cairo_operator_t            op,
  1664.                              const cairo_pattern_t      *source,
  1665.                              cairo_path_fixed_t         *path,
  1666.                              cairo_fill_rule_t           fill_rule,
  1667.                              double                      tolerance,
  1668.                              cairo_antialias_t           antialias,
  1669.                              cairo_clip_t               *clip,
  1670.                              cairo_rectangle_int_t      *extents);
  1671.  
  1672. cairo_private cairo_status_t
  1673. _cairo_surface_glyphs_extents (cairo_surface_t *surface,
  1674.                                cairo_operator_t    op,
  1675.                                const cairo_pattern_t *source,
  1676.                                cairo_glyph_t      *glyphs,
  1677.                                int                 num_glyphs,
  1678.                                cairo_scaled_font_t  *scaled_font,
  1679.                                cairo_clip_t         *clip,
  1680.                                cairo_rectangle_int_t *extents);
  1681.  
  1682. cairo_private cairo_status_t
  1683. _cairo_surface_composite_trapezoids (cairo_operator_t   op,
  1684.                                      const cairo_pattern_t *pattern,
  1685.                                      cairo_surface_t    *dst,
  1686.                                      cairo_antialias_t  antialias,
  1687.                                      int                src_x,
  1688.                                      int                src_y,
  1689.                                      int                dst_x,
  1690.                                      int                dst_y,
  1691.                                      unsigned int       width,
  1692.                                      unsigned int       height,
  1693.                                      cairo_trapezoid_t  *traps,
  1694.                                      int                ntraps,
  1695.                                      cairo_region_t     *clip_region);
  1696.  
  1697. cairo_private cairo_span_renderer_t *
  1698. _cairo_surface_create_span_renderer (cairo_operator_t                    op,
  1699.                                      const cairo_pattern_t              *pattern,
  1700.                                      cairo_surface_t                    *dst,
  1701.                                      cairo_antialias_t                   antialias,
  1702.                                      const cairo_composite_rectangles_t *rects,
  1703.                                      cairo_region_t                     *clip_region);
  1704.  
  1705. cairo_private cairo_bool_t
  1706. _cairo_surface_check_span_renderer (cairo_operator_t                     op,
  1707.                                     const cairo_pattern_t               *pattern,
  1708.                                     cairo_surface_t                     *dst,
  1709.                                     cairo_antialias_t                    antialias);
  1710.  
  1711. cairo_private cairo_status_t
  1712. _cairo_surface_acquire_source_image (cairo_surface_t         *surface,
  1713.                                      cairo_image_surface_t  **image_out,
  1714.                                      void                   **image_extra);
  1715.  
  1716. cairo_private void
  1717. _cairo_surface_release_source_image (cairo_surface_t        *surface,
  1718.                                      cairo_image_surface_t  *image,
  1719.                                      void                   *image_extra);
  1720.  
  1721. cairo_private cairo_status_t
  1722. _cairo_surface_acquire_dest_image (cairo_surface_t         *surface,
  1723.                                    cairo_rectangle_int_t   *interest_rect,
  1724.                                    cairo_image_surface_t  **image_out,
  1725.                                    cairo_rectangle_int_t   *image_rect,
  1726.                                    void                   **image_extra);
  1727.  
  1728. cairo_private void
  1729. _cairo_surface_release_dest_image (cairo_surface_t        *surface,
  1730.                                    cairo_rectangle_int_t  *interest_rect,
  1731.                                    cairo_image_surface_t  *image,
  1732.                                    cairo_rectangle_int_t  *image_rect,
  1733.                                    void                   *image_extra);
  1734.  
  1735. cairo_private cairo_status_t
  1736. _cairo_surface_clone_similar (cairo_surface_t  *surface,
  1737.                               cairo_surface_t  *src,
  1738.                               int               src_x,
  1739.                               int               src_y,
  1740.                               int               width,
  1741.                               int               height,
  1742.                               int              *clone_offset_x,
  1743.                               int              *clone_offset_y,
  1744.                               cairo_surface_t **clone_out);
  1745.  
  1746. cairo_private cairo_surface_t *
  1747. _cairo_surface_snapshot (cairo_surface_t *surface);
  1748.  
  1749. cairo_private void
  1750. _cairo_surface_attach_snapshot (cairo_surface_t *surface,
  1751.                                 cairo_surface_t *snapshot,
  1752.                                 cairo_surface_func_t detach_func);
  1753.  
  1754. cairo_private cairo_surface_t *
  1755. _cairo_surface_has_snapshot (cairo_surface_t *surface,
  1756.                              const cairo_surface_backend_t *backend);
  1757.  
  1758. cairo_private void
  1759. _cairo_surface_detach_snapshot (cairo_surface_t *snapshot);
  1760.  
  1761. cairo_private cairo_bool_t
  1762. _cairo_surface_is_similar (cairo_surface_t *surface_a,
  1763.                            cairo_surface_t *surface_b);
  1764.  
  1765. cairo_private cairo_bool_t
  1766. _cairo_surface_get_extents (cairo_surface_t         *surface,
  1767.                             cairo_rectangle_int_t   *extents);
  1768.  
  1769. cairo_private cairo_status_t
  1770. _cairo_surface_old_show_glyphs (cairo_scaled_font_t     *scaled_font,
  1771.                                 cairo_operator_t         op,
  1772.                                 const cairo_pattern_t   *pattern,
  1773.                                 cairo_surface_t         *surface,
  1774.                                 int                      source_x,
  1775.                                 int                      source_y,
  1776.                                 int                      dest_x,
  1777.                                 int                      dest_y,
  1778.                                 unsigned int             width,
  1779.                                 unsigned int             height,
  1780.                                 cairo_glyph_t           *glyphs,
  1781.                                 int                      num_glyphs,
  1782.                                 cairo_region_t          *clip_region);
  1783.  
  1784. cairo_private cairo_status_t
  1785. _cairo_surface_composite_fixup_unbounded (cairo_surface_t            *dst,
  1786.                                           cairo_surface_attributes_t *src_attr,
  1787.                                           int                         src_width,
  1788.                                           int                         src_height,
  1789.                                           cairo_surface_attributes_t *mask_attr,
  1790.                                           int                         mask_width,
  1791.                                           int                         mask_height,
  1792.                                           int                         src_x,
  1793.                                           int                         src_y,
  1794.                                           int                         mask_x,
  1795.                                           int                         mask_y,
  1796.                                           int                         dst_x,
  1797.                                           int                         dst_y,
  1798.                                           unsigned int                width,
  1799.                                           unsigned int                height,
  1800.                                           cairo_region_t            *clip_region);
  1801.  
  1802. cairo_private cairo_status_t
  1803. _cairo_surface_composite_shape_fixup_unbounded (cairo_surface_t            *dst,
  1804.                                                 cairo_surface_attributes_t *src_attr,
  1805.                                                 int                         src_width,
  1806.                                                 int                         src_height,
  1807.                                                 int                         mask_width,
  1808.                                                 int                         mask_height,
  1809.                                                 int                         src_x,
  1810.                                                 int                         src_y,
  1811.                                                 int                         mask_x,
  1812.                                                 int                         mask_y,
  1813.                                                 int                         dst_x,
  1814.                                                 int                         dst_y,
  1815.                                                 unsigned int                width,
  1816.                                                 unsigned int                height,
  1817.                                                 cairo_region_t              *clip_region);
  1818.  
  1819. cairo_private cairo_bool_t
  1820. _cairo_surface_is_opaque (const cairo_surface_t *surface);
  1821.  
  1822. cairo_private void
  1823. _cairo_surface_set_device_scale (cairo_surface_t *surface,
  1824.                                  double           sx,
  1825.                                  double           sy);
  1826.  
  1827. cairo_private cairo_bool_t
  1828. _cairo_surface_has_device_transform (cairo_surface_t *surface) cairo_pure;
  1829.  
  1830. cairo_private void
  1831. _cairo_surface_release_device_reference (cairo_surface_t *surface);
  1832.  
  1833. /* cairo-image-surface.c */
  1834.  
  1835. /* XXX: In cairo 1.2.0 we added a new %CAIRO_FORMAT_RGB16_565 but
  1836.  * neglected to adjust this macro. The net effect is that it's
  1837.  * impossible to externally create an image surface with this
  1838.  * format. This is perhaps a good thing since we also neglected to fix
  1839.  * up things like cairo_surface_write_to_png() for the new format
  1840.  * (-Wswitch-enum will tell you where). Is it obvious that format was
  1841.  * added in haste?
  1842.  *
  1843.  * The reason for the new format was to allow the xlib backend to be
  1844.  * used on X servers with a 565 visual. So the new format did its job
  1845.  * for that, even without being considered "valid" for the sake of
  1846.  * things like cairo_image_surface_create().
  1847.  *
  1848.  * Since 1.2.0 we ran into the same situtation with X servers with BGR
  1849.  * visuals. This time we invented #cairo_internal_format_t instead,
  1850.  * (see it for more discussion).
  1851.  *
  1852.  * The punchline is that %CAIRO_FORMAT_VALID must not conside any
  1853.  * internal format to be valid. Also we need to decide if the
  1854.  * RGB16_565 should be moved to instead be an internal format. If so,
  1855.  * this macro need not change for it. (We probably will need to leave
  1856.  * an RGB16_565 value in the header files for the sake of code that
  1857.  * might have that value in it.)
  1858.  *
  1859.  * If we do decide to start fully supporting RGB16_565 as an external
  1860.  * format, then %CAIRO_FORMAT_VALID needs to be adjusted to include
  1861.  * it. But that should not happen before all necessary code is fixed
  1862.  * to support it (at least cairo_surface_write_to_png() and a few spots
  1863.  * in cairo-xlib-surface.c--again see -Wswitch-enum).
  1864.  */
  1865. #define CAIRO_FORMAT_VALID(format) ((format) >= CAIRO_FORMAT_ARGB32 &&          \
  1866.                                     (format) <= CAIRO_FORMAT_RGB16_565)
  1867.  
  1868. /* pixman-required stride alignment in bytes. */
  1869. #define CAIRO_STRIDE_ALIGNMENT (sizeof (uint32_t))
  1870. #define CAIRO_STRIDE_FOR_WIDTH_BPP(w,bpp) \
  1871.    ((((bpp)*(w)+7)/8 + CAIRO_STRIDE_ALIGNMENT-1) & -CAIRO_STRIDE_ALIGNMENT)
  1872.  
  1873. #define CAIRO_CONTENT_VALID(content) ((content) &&                               \
  1874.                                       (((content) & ~(CAIRO_CONTENT_COLOR |      \
  1875.                                                       CAIRO_CONTENT_ALPHA |      \
  1876.                                                       CAIRO_CONTENT_COLOR_ALPHA))\
  1877.                                        == 0))
  1878.  
  1879. cairo_private int
  1880. _cairo_format_bits_per_pixel (cairo_format_t format) cairo_const;
  1881.  
  1882. cairo_private cairo_format_t
  1883. _cairo_format_from_content (cairo_content_t content) cairo_const;
  1884.  
  1885. cairo_private cairo_format_t
  1886. _cairo_format_from_pixman_format (pixman_format_code_t pixman_format);
  1887.  
  1888. cairo_private cairo_content_t
  1889. _cairo_content_from_format (cairo_format_t format) cairo_const;
  1890.  
  1891. cairo_private cairo_content_t
  1892. _cairo_content_from_pixman_format (pixman_format_code_t pixman_format);
  1893.  
  1894. cairo_private cairo_surface_t *
  1895. _cairo_image_surface_create_for_pixman_image (pixman_image_t            *pixman_image,
  1896.                                               pixman_format_code_t       pixman_format);
  1897.  
  1898. cairo_private pixman_format_code_t
  1899. _cairo_format_to_pixman_format_code (cairo_format_t format);
  1900.  
  1901. cairo_private cairo_bool_t
  1902. _pixman_format_from_masks (cairo_format_masks_t *masks,
  1903.                            pixman_format_code_t *format_ret);
  1904.  
  1905. cairo_private cairo_bool_t
  1906. _pixman_format_to_masks (pixman_format_code_t    pixman_format,
  1907.                          cairo_format_masks_t   *masks);
  1908.  
  1909. cairo_private void
  1910. _cairo_image_reset_static_data (void);
  1911.  
  1912. cairo_private cairo_surface_t *
  1913. _cairo_image_surface_create_with_pixman_format (unsigned char           *data,
  1914.                                                 pixman_format_code_t     pixman_format,
  1915.                                                 int                      width,
  1916.                                                 int                      height,
  1917.                                                 int                      stride);
  1918.  
  1919. cairo_private cairo_surface_t *
  1920. _cairo_image_surface_create_with_content (cairo_content_t       content,
  1921.                                           int                   width,
  1922.                                           int                   height);
  1923.  
  1924. cairo_private void
  1925. _cairo_image_surface_assume_ownership_of_data (cairo_image_surface_t *surface);
  1926.  
  1927. cairo_private cairo_image_surface_t *
  1928. _cairo_image_surface_coerce (cairo_image_surface_t      *surface);
  1929.  
  1930. cairo_private cairo_image_surface_t *
  1931. _cairo_image_surface_coerce_to_format (cairo_image_surface_t    *surface,
  1932.                                        cairo_format_t            format);
  1933.  
  1934. cairo_private void
  1935. _cairo_image_surface_span_render_row (int                                y,
  1936.                                       const cairo_half_open_span_t       *spans,
  1937.                                       unsigned                           num_spans,
  1938.                                       uint8_t                           *data,
  1939.                                       uint32_t                           stride);
  1940.  
  1941. cairo_private cairo_image_transparency_t
  1942. _cairo_image_analyze_transparency (cairo_image_surface_t      *image);
  1943.  
  1944. cairo_private cairo_bool_t
  1945. _cairo_surface_is_image (const cairo_surface_t *surface) cairo_pure;
  1946.  
  1947. cairo_private cairo_bool_t
  1948. _cairo_surface_is_recording (const cairo_surface_t *surface) cairo_pure;
  1949.  
  1950. /* cairo-pen.c */
  1951. cairo_private cairo_status_t
  1952. _cairo_pen_init (cairo_pen_t    *pen,
  1953.                  double          radius,
  1954.                  double          tolerance,
  1955.                  const cairo_matrix_t   *ctm);
  1956.  
  1957. cairo_private void
  1958. _cairo_pen_init_empty (cairo_pen_t *pen);
  1959.  
  1960. cairo_private cairo_status_t
  1961. _cairo_pen_init_copy (cairo_pen_t *pen, const cairo_pen_t *other);
  1962.  
  1963. cairo_private void
  1964. _cairo_pen_fini (cairo_pen_t *pen);
  1965.  
  1966. cairo_private cairo_status_t
  1967. _cairo_pen_add_points (cairo_pen_t *pen, cairo_point_t *point, int num_points);
  1968.  
  1969. cairo_private cairo_status_t
  1970. _cairo_pen_add_points_for_slopes (cairo_pen_t *pen,
  1971.                                   cairo_point_t *a,
  1972.                                   cairo_point_t *b,
  1973.                                   cairo_point_t *c,
  1974.                                   cairo_point_t *d);
  1975.  
  1976. cairo_private int
  1977. _cairo_pen_find_active_cw_vertex_index (const cairo_pen_t *pen,
  1978.                                         const cairo_slope_t *slope);
  1979.  
  1980. cairo_private int
  1981. _cairo_pen_find_active_ccw_vertex_index (const cairo_pen_t *pen,
  1982.                                          const cairo_slope_t *slope);
  1983.  
  1984. /* cairo-polygon.c */
  1985. cairo_private void
  1986. _cairo_polygon_init (cairo_polygon_t *polygon);
  1987.  
  1988. cairo_private void
  1989. _cairo_polygon_limit (cairo_polygon_t   *polygon,
  1990.                       const cairo_box_t *boxes,
  1991.                       int                num_boxes);
  1992.  
  1993. cairo_private void
  1994. _cairo_polygon_fini (cairo_polygon_t *polygon);
  1995.  
  1996. cairo_private cairo_status_t
  1997. _cairo_polygon_add_line (cairo_polygon_t *polygon,
  1998.                          const cairo_line_t *line,
  1999.                          int top, int bottom,
  2000.                          int dir);
  2001.  
  2002. cairo_private cairo_status_t
  2003. _cairo_polygon_add_external_edge (void *polygon,
  2004.                                   const cairo_point_t *p1,
  2005.                                   const cairo_point_t *p2);
  2006.  
  2007. cairo_private cairo_status_t
  2008. _cairo_polygon_move_to (cairo_polygon_t *polygon,
  2009.                         const cairo_point_t *point);
  2010.  
  2011. cairo_private cairo_status_t
  2012. _cairo_polygon_line_to (cairo_polygon_t *polygon,
  2013.                         const cairo_point_t *point);
  2014.  
  2015. cairo_private cairo_status_t
  2016. _cairo_polygon_close (cairo_polygon_t *polygon);
  2017.  
  2018. #define _cairo_polygon_status(P) ((cairo_polygon_t *) (P))->status
  2019.  
  2020. /* cairo-spline.c */
  2021. cairo_private cairo_bool_t
  2022. _cairo_spline_init (cairo_spline_t *spline,
  2023.                     cairo_spline_add_point_func_t add_point_func,
  2024.                     void *closure,
  2025.                     const cairo_point_t *a, const cairo_point_t *b,
  2026.                     const cairo_point_t *c, const cairo_point_t *d);
  2027.  
  2028. cairo_private cairo_status_t
  2029. _cairo_spline_decompose (cairo_spline_t *spline, double tolerance);
  2030.  
  2031. cairo_private cairo_status_t
  2032. _cairo_spline_bound (cairo_spline_add_point_func_t add_point_func,
  2033.                      void *closure,
  2034.                      const cairo_point_t *p0, const cairo_point_t *p1,
  2035.                      const cairo_point_t *p2, const cairo_point_t *p3);
  2036.  
  2037. /* cairo-matrix.c */
  2038. cairo_private void
  2039. _cairo_matrix_get_affine (const cairo_matrix_t *matrix,
  2040.                           double *xx, double *yx,
  2041.                           double *xy, double *yy,
  2042.                           double *x0, double *y0);
  2043.  
  2044. cairo_private void
  2045. _cairo_matrix_transform_bounding_box (const cairo_matrix_t *matrix,
  2046.                                       double *x1, double *y1,
  2047.                                       double *x2, double *y2,
  2048.                                       cairo_bool_t *is_tight);
  2049.  
  2050. cairo_private void
  2051. _cairo_matrix_transform_bounding_box_fixed (const cairo_matrix_t *matrix,
  2052.                                             cairo_box_t          *bbox,
  2053.                                             cairo_bool_t         *is_tight);
  2054.  
  2055. cairo_private cairo_bool_t
  2056. _cairo_matrix_is_invertible (const cairo_matrix_t *matrix) cairo_pure;
  2057.  
  2058. cairo_private cairo_bool_t
  2059. _cairo_matrix_is_scale_0 (const cairo_matrix_t *matrix) cairo_pure;
  2060.  
  2061. cairo_private double
  2062. _cairo_matrix_compute_determinant (const cairo_matrix_t *matrix) cairo_pure;
  2063.  
  2064. cairo_private cairo_status_t
  2065. _cairo_matrix_compute_basis_scale_factors (const cairo_matrix_t *matrix,
  2066.                                            double *sx, double *sy, int x_major);
  2067.  
  2068. cairo_private cairo_bool_t
  2069. _cairo_matrix_is_identity (const cairo_matrix_t *matrix) cairo_pure;
  2070.  
  2071. cairo_private cairo_bool_t
  2072. _cairo_matrix_is_translation (const cairo_matrix_t *matrix) cairo_pure;
  2073.  
  2074. cairo_private cairo_bool_t
  2075. _cairo_matrix_is_integer_translation(const cairo_matrix_t *matrix,
  2076.                                      int *itx, int *ity);
  2077.  
  2078. cairo_private cairo_bool_t
  2079. _cairo_matrix_has_unity_scale (const cairo_matrix_t *matrix);
  2080.  
  2081. cairo_private cairo_bool_t
  2082. _cairo_matrix_is_pixel_exact (const cairo_matrix_t *matrix) cairo_pure;
  2083.  
  2084. cairo_private double
  2085. _cairo_matrix_transformed_circle_major_axis (const cairo_matrix_t *matrix,
  2086.                                              double radius) cairo_pure;
  2087.  
  2088. cairo_private void
  2089. _cairo_matrix_to_pixman_matrix (const cairo_matrix_t    *matrix,
  2090.                                 pixman_transform_t      *pixman_transform,
  2091.                                 double                   xc,
  2092.                                 double                   yc);
  2093.  
  2094. /* cairo-traps.c */
  2095. cairo_private void
  2096. _cairo_traps_init (cairo_traps_t *traps);
  2097.  
  2098. cairo_private void
  2099. _cairo_traps_limit (cairo_traps_t       *traps,
  2100.                     const cairo_box_t   *boxes,
  2101.                     int                  num_boxes);
  2102.  
  2103. cairo_private cairo_status_t
  2104. _cairo_traps_init_boxes (cairo_traps_t      *traps,
  2105.                          const cairo_boxes_t *boxes);
  2106.  
  2107. cairo_private void
  2108. _cairo_traps_clear (cairo_traps_t *traps);
  2109.  
  2110. cairo_private void
  2111. _cairo_traps_fini (cairo_traps_t *traps);
  2112.  
  2113. #define _cairo_traps_status(T) (T)->status
  2114.  
  2115. cairo_private void
  2116. _cairo_traps_translate (cairo_traps_t *traps, int x, int y);
  2117.  
  2118. cairo_private cairo_status_t
  2119. _cairo_traps_tessellate_rectangle (cairo_traps_t *traps,
  2120.                                    const cairo_point_t *top_left,
  2121.                                    const cairo_point_t *bottom_right);
  2122.  
  2123. cairo_private void
  2124. _cairo_traps_add_trap (cairo_traps_t *traps,
  2125.                        cairo_fixed_t top, cairo_fixed_t bottom,
  2126.                        cairo_line_t *left, cairo_line_t *right);
  2127.  
  2128. cairo_private cairo_status_t
  2129. _cairo_bentley_ottmann_tessellate_rectilinear_polygon (cairo_traps_t     *traps,
  2130.                                                        const cairo_polygon_t *polygon,
  2131.                                                        cairo_fill_rule_t          fill_rule);
  2132.  
  2133. cairo_private cairo_status_t
  2134. _cairo_bentley_ottmann_tessellate_polygon (cairo_traps_t         *traps,
  2135.                                            const cairo_polygon_t *polygon,
  2136.                                            cairo_fill_rule_t      fill_rule);
  2137.  
  2138. cairo_private cairo_status_t
  2139. _cairo_bentley_ottmann_tessellate_traps (cairo_traps_t *traps,
  2140.                                          cairo_fill_rule_t fill_rule);
  2141.  
  2142. cairo_private cairo_status_t
  2143. _cairo_bentley_ottmann_tessellate_rectangular_traps (cairo_traps_t *traps,
  2144.                                                      cairo_fill_rule_t fill_rule);
  2145.  
  2146. cairo_private cairo_status_t
  2147. _cairo_bentley_ottmann_tessellate_boxes (const cairo_boxes_t *in,
  2148.                                          cairo_fill_rule_t fill_rule,
  2149.                                          cairo_boxes_t *out);
  2150.  
  2151. cairo_private cairo_status_t
  2152. _cairo_bentley_ottmann_tessellate_rectilinear_traps (cairo_traps_t *traps,
  2153.                                                      cairo_fill_rule_t fill_rule);
  2154.  
  2155. cairo_private cairo_status_t
  2156. _cairo_bentley_ottmann_tessellate_rectilinear_polygon_to_boxes (const cairo_polygon_t *polygon,
  2157.                                                                 cairo_fill_rule_t fill_rule,
  2158.                                                                 cairo_boxes_t *boxes);
  2159.  
  2160. cairo_private int
  2161. _cairo_traps_contain (const cairo_traps_t *traps,
  2162.                       double x, double y);
  2163.  
  2164. cairo_private void
  2165. _cairo_traps_extents (const cairo_traps_t *traps,
  2166.                       cairo_box_t         *extents);
  2167.  
  2168. cairo_private cairo_int_status_t
  2169. _cairo_traps_extract_region (cairo_traps_t  *traps,
  2170.                              cairo_region_t **region);
  2171.  
  2172. cairo_private cairo_status_t
  2173. _cairo_traps_path (const cairo_traps_t *traps,
  2174.                    cairo_path_fixed_t  *path);
  2175.  
  2176. cairo_private void
  2177. _cairo_trapezoid_array_translate_and_scale (cairo_trapezoid_t *offset_traps,
  2178.                                             cairo_trapezoid_t *src_traps,
  2179.                                             int num_traps,
  2180.                                             double tx, double ty,
  2181.                                             double sx, double sy);
  2182.  
  2183. /* cairo-pattern.c */
  2184.  
  2185. cairo_private cairo_pattern_t *
  2186. _cairo_pattern_create_in_error (cairo_status_t status);
  2187.  
  2188. cairo_private cairo_status_t
  2189. _cairo_pattern_create_copy (cairo_pattern_t       **pattern,
  2190.                             const cairo_pattern_t  *other);
  2191.  
  2192. cairo_private cairo_status_t
  2193. _cairo_pattern_init_copy (cairo_pattern_t       *pattern,
  2194.                           const cairo_pattern_t *other);
  2195.  
  2196. cairo_private void
  2197. _cairo_pattern_init_static_copy (cairo_pattern_t        *pattern,
  2198.                                  const cairo_pattern_t *other);
  2199.  
  2200. cairo_private cairo_status_t
  2201. _cairo_pattern_init_snapshot (cairo_pattern_t       *pattern,
  2202.                               const cairo_pattern_t *other);
  2203.  
  2204. cairo_private void
  2205. _cairo_pattern_init_solid (cairo_solid_pattern_t        *pattern,
  2206.                            const cairo_color_t          *color);
  2207.  
  2208. cairo_private void
  2209. _cairo_pattern_init_for_surface (cairo_surface_pattern_t *pattern,
  2210.                                  cairo_surface_t *surface);
  2211.  
  2212. cairo_private void
  2213. _cairo_pattern_init_linear (cairo_linear_pattern_t *pattern,
  2214.                             double x0, double y0, double x1, double y1);
  2215.  
  2216. cairo_private void
  2217. _cairo_pattern_init_radial (cairo_radial_pattern_t *pattern,
  2218.                             double cx0, double cy0, double radius0,
  2219.                             double cx1, double cy1, double radius1);
  2220.  
  2221. cairo_private void
  2222. _cairo_pattern_fini (cairo_pattern_t *pattern);
  2223.  
  2224. cairo_private cairo_pattern_t *
  2225. _cairo_pattern_create_solid (const cairo_color_t        *color);
  2226.  
  2227. cairo_private void
  2228. _cairo_pattern_transform (cairo_pattern_t      *pattern,
  2229.                           const cairo_matrix_t *ctm_inverse);
  2230.  
  2231. cairo_private cairo_bool_t
  2232. _cairo_gradient_pattern_is_solid (const cairo_gradient_pattern_t *gradient,
  2233.                                   const cairo_rectangle_int_t *extents,
  2234.                                   cairo_color_t *color);
  2235.  
  2236. cairo_private cairo_bool_t
  2237. _cairo_pattern_is_opaque_solid (const cairo_pattern_t *pattern);
  2238.  
  2239. cairo_private cairo_bool_t
  2240. _cairo_pattern_is_opaque (const cairo_pattern_t *pattern,
  2241.                           const cairo_rectangle_int_t *extents);
  2242.  
  2243. cairo_private cairo_bool_t
  2244. _cairo_pattern_is_clear (const cairo_pattern_t *pattern);
  2245.  
  2246. cairo_private_no_warn cairo_filter_t
  2247. _cairo_pattern_analyze_filter (const cairo_pattern_t    *pattern,
  2248.                                double                   *pad_out);
  2249.  
  2250. enum {
  2251.     CAIRO_PATTERN_ACQUIRE_NONE = 0x0,
  2252.     CAIRO_PATTERN_ACQUIRE_NO_REFLECT = 0x1
  2253. };
  2254. cairo_private cairo_int_status_t
  2255. _cairo_pattern_acquire_surface (const cairo_pattern_t      *pattern,
  2256.                                 cairo_surface_t            *dst,
  2257.                                 int                        x,
  2258.                                 int                        y,
  2259.                                 unsigned int               width,
  2260.                                 unsigned int               height,
  2261.                                 unsigned int               flags,
  2262.                                 cairo_surface_t            **surface_out,
  2263.                                 cairo_surface_attributes_t *attributes);
  2264.  
  2265. cairo_private void
  2266. _cairo_pattern_release_surface (const cairo_pattern_t      *pattern,
  2267.                                 cairo_surface_t            *surface,
  2268.                                 cairo_surface_attributes_t *attributes);
  2269.  
  2270. cairo_private cairo_int_status_t
  2271. _cairo_pattern_acquire_surfaces (const cairo_pattern_t      *src,
  2272.                                  const cairo_pattern_t      *mask,
  2273.                                  cairo_surface_t            *dst,
  2274.                                  int                        src_x,
  2275.                                  int                        src_y,
  2276.                                  int                        mask_x,
  2277.                                  int                        mask_y,
  2278.                                  unsigned int               width,
  2279.                                  unsigned int               height,
  2280.                                  unsigned int               flags,
  2281.                                  cairo_surface_t            **src_out,
  2282.                                  cairo_surface_t            **mask_out,
  2283.                                  cairo_surface_attributes_t *src_attributes,
  2284.                                  cairo_surface_attributes_t *mask_attributes);
  2285.  
  2286. cairo_private void
  2287. _cairo_pattern_get_extents (const cairo_pattern_t           *pattern,
  2288.                             cairo_rectangle_int_t           *extents);
  2289.  
  2290. cairo_private unsigned long
  2291. _cairo_pattern_hash (const cairo_pattern_t *pattern);
  2292.  
  2293. cairo_private unsigned long
  2294. _cairo_linear_pattern_hash (unsigned long hash,
  2295.                             const cairo_linear_pattern_t *linear);
  2296.  
  2297. cairo_private unsigned long
  2298. _cairo_radial_pattern_hash (unsigned long hash,
  2299.                             const cairo_radial_pattern_t *radial);
  2300.  
  2301. cairo_private cairo_bool_t
  2302. _cairo_linear_pattern_equal (const cairo_linear_pattern_t *a,
  2303.                              const cairo_linear_pattern_t *b);
  2304.  
  2305. cairo_private unsigned long
  2306. _cairo_pattern_size (const cairo_pattern_t *pattern);
  2307.  
  2308. cairo_private cairo_bool_t
  2309. _cairo_radial_pattern_equal (const cairo_radial_pattern_t *a,
  2310.                              const cairo_radial_pattern_t *b);
  2311.  
  2312. cairo_private cairo_bool_t
  2313. _cairo_pattern_equal (const cairo_pattern_t *a,
  2314.                       const cairo_pattern_t *b);
  2315.  
  2316. cairo_private void
  2317. _cairo_pattern_reset_static_data (void);
  2318.  
  2319. #if CAIRO_HAS_DRM_SURFACE
  2320.  
  2321. cairo_private void
  2322. _cairo_drm_device_reset_static_data (void);
  2323.  
  2324. #endif
  2325.  
  2326. cairo_private void
  2327. _cairo_clip_reset_static_data (void);
  2328.  
  2329. /* cairo-unicode.c */
  2330.  
  2331. cairo_private int
  2332. _cairo_utf8_get_char_validated (const char *p,
  2333.                                 uint32_t   *unicode);
  2334.  
  2335. cairo_private cairo_status_t
  2336. _cairo_utf8_to_ucs4 (const char *str,
  2337.                      int         len,
  2338.                      uint32_t  **result,
  2339.                      int        *items_written);
  2340.  
  2341. cairo_private int
  2342. _cairo_ucs4_to_utf8 (uint32_t    unicode,
  2343.                      char       *utf8);
  2344.  
  2345. #if CAIRO_HAS_WIN32_FONT || CAIRO_HAS_QUARTZ_FONT || CAIRO_HAS_PDF_OPERATORS
  2346. # define CAIRO_HAS_UTF8_TO_UTF16 1
  2347. #endif
  2348. #if CAIRO_HAS_UTF8_TO_UTF16
  2349. cairo_private cairo_status_t
  2350. _cairo_utf8_to_utf16 (const char *str,
  2351.                       int         len,
  2352.                       uint16_t  **result,
  2353.                       int        *items_written);
  2354. #endif
  2355.  
  2356. /* cairo-observer.c */
  2357.  
  2358. cairo_private void
  2359. _cairo_observers_notify (cairo_list_t *observers, void *arg);
  2360.  
  2361. /* Avoid unnecessary PLT entries.  */
  2362. slim_hidden_proto (cairo_clip_preserve);
  2363. slim_hidden_proto (cairo_close_path);
  2364. slim_hidden_proto (cairo_create);
  2365. slim_hidden_proto (cairo_curve_to);
  2366. slim_hidden_proto (cairo_destroy);
  2367. slim_hidden_proto (cairo_fill_preserve);
  2368. slim_hidden_proto (cairo_font_face_destroy);
  2369. slim_hidden_proto (cairo_font_face_get_user_data);
  2370. slim_hidden_proto_no_warn (cairo_font_face_reference);
  2371. slim_hidden_proto (cairo_font_face_set_user_data);
  2372. slim_hidden_proto (cairo_font_options_equal);
  2373. slim_hidden_proto (cairo_font_options_hash);
  2374. slim_hidden_proto (cairo_font_options_merge);
  2375. slim_hidden_proto (cairo_font_options_set_antialias);
  2376. slim_hidden_proto (cairo_font_options_set_hint_metrics);
  2377. slim_hidden_proto (cairo_font_options_set_hint_style);
  2378. slim_hidden_proto (cairo_font_options_set_subpixel_order);
  2379. slim_hidden_proto (cairo_font_options_status);
  2380. slim_hidden_proto (cairo_format_stride_for_width);
  2381. slim_hidden_proto (cairo_get_current_point);
  2382. slim_hidden_proto (cairo_get_line_width);
  2383. slim_hidden_proto (cairo_get_matrix);
  2384. slim_hidden_proto (cairo_get_target);
  2385. slim_hidden_proto (cairo_get_tolerance);
  2386. slim_hidden_proto (cairo_glyph_allocate);
  2387. slim_hidden_proto (cairo_glyph_free);
  2388. slim_hidden_proto (cairo_image_surface_create);
  2389. slim_hidden_proto (cairo_image_surface_create_for_data);
  2390. slim_hidden_proto (cairo_image_surface_get_data);
  2391. slim_hidden_proto (cairo_image_surface_get_format);
  2392. slim_hidden_proto (cairo_image_surface_get_height);
  2393. slim_hidden_proto (cairo_image_surface_get_stride);
  2394. slim_hidden_proto (cairo_image_surface_get_width);
  2395. slim_hidden_proto (cairo_line_to);
  2396. slim_hidden_proto (cairo_mask);
  2397. slim_hidden_proto (cairo_matrix_init);
  2398. slim_hidden_proto (cairo_matrix_init_identity);
  2399. slim_hidden_proto (cairo_matrix_init_rotate);
  2400. slim_hidden_proto (cairo_matrix_init_scale);
  2401. slim_hidden_proto (cairo_matrix_init_translate);
  2402. slim_hidden_proto (cairo_matrix_invert);
  2403. slim_hidden_proto (cairo_matrix_multiply);
  2404. slim_hidden_proto (cairo_matrix_scale);
  2405. slim_hidden_proto (cairo_matrix_transform_distance);
  2406. slim_hidden_proto (cairo_matrix_transform_point);
  2407. slim_hidden_proto (cairo_matrix_translate);
  2408. slim_hidden_proto (cairo_move_to);
  2409. slim_hidden_proto (cairo_new_path);
  2410. slim_hidden_proto (cairo_paint);
  2411. slim_hidden_proto (cairo_pattern_create_for_surface);
  2412. slim_hidden_proto (cairo_pattern_create_rgb);
  2413. slim_hidden_proto (cairo_pattern_create_rgba);
  2414. slim_hidden_proto (cairo_pattern_destroy);
  2415. slim_hidden_proto (cairo_pattern_get_extend);
  2416. slim_hidden_proto_no_warn (cairo_pattern_reference);
  2417. slim_hidden_proto (cairo_pattern_set_matrix);
  2418. slim_hidden_proto (cairo_pop_group);
  2419. slim_hidden_proto (cairo_push_group_with_content);
  2420. slim_hidden_proto (cairo_rel_line_to);
  2421. slim_hidden_proto (cairo_restore);
  2422. slim_hidden_proto (cairo_save);
  2423. slim_hidden_proto (cairo_scale);
  2424. slim_hidden_proto (cairo_scaled_font_create);
  2425. slim_hidden_proto (cairo_scaled_font_destroy);
  2426. slim_hidden_proto (cairo_scaled_font_extents);
  2427. slim_hidden_proto (cairo_scaled_font_get_ctm);
  2428. slim_hidden_proto (cairo_scaled_font_get_font_face);
  2429. slim_hidden_proto (cairo_scaled_font_get_font_matrix);
  2430. slim_hidden_proto (cairo_scaled_font_get_font_options);
  2431. slim_hidden_proto (cairo_scaled_font_glyph_extents);
  2432. slim_hidden_proto_no_warn (cairo_scaled_font_reference);
  2433. slim_hidden_proto (cairo_scaled_font_status);
  2434. slim_hidden_proto (cairo_scaled_font_get_user_data);
  2435. slim_hidden_proto (cairo_scaled_font_set_user_data);
  2436. slim_hidden_proto (cairo_scaled_font_text_to_glyphs);
  2437. slim_hidden_proto (cairo_set_font_options);
  2438. slim_hidden_proto (cairo_set_font_size);
  2439. slim_hidden_proto (cairo_set_line_cap);
  2440. slim_hidden_proto (cairo_set_line_join);
  2441. slim_hidden_proto (cairo_set_line_width);
  2442. slim_hidden_proto (cairo_set_matrix);
  2443. slim_hidden_proto (cairo_set_operator);
  2444. slim_hidden_proto (cairo_set_source);
  2445. slim_hidden_proto (cairo_set_source_rgb);
  2446. slim_hidden_proto (cairo_set_source_surface);
  2447. slim_hidden_proto (cairo_set_tolerance);
  2448. slim_hidden_proto (cairo_status);
  2449. slim_hidden_proto (cairo_stroke);
  2450. slim_hidden_proto (cairo_stroke_preserve);
  2451. slim_hidden_proto (cairo_surface_copy_page);
  2452. slim_hidden_proto (cairo_surface_destroy);
  2453. slim_hidden_proto (cairo_surface_finish);
  2454. slim_hidden_proto (cairo_surface_flush);
  2455. slim_hidden_proto (cairo_surface_get_content);
  2456. slim_hidden_proto (cairo_surface_get_device_offset);
  2457. slim_hidden_proto (cairo_surface_get_font_options);
  2458. slim_hidden_proto (cairo_surface_get_mime_data);
  2459. slim_hidden_proto (cairo_surface_get_type);
  2460. slim_hidden_proto (cairo_surface_has_show_text_glyphs);
  2461. slim_hidden_proto (cairo_surface_mark_dirty);
  2462. slim_hidden_proto (cairo_surface_mark_dirty_rectangle);
  2463. slim_hidden_proto_no_warn (cairo_surface_reference);
  2464. slim_hidden_proto (cairo_surface_set_device_offset);
  2465. slim_hidden_proto (cairo_surface_set_fallback_resolution);
  2466. slim_hidden_proto (cairo_surface_set_mime_data);
  2467. slim_hidden_proto (cairo_surface_show_page);
  2468. slim_hidden_proto (cairo_surface_status);
  2469. slim_hidden_proto (cairo_text_cluster_allocate);
  2470. slim_hidden_proto (cairo_text_cluster_free);
  2471. slim_hidden_proto (cairo_toy_font_face_create);
  2472. slim_hidden_proto (cairo_toy_font_face_get_slant);
  2473. slim_hidden_proto (cairo_toy_font_face_get_weight);
  2474. slim_hidden_proto (cairo_translate);
  2475. slim_hidden_proto (cairo_transform);
  2476. slim_hidden_proto (cairo_user_font_face_create);
  2477. slim_hidden_proto (cairo_user_font_face_set_init_func);
  2478. slim_hidden_proto (cairo_user_font_face_set_render_glyph_func);
  2479. slim_hidden_proto (cairo_user_font_face_set_unicode_to_glyph_func);
  2480. slim_hidden_proto (cairo_user_to_device);
  2481. slim_hidden_proto (cairo_user_to_device_distance);
  2482. slim_hidden_proto (cairo_version_string);
  2483. slim_hidden_proto (cairo_region_create);
  2484. slim_hidden_proto (cairo_region_create_rectangle);
  2485. slim_hidden_proto (cairo_region_create_rectangles);
  2486. slim_hidden_proto (cairo_region_copy);
  2487. slim_hidden_proto (cairo_region_reference);
  2488. slim_hidden_proto (cairo_region_destroy);
  2489. slim_hidden_proto (cairo_region_equal);
  2490. slim_hidden_proto (cairo_region_status);
  2491. slim_hidden_proto (cairo_region_get_extents);
  2492. slim_hidden_proto (cairo_region_num_rectangles);
  2493. slim_hidden_proto (cairo_region_get_rectangle);
  2494. slim_hidden_proto (cairo_region_is_empty);
  2495. slim_hidden_proto (cairo_region_contains_rectangle);
  2496. slim_hidden_proto (cairo_region_contains_point);
  2497. slim_hidden_proto (cairo_region_translate);
  2498. slim_hidden_proto (cairo_region_subtract);
  2499. slim_hidden_proto (cairo_region_subtract_rectangle);
  2500. slim_hidden_proto (cairo_region_intersect);
  2501. slim_hidden_proto (cairo_region_intersect_rectangle);
  2502. slim_hidden_proto (cairo_region_union);
  2503. slim_hidden_proto (cairo_region_union_rectangle);
  2504. slim_hidden_proto (cairo_region_xor);
  2505. slim_hidden_proto (cairo_region_xor_rectangle);
  2506.  
  2507. #if CAIRO_HAS_PNG_FUNCTIONS
  2508.  
  2509. slim_hidden_proto (cairo_surface_write_to_png_stream);
  2510.  
  2511. #endif
  2512.  
  2513. cairo_private_no_warn cairo_filter_t
  2514. _cairo_pattern_analyze_filter (const cairo_pattern_t    *pattern,
  2515.                                double                   *pad_out);
  2516.  
  2517. CAIRO_END_DECLS
  2518.  
  2519. #include "cairo-mutex-private.h"
  2520. #include "cairo-fixed-private.h"
  2521. #include "cairo-wideint-private.h"
  2522. #include "cairo-malloc-private.h"
  2523. #include "cairo-hash-private.h"
  2524.  
  2525. #if HAVE_VALGRIND
  2526. #include <memcheck.h>
  2527.  
  2528. #define VG(x) x
  2529.  
  2530. cairo_private void
  2531. _cairo_debug_check_image_surface_is_defined (const cairo_surface_t *surface);
  2532.  
  2533. #else
  2534.  
  2535. #define VG(x)
  2536. #define _cairo_debug_check_image_surface_is_defined(X)
  2537.  
  2538. #endif
  2539.  
  2540. cairo_private void
  2541. _cairo_debug_print_path (FILE *stream, cairo_path_fixed_t *path);
  2542.  
  2543. cairo_private void
  2544. _cairo_debug_print_clip (FILE *stream, cairo_clip_t *clip);
  2545.  
  2546. #endif
  2547.