1
/* cairo - a vector graphics library with display and print output
2
 *
3
 * Copyright © 2009 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
 * Contributor(s):
29
 *	Chris Wilson <chris@chris-wilson.co.uk>
30
 */
31

            
32
#include "cairoint.h"
33

            
34
#include "cairo-xcb-private.h"
35

            
36
#include <xcb/xcbext.h>
37

            
38
void
39
9
_cairo_xcb_connection_render_create_picture (cairo_xcb_connection_t  *connection,
40
					     xcb_render_picture_t     picture,
41
					     xcb_drawable_t           drawable,
42
					     xcb_render_pictformat_t  format,
43
					     uint32_t                 value_mask,
44
					     uint32_t	             *value_list)
45
{
46
9
    assert (connection->flags & CAIRO_XCB_HAS_RENDER);
47
9
    xcb_render_create_picture (connection->xcb_connection, picture, drawable,
48
			       format, value_mask, value_list);
49
9
}
50

            
51
void
52
_cairo_xcb_connection_render_change_picture (cairo_xcb_connection_t     *connection,
53
					     xcb_render_picture_t  picture,
54
					     uint32_t              value_mask,
55
					     uint32_t             *value_list)
56
{
57
    assert (connection->flags & CAIRO_XCB_HAS_RENDER);
58
    xcb_render_change_picture (connection->xcb_connection, picture,
59
			       value_mask, value_list);
60
}
61

            
62
void
63
_cairo_xcb_connection_render_set_picture_clip_rectangles (cairo_xcb_connection_t      *connection,
64
							  xcb_render_picture_t   picture,
65
							  int16_t                clip_x_origin,
66
							  int16_t                clip_y_origin,
67
							  uint32_t               rectangles_len,
68
							  xcb_rectangle_t *rectangles)
69
{
70
    assert (connection->flags & CAIRO_XCB_HAS_RENDER);
71
    xcb_render_set_picture_clip_rectangles (connection->xcb_connection, picture,
72
					    clip_x_origin, clip_y_origin,
73
					    rectangles_len, rectangles);
74
}
75

            
76
void
77
9
_cairo_xcb_connection_render_free_picture (cairo_xcb_connection_t *connection,
78
					   xcb_render_picture_t  picture)
79
{
80
9
    assert (connection->flags & CAIRO_XCB_HAS_RENDER);
81
9
    xcb_render_free_picture (connection->xcb_connection, picture);
82
9
}
83

            
84
void
85
3
_cairo_xcb_connection_render_composite (cairo_xcb_connection_t     *connection,
86
					uint8_t               op,
87
					xcb_render_picture_t  src,
88
					xcb_render_picture_t  mask,
89
					xcb_render_picture_t  dst,
90
					int16_t               src_x,
91
					int16_t               src_y,
92
					int16_t               mask_x,
93
					int16_t               mask_y,
94
					int16_t               dst_x,
95
					int16_t               dst_y,
96
					uint16_t              width,
97
					uint16_t              height)
98
{
99
3
    assert (connection->flags & CAIRO_XCB_RENDER_HAS_COMPOSITE);
100
3
    xcb_render_composite (connection->xcb_connection, op, src, mask, dst,
101
			  src_x, src_y, mask_x, mask_y, dst_x, dst_y, width, height);
102
3
}
103

            
104
void
105
_cairo_xcb_connection_render_trapezoids (cairo_xcb_connection_t *connection,
106
					 uint8_t                       op,
107
					 xcb_render_picture_t          src,
108
					 xcb_render_picture_t          dst,
109
					 xcb_render_pictformat_t       mask_format,
110
					 int16_t                       src_x,
111
					 int16_t                       src_y,
112
					 uint32_t                      traps_len,
113
					 xcb_render_trapezoid_t *traps)
114
{
115
    assert (connection->flags & CAIRO_XCB_RENDER_HAS_COMPOSITE_TRAPEZOIDS);
116
    xcb_render_trapezoids (connection->xcb_connection, op, src, dst,
117
			   mask_format, src_x, src_y, traps_len, traps);
118
}
119

            
120
void
121
_cairo_xcb_connection_render_create_glyph_set (cairo_xcb_connection_t	*connection,
122
					       xcb_render_glyphset_t	 id,
123
					       xcb_render_pictformat_t  format)
