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 <cworth@redhat.com>
34
 */
35

            
36
#ifndef CAIRO_GSTATE_PRIVATE_H
37
#define CAIRO_GSTATE_PRIVATE_H
38

            
39
#include "cairo-clip-private.h"
40

            
41
struct _cairo_gstate {
42
    cairo_operator_t op;
43

            
44
    double opacity;
45
    double tolerance;
46
    cairo_antialias_t antialias;
47

            
48
    cairo_stroke_style_t stroke_style;
49

            
50
    cairo_fill_rule_t fill_rule;
51

            
52
    cairo_font_face_t *font_face;
53
    cairo_scaled_font_t *scaled_font;	/* Specific to the current CTM */
54
    cairo_scaled_font_t *previous_scaled_font;	/* holdover */
55
    cairo_matrix_t font_matrix;
56
    cairo_font_options_t font_options;
57

            
58
    cairo_clip_t *clip;
59

            
60
    cairo_surface_t *target;		/* The target to which all rendering is directed */
61
    cairo_surface_t *parent_target;	/* The previous target which was receiving rendering */
62
    cairo_surface_t *original_target;	/* The original target the initial gstate was created with */
63

            
64
    /* the user is allowed to update the device after we have cached the matrices... */
65
    cairo_observer_t device_transform_observer;
66

            
67
    cairo_matrix_t ctm;
68
    cairo_matrix_t ctm_inverse;
69
    cairo_matrix_t source_ctm_inverse; /* At the time ->source was set */
70
    cairo_bool_t is_identity;
71

            
72
    cairo_pattern_t *source;
73

            
74
    struct _cairo_gstate *next;
75
};
76

            
77
/* cairo-gstate.c */
78
cairo_private cairo_status_t
79
_cairo_gstate_init (cairo_gstate_t  *gstate,
80
		    cairo_surface_t *target);
