Subversion Repositories Scribus

Rev

Rev 14952 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
14952 fschmid 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
18122 mrdocs 17
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
14952 fschmid 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 <cworth@cworth.org>
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
 
47
typedef struct _cairo_array cairo_array_t;
48
typedef struct _cairo_backend cairo_backend_t;
49
typedef struct _cairo_cache cairo_cache_t;
50
typedef struct _cairo_clip cairo_clip_t;
51
typedef struct _cairo_clip_path cairo_clip_path_t;
52
typedef struct _cairo_color cairo_color_t;
53
typedef struct _cairo_font_face_backend     cairo_font_face_backend_t;
54
typedef struct _cairo_gstate cairo_gstate_t;
55
typedef struct _cairo_hash_entry cairo_hash_entry_t;
56
typedef struct _cairo_hash_table cairo_hash_table_t;
57
typedef struct _cairo_image_surface cairo_image_surface_t;
58
typedef struct _cairo_mime_data cairo_mime_data_t;
59
typedef struct _cairo_output_stream cairo_output_stream_t;
60
typedef struct _cairo_paginated_surface_backend cairo_paginated_surface_backend_t;
61
typedef struct _cairo_path_fixed cairo_path_fixed_t;
62
typedef struct _cairo_rectangle_int16 cairo_glyph_size_t;
63
typedef struct _cairo_scaled_font_backend   cairo_scaled_font_backend_t;
64
typedef struct _cairo_scaled_font_subsets cairo_scaled_font_subsets_t;
65
typedef struct _cairo_solid_pattern cairo_solid_pattern_t;
66
typedef struct _cairo_surface_backend cairo_surface_backend_t;
67
typedef struct _cairo_surface_wrapper cairo_surface_wrapper_t;
68
typedef struct _cairo_unscaled_font_backend cairo_unscaled_font_backend_t;
69
typedef struct _cairo_xlib_screen_info cairo_xlib_screen_info_t;
70
 
71
typedef cairo_array_t cairo_user_data_array_t;
72
 
73
/**
74
 * cairo_hash_entry_t:
75
 *
76
 * A #cairo_hash_entry_t contains both a key and a value for
77
 * #cairo_hash_table_t. User-derived types for #cairo_hash_entry_t must
78
 * be type-compatible with this structure (eg. they must have an
79
 * unsigned long as the first parameter. The easiest way to get this
80
 * is to use:
81
 *
82
 *      typedef _my_entry {
83
 *          cairo_hash_entry_t base;
84
 *          ... Remainder of key and value fields here ..
85
 *      } my_entry_t;
86
 *
87
 * which then allows a pointer to my_entry_t to be passed to any of
88
 * the #cairo_hash_table_t functions as follows without requiring a cast:
89
 *
90
 *      _cairo_hash_table_insert (hash_table, &my_entry->base);
91
 *
92
 * IMPORTANT: The caller is reponsible for initializing
93
 * my_entry->base.hash with a hash code derived from the key. The
94
 * essential property of the hash code is that keys_equal must never
95
 * return %TRUE for two keys that have different hashes. The best hash
96
 * code will reduce the frequency of two keys with the same code for
97
 * which keys_equal returns %FALSE.
98
 *
99
 * Which parts of the entry make up the "key" and which part make up
100
 * the value are entirely up to the caller, (as determined by the
101
 * computation going into base.hash as well as the keys_equal
102
 * function). A few of the #cairo_hash_table_t functions accept an entry
103
 * which will be used exclusively as a "key", (indicated by a
104
 * parameter name of key). In these cases, the value-related fields of
105
 * the entry need not be initialized if so desired.
106
 **/
107
struct _cairo_hash_entry {
108
    unsigned long hash;
109
};
110
 
111
struct _cairo_array {
112
    unsigned int size;
113
    unsigned int num_elements;
114
    unsigned int element_size;
115
    char **elements;
116
 
117
    cairo_bool_t is_snapshot;
118
};
119
 
120
struct _cairo_font_options {
121
    cairo_antialias_t antialias;
122
    cairo_subpixel_order_t subpixel_order;
123
    cairo_hint_style_t hint_style;
124
    cairo_hint_metrics_t hint_metrics;
125
};
126
 