124
{
125
    assert (connection->flags & CAIRO_XCB_HAS_RENDER);
126
    xcb_render_create_glyph_set (connection->xcb_connection, id, format);
127
}
128

            
129
void
130
_cairo_xcb_connection_render_free_glyph_set (cairo_xcb_connection_t      *connection,
131
					     xcb_render_glyphset_t  glyphset)
132
{
133
    assert (connection->flags & CAIRO_XCB_HAS_RENDER);
134
    xcb_render_free_glyph_set (connection->xcb_connection, glyphset);
135
}
136

            
137
void
138
_cairo_xcb_connection_render_add_glyphs (cairo_xcb_connection_t             *connection,
139
					 xcb_render_glyphset_t         glyphset,
140
					 uint32_t                      num_glyphs,
141
					 uint32_t               *glyphs_id,
142
					 xcb_render_glyphinfo_t *glyphs,
143
					 uint32_t                      data_len,
144
					 uint8_t                *data)
145
{
146
    assert (connection->flags & CAIRO_XCB_HAS_RENDER);
147
    xcb_render_add_glyphs (connection->xcb_connection, glyphset, num_glyphs,
148
				   glyphs_id, glyphs, data_len, data);
149
}
150

            
151
void
152
_cairo_xcb_connection_render_free_glyphs (cairo_xcb_connection_t         *connection,
153
					  xcb_render_glyphset_t     glyphset,
154
					  uint32_t                  num_glyphs,
155
					  xcb_render_glyph_t *glyphs)
156
{
157
    assert (connection->flags & CAIRO_XCB_HAS_RENDER);
158
    xcb_render_free_glyphs (connection->xcb_connection, glyphset, num_glyphs, glyphs);
159
}
160

            
161
void
162
_cairo_xcb_connection_render_composite_glyphs_8 (cairo_xcb_connection_t        *connection,
163
						 uint8_t                  op,
164
						 xcb_render_picture_t     src,
165
						 xcb_render_picture_t     dst,
166
						 xcb_render_pictformat_t  mask_format,
167
						 xcb_render_glyphset_t    glyphset,
168
						 int16_t                  src_x,
169
						 int16_t                  src_y,
170
						 uint32_t                 glyphcmds_len,
171
						 uint8_t           *glyphcmds)
172
{
173
    assert (connection->flags & CAIRO_XCB_HAS_RENDER);
174
    xcb_render_composite_glyphs_8 (connection->xcb_connection, op, src, dst, mask_format,
175
				   glyphset, src_x, src_y, glyphcmds_len, glyphcmds);
176
}
177

            
178
void
179
_cairo_xcb_connection_render_composite_glyphs_16 (cairo_xcb_connection_t        *connection,
180
						  uint8_t                  op,
181
						  xcb_render_picture_t     src,
182
						  xcb_render_picture_t     dst,
183
						  xcb_render_pictformat_t  mask_format,
184
						  xcb_render_glyphset_t    glyphset,
185
						  int16_t                  src_x,
186
						  int16_t                  src_y,
187
						  uint32_t                 glyphcmds_len,
188
						  uint8_t           *glyphcmds)
189
{
190
    assert (connection->flags & CAIRO_XCB_HAS_RENDER);
191
    xcb_render_composite_glyphs_16 (connection->xcb_connection, op, src, dst, mask_format,
192
				    glyphset, src_x, src_y, glyphcmds_len, glyphcmds);
193
}
194

            
195
void
196
_cairo_xcb_connection_render_composite_glyphs_32 (cairo_xcb_connection_t        *connection,
197
						  uint8_t                  op,
198
						  xcb_render_picture_t     src,
199
						  xcb_render_picture_t     dst,
200
						  xcb_render_pictformat_t  mask_format,
201
						  xcb_render_glyphset_t    glyphset,
202
						  int16_t                  src_x,
203
						  int16_t                  src_y,
204
						  uint32_t                 glyphcmds_len,
205
						  uint8_t           *glyphcmds)