81

            
82
cairo_private void
83
_cairo_gstate_fini (cairo_gstate_t *gstate);
84

            
85
cairo_private cairo_status_t
86
_cairo_gstate_save (cairo_gstate_t **gstate, cairo_gstate_t **freelist);
87

            
88
cairo_private cairo_status_t
89
_cairo_gstate_restore (cairo_gstate_t **gstate, cairo_gstate_t **freelist);
90

            
91
cairo_private cairo_bool_t
92
_cairo_gstate_is_group (cairo_gstate_t *gstate);
93

            
94
cairo_private cairo_status_t
95
_cairo_gstate_redirect_target (cairo_gstate_t *gstate, cairo_surface_t *child);
96

            
97
cairo_private cairo_surface_t *
98
_cairo_gstate_get_target (cairo_gstate_t *gstate);
99

            
100
cairo_private cairo_surface_t *
101
_cairo_gstate_get_original_target (cairo_gstate_t *gstate);
102

            
103
cairo_private cairo_clip_t *
104
_cairo_gstate_get_clip (cairo_gstate_t *gstate);
105

            
106
cairo_private cairo_status_t
107
_cairo_gstate_set_source (cairo_gstate_t *gstate, cairo_pattern_t *source);
108

            
109
cairo_private cairo_pattern_t *
110
_cairo_gstate_get_source (cairo_gstate_t *gstate);
111

            
112
cairo_private cairo_status_t
113
_cairo_gstate_set_operator (cairo_gstate_t *gstate, cairo_operator_t op);
114

            
115
cairo_private cairo_operator_t
116
_cairo_gstate_get_operator (cairo_gstate_t *gstate);
117

            
118
cairo_private cairo_status_t
119
_cairo_gstate_set_opacity (cairo_gstate_t *gstate, double opacity);
120

            
121
cairo_private double
122
_cairo_gstate_get_opacity (cairo_gstate_t *gstate);
123

            
124
cairo_private cairo_status_t
125
_cairo_gstate_set_tolerance (cairo_gstate_t *gstate, double tolerance);
126

            
127
cairo_private double
128
_cairo_gstate_get_tolerance (cairo_gstate_t *gstate);
129

            
130
cairo_private cairo_status_t
131
_cairo_gstate_set_fill_rule (cairo_gstate_t *gstate, cairo_fill_rule_t fill_rule);
132

            
133
cairo_private cairo_fill_rule_t
134
_cairo_gstate_get_fill_rule (cairo_gstate_t *gstate);
135

            
136
cairo_private cairo_status_t
137
_cairo_gstate_set_line_width (cairo_gstate_t *gstate, double width);
138

            
139
cairo_private double
140
_cairo_gstate_get_line_width (cairo_gstate_t *gstate);
141

            
142
cairo_private cairo_status_t
143
_cairo_gstate_set_hairline (cairo_gstate_t *gstate, cairo_bool_t set_hairline);
144

            
145
cairo_private cairo_bool_t
146
_cairo_gstate_get_hairline (cairo_gstate_t *gstate);
147

            
148
cairo_private cairo_status_t
149
_cairo_gstate_set_line_cap (cairo_gstate_t *gstate, cairo_line_cap_t line_cap);
150

            
151
cairo_private cairo_line_cap_t
152
_cairo_gstate_get_line_cap (cairo_gstate_t *gstate);
153

            
154
cairo_private cairo_status_t
155
_cairo_gstate_set_line_join (cairo_gstate_t *gstate, cairo_line_join_t line_join);
156

            
157
cairo_private cairo_line_join_t
158
_cairo_gstate_get_line_join (cairo_gstate_t *gstate);
159

            
160
cairo_private cairo_status_t
161
_cairo_gstate_set_dash (cairo_gstate_t *gstate, const double *dash, int num_dashes, double offset);
162

            
163
cairo_private void
164
_cairo_gstate_get_dash (cairo_gstate_t *gstate, double *dash, int *num_dashes, double *offset);
165

            
166
cairo_private cairo_status_t
167
_cairo_gstate_set_miter_limit (cairo_gstate_t *gstate, double limit);
168

            
169
cairo_private double
170
_cairo_gstate_get_miter_limit (cairo_gstate_t *gstate);
171

            
172
cairo_private void
173
_cairo_gstate_get_matrix (cairo_gstate_t *gstate, cairo_matrix_t *matrix);
174

            
175
cairo_private cairo_status_t
176
_cairo_gstate_translate (cairo_gstate_t *gstate, double tx, double ty);
177

            
178
cairo_private cairo_status_t
179
_cairo_gstate_scale (cairo_gstate_t *gstate, double sx, double sy);
180

            
181
cairo_private cairo_status_t
182
_cairo_gstate_rotate (cairo_gstate_t *gstate, double angle);
183

            
184
cairo_private cairo_status_t
185
_cairo_gstate_transform (cairo_gstate_t	      *gstate,
186
			 const cairo_matrix_t *matrix);
187

            
188
cairo_private cairo_status_t
189
_cairo_gstate_set_matrix (cairo_gstate_t       *gstate,
190
			  const cairo_matrix_t *matrix);