127
/* XXX: Right now, the _cairo_color structure puts unpremultiplied
128
   color in the doubles and premultiplied color in the shorts. Yes,
129
   this is crazy insane, (but at least we don't export this
130
   madness). I'm still working on a cleaner API, but in the meantime,
131
   at least this does prevent precision loss in color when changing
132
   alpha. */
133
struct _cairo_color {
134
    double red;
135
    double green;
136
    double blue;
137
    double alpha;
138
 
139
    unsigned short red_short;
140
    unsigned short green_short;
141
    unsigned short blue_short;
142
    unsigned short alpha_short;
143
};
144
 
145
typedef enum _cairo_paginated_mode {
146
    CAIRO_PAGINATED_MODE_ANALYZE,       /* analyze page regions */
147
    CAIRO_PAGINATED_MODE_RENDER,        /* render page contents */
148
    CAIRO_PAGINATED_MODE_FALLBACK       /* paint fallback images */
149
} cairo_paginated_mode_t;
150
 
151
/* Sure wish C had a real enum type so that this would be distinct
152
 * from #cairo_status_t. Oh well, without that, I'll use this bogus 100
153
 * offset.  We want to keep it fit in int8_t as the compiler may choose
154
 * that for #cairo_status_t */
155
typedef enum _cairo_int_status {
156
    CAIRO_INT_STATUS_UNSUPPORTED = 100,
157
    CAIRO_INT_STATUS_DEGENERATE,
158
    CAIRO_INT_STATUS_NOTHING_TO_DO,
159
    CAIRO_INT_STATUS_FLATTEN_TRANSPARENCY,
160
    CAIRO_INT_STATUS_IMAGE_FALLBACK,
161
    CAIRO_INT_STATUS_ANALYZE_META_SURFACE_PATTERN,
162
 
163
    CAIRO_INT_STATUS_LAST_STATUS
164
} cairo_int_status_t;
165
 
166
typedef enum _cairo_internal_surface_type {
167
    CAIRO_INTERNAL_SURFACE_TYPE_PAGINATED = 0x1000,
168
    CAIRO_INTERNAL_SURFACE_TYPE_ANALYSIS,
169
    CAIRO_INTERNAL_SURFACE_TYPE_TEST_FALLBACK,
170
    CAIRO_INTERNAL_SURFACE_TYPE_TEST_PAGINATED,
171
    CAIRO_INTERNAL_SURFACE_TYPE_TEST_WRAPPING,
172
    CAIRO_INTERNAL_SURFACE_TYPE_NULL,
173
    CAIRO_INTERNAL_SURFACE_TYPE_TYPE3_GLYPH
174
} cairo_internal_surface_type_t;
175
 
176
#define CAIRO_HAS_TEST_PAGINATED_SURFACE 1
177
#define CAIRO_HAS_TEST_NULL_SURFACE 1
178
#define CAIRO_HAS_TEST_WRAPPING_SURFACE 1
179
 
180
typedef struct _cairo_slope {
181
    cairo_fixed_t dx;
182
    cairo_fixed_t dy;
183
} cairo_slope_t, cairo_distance_t;
184
 
185
typedef struct _cairo_point_double {
186
    double x;
187
    double y;
188
} cairo_point_double_t;
189
 
190
typedef struct _cairo_distance_double {
191
    double dx;
192
    double dy;
193
} cairo_distance_double_t;
194
 
195
typedef struct _cairo_line {
196
    cairo_point_t p1;
197
    cairo_point_t p2;
198
} cairo_line_t, cairo_box_t;
199
 
200
typedef struct _cairo_trapezoid {
201
    cairo_fixed_t top, bottom;
202
    cairo_line_t left, right;
203
} cairo_trapezoid_t;
204
 
205
typedef struct _cairo_point_int {
206
    int x, y;
207
} cairo_point_int_t;
208
 
209
#define CAIRO_RECT_INT_MIN (INT_MIN >> CAIRO_FIXED_FRAC_BITS)
210
#define CAIRO_RECT_INT_MAX (INT_MAX >> CAIRO_FIXED_FRAC_BITS)
211
 
212
/* Rectangles that take part in a composite operation.
213
 *
214
 * This defines four translations that define which pixels of the
215
 * source pattern, mask, clip and destination surface take part in a
216
 * general composite operation.  The idea is that the pixels at
217
 *
218
 *      (i,j)+(src.x, src.y) of the source,
219
 *      (i,j)+(mask.x, mask.y) of the mask,
220
 *      (i,j)+(clip.x, clip.y) of the clip and
221
 *      (i,j)+(dst.x, dst.y) of the destination
222
 *
223
 * all combine together to form the result at (i,j)+(dst.x,dst.y),
224
 * for i,j ranging in [0,width) and [0,height) respectively.
225
 */