206
{
207
    assert (connection->flags & CAIRO_XCB_HAS_RENDER);
208
    xcb_render_composite_glyphs_32 (connection->xcb_connection, op, src, dst, mask_format,
209
				    glyphset, src_x, src_y, glyphcmds_len, glyphcmds);
210
}
211

            
212
void
213
30
_cairo_xcb_connection_render_fill_rectangles (cairo_xcb_connection_t      *connection,
214
					      uint8_t                op,
215
					      xcb_render_picture_t   dst,
216
					      xcb_render_color_t     color,
217
					      uint32_t               num_rects,
218
					      xcb_rectangle_t *rects)
219
{
220
30
    assert (connection->flags & CAIRO_XCB_RENDER_HAS_FILL_RECTANGLES);
221
30
    xcb_render_fill_rectangles (connection->xcb_connection, op, dst, color,
222
				num_rects, rects);
223
30
}
224

            
225
void
226
_cairo_xcb_connection_render_set_picture_transform (cairo_xcb_connection_t       *connection,
227
						    xcb_render_picture_t    picture,
228
						    xcb_render_transform_t  *transform)
229
{
230
    assert (connection->flags & CAIRO_XCB_RENDER_HAS_PICTURE_TRANSFORM);
231
    xcb_render_set_picture_transform (connection->xcb_connection, picture, *transform);
232
}
233

            
234
void
235
_cairo_xcb_connection_render_set_picture_filter (cairo_xcb_connection_t         *connection,
236
						 xcb_render_picture_t      picture,
237
						 uint16_t                  filter_len,
238
						 char               *filter)
239
{
240
    assert (connection->flags & CAIRO_XCB_RENDER_HAS_FILTERS);
241
    xcb_render_set_picture_filter (connection->xcb_connection, picture,
242
				   filter_len, filter, 0, NULL);
243
}
244

            
245
void
246
_cairo_xcb_connection_render_create_solid_fill (cairo_xcb_connection_t     *connection,
247
						xcb_render_picture_t  picture,
248
						xcb_render_color_t    color)
249
{
250
    assert (connection->flags & CAIRO_XCB_RENDER_HAS_GRADIENTS);
251
    xcb_render_create_solid_fill (connection->xcb_connection, picture, color);
252
}
253

            
254
void
255
_cairo_xcb_connection_render_create_linear_gradient (cairo_xcb_connection_t         *connection,
256
						     xcb_render_picture_t      picture,
257
						     xcb_render_pointfix_t     p1,
258
						     xcb_render_pointfix_t     p2,
259
						     uint32_t                  num_stops,
260
						     xcb_render_fixed_t *stops,
261
						     xcb_render_color_t *colors)
262
{
263
    assert (connection->flags & CAIRO_XCB_RENDER_HAS_GRADIENTS);
264
    xcb_render_create_linear_gradient (connection->xcb_connection, picture,
265
				       p1, p2, num_stops, stops, colors);
266
}
267

            
268
void
269
_cairo_xcb_connection_render_create_radial_gradient (cairo_xcb_connection_t         *connection,
270
						     xcb_render_picture_t      picture,
271
						     xcb_render_pointfix_t     inner,
272
						     xcb_render_pointfix_t     outer,
273
						     xcb_render_fixed_t        inner_radius,
274
						     xcb_render_fixed_t        outer_radius,
275
						     uint32_t                  num_stops,
276
						     xcb_render_fixed_t *stops,
277
						     xcb_render_color_t *colors)
278
{
279
    assert (connection->flags & CAIRO_XCB_RENDER_HAS_GRADIENTS);
280
    xcb_render_create_radial_gradient (connection->xcb_connection, picture,
281
				       inner, outer, inner_radius, outer_radius,
282
				       num_stops, stops, colors);
283
}
284

            
285
void
286
_cairo_xcb_connection_render_create_conical_gradient (cairo_xcb_connection_t         *connection,
287
						      xcb_render_picture_t      picture,
288
						      xcb_render_pointfix_t     center,
289
						      xcb_render_fixed_t        angle,
290
						      uint32_t                  num_stops,
291
						      xcb_render_fixed_t *stops,
292
						      xcb_render_color_t *colors)
293
{
294
    assert (connection->flags & CAIRO_XCB_RENDER_HAS_GRADIENTS);
295
    xcb_render_create_conical_gradient (connection->xcb_connection, picture,
296
				       center, angle, num_stops, stops, colors);
297
}