1
/* cairo - a vector graphics library with display and print output
2
 *
3
 * Copyright © 2010 Intel Corporation
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 Intel Corporation
31
 *
32
 * Contributor(s):
33
 *	Chris Wilson <chris@chris-wilson.co.uk>
34
 */
35

            
36
#ifndef CAIRO_BACKEND_PRIVATE_H
37
#define CAIRO_BACKEND_PRIVATE_H
38

            
39
#include "cairo-types-private.h"
40
#include "cairo-private.h"
41

            
42
typedef enum _cairo_backend_type {
43
    CAIRO_TYPE_DEFAULT,
44
    CAIRO_TYPE_SKIA,
45
} cairo_backend_type_t;
46

            
47
struct _cairo_backend {
48
    cairo_backend_type_t type;
49
    void (*destroy) (void *cr);
50

            
51
    cairo_surface_t *(*get_original_target) (void *cr);
52
    cairo_surface_t *(*get_current_target) (void *cr);
53

            
54
    cairo_status_t (*save) (void *cr);
55
    cairo_status_t (*restore) (void *cr);
56

            
57
    cairo_status_t (*push_group) (void *cr, cairo_content_t content);
58
    cairo_pattern_t *(*pop_group) (void *cr);
59

            
60
    cairo_status_t (*set_source_rgba) (void *cr, double red, double green, double blue, double alpha);
61
    cairo_status_t (*set_source_surface) (void *cr, cairo_surface_t *surface, double x, double y);
62
    cairo_status_t (*set_source) (void *cr, cairo_pattern_t *source);
63
    cairo_pattern_t *(*get_source) (void *cr);
64

            
65
    cairo_status_t (*set_antialias) (void *cr, cairo_antialias_t antialias);
66
    cairo_status_t (*set_dash) (void *cr, const double *dashes, int num_dashes, double offset);
67
    cairo_status_t (*set_fill_rule) (void *cr, cairo_fill_rule_t fill_rule);
68
    cairo_status_t (*set_line_cap) (void *cr, cairo_line_cap_t line_cap);
69
    cairo_status_t (*set_line_join) (void *cr, cairo_line_join_t line_join);
70
    cairo_status_t (*set_line_width) (void *cr, double line_width);
71
    cairo_status_t (*set_hairline) (void *cr, cairo_bool_t set_hairline);
72
    cairo_status_t (*set_miter_limit) (void *cr, double limit);
73
    cairo_status_t (*set_opacity) (void *cr, double opacity);
74
    cairo_status_t (*set_operator) (void *cr, cairo_operator_t op);
75
    cairo_status_t (*set_tolerance) (void *cr, double tolerance);
76

            
77
    cairo_antialias_t (*get_antialias) (void *cr);
78
    void (*get_dash) (void *cr, double *dashes, int *num_dashes, double *offset);
79
    cairo_fill_rule_t (*get_fill_rule) (void *cr);
80
    cairo_line_cap_t (*get_line_cap) (void *cr);
81
    cairo_line_join_t (*get_line_join) (void *cr);
82
    double (*get_line_width) (void *cr);
83
    cairo_bool_t (*get_hairline) (void *cr);
84
    double (*get_miter_limit) (void *cr);
85
    double (*get_opacity) (void *cr);
86
    cairo_operator_t (*get_operator) (void *cr);
87
    double (*get_tolerance) (void *cr);
88

            
89
    cairo_status_t (*translate) (void *cr, double tx, double ty);
90
    cairo_status_t (*scale) (void *cr, double sx, double sy);
91
    cairo_status_t (*rotate) (void *cr, double theta);
92
    cairo_status_t (*transform) (void *cr, const cairo_matrix_t *matrix);
93
    cairo_status_t (*set_matrix) (void *cr, const cairo_matrix_t *matrix);
94
    cairo_status_t (*set_identity_matrix) (void *cr);
95
    void (*get_matrix) (void *cr, cairo_matrix_t *matrix);
96

            
97
    void (*user_to_device) (void *cr, double *x, double *y);
98
    void (*user_to_device_distance) (void *cr, double *x, double *y);
99
    void (*device_to_user) (void *cr, double *x, double *y);
100
    void (*device_to_user_distance) (void *cr, double *x, double *y);
101

            
102
    void (*user_to_backend) (void *cr, double *x, double *y);
103
    void (*user_to_backend_distance) (void *cr, double *x, double *y);
104
    void (*backend_to_user) (void *cr, double *x, double *y);
105
    void (*backend_to_user_distance) (void *cr, double *x, double *y);
106

            
107
    cairo_status_t (*new_path) (void *cr);
108
    cairo_status_t (*new_sub_path) (void *cr);
109
    cairo_status_t (*move_to) (void *cr, double x, double y);
110
    cairo_status_t (*rel_move_to) (void *cr, double dx, double dy);
111
    cairo_status_t (*line_to) (void *cr, double x, double y);
112
    cairo_status_t (*rel_line_to) (void *cr, double dx, double dy);
113
    cairo_status_t (*curve_to) (void *cr, double x1, double y1, double x2, double y2, double x3, double y3);
114
    cairo_status_t (*rel_curve_to) (void *cr, double dx1, double dy1, double dx2, double dy2, double dx3, double dy3);
115
    cairo_status_t (*arc_to) (void *cr, double x1, double y1, double x2, double y2, double radius);
116
    cairo_status_t (*rel_arc_to) (void *cr, double dx1, double dy1, double dx2, double dy2, double radius);
117
    cairo_status_t (*close_path) (void *cr);
118

            
119
    cairo_status_t (*arc) (void *cr, double xc, double yc, double radius, double angle1, double angle2, cairo_bool_t forward);
120
    cairo_status_t (*rectangle) (void *cr, double x, double y, double width, double height);
121

            
122
    void (*path_extents) (void *cr, double *x1, double *y1, double *x2, double *y2);
123
    cairo_bool_t (*has_current_point) (void *cr);
124
    cairo_bool_t (*get_current_point) (void *cr, double *x, double *y);
125

            
126
    cairo_path_t *(*copy_path) (void *cr);
127
    cairo_path_t *(*copy_path_flat) (void *cr);
128
    cairo_status_t (*append_path) (void *cr, const cairo_path_t *path);
129

            
130
    cairo_status_t (*stroke_to_path) (void *cr);
131

            
132
    cairo_status_t (*clip) (void *cr);
133
    cairo_status_t (*clip_preserve) (void *cr);
134
    cairo_status_t (*in_clip) (void *cr, double x, double y, cairo_bool_t *inside);
135
    cairo_status_t (*clip_extents) (void *cr, double *x1, double *y1, double *x2, double *y2);
136
    cairo_status_t (*reset_clip) (void *cr);
137
    cairo_rectangle_list_t *(*clip_copy_rectangle_list) (void *cr);
138

            
139
    cairo_status_t (*paint) (void *cr);
140
    cairo_status_t (*paint_with_alpha) (void *cr, double opacity);
141
    cairo_status_t (*mask) (void *cr, cairo_pattern_t *pattern);
142

            
143
    cairo_status_t (*stroke) (void *cr);
144
    cairo_status_t (*stroke_preserve) (void *cr);
145
    cairo_status_t (*in_stroke) (void *cr, double x, double y, cairo_bool_t *inside);
146
    cairo_status_t (*stroke_extents) (void *cr, double *x1, double *y1, double *x2, double *y2);
147

            
148
    cairo_status_t (*fill) (void *cr);
149
    cairo_status_t (*fill_preserve) (void *cr);
150
    cairo_status_t (*in_fill) (void *cr, double x, double y, cairo_bool_t *inside);
151
    cairo_status_t (*fill_extents) (void *cr, double *x1, double *y1, double *x2, double *y2);
152

            
153
    cairo_status_t (*set_font_face) (void *cr, cairo_font_face_t *font_face);
154
    cairo_font_face_t *(*get_font_face) (void *cr);
155
    cairo_status_t (*set_font_size) (void *cr, double size);
156
    cairo_status_t (*set_font_matrix) (void *cr, const cairo_matrix_t *matrix);
157
    void (*get_font_matrix) (void *cr, cairo_matrix_t *matrix);
158
    cairo_status_t (*set_font_options) (void *cr, const cairo_font_options_t *options);
159
    void (*get_font_options) (void *cr, cairo_font_options_t *options);
160
    cairo_status_t (*set_scaled_font) (void *cr, cairo_scaled_font_t *scaled_font);
161
    cairo_scaled_font_t *(*get_scaled_font) (void *cr);
162
    cairo_status_t (*font_extents) (void *cr, cairo_font_extents_t *extents);
163

            
164
    cairo_status_t (*glyphs) (void *cr,
165
			      const cairo_glyph_t *glyphs, int num_glyphs,
166
			      cairo_glyph_text_info_t *info);
167
    cairo_status_t (*glyph_path) (void *cr,
168
				  const cairo_glyph_t *glyphs, int num_glyphs);
169

            
170
    cairo_status_t (*glyph_extents) (void *cr,
171
				     const cairo_glyph_t *glyphs,
172
				     int num_glyphs,
173
				     cairo_text_extents_t *extents);
174

            
175
    cairo_status_t (*copy_page) (void *cr);
176
    cairo_status_t (*show_page) (void *cr);
177

            
178
    cairo_status_t (*tag_begin) (void *cr, const char *tag_name, const char *attributes);
179
    cairo_status_t (*tag_end) (void *cr, const char *tag_name);
180
};
181

            
182
static inline void
183
4266
_cairo_backend_to_user (cairo_t *cr, double *x, double *y)
184
{
185
4266
    cr->backend->backend_to_user (cr, x, y);
186
4266
}
187

            
188
static inline void
189
_cairo_backend_to_user_distance (cairo_t *cr, double *x, double *y)
190
{
191
    cr->backend->backend_to_user_distance (cr, x, y);
192
}
193

            
194
static inline void
195
_cairo_user_to_backend (cairo_t *cr, double *x, double *y)
196
{
197
    cr->backend->user_to_backend (cr, x, y);
198
}
199

            
200
static inline void
201
_cairo_user_to_backend_distance (cairo_t *cr, double *x, double *y)
202
{
203
    cr->backend->user_to_backend_distance (cr, x, y);
204
}
205

            
206
#endif /* CAIRO_BACKEND_PRIVATE_H */