1 /* cairo - a vector graphics library with display and print output
3 * Copyright © 2002 University of Southern California
4 * Copyright © 2005 Red Hat, Inc.
6 * This library is free software; you can redistribute it and/or
7 * modify it either under the terms of the GNU Lesser General Public
8 * License version 2.1 as published by the Free Software Foundation
9 * (the "LGPL") or, at your option, under the terms of the Mozilla
10 * Public License Version 1.1 (the "MPL"). If you do not alter this
11 * notice, a recipient may use your version of this file under either
12 * the MPL or the LGPL.
14 * You should have received a copy of the LGPL along with this library
15 * in the file COPYING-LGPL-2.1; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 * You should have received a copy of the MPL along with this library
18 * in the file COPYING-MPL-1.1
20 * The contents of this file are subject to the Mozilla Public License
21 * Version 1.1 (the "License"); you may not use this file except in
22 * compliance with the License. You may obtain a copy of the License at
23 * http://www.mozilla.org/MPL/
25 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
26 * OF ANY KIND, either express or implied. See the LGPL or the MPL for
27 * the specific language governing rights and limitations.
29 * The Original Code is the cairo graphics library.
31 * The Initial Developer of the Original Code is University of Southern
35 * Carl D. Worth <cworth@cworth.org>
38 #ifndef CAIRO_IMAGE_SURFACE_PRIVATE_H
39 #define CAIRO_IMAGE_SURFACE_PRIVATE_H
41 #include "cairo-surface-private.h"
47 /* The canonical image backend */
48 struct _cairo_image_surface {
51 pixman_image_t *pixman_image;
52 const cairo_compositor_t *compositor;
54 /* Parenting is tricky wrt lifetime tracking...
56 * One use for tracking the parent of an image surface is for
57 * create_similar_image() where we wish to create a device specific
58 * surface but return an image surface to the user. In such a case,
59 * the image may be owned by the device specific surface, its parent,
60 * but the user lifetime tracking is then performed on the image. So
61 * when the image is then finalized we call cairo_surface_destroy()
62 * on the parent. However, for normal usage where the lifetime tracking
63 * is done on the parent surface, we need to be careful to unhook
64 * the image->parent pointer before finalizing the image.
66 cairo_surface_t *parent;
68 pixman_format_code_t pixman_format;
69 cairo_format_t format;
77 unsigned owns_data : 1;
78 unsigned transparency : 2;
80 unsigned shadow_cache_init : 1;
82 #define to_image_surface(S) ((cairo_image_surface_t *)(S))
84 /* A wrapper for holding pixman images returned by create_for_pattern */
85 typedef struct _cairo_image_source {
88 pixman_image_t *pixman_image;
89 unsigned is_opaque_solid : 1;
90 } cairo_image_source_t;
92 cairo_private extern const cairo_surface_backend_t _cairo_image_surface_backend;
93 cairo_private extern const cairo_surface_backend_t _cairo_image_source_backend;
95 cairo_private const cairo_compositor_t *
96 _cairo_image_mask_compositor_get (void);
98 cairo_private const cairo_compositor_t *
99 _cairo_image_traps_compositor_get (void);
101 cairo_private const cairo_compositor_t *
102 _cairo_image_spans_compositor_get (void);
104 #define _cairo_image_default_compositor_get _cairo_image_spans_compositor_get
106 cairo_private cairo_int_status_t
107 _cairo_image_surface_paint (void *abstract_surface,
109 const cairo_pattern_t *source,
110 const cairo_clip_t *clip);
112 cairo_private cairo_int_status_t
113 _cairo_image_surface_mask (void *abstract_surface,
115 const cairo_pattern_t *source,
116 const cairo_pattern_t *mask,
117 const cairo_clip_t *clip);
119 cairo_private cairo_int_status_t
120 _cairo_image_surface_stroke (void *abstract_surface,
122 const cairo_pattern_t *source,
123 const cairo_path_fixed_t *path,
124 const cairo_stroke_style_t *style,
125 const cairo_matrix_t *ctm,
126 const cairo_matrix_t *ctm_inverse,
128 cairo_antialias_t antialias,
129 const cairo_clip_t *clip);
131 cairo_private cairo_int_status_t
132 _cairo_image_surface_fill (void *abstract_surface,
134 const cairo_pattern_t *source,
135 const cairo_path_fixed_t *path,
136 cairo_fill_rule_t fill_rule,
138 cairo_antialias_t antialias,
139 const cairo_clip_t *clip);
141 cairo_private cairo_int_status_t
142 _cairo_image_surface_glyphs (void *abstract_surface,
144 const cairo_pattern_t *source,
145 cairo_glyph_t *glyphs,
147 cairo_scaled_font_t *scaled_font,
148 const cairo_clip_t *clip);
151 _cairo_image_surface_init (cairo_image_surface_t *surface,
152 pixman_image_t *pixman_image,
153 pixman_format_code_t pixman_format);
155 cairo_private cairo_surface_t *
156 _cairo_image_surface_create_similar (void *abstract_other,
157 cairo_content_t content,
161 cairo_private cairo_image_surface_t *
162 _cairo_image_surface_map_to_image (void *abstract_other,
163 const cairo_rectangle_int_t *extents);
165 cairo_private cairo_int_status_t
166 _cairo_image_surface_unmap_image (void *abstract_surface,
167 cairo_image_surface_t *image);
169 cairo_private cairo_surface_t *
170 _cairo_image_surface_source (void *abstract_surface,
171 cairo_rectangle_int_t *extents);
173 cairo_private cairo_status_t
174 _cairo_image_surface_acquire_source_image (void *abstract_surface,
175 cairo_image_surface_t **image_out,
179 _cairo_image_surface_release_source_image (void *abstract_surface,
180 cairo_image_surface_t *image,
183 cairo_private cairo_surface_t *
184 _cairo_image_surface_snapshot (void *abstract_surface);
186 cairo_private_no_warn cairo_bool_t
187 _cairo_image_surface_get_extents (void *abstract_surface,
188 cairo_rectangle_int_t *rectangle);
191 _cairo_image_surface_get_font_options (void *abstract_surface,
192 cairo_font_options_t *options);
194 cairo_private cairo_surface_t *
195 _cairo_image_source_create_for_pattern (cairo_surface_t *dst,
196 const cairo_pattern_t *pattern,
197 cairo_bool_t is_mask,
198 const cairo_rectangle_int_t *extents,
199 const cairo_rectangle_int_t *sample,
200 int *src_x, int *src_y);
202 cairo_private cairo_status_t
203 _cairo_image_surface_finish (void *abstract_surface);
205 cairo_private pixman_image_t *
206 _pixman_image_for_color (const cairo_color_t *cairo_color);
208 cairo_private pixman_image_t *
209 _pixman_image_for_pattern (cairo_image_surface_t *dst,
210 const cairo_pattern_t *pattern,
211 cairo_bool_t is_mask,
212 const cairo_rectangle_int_t *extents,
213 const cairo_rectangle_int_t *sample,
217 _pixman_image_add_traps (pixman_image_t *image,
218 int dst_x, int dst_y,
219 cairo_traps_t *traps);
222 _pixman_image_add_tristrip (pixman_image_t *image,
223 int dst_x, int dst_y,
224 cairo_tristrip_t *strip);
226 cairo_private cairo_image_surface_t *
227 _cairo_image_surface_clone_subimage (cairo_surface_t *surface,
228 const cairo_rectangle_int_t *extents);
230 /* Similar to clone; but allow format conversion */
231 cairo_private cairo_image_surface_t *
232 _cairo_image_surface_create_from_image (cairo_image_surface_t *other,
233 pixman_format_code_t format,
234 int x, int y, int width, int height,
239 #endif /* CAIRO_IMAGE_SURFACE_PRIVATE_H */