2
* Copyright � 2002 University of Southern California
4
* Permission to use, copy, modify, distribute, and sell this software
5
* and its documentation for any purpose is hereby granted without
6
* fee, provided that the above copyright notice appear in all copies
7
* and that both that copyright notice and this permission notice
8
* appear in supporting documentation, and that the name of the
9
* University of Southern California not be used in advertising or
10
* publicity pertaining to distribution of the software without
11
* specific, written prior permission. The University of Southern
12
* California makes no representations about the suitability of this
13
* software for any purpose. It is provided "as is" without express
14
* or implied warranty.
16
* THE UNIVERSITY OF SOUTHERN CALIFORNIA DISCLAIMS ALL WARRANTIES WITH
17
* REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF
18
* MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL THE UNIVERSITY OF
19
* SOUTHERN CALIFORNIA BE LIABLE FOR ANY SPECIAL, INDIRECT OR
20
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
21
* OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
22
* NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
23
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
25
* Author: Carl D. Worth <cworth@isi.edu>
30
typedef struct cairo_filler {
31
cairo_gstate_t *gstate;
34
cairo_point_t current_point;
36
cairo_polygon_t polygon;
40
_cairo_filler_init (cairo_filler_t *filler, cairo_gstate_t *gstate, cairo_traps_t *traps);
43
_cairo_filler_fini (cairo_filler_t *filler);
46
_cairo_filler_move_to (void *closure, cairo_point_t *point);
49
_cairo_filler_line_to (void *closure, cairo_point_t *point);
52
_cairo_filler_curve_to (void *closure,
58
_cairo_filler_close_path (void *closure);
61
_cairo_filler_init (cairo_filler_t *filler, cairo_gstate_t *gstate, cairo_traps_t *traps)
63
filler->gstate = gstate;
64
filler->traps = traps;
66
filler->current_point.x = 0;
67
filler->current_point.y = 0;
69
_cairo_polygon_init (&filler->polygon);
73
_cairo_filler_fini (cairo_filler_t *filler)
75
_cairo_polygon_fini (&filler->polygon);
79
_cairo_filler_move_to (void *closure, cairo_point_t *point)
81
cairo_status_t status;
82
cairo_filler_t *filler = closure;
83
cairo_polygon_t *polygon = &filler->polygon;
85
status = _cairo_polygon_close (polygon);
89
status = _cairo_polygon_move_to (polygon, point);
93
filler->current_point = *point;
95
return CAIRO_STATUS_SUCCESS;
99
_cairo_filler_line_to (void *closure, cairo_point_t *point)
101
cairo_status_t status;
102
cairo_filler_t *filler = closure;
103
cairo_polygon_t *polygon = &filler->polygon;
105
status = _cairo_polygon_line_to (polygon, point);
109
filler->current_point = *point;
111
return CAIRO_STATUS_SUCCESS;
114
static cairo_status_t
115
_cairo_filler_curve_to (void *closure,
121
cairo_status_t status = CAIRO_STATUS_SUCCESS;
122
cairo_filler_t *filler = closure;
123
cairo_polygon_t *polygon = &filler->polygon;
124
cairo_gstate_t *gstate = filler->gstate;
125
cairo_spline_t spline;
127
status = _cairo_spline_init (&spline, &filler->current_point, b, c, d);
129
if (status == CAIRO_INT_STATUS_DEGENERATE)
130
return CAIRO_STATUS_SUCCESS;
132
_cairo_spline_decompose (&spline, gstate->tolerance);
136
for (i = 1; i < spline.num_points; i++) {
137
status = _cairo_polygon_line_to (polygon, &spline.points[i]);
143
_cairo_spline_fini (&spline);
145
filler->current_point = *d;
150
static cairo_status_t
151
_cairo_filler_close_path (void *closure)
153
cairo_status_t status;
154
cairo_filler_t *filler = closure;
155
cairo_polygon_t *polygon = &filler->polygon;
157
status = _cairo_polygon_close (polygon);
161
return CAIRO_STATUS_SUCCESS;
165
_cairo_path_fill_to_traps (cairo_path_t *path, cairo_gstate_t *gstate, cairo_traps_t *traps)
167
cairo_status_t status = CAIRO_STATUS_SUCCESS;
168
cairo_filler_t filler;
170
_cairo_filler_init (&filler, gstate, traps);
172
status = _cairo_path_interpret (path,
173
CAIRO_DIRECTION_FORWARD,
174
_cairo_filler_move_to,
175
_cairo_filler_line_to,
176
_cairo_filler_curve_to,
177
_cairo_filler_close_path,
182
status = _cairo_polygon_close (&filler.polygon);
186
status = _cairo_traps_tessellate_polygon (filler.traps,
188
filler.gstate->fill_rule);
193
_cairo_filler_fini (&filler);