beta-0.89.2
[luatex.git] / source / libs / cairo / cairo-src / src / cairo-xlib-fallback-compositor.c
blobed2845db57db7827ddfb591a2baabd9404d45a5e
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
34 * California.
36 * Contributor(s):
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
43 #include "cairoint.h"
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;
59 static cairo_bool_t
60 unclipped (cairo_xlib_surface_t *xlib, cairo_clip_t *clip)
62 cairo_rectangle_int_t r;
64 r.x = r.y = 0;
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;
76 cairo_surface_t *shm;
77 cairo_bool_t overwrite;
79 TRACE ((stderr, "%s\n", __FUNCTION__));
81 overwrite =
82 extents->op <= CAIRO_OPERATOR_SOURCE && unclipped (xlib, extents->clip);
84 shm = _cairo_xlib_surface_get_shm (xlib, overwrite);
85 if (shm == NULL)
86 return CAIRO_INT_STATUS_UNSUPPORTED;
88 status = _cairo_compositor_paint (_get_compositor (shm), shm,
89 extents->op,
90 &extents->source_pattern.base,
91 extents->clip);
92 if (unlikely (status))
93 return status;
95 xlib->base.is_clear =
96 extents->op == CAIRO_OPERATOR_CLEAR && unclipped (xlib, extents->clip);
97 xlib->base.serial++;
98 xlib->fallback++;
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);
113 if (shm == NULL)
114 return CAIRO_INT_STATUS_UNSUPPORTED;
116 status = _cairo_compositor_mask (_get_compositor (shm), shm,
117 extents->op,
118 &extents->source_pattern.base,
119 &extents->mask_pattern.base,
120 extents->clip);
121 if (unlikely (status))
122 return status;
124 xlib->base.is_clear = FALSE;
125 xlib->base.serial++;
126 xlib->fallback++;
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,
137 double tolerance,
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);
147 if (shm == NULL)
148 return CAIRO_INT_STATUS_UNSUPPORTED;
150 status = _cairo_compositor_stroke (_get_compositor (shm), shm,
151 extents->op,
152 &extents->source_pattern.base,
153 path, style,
154 ctm, ctm_inverse,
155 tolerance,
156 antialias,
157 extents->clip);
158 if (unlikely (status))
159 return status;
161 xlib->base.is_clear = FALSE;
162 xlib->base.serial++;
163 xlib->fallback++;
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,
172 double tolerance,
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);
182 if (shm == NULL)
183 return CAIRO_INT_STATUS_UNSUPPORTED;
185 status = _cairo_compositor_fill (_get_compositor (shm), shm,
186 extents->op,
187 &extents->source_pattern.base,
188 path,
189 fill_rule, tolerance, antialias,
190 extents->clip);
191 if (unlikely (status))
192 return status;
194 xlib->base.is_clear = FALSE;
195 xlib->base.serial++;
196 xlib->fallback++;
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,
205 int num_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);
215 if (shm == NULL)
216 return CAIRO_INT_STATUS_UNSUPPORTED;
218 status = _cairo_compositor_glyphs (_get_compositor (shm), shm,
219 extents->op,
220 &extents->source_pattern.base,
221 glyphs, num_glyphs, scaled_font,
222 extents->clip);
223 if (unlikely (status))
224 return status;
226 xlib->base.is_clear = FALSE;
227 xlib->base.serial++;
228 xlib->fallback++;
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 */