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
3
 *
4
 * Copyright © 2002 University of Southern California
5
 * Copyright © 2005 Red Hat, Inc.
6
 * Copyright © 2011 Intel Corporation
7
 *
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.
15
 *
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
21
 *
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/
26
 *
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.
30
 *
31
 * The Original Code is the cairo graphics library.
32
 *
33
 * The Initial Developer of the Original Code is University of Southern
34
 * California.
35
 *
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>
40
 */
41

            
42
#include "cairoint.h"
43

            
44
#include "cairo-compositor-private.h"
45
#include "cairo-image-surface-private.h"
46
#include "cairo-surface-offset-private.h"
47

            
48
/* high-level compositor interface */
49

            
50
static cairo_int_status_t
51
_cairo_fallback_compositor_paint (const cairo_compositor_t	*_compositor,
52
				  cairo_composite_rectangles_t	*extents)
53
{
54
    cairo_image_surface_t *image;
55
    cairo_int_status_t status;
56

            
57
    TRACE ((stderr, "%s\n", __FUNCTION__));
58

            
59
    image = _cairo_surface_map_to_image (extents->surface, &extents->unbounded);
60

            
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);
67

            
68
    return _cairo_surface_unmap_image (extents->surface, image);
69
}
70

            
71
static cairo_int_status_t
72
_cairo_fallback_compositor_mask (const cairo_compositor_t	*_compositor,
73
				 cairo_composite_rectangles_t	*extents)
74
{
75
    cairo_image_surface_t *image;
76
    cairo_int_status_t status;
77

            
78
    TRACE ((stderr, "%s\n", __FUNCTION__));
79

            
80
    image = _cairo_surface_map_to_image (extents->surface, &extents->unbounded);
81

            
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);
89

            
90
    return _cairo_surface_unmap_image (extents->surface, image);
91
}
92

            
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)
102
{
103
    cairo_image_surface_t *image;
104
    cairo_int_status_t status;
105

            
106
    TRACE ((stderr, "%s\n", __FUNCTION__));
107

            
108
    image = _cairo_surface_map_to_image (extents->surface, &extents->unbounded);
109

            
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);
120

            
121
    return _cairo_surface_unmap_image (extents->surface, image);
122
}
123

            
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)
131
{
132
    cairo_image_surface_t *image;
133
    cairo_int_status_t status;
134

            
135
    TRACE ((stderr, "%s\n", __FUNCTION__));
136

            
137
    image = _cairo_surface_map_to_image (extents->surface, &extents->unbounded);
138

            
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);
147

            
148
    return _cairo_surface_unmap_image (extents->surface, image);
149
}
150

            
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)
158
{
159
    cairo_image_surface_t *image;
160
    cairo_int_status_t status;
161

            
162
    TRACE ((stderr, "%s\n", __FUNCTION__));
163

            
164
    image = _cairo_surface_map_to_image (extents->surface, &extents->unbounded);
165

            
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);
173

            
174
    return _cairo_surface_unmap_image (extents->surface, image);
175
}
176

            
177
const cairo_compositor_t _cairo_fallback_compositor = {
178
     &__cairo_no_compositor,
179

            
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,
185
};