Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
3959 | Serge | 1 | /* cairo - a vector graphics library with display and print output |
2 | * |
||
3 | * Copyright © 2005 Red Hat, Inc. |
||
4 | * |
||
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. |
||
12 | * |
||
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 |
||
18 | * |
||
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/ |
||
23 | * |
||
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. |
||
27 | * |
||
28 | * The Original Code is the cairo graphics library. |
||
29 | * |
||
30 | * The Initial Developer of the Original Code is Red Hat, Inc. |
||
31 | * |
||
32 | * Contributor(s): |
||
33 | * Carl D. Worth |
||
34 | */ |
||
35 | |||
36 | #ifndef CAIRO_PATTERN_PRIVATE_H |
||
37 | #define CAIRO_PATTERN_PRIVATE_H |
||
38 | |||
39 | #include "cairo-error-private.h" |
||
40 | #include "cairo-types-private.h" |
||
41 | #include "cairo-list-private.h" |
||
42 | #include "cairo-surface-private.h" |
||
43 | |||
44 | #include |
||
45 | |||
46 | CAIRO_BEGIN_DECLS |
||
47 | |||
48 | typedef struct _cairo_pattern_observer cairo_pattern_observer_t; |
||
49 | |||
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, |
||
55 | }; |
||
56 | |||
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; |
||
62 | }; |
||
63 | |||
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; |
||
69 | |||
70 | cairo_pattern_type_t type; |
||
71 | |||
72 | cairo_filter_t filter; |
||
73 | cairo_extend_t extend; |
||
74 | cairo_bool_t has_component_alpha; |
||
75 | |||
76 | cairo_matrix_t matrix; |
||
77 | double opacity; |
||
78 | }; |
||
79 | |||
80 | struct _cairo_solid_pattern { |
||
81 | cairo_pattern_t base; |
||
82 | cairo_color_t color; |
||
83 | }; |
||
84 | |||
85 | typedef struct _cairo_surface_pattern { |
||
86 | cairo_pattern_t base; |
||
87 | |||
88 | cairo_surface_t *surface; |
||
89 | } cairo_surface_pattern_t; |
||
90 | |||
91 | typedef struct _cairo_gradient_stop { |
||
92 | double offset; |
||
93 | cairo_color_stop_t color; |
||
94 | } cairo_gradient_stop_t; |
||
95 | |||
96 | typedef struct _cairo_gradient_pattern { |
||
97 | cairo_pattern_t base; |
||
98 | |||
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; |
||
104 | |||
105 | typedef struct _cairo_linear_pattern { |
||
106 | cairo_gradient_pattern_t base; |
||
107 | |||
108 | cairo_point_double_t pd1; |
||
109 | cairo_point_double_t pd2; |
||
110 | } cairo_linear_pattern_t; |
||
111 | |||
112 | typedef struct _cairo_radial_pattern { |
||
113 | cairo_gradient_pattern_t base; |
||
114 | |||
115 | cairo_circle_double_t cd1; |
||
116 | cairo_circle_double_t cd2; |
||
117 | } cairo_radial_pattern_t; |
||
118 | |||
119 | typedef union { |
||
120 | cairo_gradient_pattern_t base; |
||
121 | |||
122 | cairo_linear_pattern_t linear; |
||
123 | cairo_radial_pattern_t radial; |
||
124 | } cairo_gradient_pattern_union_t; |
||
125 | |||
126 | /* |
||
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. |
||
133 | * |
||
134 | * Cairo uses the same convention as the PDF Reference for numbering |
||
135 | * the points and side of the patch. |
||
136 | * |
||
137 | * |
||
138 | * Side 1 |
||
139 | * |
||
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] |
||
144 | * |
||
145 | * Side 3 |
||
146 | * |
||
147 | * |
||
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] |
||
154 | */ |
||
155 | |||
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; |
||
160 | |||
161 | typedef struct _cairo_mesh_pattern { |
||
162 | cairo_pattern_t base; |
||
163 | |||
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; |
||
170 | |||
171 | typedef struct _cairo_raster_source_pattern { |
||
172 | cairo_pattern_t base; |
||
173 | |||
174 | cairo_content_t content; |
||
175 | cairo_rectangle_int_t extents; |
||
176 | |||
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; |
||
182 | |||
183 | /* an explicit pre-allocated member in preference to the general user-data */ |
||
184 | void *user_data; |
||
185 | } cairo_raster_source_pattern_t; |
||
186 | |||
187 | typedef union { |
||
188 | cairo_pattern_t base; |
||
189 | |||
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; |
||
196 | |||
197 | /* cairo-pattern.c */ |
||
198 | |||
199 | cairo_private cairo_pattern_t * |
||
200 | _cairo_pattern_create_in_error (cairo_status_t status); |
||
201 | |||
202 | cairo_private cairo_status_t |
||
203 | _cairo_pattern_create_copy (cairo_pattern_t **pattern, |
||
204 | const cairo_pattern_t *other); |
||
205 | |||
206 | cairo_private void |
||
207 | _cairo_pattern_init (cairo_pattern_t *pattern, |
||
208 | cairo_pattern_type_t type); |
||
209 | |||
210 | cairo_private cairo_status_t |
||
211 | _cairo_pattern_init_copy (cairo_pattern_t *pattern, |
||
212 | const cairo_pattern_t *other); |
||
213 | |||
214 | cairo_private void |
||
215 | _cairo_pattern_init_static_copy (cairo_pattern_t *pattern, |
||
216 | const cairo_pattern_t *other); |
||
217 | |||
218 | cairo_private cairo_status_t |
||
219 | _cairo_pattern_init_snapshot (cairo_pattern_t *pattern, |
||
220 | const cairo_pattern_t *other); |
||
221 | |||
222 | cairo_private void |
||
223 | _cairo_pattern_init_solid (cairo_solid_pattern_t *pattern, |
||
224 | const cairo_color_t *color); |
||
225 | |||
226 | cairo_private void |
||
227 | _cairo_pattern_init_for_surface (cairo_surface_pattern_t *pattern, |
||
228 | cairo_surface_t *surface); |
||
229 | |||
230 | cairo_private void |
||
231 | _cairo_pattern_fini (cairo_pattern_t *pattern); |
||
232 | |||
233 | cairo_private cairo_pattern_t * |
||
234 | _cairo_pattern_create_solid (const cairo_color_t *color); |
||
235 | |||
236 | cairo_private void |
||
237 | _cairo_pattern_transform (cairo_pattern_t *pattern, |
||
238 | const cairo_matrix_t *ctm_inverse); |
||
239 | |||
240 | cairo_private cairo_bool_t |
||
241 | _cairo_pattern_is_opaque_solid (const cairo_pattern_t *pattern); |
||
242 | |||
243 | cairo_private cairo_bool_t |
||
244 | _cairo_pattern_is_opaque (const cairo_pattern_t *pattern, |
||
245 | const cairo_rectangle_int_t *extents); |
||
246 | |||
247 | cairo_private cairo_bool_t |
||
248 | _cairo_pattern_is_clear (const cairo_pattern_t *pattern); |
||
249 | |||
250 | cairo_private cairo_bool_t |
||
251 | _cairo_gradient_pattern_is_solid (const cairo_gradient_pattern_t *gradient, |
||
252 | const cairo_rectangle_int_t *extents, |
||
253 | cairo_color_t *color); |
||
254 | |||
255 | cairo_private void |
||
256 | _cairo_gradient_pattern_fit_to_range (const cairo_gradient_pattern_t *gradient, |
||
257 | double max_value, |
||
258 | cairo_matrix_t *out_matrix, |
||
259 | cairo_circle_double_t out_circle[2]); |
||
260 | |||
261 | cairo_private cairo_bool_t |
||
262 | _cairo_radial_pattern_focus_is_inside (const cairo_radial_pattern_t *radial); |
||
263 | |||
264 | cairo_private void |
||
265 | _cairo_gradient_pattern_box_to_parameter (const cairo_gradient_pattern_t *gradient, |
||
266 | double x0, double y0, |
||
267 | double x1, double y1, |
||
268 | double tolerance, |
||
269 | double out_range[2]); |
||
270 | |||
271 | cairo_private void |
||
272 | _cairo_gradient_pattern_interpolate (const cairo_gradient_pattern_t *gradient, |
||
273 | double t, |
||
274 | cairo_circle_double_t *out_circle); |
||
275 | |||
276 | cairo_private void |
||
277 | _cairo_pattern_alpha_range (const cairo_pattern_t *pattern, |
||
278 | double *out_min, |
||
279 | double *out_max); |
||
280 | |||
281 | cairo_private cairo_bool_t |
||
282 | _cairo_mesh_pattern_coord_box (const cairo_mesh_pattern_t *mesh, |
||
283 | double *out_xmin, |
||
284 | double *out_ymin, |
||
285 | double *out_xmax, |
||
286 | double *out_ymax); |
||
287 | |||
288 | cairo_private_no_warn cairo_filter_t |
||
289 | _cairo_pattern_sampled_area (const cairo_pattern_t *pattern, |
||
290 | const cairo_rectangle_int_t *extents, |
||
291 | cairo_rectangle_int_t *sample); |
||
292 | |||
293 | cairo_private void |
||
294 | _cairo_pattern_get_extents (const cairo_pattern_t *pattern, |
||
295 | cairo_rectangle_int_t *extents); |
||
296 | |||
297 | cairo_private cairo_int_status_t |
||
298 | _cairo_pattern_get_ink_extents (const cairo_pattern_t *pattern, |
||
299 | cairo_rectangle_int_t *extents); |
||
300 | |||
301 | cairo_private unsigned long |
||
302 | _cairo_pattern_hash (const cairo_pattern_t *pattern); |
||
303 | |||
304 | cairo_private unsigned long |
||
305 | _cairo_linear_pattern_hash (unsigned long hash, |
||
306 | const cairo_linear_pattern_t *linear); |
||
307 | |||
308 | cairo_private unsigned long |
||
309 | _cairo_radial_pattern_hash (unsigned long hash, |
||
310 | const cairo_radial_pattern_t *radial); |
||
311 | |||
312 | cairo_private cairo_bool_t |
||
313 | _cairo_linear_pattern_equal (const cairo_linear_pattern_t *a, |
||
314 | const cairo_linear_pattern_t *b); |
||
315 | |||
316 | cairo_private unsigned long |
||
317 | _cairo_pattern_size (const cairo_pattern_t *pattern); |
||
318 | |||
319 | cairo_private cairo_bool_t |
||
320 | _cairo_radial_pattern_equal (const cairo_radial_pattern_t *a, |
||
321 | const cairo_radial_pattern_t *b); |
||
322 | |||
323 | cairo_private cairo_bool_t |
||
324 | _cairo_pattern_equal (const cairo_pattern_t *a, |
||
325 | const cairo_pattern_t *b); |
||
326 | |||
327 | /* cairo-mesh-pattern-rasterizer.c */ |
||
328 | |||
329 | cairo_private void |
||
330 | _cairo_mesh_pattern_rasterize (const cairo_mesh_pattern_t *mesh, |
||
331 | void *data, |
||
332 | int width, |
||
333 | int height, |
||
334 | int stride, |
||
335 | double x_offset, |
||
336 | double y_offset); |
||
337 | |||
338 | cairo_private cairo_surface_t * |
||
339 | _cairo_raster_source_pattern_acquire (const cairo_pattern_t *abstract_pattern, |
||
340 | cairo_surface_t *target, |
||
341 | const cairo_rectangle_int_t *extents); |
||
342 | |||
343 | cairo_private void |
||
344 | _cairo_raster_source_pattern_release (const cairo_pattern_t *abstract_pattern, |
||
345 | cairo_surface_t *surface); |
||
346 | |||
347 | cairo_private cairo_status_t |
||
348 | _cairo_raster_source_pattern_snapshot (cairo_pattern_t *abstract_pattern); |
||
349 | |||
350 | cairo_private cairo_status_t |
||
351 | _cairo_raster_source_pattern_init_copy (cairo_pattern_t *pattern, |
||
352 | const cairo_pattern_t *other); |
||
353 | |||
354 | cairo_private void |
||
355 | _cairo_raster_source_pattern_finish (cairo_pattern_t *abstract_pattern); |
||
356 | |||
357 | cairo_private void |
||
358 | _cairo_debug_print_pattern (FILE *file, const cairo_pattern_t *pattern); |
||
359 | |||
360 | CAIRO_END_DECLS |
||
361 | |||
362 | #endif /* CAIRO_PATTERN_PRIVATE */ |