beta-0.89.2
[luatex.git] / source / libs / cairo / cairo-src / src / cairo-pattern-private.h
blobbe8ab9fc239a555bbc9bd0cb4fc9f0966005f24c
1 /* cairo - a vector graphics library with display and print output
3 * Copyright © 2005 Red Hat, Inc.
5 * This library is free software; you can redistribute it and/or
6 * modify it either under the terms of the GNU Lesser General Public
7 * License version 2.1 as published by the Free Software Foundation
8 * (the "LGPL") or, at your option, under the terms of the Mozilla
9 * Public License Version 1.1 (the "MPL"). If you do not alter this
10 * notice, a recipient may use your version of this file under either
11 * the MPL or the LGPL.
13 * You should have received a copy of the LGPL along with this library
14 * in the file COPYING-LGPL-2.1; if not, write to the Free Software
15 * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
16 * You should have received a copy of the MPL along with this library
17 * in the file COPYING-MPL-1.1
19 * The contents of this file are subject to the Mozilla Public License
20 * Version 1.1 (the "License"); you may not use this file except in
21 * compliance with the License. You may obtain a copy of the License at
22 * http://www.mozilla.org/MPL/
24 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
25 * OF ANY KIND, either express or implied. See the LGPL or the MPL for
26 * the specific language governing rights and limitations.
28 * The Original Code is the cairo graphics library.
30 * The Initial Developer of the Original Code is Red Hat, Inc.
32 * Contributor(s):
33 * Carl D. Worth <cworth@redhat.com>
36 #ifndef CAIRO_PATTERN_PRIVATE_H
37 #define CAIRO_PATTERN_PRIVATE_H
39 #include "cairo-error-private.h"
40 #include "cairo-types-private.h"
41 #include "cairo-list-private.h"
42 #include "cairo-surface-private.h"
44 #include <stdio.h> /* FILE* */
46 CAIRO_BEGIN_DECLS
48 typedef struct _cairo_pattern_observer cairo_pattern_observer_t;
50 enum {
51 CAIRO_PATTERN_NOTIFY_MATRIX = 0x1,
52 CAIRO_PATTERN_NOTIFY_FILTER = 0x2,
53 CAIRO_PATTERN_NOTIFY_EXTEND = 0x4,
54 CAIRO_PATTERN_NOTIFY_OPACITY = 0x9,
57 struct _cairo_pattern_observer {
58 void (*notify) (cairo_pattern_observer_t *,
59 cairo_pattern_t *pattern,
60 unsigned int flags);
61 cairo_list_t link;
64 struct _cairo_pattern {
65 cairo_reference_count_t ref_count;
66 cairo_status_t status;
67 cairo_user_data_array_t user_data;
68 cairo_list_t observers;
70 cairo_pattern_type_t type;
72 cairo_filter_t filter;
73 cairo_extend_t extend;
74 cairo_bool_t has_component_alpha;
76 cairo_matrix_t matrix;
77 double opacity;
80 struct _cairo_solid_pattern {
81 cairo_pattern_t base;
82 cairo_color_t color;
85 typedef struct _cairo_surface_pattern {
86 cairo_pattern_t base;
88 cairo_surface_t *surface;
89 } cairo_surface_pattern_t;
91 typedef struct _cairo_gradient_stop {
92 double offset;
93 cairo_color_stop_t color;
94 } cairo_gradient_stop_t;
96 typedef struct _cairo_gradient_pattern {
97 cairo_pattern_t base;
99 unsigned int n_stops;
100 unsigned int stops_size;
101 cairo_gradient_stop_t *stops;
102 cairo_gradient_stop_t stops_embedded[2];
103 } cairo_gradient_pattern_t;
105 typedef struct _cairo_linear_pattern {
106 cairo_gradient_pattern_t base;
108 cairo_point_double_t pd1;
109 cairo_point_double_t pd2;
110 } cairo_linear_pattern_t;
112 typedef struct _cairo_radial_pattern {
113 cairo_gradient_pattern_t base;
115 cairo_circle_double_t cd1;
116 cairo_circle_double_t cd2;
117 } cairo_radial_pattern_t;
119 typedef union {
120 cairo_gradient_pattern_t base;
122 cairo_linear_pattern_t linear;
123 cairo_radial_pattern_t radial;
124 } cairo_gradient_pattern_union_t;
127 * A mesh patch is a tensor-product patch (bicubic Bezier surface
128 * patch). It has 16 control points. Each set of 4 points along the
129 * sides of the 4x4 grid of control points is a Bezier curve that
130 * defines one side of the patch. A color is assigned to each
131 * corner. The inner 4 points provide additional control over the
132 * shape and the color mapping.
134 * Cairo uses the same convention as the PDF Reference for numbering
135 * the points and side of the patch.
138 * Side 1
140 * p[0][3] p[1][3] p[2][3] p[3][3]
141 * Side 0 p[0][2] p[1][2] p[2][2] p[3][2] Side 2
142 * p[0][1] p[1][1] p[2][1] p[3][1]
143 * p[0][0] p[1][0] p[2][0] p[3][0]
145 * Side 3
148 * Point Color
149 * -------------------------
150 * points[0][0] colors[0]
151 * points[0][3] colors[1]
152 * points[3][3] colors[2]
153 * points[3][0] colors[3]
156 typedef struct _cairo_mesh_patch {
157 cairo_point_double_t points[4][4];
158 cairo_color_t colors[4];
159 } cairo_mesh_patch_t;
161 typedef struct _cairo_mesh_pattern {
162 cairo_pattern_t base;
164 cairo_array_t patches;
165 cairo_mesh_patch_t *current_patch;
166 int current_side;
167 cairo_bool_t has_control_point[4];
168 cairo_bool_t has_color[4];
169 } cairo_mesh_pattern_t;
171 typedef struct _cairo_raster_source_pattern {
172 cairo_pattern_t base;
174 cairo_content_t content;
175 cairo_rectangle_int_t extents;
177 cairo_raster_source_acquire_func_t acquire;
178 cairo_raster_source_release_func_t release;
179 cairo_raster_source_snapshot_func_t snapshot;
180 cairo_raster_source_copy_func_t copy;
181 cairo_raster_source_finish_func_t finish;
183 /* an explicit pre-allocated member in preference to the general user-data */
184 void *user_data;
185 } cairo_raster_source_pattern_t;
187 typedef union {
188 cairo_pattern_t base;
190 cairo_solid_pattern_t solid;
191 cairo_surface_pattern_t surface;
192 cairo_gradient_pattern_union_t gradient;
193 cairo_mesh_pattern_t mesh;
194 cairo_raster_source_pattern_t raster_source;
195 } cairo_pattern_union_t;
197 /* cairo-pattern.c */
199 cairo_private cairo_pattern_t *
200 _cairo_pattern_create_in_error (cairo_status_t status);
202 cairo_private cairo_status_t
203 _cairo_pattern_create_copy (cairo_pattern_t **pattern,
204 const cairo_pattern_t *other);
206 cairo_private void
207 _cairo_pattern_init (cairo_pattern_t *pattern,
208 cairo_pattern_type_t type);
210 cairo_private cairo_status_t
211 _cairo_pattern_init_copy (cairo_pattern_t *pattern,
212 const cairo_pattern_t *other);
214 cairo_private void
215 _cairo_pattern_init_static_copy (cairo_pattern_t *pattern,
216 const cairo_pattern_t *other);
218 cairo_private cairo_status_t
219 _cairo_pattern_init_snapshot (cairo_pattern_t *pattern,
220 const cairo_pattern_t *other);
222 cairo_private void
223 _cairo_pattern_init_solid (cairo_solid_pattern_t *pattern,
224 const cairo_color_t *color);
226 cairo_private void
227 _cairo_pattern_init_for_surface (cairo_surface_pattern_t *pattern,
228 cairo_surface_t *surface);
230 cairo_private void
231 _cairo_pattern_fini (cairo_pattern_t *pattern);
233 cairo_private cairo_pattern_t *
234 _cairo_pattern_create_solid (const cairo_color_t *color);
236 cairo_private void
237 _cairo_pattern_transform (cairo_pattern_t *pattern,
238 const cairo_matrix_t *ctm_inverse);
240 cairo_private void
241 _cairo_pattern_pretransform (cairo_pattern_t *pattern,
242 const cairo_matrix_t *ctm);
244 cairo_private cairo_bool_t
245 _cairo_pattern_is_opaque_solid (const cairo_pattern_t *pattern);
247 cairo_private cairo_bool_t
248 _cairo_pattern_is_opaque (const cairo_pattern_t *pattern,
249 const cairo_rectangle_int_t *extents);
251 cairo_private cairo_bool_t
252 _cairo_pattern_is_clear (const cairo_pattern_t *pattern);
254 cairo_private cairo_bool_t
255 _cairo_gradient_pattern_is_solid (const cairo_gradient_pattern_t *gradient,
256 const cairo_rectangle_int_t *extents,
257 cairo_color_t *color);
259 cairo_private void
260 _cairo_gradient_pattern_fit_to_range (const cairo_gradient_pattern_t *gradient,
261 double max_value,
262 cairo_matrix_t *out_matrix,
263 cairo_circle_double_t out_circle[2]);
265 cairo_private cairo_bool_t
266 _cairo_radial_pattern_focus_is_inside (const cairo_radial_pattern_t *radial);
268 cairo_private void
269 _cairo_gradient_pattern_box_to_parameter (const cairo_gradient_pattern_t *gradient,
270 double x0, double y0,
271 double x1, double y1,
272 double tolerance,
273 double out_range[2]);
275 cairo_private void
276 _cairo_gradient_pattern_interpolate (const cairo_gradient_pattern_t *gradient,
277 double t,
278 cairo_circle_double_t *out_circle);
280 cairo_private void
281 _cairo_pattern_alpha_range (const cairo_pattern_t *pattern,
282 double *out_min,
283 double *out_max);
285 cairo_private cairo_bool_t
286 _cairo_mesh_pattern_coord_box (const cairo_mesh_pattern_t *mesh,
287 double *out_xmin,
288 double *out_ymin,
289 double *out_xmax,
290 double *out_ymax);
292 cairo_private void
293 _cairo_pattern_sampled_area (const cairo_pattern_t *pattern,
294 const cairo_rectangle_int_t *extents,
295 cairo_rectangle_int_t *sample);
297 cairo_private void
298 _cairo_pattern_get_extents (const cairo_pattern_t *pattern,
299 cairo_rectangle_int_t *extents);
301 cairo_private cairo_int_status_t
302 _cairo_pattern_get_ink_extents (const cairo_pattern_t *pattern,
303 cairo_rectangle_int_t *extents);
305 cairo_private unsigned long
306 _cairo_pattern_hash (const cairo_pattern_t *pattern);
308 cairo_private unsigned long
309 _cairo_linear_pattern_hash (unsigned long hash,
310 const cairo_linear_pattern_t *linear);
312 cairo_private unsigned long
313 _cairo_radial_pattern_hash (unsigned long hash,
314 const cairo_radial_pattern_t *radial);
316 cairo_private cairo_bool_t
317 _cairo_linear_pattern_equal (const cairo_linear_pattern_t *a,
318 const cairo_linear_pattern_t *b);
320 cairo_private unsigned long
321 _cairo_pattern_size (const cairo_pattern_t *pattern);
323 cairo_private cairo_bool_t
324 _cairo_radial_pattern_equal (const cairo_radial_pattern_t *a,
325 const cairo_radial_pattern_t *b);
327 cairo_private cairo_bool_t
328 _cairo_pattern_equal (const cairo_pattern_t *a,
329 const cairo_pattern_t *b);
331 cairo_private cairo_filter_t
332 _cairo_pattern_analyze_filter (const cairo_pattern_t *pattern);
334 /* cairo-mesh-pattern-rasterizer.c */
336 cairo_private void
337 _cairo_mesh_pattern_rasterize (const cairo_mesh_pattern_t *mesh,
338 void *data,
339 int width,
340 int height,
341 int stride,
342 double x_offset,
343 double y_offset);
345 cairo_private cairo_surface_t *
346 _cairo_raster_source_pattern_acquire (const cairo_pattern_t *abstract_pattern,
347 cairo_surface_t *target,
348 const cairo_rectangle_int_t *extents);
350 cairo_private void
351 _cairo_raster_source_pattern_release (const cairo_pattern_t *abstract_pattern,
352 cairo_surface_t *surface);
354 cairo_private cairo_status_t
355 _cairo_raster_source_pattern_snapshot (cairo_pattern_t *abstract_pattern);
357 cairo_private cairo_status_t
358 _cairo_raster_source_pattern_init_copy (cairo_pattern_t *pattern,
359 const cairo_pattern_t *other);
361 cairo_private void
362 _cairo_raster_source_pattern_finish (cairo_pattern_t *abstract_pattern);
364 cairo_private void
365 _cairo_debug_print_pattern (FILE *file, const cairo_pattern_t *pattern);
367 CAIRO_END_DECLS
369 #endif /* CAIRO_PATTERN_PRIVATE */