191

            
192
cairo_private void
193
_cairo_gstate_identity_matrix (cairo_gstate_t *gstate);
194

            
195
cairo_private void
196
_cairo_gstate_user_to_device (cairo_gstate_t *gstate, double *x, double *y);
197

            
198
cairo_private void
199
_cairo_gstate_user_to_device_distance (cairo_gstate_t *gstate, double *dx, double *dy);
200

            
201
cairo_private void
202
_cairo_gstate_device_to_user (cairo_gstate_t *gstate, double *x, double *y);
203

            
204
cairo_private void
205
_cairo_gstate_device_to_user_distance (cairo_gstate_t *gstate, double *dx, double *dy);
206

            
207
cairo_private void
208
_do_cairo_gstate_user_to_backend (cairo_gstate_t *gstate, double *x, double *y);
209

            
210
static inline void
211
30285726
_cairo_gstate_user_to_backend (cairo_gstate_t *gstate, double *x, double *y)
212
{
213
30285726
    if (! gstate->is_identity)
214
463893
	_do_cairo_gstate_user_to_backend (gstate, x, y);
215
30285726
}
216

            
217
cairo_private void
218
_do_cairo_gstate_user_to_backend_distance (cairo_gstate_t *gstate, double *x, double *y);
219

            
220
static inline void
221
81469182
_cairo_gstate_user_to_backend_distance (cairo_gstate_t *gstate, double *x, double *y)
222
{
223
81469182
    if (! gstate->is_identity)
224
597297
	_do_cairo_gstate_user_to_backend_distance (gstate, x, y);
225
81469182
}
226

            
227
cairo_private void
228
_do_cairo_gstate_backend_to_user (cairo_gstate_t *gstate, double *x, double *y);
229

            
230
static inline void
231
40014
_cairo_gstate_backend_to_user (cairo_gstate_t *gstate, double *x, double *y)
232
{
233
40014
    if (! gstate->is_identity)
234
5007
	_do_cairo_gstate_backend_to_user (gstate, x, y);
235
40014
}
236

            
237
cairo_private void
238
_do_cairo_gstate_backend_to_user_distance (cairo_gstate_t *gstate, double *x, double *y);
239

            
240
static inline void
241
_cairo_gstate_backend_to_user_distance (cairo_gstate_t *gstate, double *x, double *y)
242
{
243
    if (! gstate->is_identity)
244
	_do_cairo_gstate_backend_to_user_distance (gstate, x, y);
245
}
246

            
247
cairo_private void
248
_cairo_gstate_backend_to_user_rectangle (cairo_gstate_t *gstate,
249
                                         double *x1, double *y1,
250
                                         double *x2, double *y2,
251
                                         cairo_bool_t *is_tight);
252

            
253
cairo_private void
254
_cairo_gstate_path_extents (cairo_gstate_t     *gstate,
255
			    cairo_path_fixed_t *path,
256
			    double *x1, double *y1,
257
			    double *x2, double *y2);
258

            
259
cairo_private cairo_status_t
260
_cairo_gstate_paint (cairo_gstate_t *gstate);
261

            
262
cairo_private cairo_status_t
263
_cairo_gstate_mask (cairo_gstate_t  *gstate,
264
		    cairo_pattern_t *mask);
265

            
266
cairo_private cairo_status_t
267
_cairo_gstate_stroke (cairo_gstate_t *gstate, cairo_path_fixed_t *path);
268

            
269
cairo_private cairo_status_t
270
_cairo_gstate_fill (cairo_gstate_t *gstate, cairo_path_fixed_t *path);
271

            
272
cairo_private cairo_status_t
273
_cairo_gstate_copy_page (cairo_gstate_t *gstate);
274

            
275
cairo_private cairo_status_t
276
_cairo_gstate_show_page (cairo_gstate_t *gstate);
277

            
278
cairo_private cairo_status_t
279
_cairo_gstate_stroke_extents (cairo_gstate_t	 *gstate,
280
			      cairo_path_fixed_t *path,
281
                              double *x1, double *y1,
282
			      double *x2, double *y2);
283

            
284
cairo_private cairo_status_t
285
_cairo_gstate_fill_extents (cairo_gstate_t     *gstate,
286
			    cairo_path_fixed_t *path,
287
                            double *x1, double *y1,
288
			    double *x2, double *y2);
289

            
290
cairo_private cairo_status_t
291
_cairo_gstate_in_stroke (cairo_gstate_t	    *gstate,
292
			 cairo_path_fixed_t *path,
293
			 double		     x,
294
			 double		     y,
295
			 cairo_bool_t	    *inside_ret);
296

            
297
cairo_private cairo_bool_t
298
_cairo_gstate_in_fill (cairo_gstate_t	  *gstate,
299
		       cairo_path_fixed_t *path,
300
		       double		   x,
301
		       double		   y);
302

            
303
cairo_private cairo_bool_t
304
_cairo_gstate_in_clip (cairo_gstate_t	  *gstate,
305
		       double		   x,
306
		       double		   y);
