ShaderEffect subclasses from Effect, not DependencyObject
[moon.git] / cairo / src / cairo-types-private.h
blob12e1a20e5c1d70709a1f99afc403ab1d5c744d75
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
4 * Copyright © 2002 University of Southern California
5 * Copyright © 2005 Red Hat, Inc.
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.
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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 * You should have received a copy of the MPL along with this library
19 * in the file COPYING-MPL-1.1
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/
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.
30 * The Original Code is the cairo graphics library.
32 * The Initial Developer of the Original Code is University of Southern
33 * California.
35 * Contributor(s):
36 * Carl D. Worth <cworth@cworth.org>
39 #ifndef CAIRO_TYPES_PRIVATE_H
40 #define CAIRO_TYPES_PRIVATE_H
42 #include "cairo.h"
43 #include "cairo-fixed-type-private.h"
45 typedef struct _cairo_array cairo_array_t;
46 typedef struct _cairo_cache cairo_cache_t;
47 typedef struct _cairo_clip cairo_clip_t;
48 typedef struct _cairo_clip_path cairo_clip_path_t;
49 typedef struct _cairo_color cairo_color_t;
50 typedef struct _cairo_font_face_backend cairo_font_face_backend_t;
51 typedef struct _cairo_gstate cairo_gstate_t;
52 typedef struct _cairo_hash_entry cairo_hash_entry_t;
53 typedef struct _cairo_hash_table cairo_hash_table_t;
54 typedef struct _cairo_image_surface cairo_image_surface_t;
55 typedef struct _cairo_output_stream cairo_output_stream_t;
56 typedef struct _cairo_paginated_surface_backend cairo_paginated_surface_backend_t;
57 typedef struct _cairo_path_fixed cairo_path_fixed_t;
58 typedef struct _cairo_rectangle_int16 cairo_glyph_size_t;
59 typedef struct _cairo_region cairo_region_t;
60 typedef struct _cairo_scaled_font_backend cairo_scaled_font_backend_t;
61 typedef struct _cairo_scaled_font_subsets cairo_scaled_font_subsets_t;
62 typedef struct _cairo_solid_pattern cairo_solid_pattern_t;
63 typedef struct _cairo_surface_backend cairo_surface_backend_t;
64 typedef struct _cairo_unscaled_font_backend cairo_unscaled_font_backend_t;
65 typedef struct _cairo_xlib_screen_info cairo_xlib_screen_info_t;
67 typedef cairo_array_t cairo_user_data_array_t;
69 /**
70 * cairo_hash_entry_t:
72 * A #cairo_hash_entry_t contains both a key and a value for
73 * #cairo_hash_table_t. User-derived types for #cairo_hash_entry_t must
74 * be type-compatible with this structure (eg. they must have an
75 * unsigned long as the first parameter. The easiest way to get this
76 * is to use:
78 * typedef _my_entry {
79 * cairo_hash_entry_t base;
80 * ... Remainder of key and value fields here ..
81 * } my_entry_t;
83 * which then allows a pointer to my_entry_t to be passed to any of
84 * the #cairo_hash_table_t functions as follows without requiring a cast:
86 * _cairo_hash_table_insert (hash_table, &my_entry->base);
88 * IMPORTANT: The caller is reponsible for initializing
89 * my_entry->base.hash with a hash code derived from the key. The
90 * essential property of the hash code is that keys_equal must never
91 * return %TRUE for two keys that have different hashes. The best hash
92 * code will reduce the frequency of two keys with the same code for
93 * which keys_equal returns %FALSE.
95 * Which parts of the entry make up the "key" and which part make up
96 * the value are entirely up to the caller, (as determined by the
97 * computation going into base.hash as well as the keys_equal
98 * function). A few of the #cairo_hash_table_t functions accept an entry
99 * which will be used exclusively as a "key", (indicated by a
100 * parameter name of key). In these cases, the value-related fields of
101 * the entry need not be initialized if so desired.
103 struct _cairo_hash_entry {
104 unsigned long hash;
107 struct _cairo_array {
108 unsigned int size;
109 unsigned int num_elements;
110 unsigned int element_size;
111 char **elements;
113 cairo_bool_t is_snapshot;
116 struct _cairo_font_options {
117 cairo_antialias_t antialias;
118 cairo_subpixel_order_t subpixel_order;
119 cairo_hint_style_t hint_style;
120 cairo_hint_metrics_t hint_metrics;
123 struct _cairo_cache {
124 cairo_hash_table_t *hash_table;
126 cairo_destroy_func_t entry_destroy;
128 unsigned long max_size;
129 unsigned long size;
131 int freeze_count;
134 /* XXX: Right now, the _cairo_color structure puts unpremultiplied
135 color in the doubles and premultiplied color in the shorts. Yes,
136 this is crazy insane, (but at least we don't export this
137 madness). I'm still working on a cleaner API, but in the meantime,
138 at least this does prevent precision loss in color when changing
139 alpha. */
140 struct _cairo_color {
141 double red;
142 double green;
143 double blue;
144 double alpha;
146 unsigned short red_short;
147 unsigned short green_short;
148 unsigned short blue_short;
149 unsigned short alpha_short;
152 typedef enum _cairo_paginated_mode {
153 CAIRO_PAGINATED_MODE_ANALYZE, /* analyze page regions */
154 CAIRO_PAGINATED_MODE_RENDER, /* render page contents */
155 CAIRO_PAGINATED_MODE_FALLBACK /* paint fallback images */
156 } cairo_paginated_mode_t;
158 /* Sure wish C had a real enum type so that this would be distinct
159 * from #cairo_status_t. Oh well, without that, I'll use this bogus 100
160 * offset. We want to keep it fit in int8_t as the compiler may choose
161 * that for #cairo_status_t */
162 typedef enum _cairo_int_status {
163 CAIRO_INT_STATUS_UNSUPPORTED = 100,
164 CAIRO_INT_STATUS_DEGENERATE,
165 CAIRO_INT_STATUS_NOTHING_TO_DO,
166 CAIRO_INT_STATUS_FLATTEN_TRANSPARENCY,
167 CAIRO_INT_STATUS_IMAGE_FALLBACK,
168 CAIRO_INT_STATUS_ANALYZE_META_SURFACE_PATTERN,
170 CAIRO_INT_STATUS_LAST_STATUS
171 } cairo_int_status_t;
173 typedef enum _cairo_internal_surface_type {
174 CAIRO_INTERNAL_SURFACE_TYPE_META = 0x1000,
175 CAIRO_INTERNAL_SURFACE_TYPE_PAGINATED,
176 CAIRO_INTERNAL_SURFACE_TYPE_ANALYSIS,
177 CAIRO_INTERNAL_SURFACE_TYPE_TEST_META,
178 CAIRO_INTERNAL_SURFACE_TYPE_TEST_FALLBACK,
179 CAIRO_INTERNAL_SURFACE_TYPE_TEST_PAGINATED,
180 CAIRO_INTERNAL_SURFACE_TYPE_NULL,
181 CAIRO_INTERNAL_SURFACE_TYPE_TYPE3_GLYPH
182 } cairo_internal_surface_type_t;
184 typedef struct _cairo_point {
185 cairo_fixed_t x;
186 cairo_fixed_t y;
187 } cairo_point_t;
189 typedef struct _cairo_slope
191 cairo_fixed_t dx;
192 cairo_fixed_t dy;
193 } cairo_slope_t, cairo_distance_t;
195 typedef struct _cairo_point_double {
196 double x;
197 double y;
198 } cairo_point_double_t;
200 typedef struct _cairo_distance_double {
201 double dx;
202 double dy;
203 } cairo_distance_double_t;
205 typedef struct _cairo_line {
206 cairo_point_t p1;
207 cairo_point_t p2;
208 } cairo_line_t, cairo_box_t;
210 typedef struct _cairo_trapezoid {
211 cairo_fixed_t top, bottom;
212 cairo_line_t left, right;
213 } cairo_trapezoid_t;
215 struct _cairo_rectangle_int16 {
216 int16_t x, y;
217 uint16_t width, height;
220 struct _cairo_rectangle_int32 {
221 int32_t x, y;
222 uint32_t width, height;
225 struct _cairo_point_int16 {
226 int16_t x, y;
229 struct _cairo_point_int32 {
230 int32_t x, y;
233 #if CAIRO_FIXED_BITS == 32 && CAIRO_FIXED_FRAC_BITS >= 16
234 typedef struct _cairo_rectangle_int16 cairo_rectangle_int_t;
235 typedef struct _cairo_point_int16 cairo_point_int_t;
236 #define CAIRO_RECT_INT_MIN (INT16_MIN >> (CAIRO_FIXED_FRAC_BITS - 16))
237 #define CAIRO_RECT_INT_MAX (INT16_MAX >> (CAIRO_FIXED_FRAC_BITS - 16))
238 #elif CAIRO_FIXED_BITS == 32
239 typedef struct _cairo_rectangle_int32 cairo_rectangle_int_t;
240 typedef struct _cairo_point_int32 cairo_point_int_t;
241 #define CAIRO_RECT_INT_MIN (INT32_MIN >> CAIRO_FIXED_FRAC_BITS)
242 #define CAIRO_RECT_INT_MAX (INT32_MAX >> CAIRO_FIXED_FRAC_BITS)
243 #else
244 #error Not sure how to pick a cairo_rectangle_int_t and cairo_point_int_t for your CAIRO_FIXED_BITS!
245 #endif
247 typedef struct _cairo_box_int {
248 cairo_point_int_t p1;
249 cairo_point_int_t p2;
250 } cairo_box_int_t;
252 typedef enum _cairo_direction {
253 CAIRO_DIRECTION_FORWARD,
254 CAIRO_DIRECTION_REVERSE
255 } cairo_direction_t;
257 typedef enum _cairo_clip_mode {
258 CAIRO_CLIP_MODE_PATH,
259 CAIRO_CLIP_MODE_REGION,
260 CAIRO_CLIP_MODE_MASK
261 } cairo_clip_mode_t;
263 typedef struct _cairo_edge {
264 cairo_line_t edge;
265 int clockWise;
267 cairo_fixed_t current_x;
268 } cairo_edge_t;
270 typedef struct _cairo_polygon {
271 cairo_status_t status;
273 cairo_point_t first_point;
274 cairo_point_t current_point;
275 cairo_bool_t has_current_point;
277 int num_edges;
278 int edges_size;
279 cairo_edge_t *edges;
280 cairo_edge_t edges_embedded[32];
281 } cairo_polygon_t;
283 typedef struct _cairo_spline_knots {
284 cairo_point_t a, b, c, d;
285 } cairo_spline_knots_t;
286 typedef struct _cairo_spline {
287 cairo_spline_knots_t knots;
289 cairo_slope_t initial_slope;
290 cairo_slope_t final_slope;
292 int num_points;
293 int points_size;
294 cairo_point_t *points;
295 cairo_point_t points_embedded[64];
296 } cairo_spline_t;
298 typedef struct _cairo_pen_vertex {
299 cairo_point_t point;
301 cairo_slope_t slope_ccw;
302 cairo_slope_t slope_cw;
303 } cairo_pen_vertex_t;
305 typedef struct _cairo_pen {
306 double radius;
307 double tolerance;
309 int num_vertices;
310 cairo_pen_vertex_t *vertices;
311 cairo_pen_vertex_t vertices_embedded[32];
312 } cairo_pen_t;
314 typedef struct _cairo_stroke_style {
315 double line_width;
316 cairo_line_cap_t line_cap;
317 cairo_line_join_t line_join;
318 double miter_limit;
319 double *dash;
320 unsigned int num_dashes;
321 double dash_offset;
322 } cairo_stroke_style_t;
324 typedef struct _cairo_format_masks {
325 int bpp;
326 unsigned long alpha_mask;
327 unsigned long red_mask;
328 unsigned long green_mask;
329 unsigned long blue_mask;
330 } cairo_format_masks_t;
332 typedef enum {
333 CAIRO_STOCK_WHITE,
334 CAIRO_STOCK_BLACK,
335 CAIRO_STOCK_TRANSPARENT
336 } cairo_stock_t;
338 typedef enum _cairo_image_transparency {
339 CAIRO_IMAGE_IS_OPAQUE,
340 CAIRO_IMAGE_HAS_BILEVEL_ALPHA,
341 CAIRO_IMAGE_HAS_ALPHA,
342 CAIRO_IMAGE_UNKNOWN
343 } cairo_image_transparency_t;
345 #endif /* CAIRO_TYPES_PRIVATE_H */