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
37 * Carl D. Worth <cworth@cworth.org>
38 * Joonas Pihlaja <jpihlaja@cc.helsinki.fi>
39 * Chris Wilson <chris@chris-wilson.co.uk>
44 #include "cairo-compositor-private.h"
45 #include "cairo-surface-offset-private.h"
47 /* high-level compositor interface */
49 static cairo_int_status_t
50 _cairo_fallback_compositor_paint (const cairo_compositor_t *_compositor,
51 cairo_composite_rectangles_t *extents)
53 cairo_surface_t *image;
54 cairo_int_status_t status;
56 TRACE ((stderr, "%s\n", __FUNCTION__));
57 image = cairo_surface_map_to_image (extents->surface, &extents->unbounded);
58 status = _cairo_surface_offset_paint (image,
62 &extents->source_pattern.base,
64 cairo_surface_unmap_image (extents->surface, image);
69 static cairo_int_status_t
70 _cairo_fallback_compositor_mask (const cairo_compositor_t *_compositor,
71 cairo_composite_rectangles_t *extents)
73 cairo_surface_t *image;
74 cairo_int_status_t status;
76 TRACE ((stderr, "%s\n", __FUNCTION__));
77 image = cairo_surface_map_to_image (extents->surface, &extents->unbounded);
78 status = _cairo_surface_offset_mask (image,
82 &extents->source_pattern.base,
83 &extents->mask_pattern.base,
85 cairo_surface_unmap_image (extents->surface, image);
90 static cairo_int_status_t
91 _cairo_fallback_compositor_stroke (const cairo_compositor_t *_compositor,
92 cairo_composite_rectangles_t *extents,
93 const cairo_path_fixed_t *path,
94 const cairo_stroke_style_t *style,
95 const cairo_matrix_t *ctm,
96 const cairo_matrix_t *ctm_inverse,
98 cairo_antialias_t antialias)
100 cairo_surface_t *image;
101 cairo_int_status_t status;
103 TRACE ((stderr, "%s\n", __FUNCTION__));
104 image = cairo_surface_map_to_image (extents->surface, &extents->unbounded);
105 status = _cairo_surface_offset_stroke (image,
106 extents->unbounded.x,
107 extents->unbounded.y,
109 &extents->source_pattern.base,
115 cairo_surface_unmap_image (extents->surface, image);
120 static cairo_int_status_t
121 _cairo_fallback_compositor_fill (const cairo_compositor_t *_compositor,
122 cairo_composite_rectangles_t *extents,
123 const cairo_path_fixed_t *path,
124 cairo_fill_rule_t fill_rule,
126 cairo_antialias_t antialias)
128 cairo_surface_t *image;
129 cairo_int_status_t status;
131 TRACE ((stderr, "%s\n", __FUNCTION__));
132 image = cairo_surface_map_to_image (extents->surface, &extents->unbounded);
133 status = _cairo_surface_offset_fill (image,
134 extents->unbounded.x,
135 extents->unbounded.y,
137 &extents->source_pattern.base,
139 fill_rule, tolerance, antialias,
141 cairo_surface_unmap_image (extents->surface, image);
146 static cairo_int_status_t
147 _cairo_fallback_compositor_glyphs (const cairo_compositor_t *_compositor,
148 cairo_composite_rectangles_t *extents,
149 cairo_scaled_font_t *scaled_font,
150 cairo_glyph_t *glyphs,
152 cairo_bool_t overlap)
154 cairo_surface_t *image;
155 cairo_int_status_t status;
157 TRACE ((stderr, "%s\n", __FUNCTION__));
158 image = cairo_surface_map_to_image (extents->surface, &extents->unbounded);
159 status = _cairo_surface_offset_glyphs (image,
160 extents->unbounded.x,
161 extents->unbounded.y,
163 &extents->source_pattern.base,
164 scaled_font, glyphs, num_glyphs,
166 cairo_surface_unmap_image (extents->surface, image);
171 const cairo_compositor_t _cairo_fallback_compositor = {
172 &__cairo_no_compositor,
174 _cairo_fallback_compositor_paint,
175 _cairo_fallback_compositor_mask,
176 _cairo_fallback_compositor_stroke,
177 _cairo_fallback_compositor_fill,
178 _cairo_fallback_compositor_glyphs,