1 /* -*- Mode: c; c-basic-offset: 4; indent-tabs-mode: t; tab-width: 8; -*- */
2 /* cairo - a vector graphics library with display and print output
4 * Copyright © 2002 University of Southern California
5 * Copyright © 2005 Red Hat, Inc.
6 * Copyright © 2011 Intel Corporation
8 * This library is free software; you can redistribute it and/or
9 * modify it either under the terms of the GNU Lesser General Public
10 * License version 2.1 as published by the Free Software Foundation
11 * (the "LGPL") or, at your option, under the terms of the Mozilla
12 * Public License Version 1.1 (the "MPL"). If you do not alter this
13 * notice, a recipient may use your version of this file under either
14 * the MPL or the LGPL.
16 * You should have received a copy of the LGPL along with this library
17 * in the file COPYING-LGPL-2.1; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
19 * You should have received a copy of the MPL along with this library
20 * in the file COPYING-MPL-1.1
22 * The contents of this file are subject to the Mozilla Public License
23 * Version 1.1 (the "License"); you may not use this file except in
24 * compliance with the License. You may obtain a copy of the License at
25 * http://www.mozilla.org/MPL/
27 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
28 * OF ANY KIND, either express or implied. See the LGPL or the MPL for
29 * the specific language governing rights and limitations.
31 * The Original Code is the cairo graphics library.
33 * The Initial Developer of the Original Code is University of Southern
37 * Carl D. Worth <cworth@cworth.org>
38 * Behdad Esfahbod <behdad@behdad.org>
39 * Chris Wilson <chris@chris-wilson.co.uk>
40 * Karl Tomlinson <karlt+@karlt.net>, Mozilla Corporation
45 #if !CAIRO_HAS_XLIB_XCB_FUNCTIONS
47 #include "cairo-xlib-private.h"
49 #include "cairo-compositor-private.h"
50 #include "cairo-image-surface-private.h"
51 #include "cairo-surface-offset-private.h"
53 static const cairo_compositor_t
*
54 _get_compositor (cairo_surface_t
*surface
)
56 return ((cairo_image_surface_t
*)surface
)->compositor
;
60 unclipped (cairo_xlib_surface_t
*xlib
, cairo_clip_t
*clip
)
62 cairo_rectangle_int_t r
;
65 r
.width
= xlib
->width
;
66 r
.height
= xlib
->height
;
67 return _cairo_clip_contains_rectangle (clip
, &r
);
70 static cairo_int_status_t
71 _cairo_xlib_shm_compositor_paint (const cairo_compositor_t
*_compositor
,
72 cairo_composite_rectangles_t
*extents
)
74 cairo_xlib_surface_t
*xlib
= (cairo_xlib_surface_t
*)extents
->surface
;
75 cairo_int_status_t status
;
77 cairo_bool_t overwrite
;
79 TRACE ((stderr
, "%s\n", __FUNCTION__
));
82 extents
->op
<= CAIRO_OPERATOR_SOURCE
&& unclipped (xlib
, extents
->clip
);
84 shm
= _cairo_xlib_surface_get_shm (xlib
, overwrite
);
86 return CAIRO_INT_STATUS_UNSUPPORTED
;
88 status
= _cairo_compositor_paint (_get_compositor (shm
), shm
,
90 &extents
->source_pattern
.base
,
92 if (unlikely (status
))
96 extents
->op
== CAIRO_OPERATOR_CLEAR
&& unclipped (xlib
, extents
->clip
);
99 return CAIRO_INT_STATUS_NOTHING_TO_DO
;
102 static cairo_int_status_t
103 _cairo_xlib_shm_compositor_mask (const cairo_compositor_t
*_compositor
,
104 cairo_composite_rectangles_t
*extents
)
106 cairo_xlib_surface_t
*xlib
= (cairo_xlib_surface_t
*)extents
->surface
;
107 cairo_int_status_t status
;
108 cairo_surface_t
*shm
;
110 TRACE ((stderr
, "%s\n", __FUNCTION__
));
112 shm
= _cairo_xlib_surface_get_shm (xlib
, FALSE
);
114 return CAIRO_INT_STATUS_UNSUPPORTED
;
116 status
= _cairo_compositor_mask (_get_compositor (shm
), shm
,
118 &extents
->source_pattern
.base
,
119 &extents
->mask_pattern
.base
,
121 if (unlikely (status
))
124 xlib
->base
.is_clear
= FALSE
;
127 return CAIRO_INT_STATUS_NOTHING_TO_DO
;
130 static cairo_int_status_t
131 _cairo_xlib_shm_compositor_stroke (const cairo_compositor_t
*_compositor
,
132 cairo_composite_rectangles_t
*extents
,
133 const cairo_path_fixed_t
*path
,
134 const cairo_stroke_style_t
*style
,
135 const cairo_matrix_t
*ctm
,
136 const cairo_matrix_t
*ctm_inverse
,
138 cairo_antialias_t antialias
)
140 cairo_xlib_surface_t
*xlib
= (cairo_xlib_surface_t
*)extents
->surface
;
141 cairo_int_status_t status
;
142 cairo_surface_t
*shm
;
144 TRACE ((stderr
, "%s\n", __FUNCTION__
));
146 shm
= _cairo_xlib_surface_get_shm (xlib
, FALSE
);
148 return CAIRO_INT_STATUS_UNSUPPORTED
;
150 status
= _cairo_compositor_stroke (_get_compositor (shm
), shm
,
152 &extents
->source_pattern
.base
,
158 if (unlikely (status
))
161 xlib
->base
.is_clear
= FALSE
;
164 return CAIRO_INT_STATUS_NOTHING_TO_DO
;
167 static cairo_int_status_t
168 _cairo_xlib_shm_compositor_fill (const cairo_compositor_t
*_compositor
,
169 cairo_composite_rectangles_t
*extents
,
170 const cairo_path_fixed_t
*path
,
171 cairo_fill_rule_t fill_rule
,
173 cairo_antialias_t antialias
)
175 cairo_xlib_surface_t
*xlib
= (cairo_xlib_surface_t
*)extents
->surface
;
176 cairo_int_status_t status
;
177 cairo_surface_t
*shm
;
179 TRACE ((stderr
, "%s\n", __FUNCTION__
));
181 shm
= _cairo_xlib_surface_get_shm (xlib
, FALSE
);
183 return CAIRO_INT_STATUS_UNSUPPORTED
;
185 status
= _cairo_compositor_fill (_get_compositor (shm
), shm
,
187 &extents
->source_pattern
.base
,
189 fill_rule
, tolerance
, antialias
,
191 if (unlikely (status
))
194 xlib
->base
.is_clear
= FALSE
;
197 return CAIRO_INT_STATUS_NOTHING_TO_DO
;
200 static cairo_int_status_t
201 _cairo_xlib_shm_compositor_glyphs (const cairo_compositor_t
*_compositor
,
202 cairo_composite_rectangles_t
*extents
,
203 cairo_scaled_font_t
*scaled_font
,
204 cairo_glyph_t
*glyphs
,
206 cairo_bool_t overlap
)
208 cairo_xlib_surface_t
*xlib
= (cairo_xlib_surface_t
*)extents
->surface
;
209 cairo_int_status_t status
;
210 cairo_surface_t
*shm
;
212 TRACE ((stderr
, "%s\n", __FUNCTION__
));
214 shm
= _cairo_xlib_surface_get_shm (xlib
, FALSE
);
216 return CAIRO_INT_STATUS_UNSUPPORTED
;
218 status
= _cairo_compositor_glyphs (_get_compositor (shm
), shm
,
220 &extents
->source_pattern
.base
,
221 glyphs
, num_glyphs
, scaled_font
,
223 if (unlikely (status
))
226 xlib
->base
.is_clear
= FALSE
;
229 return CAIRO_INT_STATUS_NOTHING_TO_DO
;
232 static const cairo_compositor_t _cairo_xlib_shm_compositor
= {
233 &_cairo_fallback_compositor
,
235 _cairo_xlib_shm_compositor_paint
,
236 _cairo_xlib_shm_compositor_mask
,
237 _cairo_xlib_shm_compositor_stroke
,
238 _cairo_xlib_shm_compositor_fill
,
239 _cairo_xlib_shm_compositor_glyphs
,
242 const cairo_compositor_t
*
243 _cairo_xlib_fallback_compositor_get (void)
245 return &_cairo_xlib_shm_compositor
;
248 #endif /* !CAIRO_HAS_XLIB_XCB_FUNCTIONS */