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;
81 #define to_image_surface(S) ((cairo_image_surface_t *)(S))
83 /* A wrapper for holding pixman images returned by create_for_pattern */
84 typedef struct _cairo_image_source {
87 pixman_image_t *pixman_image;
88 unsigned is_opaque_solid : 1;
89 } cairo_image_source_t;
91 cairo_private extern const cairo_surface_backend_t _cairo_image_surface_backend;
92 cairo_private extern const cairo_surface_backend_t _cairo_image_source_backend;
94 cairo_private const cairo_compositor_t *
95 _cairo_image_mask_compositor_get (void);
97 cairo_private const cairo_compositor_t *
98 _cairo_image_traps_compositor_get (void);
100 cairo_private const cairo_compositor_t *
101 _cairo_image_spans_compositor_get (void);
103 #define _cairo_image_default_compositor_get _cairo_image_spans_compositor_get
105 cairo_private cairo_int_status_t
106 _cairo_image_surface_paint (void *abstract_surface,
108 const cairo_pattern_t *source,
109 const cairo_clip_t *clip);
111 cairo_private cairo_int_status_t
112 _cairo_image_surface_mask (void *abstract_surface,
114 const cairo_pattern_t *source,
115 const cairo_pattern_t *mask,
116 const cairo_clip_t *clip);
118 cairo_private cairo_int_status_t
119 _cairo_image_surface_stroke (void *abstract_surface,
121 const cairo_pattern_t *source,
122 const cairo_path_fixed_t *path,
123 const cairo_stroke_style_t *style,
124 const cairo_matrix_t *ctm,
125 const cairo_matrix_t *ctm_inverse,
127 cairo_antialias_t antialias,
128 const cairo_clip_t *clip);
130 cairo_private cairo_int_status_t
131 _cairo_image_surface_fill (void *abstract_surface,
133 const cairo_pattern_t *source,
134 const cairo_path_fixed_t *path,
135 cairo_fill_rule_t fill_rule,
137 cairo_antialias_t antialias,
138 const cairo_clip_t *clip);
140 cairo_private cairo_int_status_t
141 _cairo_image_surface_glyphs (void *abstract_surface,
143 const cairo_pattern_t *source,
144 cairo_glyph_t *glyphs,
146 cairo_scaled_font_t *scaled_font,
147 const cairo_clip_t *clip);
150 _cairo_image_surface_init (cairo_image_surface_t *surface,
151 pixman_image_t *pixman_image,
152 pixman_format_code_t pixman_format);
154 cairo_private cairo_surface_t *
155 _cairo_image_surface_map_to_image (void *abstract_other,
156 const cairo_rectangle_int_t *extents);
158 cairo_private cairo_int_status_t
159 _cairo_image_surface_unmap_image (void *abstract_surface,
160 cairo_image_surface_t *image);
162 cairo_private cairo_surface_t *
163 _cairo_image_surface_source (void *abstract_surface,
164 cairo_rectangle_int_t *extents);
166 cairo_private cairo_status_t
167 _cairo_image_surface_acquire_source_image (void *abstract_surface,
168 cairo_image_surface_t **image_out,
172 _cairo_image_surface_release_source_image (void *abstract_surface,
173 cairo_image_surface_t *image,
176 cairo_private cairo_surface_t *
177 _cairo_image_surface_snapshot (void *abstract_surface);
179 cairo_private_no_warn cairo_bool_t
180 _cairo_image_surface_get_extents (void *abstract_surface,
181 cairo_rectangle_int_t *rectangle);
184 _cairo_image_surface_get_font_options (void *abstract_surface,
185 cairo_font_options_t *options);
187 cairo_private cairo_surface_t *
188 _cairo_image_source_create_for_pattern (cairo_surface_t *dst,
189 const cairo_pattern_t *pattern,
190 cairo_bool_t is_mask,
191 const cairo_rectangle_int_t *extents,
192 const cairo_rectangle_int_t *sample,
193 int *src_x, int *src_y);
195 cairo_private cairo_status_t
196 _cairo_image_surface_finish (void *abstract_surface);
198 cairo_private pixman_image_t *
199 _pixman_image_for_color (const cairo_color_t *cairo_color);
201 cairo_private pixman_image_t *
202 _pixman_image_for_pattern (cairo_image_surface_t *dst,
203 const cairo_pattern_t *pattern,
204 cairo_bool_t is_mask,
205 const cairo_rectangle_int_t *extents,
206 const cairo_rectangle_int_t *sample,
210 _pixman_image_add_traps (pixman_image_t *image,
211 int dst_x, int dst_y,
212 cairo_traps_t *traps);
215 _pixman_image_add_tristrip (pixman_image_t *image,
216 int dst_x, int dst_y,
217 cairo_tristrip_t *strip);
221 #endif /* CAIRO_IMAGE_SURFACE_PRIVATE_H */