307

            
308
cairo_private cairo_status_t
309
_cairo_gstate_clip (cairo_gstate_t *gstate, cairo_path_fixed_t *path);
310

            
311
cairo_private cairo_status_t
312
_cairo_gstate_reset_clip (cairo_gstate_t *gstate);
313

            
314
cairo_private cairo_bool_t
315
_cairo_gstate_clip_extents (cairo_gstate_t *gstate,
316
		            double         *x1,
317
		            double         *y1,
318
			    double         *x2,
319
			    double         *y2);
320

            
321
cairo_private cairo_rectangle_list_t*
322
_cairo_gstate_copy_clip_rectangle_list (cairo_gstate_t *gstate);
323

            
324
cairo_private cairo_status_t
325
_cairo_gstate_show_surface (cairo_gstate_t	*gstate,
326
			    cairo_surface_t	*surface,
327
			    double		 x,
328
			    double		 y,
329
			    double		width,
330
			    double		height);
331

            
332
cairo_private cairo_status_t
333
_cairo_gstate_tag_begin (cairo_gstate_t	*gstate,
334
			 const char     *tag_name,
335
			 const char     *attributes);
336

            
337
cairo_private cairo_status_t
338
_cairo_gstate_tag_end (cairo_gstate_t	*gstate,
339
		       const char       *tag_name);
340

            
341
cairo_private cairo_status_t
342
_cairo_gstate_set_font_size (cairo_gstate_t *gstate,
343
			     double          size);
344

            
345
cairo_private void
346
_cairo_gstate_get_font_matrix (cairo_gstate_t *gstate,
347
			       cairo_matrix_t *matrix);
348

            
349
cairo_private cairo_status_t
350
_cairo_gstate_set_font_matrix (cairo_gstate_t	    *gstate,
351
			       const cairo_matrix_t *matrix);
352

            
353
cairo_private void
354
_cairo_gstate_get_font_options (cairo_gstate_t       *gstate,
355
				cairo_font_options_t *options);
356

            
357
cairo_private void
358
_cairo_gstate_set_font_options (cairo_gstate_t	           *gstate,
359
				const cairo_font_options_t *options);
360

            
361
cairo_private cairo_status_t
362
_cairo_gstate_get_font_face (cairo_gstate_t     *gstate,
363
			     cairo_font_face_t **font_face);
364

            
365
cairo_private cairo_status_t
366
_cairo_gstate_get_scaled_font (cairo_gstate_t       *gstate,
367
			       cairo_scaled_font_t **scaled_font);
368

            
369
cairo_private cairo_status_t
370
_cairo_gstate_get_font_extents (cairo_gstate_t *gstate,
371
				cairo_font_extents_t *extents);
372

            
373
cairo_private cairo_status_t
374
_cairo_gstate_set_font_face (cairo_gstate_t    *gstate,
375
			     cairo_font_face_t *font_face);
376

            
377
cairo_private cairo_status_t
378
_cairo_gstate_glyph_extents (cairo_gstate_t *gstate,
379
			     const cairo_glyph_t *glyphs,
380
			     int num_glyphs,
381
			     cairo_text_extents_t *extents);
382

            
383
cairo_private cairo_status_t
384
_cairo_gstate_show_text_glyphs (cairo_gstate_t		   *gstate,
385
				const cairo_glyph_t	   *glyphs,
386
				int			    num_glyphs,
387
				cairo_glyph_text_info_t    *info);
388

            
389
cairo_private cairo_status_t
390
_cairo_gstate_glyph_path (cairo_gstate_t      *gstate,
391
			  const cairo_glyph_t *glyphs,
392
			  int		       num_glyphs,
393
			  cairo_path_fixed_t  *path);
394

            
395
cairo_private cairo_status_t
396
_cairo_gstate_set_antialias (cairo_gstate_t *gstate,
397
			     cairo_antialias_t antialias);
398

            
399
cairo_private cairo_antialias_t
400
_cairo_gstate_get_antialias (cairo_gstate_t *gstate);
401

            
402
#endif /* CAIRO_GSTATE_PRIVATE_H */