beta-0.89.2
[luatex.git] / source / libs / cairo / cairo-src / src / cairo-fallback-compositor.c
blob3f6199fe2bbdb4f26c335ec930f2dc4aece89b69
1 /* -*- Mode: c; tab-width: 8; c-basic-offset: 4; indent-tabs-mode: t; -*- */
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 * Joonas Pihlaja <jpihlaja@cc.helsinki.fi>
39 * Chris Wilson <chris@chris-wilson.co.uk>
42 #include "cairoint.h"
44 #include "cairo-compositor-private.h"
45 #include "cairo-image-surface-private.h"
46 #include "cairo-surface-offset-private.h"
48 /* high-level compositor interface */
50 static cairo_int_status_t
51 _cairo_fallback_compositor_paint (const cairo_compositor_t *_compositor,
52 cairo_composite_rectangles_t *extents)
54 cairo_image_surface_t *image;
55 cairo_int_status_t status;
57 TRACE ((stderr, "%s\n", __FUNCTION__));
59 image = _cairo_surface_map_to_image (extents->surface, &extents->unbounded);
61 status = _cairo_surface_offset_paint (&image->base,
62 extents->unbounded.x,
63 extents->unbounded.y,
64 extents->op,
65 &extents->source_pattern.base,
66 extents->clip);
68 return _cairo_surface_unmap_image (extents->surface, image);
71 static cairo_int_status_t
72 _cairo_fallback_compositor_mask (const cairo_compositor_t *_compositor,
73 cairo_composite_rectangles_t *extents)
75 cairo_image_surface_t *image;
76 cairo_int_status_t status;
78 TRACE ((stderr, "%s\n", __FUNCTION__));
80 image = _cairo_surface_map_to_image (extents->surface, &extents->unbounded);
82 status = _cairo_surface_offset_mask (&image->base,
83 extents->unbounded.x,
84 extents->unbounded.y,
85 extents->op,
86 &extents->source_pattern.base,
87 &extents->mask_pattern.base,
88 extents->clip);
90 return _cairo_surface_unmap_image (extents->surface, image);
93 static cairo_int_status_t
94 _cairo_fallback_compositor_stroke (const cairo_compositor_t *_compositor,
95 cairo_composite_rectangles_t *extents,
96 const cairo_path_fixed_t *path,
97 const cairo_stroke_style_t *style,
98 const cairo_matrix_t *ctm,
99 const cairo_matrix_t *ctm_inverse,
100 double tolerance,
101 cairo_antialias_t antialias)
103 cairo_image_surface_t *image;
104 cairo_int_status_t status;
106 TRACE ((stderr, "%s\n", __FUNCTION__));
108 image = _cairo_surface_map_to_image (extents->surface, &extents->unbounded);
110 status = _cairo_surface_offset_stroke (&image->base,
111 extents->unbounded.x,
112 extents->unbounded.y,
113 extents->op,
114 &extents->source_pattern.base,
115 path, style,
116 ctm, ctm_inverse,
117 tolerance,
118 antialias,
119 extents->clip);
121 return _cairo_surface_unmap_image (extents->surface, image);
124 static cairo_int_status_t
125 _cairo_fallback_compositor_fill (const cairo_compositor_t *_compositor,
126 cairo_composite_rectangles_t *extents,
127 const cairo_path_fixed_t *path,
128 cairo_fill_rule_t fill_rule,
129 double tolerance,
130 cairo_antialias_t antialias)
132 cairo_image_surface_t *image;
133 cairo_int_status_t status;
135 TRACE ((stderr, "%s\n", __FUNCTION__));
137 image = _cairo_surface_map_to_image (extents->surface, &extents->unbounded);
139 status = _cairo_surface_offset_fill (&image->base,
140 extents->unbounded.x,
141 extents->unbounded.y,
142 extents->op,
143 &extents->source_pattern.base,
144 path,
145 fill_rule, tolerance, antialias,
146 extents->clip);
148 return _cairo_surface_unmap_image (extents->surface, image);
151 static cairo_int_status_t
152 _cairo_fallback_compositor_glyphs (const cairo_compositor_t *_compositor,
153 cairo_composite_rectangles_t *extents,
154 cairo_scaled_font_t *scaled_font,
155 cairo_glyph_t *glyphs,
156 int num_glyphs,
157 cairo_bool_t overlap)
159 cairo_image_surface_t *image;
160 cairo_int_status_t status;
162 TRACE ((stderr, "%s\n", __FUNCTION__));
164 image = _cairo_surface_map_to_image (extents->surface, &extents->unbounded);
166 status = _cairo_surface_offset_glyphs (&image->base,
167 extents->unbounded.x,
168 extents->unbounded.y,
169 extents->op,
170 &extents->source_pattern.base,
171 scaled_font, glyphs, num_glyphs,
172 extents->clip);
174 return _cairo_surface_unmap_image (extents->surface, image);
177 const cairo_compositor_t _cairo_fallback_compositor = {
178 &__cairo_no_compositor,
180 _cairo_fallback_compositor_paint,
181 _cairo_fallback_compositor_mask,
182 _cairo_fallback_compositor_stroke,
183 _cairo_fallback_compositor_fill,
184 _cairo_fallback_compositor_glyphs,