Rev 1892 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
1892 | serge | 1 | /* -*- Mode: c; tab-width: 8; c-basic-offset: 4; indent-tabs-mode: t; -*- */ |
2 | /* cairo - a vector graphics library with display and print output |
||
3 | * |
||
4 | * Copyright © 2002 University of Southern California |
||
5 | * Copyright © 2005 Red Hat, Inc. |
||
6 | * |
||
7 | * This library is free software; you can redistribute it and/or |
||
8 | * modify it either under the terms of the GNU Lesser General Public |
||
9 | * License version 2.1 as published by the Free Software Foundation |
||
10 | * (the "LGPL") or, at your option, under the terms of the Mozilla |
||
11 | * Public License Version 1.1 (the "MPL"). If you do not alter this |
||
12 | * notice, a recipient may use your version of this file under either |
||
13 | * the MPL or the LGPL. |
||
14 | * |
||
15 | * You should have received a copy of the LGPL along with this library |
||
16 | * in the file COPYING-LGPL-2.1; if not, write to the Free Software |
||
17 | * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA |
||
18 | * You should have received a copy of the MPL along with this library |
||
19 | * in the file COPYING-MPL-1.1 |
||
20 | * |
||
21 | * The contents of this file are subject to the Mozilla Public License |
||
22 | * Version 1.1 (the "License"); you may not use this file except in |
||
23 | * compliance with the License. You may obtain a copy of the License at |
||
24 | * http://www.mozilla.org/MPL/ |
||
25 | * |
||
26 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY |
||
27 | * OF ANY KIND, either express or implied. See the LGPL or the MPL for |
||
28 | * the specific language governing rights and limitations. |
||
29 | * |
||
30 | * The Original Code is the cairo graphics library. |
||
31 | * |
||
32 | * The Initial Developer of the Original Code is University of Southern |
||
33 | * California. |
||
34 | * |
||
35 | * Contributor(s): |
||
36 | * Carl D. Worth |
||
37 | */ |
||
38 | |||
39 | #ifndef CAIRO_TYPES_PRIVATE_H |
||
40 | #define CAIRO_TYPES_PRIVATE_H |
||
41 | |||
42 | #include "cairo.h" |
||
43 | #include "cairo-fixed-type-private.h" |
||
44 | #include "cairo-list-private.h" |
||
45 | #include "cairo-reference-count-private.h" |
||
46 | |||
3959 | Serge | 47 | CAIRO_BEGIN_DECLS |
48 | |||
1892 | serge | 49 | /** |
50 | * SECTION:cairo-types |
||
51 | * @Title: Types |
||
52 | * @Short_Description: Generic data types |
||
53 | * |
||
54 | * This section lists generic data types used in the cairo API. |
||
3959 | Serge | 55 | **/ |
1892 | serge | 56 | |
57 | typedef struct _cairo_array cairo_array_t; |
||
58 | typedef struct _cairo_backend cairo_backend_t; |
||
59 | typedef struct _cairo_boxes_t cairo_boxes_t; |
||
60 | typedef struct _cairo_cache cairo_cache_t; |
||
61 | typedef struct _cairo_composite_rectangles cairo_composite_rectangles_t; |
||
62 | typedef struct _cairo_clip cairo_clip_t; |
||
63 | typedef struct _cairo_clip_path cairo_clip_path_t; |
||
64 | typedef struct _cairo_color cairo_color_t; |
||
65 | typedef struct _cairo_color_stop cairo_color_stop_t; |
||
3959 | Serge | 66 | typedef struct _cairo_contour cairo_contour_t; |
67 | typedef struct _cairo_contour_chain cairo_contour_chain_t; |
||
68 | typedef struct _cairo_contour_iter cairo_contour_iter_t; |
||
69 | typedef struct _cairo_damage cairo_damage_t; |
||
1892 | serge | 70 | typedef struct _cairo_device_backend cairo_device_backend_t; |
71 | typedef struct _cairo_font_face_backend cairo_font_face_backend_t; |
||
72 | typedef struct _cairo_gstate cairo_gstate_t; |
||
3959 | Serge | 73 | typedef struct _cairo_gstate_backend cairo_gstate_backend_t; |
74 | typedef struct _cairo_glyph_text_info cairo_glyph_text_info_t; |
||
1892 | serge | 75 | typedef struct _cairo_hash_entry cairo_hash_entry_t; |
76 | typedef struct _cairo_hash_table cairo_hash_table_t; |
||
77 | typedef struct _cairo_image_surface cairo_image_surface_t; |
||
78 | typedef struct _cairo_mime_data cairo_mime_data_t; |
||
79 | typedef struct _cairo_observer cairo_observer_t; |
||
80 | typedef struct _cairo_output_stream cairo_output_stream_t; |
||
81 | typedef struct _cairo_paginated_surface_backend cairo_paginated_surface_backend_t; |
||
82 | typedef struct _cairo_path_fixed cairo_path_fixed_t; |
||
83 | typedef struct _cairo_rectangle_int16 cairo_glyph_size_t; |
||
84 | typedef struct _cairo_scaled_font_subsets cairo_scaled_font_subsets_t; |
||
85 | typedef struct _cairo_solid_pattern cairo_solid_pattern_t; |
||
3959 | Serge | 86 | typedef struct _cairo_surface_attributes cairo_surface_attributes_t; |
1892 | serge | 87 | typedef struct _cairo_surface_backend cairo_surface_backend_t; |
3959 | Serge | 88 | typedef struct _cairo_surface_observer cairo_surface_observer_t; |
1892 | serge | 89 | typedef struct _cairo_surface_snapshot cairo_surface_snapshot_t; |
90 | typedef struct _cairo_surface_subsurface cairo_surface_subsurface_t; |
||
91 | typedef struct _cairo_surface_wrapper cairo_surface_wrapper_t; |
||
3959 | Serge | 92 | typedef struct _cairo_traps cairo_traps_t; |
93 | typedef struct _cairo_tristrip cairo_tristrip_t; |
||
1892 | serge | 94 | typedef struct _cairo_unscaled_font_backend cairo_unscaled_font_backend_t; |
95 | typedef struct _cairo_xlib_screen_info cairo_xlib_screen_info_t; |
||
96 | |||
97 | typedef cairo_array_t cairo_user_data_array_t; |
||
98 | |||
3959 | Serge | 99 | typedef struct _cairo_scaled_font_private cairo_scaled_font_private_t; |
100 | typedef struct _cairo_scaled_font_backend cairo_scaled_font_backend_t; |
||
101 | typedef struct _cairo_scaled_glyph cairo_scaled_glyph_t; |
||
102 | typedef struct _cairo_scaled_glyph_private cairo_scaled_glyph_private_t; |
||
103 | |||
104 | typedef struct cairo_compositor cairo_compositor_t; |
||
105 | typedef struct cairo_fallback_compositor cairo_fallback_compositor_t; |
||
106 | typedef struct cairo_mask_compositor cairo_mask_compositor_t; |
||
107 | typedef struct cairo_traps_compositor cairo_traps_compositor_t; |
||
108 | typedef struct cairo_spans_compositor cairo_spans_compositor_t; |
||
109 | |||
1892 | serge | 110 | struct _cairo_observer { |
111 | cairo_list_t link; |
||
112 | void (*callback) (cairo_observer_t *self, void *arg); |
||
113 | }; |
||
114 | |||
115 | /** |
||
116 | * cairo_hash_entry_t: |
||
117 | * |
||
118 | * A #cairo_hash_entry_t contains both a key and a value for |
||
119 | * #cairo_hash_table_t. User-derived types for #cairo_hash_entry_t must |
||
120 | * be type-compatible with this structure (eg. they must have an |
||
121 | * unsigned long as the first parameter. The easiest way to get this |
||
122 | * is to use: |
||
123 | * |
||
124 | * typedef _my_entry { |
||
125 | * cairo_hash_entry_t base; |
||
126 | * ... Remainder of key and value fields here .. |
||
127 | * } my_entry_t; |
||
128 | * |
||
129 | * which then allows a pointer to my_entry_t to be passed to any of |
||
130 | * the #cairo_hash_table_t functions as follows without requiring a cast: |
||
131 | * |
||
132 | * _cairo_hash_table_insert (hash_table, &my_entry->base); |
||
133 | * |
||
3959 | Serge | 134 | * IMPORTANT: The caller is responsible for initializing |
1892 | serge | 135 | * my_entry->base.hash with a hash code derived from the key. The |
136 | * essential property of the hash code is that keys_equal must never |
||
137 | * return %TRUE for two keys that have different hashes. The best hash |
||
138 | * code will reduce the frequency of two keys with the same code for |
||
139 | * which keys_equal returns %FALSE. |
||
140 | * |
||
141 | * Which parts of the entry make up the "key" and which part make up |
||
142 | * the value are entirely up to the caller, (as determined by the |
||
143 | * computation going into base.hash as well as the keys_equal |
||
144 | * function). A few of the #cairo_hash_table_t functions accept an entry |
||
145 | * which will be used exclusively as a "key", (indicated by a |
||
146 | * parameter name of key). In these cases, the value-related fields of |
||
147 | * the entry need not be initialized if so desired. |
||
148 | **/ |
||
149 | struct _cairo_hash_entry { |
||
150 | unsigned long hash; |
||
151 | }; |
||
152 | |||
153 | struct _cairo_array { |
||
154 | unsigned int size; |
||
155 | unsigned int num_elements; |
||
156 | unsigned int element_size; |
||
3959 | Serge | 157 | char *elements; |
1892 | serge | 158 | }; |
159 | |||
160 | /** |
||
161 | * cairo_lcd_filter_t: |
||
162 | * @CAIRO_LCD_FILTER_DEFAULT: Use the default LCD filter for |
||
163 | * font backend and target device |
||
164 | * @CAIRO_LCD_FILTER_NONE: Do not perform LCD filtering |
||
165 | * @CAIRO_LCD_FILTER_INTRA_PIXEL: Intra-pixel filter |
||
166 | * @CAIRO_LCD_FILTER_FIR3: FIR filter with a 3x3 kernel |
||
167 | * @CAIRO_LCD_FILTER_FIR5: FIR filter with a 5x5 kernel |
||
168 | * |
||
169 | * The LCD filter specifies the low-pass filter applied to LCD-optimized |
||
170 | * bitmaps generated with an antialiasing mode of %CAIRO_ANTIALIAS_SUBPIXEL. |
||
171 | * |
||
172 | * Note: This API was temporarily made available in the public |
||
173 | * interface during the 1.7.x development series, but was made private |
||
174 | * before 1.8. |
||
175 | **/ |
||
176 | typedef enum _cairo_lcd_filter { |
||
177 | CAIRO_LCD_FILTER_DEFAULT, |
||
178 | CAIRO_LCD_FILTER_NONE, |
||
179 | CAIRO_LCD_FILTER_INTRA_PIXEL, |
||
180 | CAIRO_LCD_FILTER_FIR3, |
||
181 | CAIRO_LCD_FILTER_FIR5 |
||
182 | } cairo_lcd_filter_t; |
||
183 | |||
3959 | Serge | 184 | typedef enum _cairo_round_glyph_positions { |
185 | CAIRO_ROUND_GLYPH_POS_DEFAULT, |
||
186 | CAIRO_ROUND_GLYPH_POS_ON, |
||
187 | CAIRO_ROUND_GLYPH_POS_OFF |
||
188 | } cairo_round_glyph_positions_t; |
||
189 | |||
1892 | serge | 190 | struct _cairo_font_options { |
191 | cairo_antialias_t antialias; |
||
192 | cairo_subpixel_order_t subpixel_order; |
||
193 | cairo_lcd_filter_t lcd_filter; |
||
194 | cairo_hint_style_t hint_style; |
||
195 | cairo_hint_metrics_t hint_metrics; |
||
3959 | Serge | 196 | cairo_round_glyph_positions_t round_glyph_positions; |
1892 | serge | 197 | }; |
198 | |||
3959 | Serge | 199 | struct _cairo_glyph_text_info { |
200 | const char *utf8; |
||
201 | int utf8_len; |
||
202 | |||
203 | const cairo_text_cluster_t *clusters; |
||
204 | int num_clusters; |
||
205 | cairo_text_cluster_flags_t cluster_flags; |
||
206 | }; |
||
207 | |||
208 | |||
1892 | serge | 209 | /* XXX: Right now, the _cairo_color structure puts unpremultiplied |
210 | color in the doubles and premultiplied color in the shorts. Yes, |
||
211 | this is crazy insane, (but at least we don't export this |
||
212 | madness). I'm still working on a cleaner API, but in the meantime, |
||
213 | at least this does prevent precision loss in color when changing |
||
214 | alpha. */ |
||
215 | struct _cairo_color { |
||
216 | double red; |
||
217 | double green; |
||
218 | double blue; |
||
219 | double alpha; |
||
220 | |||
221 | unsigned short red_short; |
||
222 | unsigned short green_short; |
||
223 | unsigned short blue_short; |
||
224 | unsigned short alpha_short; |
||
225 | }; |
||
226 | |||
227 | struct _cairo_color_stop { |
||
228 | /* unpremultiplied */ |
||
229 | double red; |
||
230 | double green; |
||
231 | double blue; |
||
232 | double alpha; |
||
233 | |||
234 | /* unpremultipled, for convenience */ |
||
235 | uint16_t red_short; |
||
236 | uint16_t green_short; |
||
237 | uint16_t blue_short; |
||
238 | uint16_t alpha_short; |
||
239 | }; |
||
240 | |||
241 | typedef enum _cairo_paginated_mode { |
||
242 | CAIRO_PAGINATED_MODE_ANALYZE, /* analyze page regions */ |
||
243 | CAIRO_PAGINATED_MODE_RENDER, /* render page contents */ |
||
3959 | Serge | 244 | CAIRO_PAGINATED_MODE_FALLBACK /* paint fallback images */ |
1892 | serge | 245 | } cairo_paginated_mode_t; |
246 | |||
247 | typedef enum _cairo_internal_surface_type { |
||
248 | CAIRO_INTERNAL_SURFACE_TYPE_SNAPSHOT = 0x1000, |
||
249 | CAIRO_INTERNAL_SURFACE_TYPE_PAGINATED, |
||
250 | CAIRO_INTERNAL_SURFACE_TYPE_ANALYSIS, |
||
3959 | Serge | 251 | CAIRO_INTERNAL_SURFACE_TYPE_OBSERVER, |
1892 | serge | 252 | CAIRO_INTERNAL_SURFACE_TYPE_TEST_FALLBACK, |
253 | CAIRO_INTERNAL_SURFACE_TYPE_TEST_PAGINATED, |
||
254 | CAIRO_INTERNAL_SURFACE_TYPE_TEST_WRAPPING, |
||
255 | CAIRO_INTERNAL_SURFACE_TYPE_NULL, |
||
256 | CAIRO_INTERNAL_SURFACE_TYPE_TYPE3_GLYPH |
||
257 | } cairo_internal_surface_type_t; |
||
258 | |||
3959 | Serge | 259 | typedef enum _cairo_internal_device_type { |
260 | CAIRO_INTERNAL_DEVICE_TYPE_OBSERVER = 0x1000, |
||
261 | } cairo_device_surface_type_t; |
||
262 | |||
1892 | serge | 263 | #define CAIRO_HAS_TEST_PAGINATED_SURFACE 1 |
264 | |||
265 | typedef struct _cairo_slope { |
||
266 | cairo_fixed_t dx; |
||
267 | cairo_fixed_t dy; |
||
268 | } cairo_slope_t, cairo_distance_t; |
||
269 | |||
270 | typedef struct _cairo_point_double { |
||
271 | double x; |
||
272 | double y; |
||
273 | } cairo_point_double_t; |
||
274 | |||
3959 | Serge | 275 | typedef struct _cairo_circle_double { |
276 | cairo_point_double_t center; |
||
277 | double radius; |
||
278 | } cairo_circle_double_t; |
||
279 | |||
1892 | serge | 280 | typedef struct _cairo_distance_double { |
281 | double dx; |
||
282 | double dy; |
||
283 | } cairo_distance_double_t; |
||
284 | |||
3959 | Serge | 285 | typedef struct _cairo_box_double { |
286 | cairo_point_double_t p1; |
||
287 | cairo_point_double_t p2; |
||
288 | } cairo_box_double_t; |
||
289 | |||
1892 | serge | 290 | typedef struct _cairo_line { |
291 | cairo_point_t p1; |
||
292 | cairo_point_t p2; |
||
293 | } cairo_line_t, cairo_box_t; |
||
294 | |||
295 | typedef struct _cairo_trapezoid { |
||
296 | cairo_fixed_t top, bottom; |
||
297 | cairo_line_t left, right; |
||
298 | } cairo_trapezoid_t; |
||
299 | |||
300 | typedef struct _cairo_point_int { |
||
301 | int x, y; |
||
302 | } cairo_point_int_t; |
||
303 | |||
304 | #define CAIRO_RECT_INT_MIN (INT_MIN >> CAIRO_FIXED_FRAC_BITS) |
||
305 | #define CAIRO_RECT_INT_MAX (INT_MAX >> CAIRO_FIXED_FRAC_BITS) |
||
306 | |||
307 | typedef enum _cairo_direction { |
||
308 | CAIRO_DIRECTION_FORWARD, |
||
309 | CAIRO_DIRECTION_REVERSE |
||
310 | } cairo_direction_t; |
||
311 | |||
312 | typedef struct _cairo_edge { |
||
313 | cairo_line_t line; |
||
314 | int top, bottom; |
||
315 | int dir; |
||
316 | } cairo_edge_t; |
||
317 | |||
318 | typedef struct _cairo_polygon { |
||
319 | cairo_status_t status; |
||
320 | |||
321 | cairo_box_t extents; |
||
322 | cairo_box_t limit; |
||
323 | const cairo_box_t *limits; |
||
324 | int num_limits; |
||
325 | |||
326 | int num_edges; |
||
327 | int edges_size; |
||
328 | cairo_edge_t *edges; |
||
329 | cairo_edge_t edges_embedded[32]; |
||
330 | } cairo_polygon_t; |
||
331 | |||
332 | typedef cairo_warn cairo_status_t |
||
333 | (*cairo_spline_add_point_func_t) (void *closure, |
||
3959 | Serge | 334 | const cairo_point_t *point, |
335 | const cairo_slope_t *tangent); |
||
1892 | serge | 336 | |
337 | typedef struct _cairo_spline_knots { |
||
338 | cairo_point_t a, b, c, d; |
||
339 | } cairo_spline_knots_t; |
||
340 | |||
341 | typedef struct _cairo_spline { |
||
342 | cairo_spline_add_point_func_t add_point_func; |
||
343 | void *closure; |
||
344 | |||
345 | cairo_spline_knots_t knots; |
||
346 | |||
347 | cairo_slope_t initial_slope; |
||
348 | cairo_slope_t final_slope; |
||
349 | |||
350 | cairo_bool_t has_point; |
||
351 | cairo_point_t last_point; |
||
352 | } cairo_spline_t; |
||
353 | |||
354 | typedef struct _cairo_pen_vertex { |
||
355 | cairo_point_t point; |
||
356 | |||
357 | cairo_slope_t slope_ccw; |
||
358 | cairo_slope_t slope_cw; |
||
359 | } cairo_pen_vertex_t; |
||
360 | |||
361 | typedef struct _cairo_pen { |
||
362 | double radius; |
||
363 | double tolerance; |
||
364 | |||
365 | int num_vertices; |
||
366 | cairo_pen_vertex_t *vertices; |
||
367 | cairo_pen_vertex_t vertices_embedded[32]; |
||
368 | } cairo_pen_t; |
||
369 | |||
370 | typedef struct _cairo_stroke_style { |
||
371 | double line_width; |
||
372 | cairo_line_cap_t line_cap; |
||
373 | cairo_line_join_t line_join; |
||
374 | double miter_limit; |
||
375 | double *dash; |
||
376 | unsigned int num_dashes; |
||
377 | double dash_offset; |
||
378 | } cairo_stroke_style_t; |
||
379 | |||
380 | typedef struct _cairo_format_masks { |
||
381 | int bpp; |
||
382 | unsigned long alpha_mask; |
||
383 | unsigned long red_mask; |
||
384 | unsigned long green_mask; |
||
385 | unsigned long blue_mask; |
||
386 | } cairo_format_masks_t; |
||
387 | |||
388 | typedef enum { |
||
389 | CAIRO_STOCK_WHITE, |
||
390 | CAIRO_STOCK_BLACK, |
||
391 | CAIRO_STOCK_TRANSPARENT, |
||
392 | CAIRO_STOCK_NUM_COLORS, |
||
393 | } cairo_stock_t; |
||
394 | |||
395 | typedef enum _cairo_image_transparency { |
||
396 | CAIRO_IMAGE_IS_OPAQUE, |
||
397 | CAIRO_IMAGE_HAS_BILEVEL_ALPHA, |
||
398 | CAIRO_IMAGE_HAS_ALPHA, |
||
399 | CAIRO_IMAGE_UNKNOWN |
||
400 | } cairo_image_transparency_t; |
||
401 | |||
3959 | Serge | 402 | typedef enum _cairo_image_color { |
403 | CAIRO_IMAGE_IS_COLOR, |
||
404 | CAIRO_IMAGE_IS_GRAYSCALE, |
||
405 | CAIRO_IMAGE_IS_MONOCHROME, |
||
406 | CAIRO_IMAGE_UNKNOWN_COLOR |
||
407 | } cairo_image_color_t; |
||
408 | |||
409 | |||
1892 | serge | 410 | struct _cairo_mime_data { |
411 | cairo_reference_count_t ref_count; |
||
412 | unsigned char *data; |
||
413 | unsigned long length; |
||
414 | cairo_destroy_func_t destroy; |
||
415 | void *closure; |
||
416 | }; |
||
417 | |||
418 | /* |
||
419 | * A #cairo_unscaled_font_t is just an opaque handle we use in the |
||
420 | * glyph cache. |
||
421 | */ |
||
422 | typedef struct _cairo_unscaled_font { |
||
423 | cairo_hash_entry_t hash_entry; |
||
424 | cairo_reference_count_t ref_count; |
||
425 | const cairo_unscaled_font_backend_t *backend; |
||
426 | } cairo_unscaled_font_t; |
||
3959 | Serge | 427 | CAIRO_END_DECLS |
1892 | serge | 428 | |
429 | #endif /* CAIRO_TYPES_PRIVATE_H */ |