1 /* cairo - a vector graphics library with display and print output
3 * Copyright © 2005 Red Hat, Inc
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.
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
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/
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.
28 * The Original Code is the cairo graphics library.
30 * The Initial Developer of the Original Code is Red Hat, Inc.
33 * Kristian Høgsberg <krh@redhat.com>
34 * Adrian Johnson <ajohnson@redneon.com>
37 #ifndef CAIRO_RECORDING_SURFACE_H
38 #define CAIRO_RECORDING_SURFACE_H
41 #include "cairo-path-fixed-private.h"
42 #include "cairo-pattern-private.h"
43 #include "cairo-surface-backend-private.h"
46 /* The 5 basic drawing operations. */
51 CAIRO_COMMAND_SHOW_TEXT_GLYPHS
,
52 } cairo_command_type_t
;
55 CAIRO_RECORDING_REGION_ALL
,
56 CAIRO_RECORDING_REGION_NATIVE
,
57 CAIRO_RECORDING_REGION_IMAGE_FALLBACK
58 } cairo_recording_region_type_t
;
60 typedef struct _cairo_command_header
{
61 cairo_command_type_t type
;
62 cairo_recording_region_type_t region
;
64 cairo_rectangle_int_t extents
;
68 struct _cairo_command_header
*chain
;
69 } cairo_command_header_t
;
71 typedef struct _cairo_command_paint
{
72 cairo_command_header_t header
;
73 cairo_pattern_union_t source
;
74 } cairo_command_paint_t
;
76 typedef struct _cairo_command_mask
{
77 cairo_command_header_t header
;
78 cairo_pattern_union_t source
;
79 cairo_pattern_union_t mask
;
80 } cairo_command_mask_t
;
82 typedef struct _cairo_command_stroke
{
83 cairo_command_header_t header
;
84 cairo_pattern_union_t source
;
85 cairo_path_fixed_t path
;
86 cairo_stroke_style_t style
;
88 cairo_matrix_t ctm_inverse
;
90 cairo_antialias_t antialias
;
91 } cairo_command_stroke_t
;
93 typedef struct _cairo_command_fill
{
94 cairo_command_header_t header
;
95 cairo_pattern_union_t source
;
96 cairo_path_fixed_t path
;
97 cairo_fill_rule_t fill_rule
;
99 cairo_antialias_t antialias
;
100 } cairo_command_fill_t
;
102 typedef struct _cairo_command_show_text_glyphs
{
103 cairo_command_header_t header
;
104 cairo_pattern_union_t source
;
107 cairo_glyph_t
*glyphs
;
108 unsigned int num_glyphs
;
109 cairo_text_cluster_t
*clusters
;
111 cairo_text_cluster_flags_t cluster_flags
;
112 cairo_scaled_font_t
*scaled_font
;
113 } cairo_command_show_text_glyphs_t
;
115 typedef union _cairo_command
{
116 cairo_command_header_t header
;
118 cairo_command_paint_t paint
;
119 cairo_command_mask_t mask
;
120 cairo_command_stroke_t stroke
;
121 cairo_command_fill_t fill
;
122 cairo_command_show_text_glyphs_t show_text_glyphs
;
125 typedef struct _cairo_recording_surface
{
126 cairo_surface_t base
;
128 /* A recording-surface is logically unbounded, but when used as a
129 * source we need to render it to an image, so we need a size at
130 * which to create that image. */
131 cairo_rectangle_t extents_pixels
;
132 cairo_rectangle_int_t extents
;
133 cairo_bool_t unbounded
;
135 cairo_array_t commands
;
136 unsigned int *indices
;
137 unsigned int num_indices
;
138 cairo_bool_t optimize_clears
;
139 cairo_bool_t has_bilevel_alpha
;
140 cairo_bool_t has_only_op_over
;
144 struct bbtree
*left
, *right
;
145 cairo_command_header_t
*chain
;
147 } cairo_recording_surface_t
;
149 slim_hidden_proto (cairo_recording_surface_create
);
151 cairo_private cairo_int_status_t
152 _cairo_recording_surface_get_path (cairo_surface_t
*surface
,
153 cairo_path_fixed_t
*path
);
155 cairo_private cairo_status_t
156 _cairo_recording_surface_replay_one (cairo_recording_surface_t
*surface
,
158 cairo_surface_t
*target
);
160 cairo_private cairo_status_t
161 _cairo_recording_surface_replay (cairo_surface_t
*surface
,
162 cairo_surface_t
*target
);
164 cairo_private cairo_status_t
165 _cairo_recording_surface_replay_with_clip (cairo_surface_t
*surface
,
166 const cairo_matrix_t
*surface_transform
,
167 cairo_surface_t
*target
,
168 const cairo_clip_t
*target_clip
);
170 cairo_private cairo_status_t
171 _cairo_recording_surface_replay_and_create_regions (cairo_surface_t
*surface
,
172 cairo_surface_t
*target
);
173 cairo_private cairo_status_t
174 _cairo_recording_surface_replay_region (cairo_surface_t
*surface
,
175 const cairo_rectangle_int_t
*surface_extents
,
176 cairo_surface_t
*target
,
177 cairo_recording_region_type_t region
);
179 cairo_private cairo_status_t
180 _cairo_recording_surface_get_bbox (cairo_recording_surface_t
*recording
,
182 const cairo_matrix_t
*transform
);
184 cairo_private cairo_status_t
185 _cairo_recording_surface_get_ink_bbox (cairo_recording_surface_t
*surface
,
187 const cairo_matrix_t
*transform
);
189 cairo_private cairo_bool_t
190 _cairo_recording_surface_has_only_bilevel_alpha (cairo_recording_surface_t
*surface
);
192 cairo_private cairo_bool_t
193 _cairo_recording_surface_has_only_op_over (cairo_recording_surface_t
*surface
);
195 #endif /* CAIRO_RECORDING_SURFACE_H */