3388c6493db66322986ee66b9b878322328d2754
[framework/graphics/cairo.git] / src / cairo-image-surface-private.h
1 /* cairo - a vector graphics library with display and print output
2  *
3  * Copyright © 2002 University of Southern California
4  * Copyright © 2005 Red Hat, Inc.
5  *
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.
13  *
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
19  *
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/
24  *
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.
28  *
29  * The Original Code is the cairo graphics library.
30  *
31  * The Initial Developer of the Original Code is University of Southern
32  * California.
33  *
34  * Contributor(s):
35  *      Carl D. Worth <cworth@cworth.org>
36  */
37
38 #ifndef CAIRO_IMAGE_SURFACE_PRIVATE_H
39 #define CAIRO_IMAGE_SURFACE_PRIVATE_H
40
41 #include "cairo-surface-private.h"
42
43 #include <pixman.h>
44
45 CAIRO_BEGIN_DECLS
46
47 /* The canonical image backend */
48 struct _cairo_image_surface {
49     cairo_surface_t base;
50
51     pixman_image_t *pixman_image;
52     const cairo_compositor_t *compositor;
53
54     /* Parenting is tricky wrt lifetime tracking...
55      *
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.
65      */
66     cairo_surface_t *parent;
67
68     pixman_format_code_t pixman_format;
69     cairo_format_t format;
70     unsigned char *data;
71
72     int width;
73     int height;
74     int stride;
75     int depth;
76
77     unsigned owns_data : 1;
78     unsigned transparency : 2;
79     unsigned color : 2;
80 };
81 #define to_image_surface(S) ((cairo_image_surface_t *)(S))
82
83 /* A wrapper for holding pixman images returned by create_for_pattern */
84 typedef struct _cairo_image_source {
85     cairo_surface_t base;
86
87     pixman_image_t *pixman_image;
88     unsigned is_opaque_solid : 1;
89 } cairo_image_source_t;
90
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;
93
94 cairo_private const cairo_compositor_t *
95 _cairo_image_mask_compositor_get (void);
96
97 cairo_private const cairo_compositor_t *
98 _cairo_image_traps_compositor_get (void);
99
100 cairo_private const cairo_compositor_t *
101 _cairo_image_spans_compositor_get (void);
102
103 #define _cairo_image_default_compositor_get _cairo_image_spans_compositor_get
104
105 cairo_private cairo_int_status_t
106 _cairo_image_surface_paint (void                        *abstract_surface,
107                             cairo_operator_t             op,
108                             const cairo_pattern_t       *source,
109                             const cairo_clip_t          *clip);
110
111 cairo_private cairo_int_status_t
112 _cairo_image_surface_mask (void                         *abstract_surface,
113                            cairo_operator_t              op,
114                            const cairo_pattern_t        *source,
115                            const cairo_pattern_t        *mask,
116                            const cairo_clip_t           *clip);
117
118 cairo_private cairo_int_status_t
119 _cairo_image_surface_stroke (void                       *abstract_surface,
120                              cairo_operator_t            op,
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,
126                              double                      tolerance,
127                              cairo_antialias_t           antialias,
128                              const cairo_clip_t         *clip);
129
130 cairo_private cairo_int_status_t
131 _cairo_image_surface_fill (void                         *abstract_surface,
132                            cairo_operator_t              op,
133                            const cairo_pattern_t        *source,
134                            const cairo_path_fixed_t     *path,
135                            cairo_fill_rule_t             fill_rule,
136                            double                        tolerance,
137                            cairo_antialias_t             antialias,
138                            const cairo_clip_t           *clip);
139
140 cairo_private cairo_int_status_t
141 _cairo_image_surface_glyphs (void                       *abstract_surface,
142                              cairo_operator_t            op,
143                              const cairo_pattern_t      *source,
144                              cairo_glyph_t              *glyphs,
145                              int                         num_glyphs,
146                              cairo_scaled_font_t        *scaled_font,
147                              const cairo_clip_t         *clip);
148
149 cairo_private void
150 _cairo_image_surface_init (cairo_image_surface_t *surface,
151                            pixman_image_t       *pixman_image,
152                            pixman_format_code_t  pixman_format);
153
154 cairo_private cairo_surface_t *
155 _cairo_image_surface_map_to_image (void *abstract_other,
156                                    const cairo_rectangle_int_t *extents);
157
158 cairo_private cairo_int_status_t
159 _cairo_image_surface_unmap_image (void *abstract_surface,
160                                   cairo_image_surface_t *image);
161
162 cairo_private cairo_surface_t *
163 _cairo_image_surface_source (void                       *abstract_surface,
164                              cairo_rectangle_int_t      *extents);
165
166 cairo_private cairo_status_t
167 _cairo_image_surface_acquire_source_image (void                    *abstract_surface,
168                                            cairo_image_surface_t  **image_out,
169                                            void                   **image_extra);
170
171 cairo_private void
172 _cairo_image_surface_release_source_image (void                   *abstract_surface,
173                                            cairo_image_surface_t  *image,
174                                            void                   *image_extra);
175
176 cairo_private cairo_surface_t *
177 _cairo_image_surface_snapshot (void *abstract_surface);
178
179 cairo_private_no_warn cairo_bool_t
180 _cairo_image_surface_get_extents (void                    *abstract_surface,
181                                   cairo_rectangle_int_t   *rectangle);
182
183 cairo_private void
184 _cairo_image_surface_get_font_options (void                  *abstract_surface,
185                                        cairo_font_options_t  *options);
186
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);
194
195 cairo_private cairo_status_t
196 _cairo_image_surface_finish (void *abstract_surface);
197
198 cairo_private pixman_image_t *
199 _pixman_image_for_color (const cairo_color_t *cairo_color);
200
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,
207                            int *tx, int *ty);
208
209 cairo_private void
210 _pixman_image_add_traps (pixman_image_t *image,
211                          int dst_x, int dst_y,
212                          cairo_traps_t *traps);
213
214 cairo_private void
215 _pixman_image_add_tristrip (pixman_image_t *image,
216                             int dst_x, int dst_y,
217                             cairo_tristrip_t *strip);
218
219 CAIRO_END_DECLS
220
221 #endif /* CAIRO_IMAGE_SURFACE_PRIVATE_H */