226
typedef struct _cairo_composite_rectangles {
227
        cairo_point_int_t src;
228
        cairo_point_int_t mask;
229
        cairo_point_int_t clip;
230
        cairo_point_int_t dst;
231
        int width;
232
        int height;
233
} cairo_composite_rectangles_t;
234
 
235
typedef enum _cairo_direction {
236
    CAIRO_DIRECTION_FORWARD,
237
    CAIRO_DIRECTION_REVERSE
238
} cairo_direction_t;
239
 
240
typedef struct _cairo_edge {
241
    cairo_line_t line;
242
    int top, bottom;
243
    int dir;
244
} cairo_edge_t;
245
 
246
typedef struct _cairo_polygon {
247
    cairo_status_t status;
248
 
249
    cairo_point_t first_point;
250
    cairo_point_t last_point;
251
    cairo_point_t current_point;
252
    cairo_slope_t current_edge;
253
    cairo_bool_t has_current_point;
254
    cairo_bool_t has_current_edge;
255
 
256
    cairo_box_t extents;
257
    cairo_box_t limit;
258
    const cairo_box_t *limits;
259
    int num_limits;
260
 
261
    int num_edges;
262
    int edges_size;
263
    cairo_edge_t *edges;
264
    cairo_edge_t  edges_embedded[32];
265
} cairo_polygon_t;
266
 
267
typedef cairo_warn cairo_status_t
268
(*cairo_spline_add_point_func_t) (void *closure,
269
                                  const cairo_point_t *point);
270
 
271
typedef struct _cairo_spline_knots {
272
    cairo_point_t a, b, c, d;
273
} cairo_spline_knots_t;
274
 
275
typedef struct _cairo_spline {
276
    cairo_spline_add_point_func_t add_point_func;
277
    void *closure;
278
 
279
    cairo_spline_knots_t knots;
280
 
281
    cairo_slope_t initial_slope;
282
    cairo_slope_t final_slope;
283
 
284
    cairo_bool_t has_point;
285
    cairo_point_t last_point;
286
} cairo_spline_t;
287
 
288
typedef struct _cairo_pen_vertex {
289
    cairo_point_t point;
290
 
291
    cairo_slope_t slope_ccw;
292
    cairo_slope_t slope_cw;
293
} cairo_pen_vertex_t;
294
 
295
typedef struct _cairo_pen {
296
    double radius;
297
    double tolerance;
298
 
299
    int num_vertices;
300
    cairo_pen_vertex_t *vertices;
301
    cairo_pen_vertex_t  vertices_embedded[32];
302
} cairo_pen_t;
303
 
304
typedef struct _cairo_stroke_style {
305
    double               line_width;
306
    cairo_line_cap_t     line_cap;
307
    cairo_line_join_t    line_join;
308
    double               miter_limit;
309
    double              *dash;
310
    unsigned int         num_dashes;
311
    double               dash_offset;
312
} cairo_stroke_style_t;
313
 
314
typedef struct _cairo_format_masks {
315
    int bpp;
316
    unsigned long alpha_mask;
317
    unsigned long red_mask;
318
    unsigned long green_mask;
319
    unsigned long blue_mask;
320
} cairo_format_masks_t;
321
 
322
typedef enum {
323
    CAIRO_STOCK_WHITE,
324
    CAIRO_STOCK_BLACK,
325
    CAIRO_STOCK_TRANSPARENT
326
} cairo_stock_t;
327
 
328
typedef enum _cairo_image_transparency {
329
    CAIRO_IMAGE_IS_OPAQUE,
330
    CAIRO_IMAGE_HAS_BILEVEL_ALPHA,
331
    CAIRO_IMAGE_HAS_ALPHA,
332
    CAIRO_IMAGE_UNKNOWN
333
} cairo_image_transparency_t;
334
 
335
struct _cairo_mime_data {
336
    cairo_reference_count_t ref_count;
337
    unsigned char *data;
338
    unsigned int length;
339
    cairo_destroy_func_t destroy;
340
    void *closure;
341
};
342
 
343
#endif /* CAIRO_TYPES_PRIVATE_H */