diff options
author | Carl Worth <cworth@cworth.org> | 2005-10-13 16:55:14 +0000 |
---|---|---|
committer | Carl Worth <cworth@cworth.org> | 2005-10-13 16:55:14 +0000 |
commit | 31a561e2c233ab93c6e644e00d8e6d26e12b9bef (patch) | |
tree | 34ada241e0e2ed5f8797dcec2f75fa0a313e18dc | |
parent | 097f240c6d2403f1a3530c61a8c437444f936d97 (diff) |
Push fill_path fallbacks down from gstate into the surface where all the other fallbacks are.
Add _cairo_surface_is_meta.
Add antialias to the fill_path meta-surface command.
Add an antialias parameter to the backend fill_path function.
Fix test description.
Reviewed by: keithp
-rw-r--r-- | ChangeLog | 26 | ||||
-rw-r--r-- | src/cairo-gstate.c | 27 | ||||
-rw-r--r-- | src/cairo-meta-surface-private.h | 3 | ||||
-rw-r--r-- | src/cairo-meta-surface.c | 22 | ||||
-rw-r--r-- | src/cairo-pdf-surface.c | 9 | ||||
-rw-r--r-- | src/cairo-ps-surface.c | 22 | ||||
-rw-r--r-- | src/cairo-surface.c | 65 | ||||
-rw-r--r-- | src/cairoint.h | 21 | ||||
-rw-r--r-- | test/fill-and-stroke.c | 2 |
9 files changed, 144 insertions, 53 deletions
@@ -1,5 +1,31 @@ 2005-10-13 Carl Worth <cworth@cworth.org> + Reviewed by: keithp + + * src/cairo-surface.c: (_fallback_fill_path), + (_cairo_surface_fill_path): + * src/cairo-gstate.c: (_cairo_gstate_fill): Push fill_path + fallbacks down from gstate into the surface where all the other + fallbacks are. + + * src/cairo-meta-surface-private.h: + * src/cairo-meta-surface.c: (_cairo_surface_is_meta): + Add _cairo_surface_is_meta. + + * src/cairo-meta-surface.c: (_cairo_meta_surface_fill_path), + (_cairo_meta_surface_replay): Add antialias to the fill_path + meta-surface command. + + * src/cairoint.h: + * src/cairo-pdf-surface.c: (_cairo_pdf_surface_fill_path): + * src/cairo-ps-surface.c: (_cairo_ps_surface_fill_path), + (_ps_output_fill_path): Add an antialias parameter to the backend + fill_path function. + + * test/fill-and-stroke.c: Fix test description. + +2005-10-13 Carl Worth <cworth@cworth.org> + * src/cairo-gstate.c: (_cairo_gstate_clip_and_composite_trapezoids): Fix indentation. diff --git a/src/cairo-gstate.c b/src/cairo-gstate.c index 88546a01..7ac2c128 100644 --- a/src/cairo-gstate.c +++ b/src/cairo-gstate.c @@ -1557,7 +1557,6 @@ cairo_status_t _cairo_gstate_fill (cairo_gstate_t *gstate, cairo_path_fixed_t *path) { cairo_status_t status; - cairo_traps_t traps; cairo_pattern_union_t pattern; if (gstate->source->status) @@ -1574,29 +1573,11 @@ _cairo_gstate_fill (cairo_gstate_t *gstate, cairo_path_fixed_t *path) gstate->target, path, gstate->fill_rule, - gstate->tolerance); + gstate->tolerance, + &gstate->clip, + gstate->antialias); - _cairo_pattern_fini (&pattern.base); - - if (status != CAIRO_INT_STATUS_UNSUPPORTED) - return status; - - _cairo_traps_init (&traps); - - status = _cairo_path_fixed_fill_to_traps (path, - gstate->fill_rule, - gstate->tolerance, - &traps); - if (status) { - _cairo_traps_fini (&traps); - return status; - } - - _cairo_gstate_clip_and_composite_trapezoids (gstate, &traps); - - _cairo_traps_fini (&traps); - - return CAIRO_STATUS_SUCCESS; + return status; } cairo_status_t diff --git a/src/cairo-meta-surface-private.h b/src/cairo-meta-surface-private.h index 0a80fe70..975d596c 100644 --- a/src/cairo-meta-surface-private.h +++ b/src/cairo-meta-surface-private.h @@ -152,4 +152,7 @@ cairo_private cairo_int_status_t _cairo_meta_surface_replay (cairo_surface_t *surface, cairo_surface_t *target); +cairo_private cairo_bool_t +_cairo_surface_is_meta (const cairo_surface_t *surface); + #endif /* CAIRO_META_SURFACE_H */ diff --git a/src/cairo-meta-surface.c b/src/cairo-meta-surface.c index 2d3ae362..d3b57cb1 100644 --- a/src/cairo-meta-surface.c +++ b/src/cairo-meta-surface.c @@ -383,7 +383,8 @@ _cairo_meta_surface_fill_path (cairo_operator_t operator, void *abstract_surface, cairo_path_fixed_t *path, cairo_fill_rule_t fill_rule, - double tolerance) + double tolerance, + cairo_antialias_t antialias) { cairo_meta_surface_t *meta = abstract_surface; cairo_command_fill_path_t *command; @@ -404,6 +405,7 @@ _cairo_meta_surface_fill_path (cairo_operator_t operator, } command->fill_rule = fill_rule; command->tolerance = tolerance; + command->antialias = antialias; if (_cairo_array_append (&meta->commands, &command, 1) == NULL) { _cairo_path_fixed_fini (&command->path); @@ -415,6 +417,20 @@ _cairo_meta_surface_fill_path (cairo_operator_t operator, return CAIRO_STATUS_SUCCESS; } +/** + * _cairo_surface_is_meta: + * @surface: a #cairo_surface_t + * + * Checks if a surface is a #cairo_meta_surface_t + * + * Return value: TRUE if the surface is a meta surface + **/ +cairo_bool_t +_cairo_surface_is_meta (const cairo_surface_t *surface) +{ + return surface->backend == &cairo_meta_surface_backend; +} + static const cairo_surface_backend_t cairo_meta_surface_backend = { _cairo_meta_surface_create_similar, _cairo_meta_surface_finish, @@ -570,7 +586,9 @@ _cairo_meta_surface_replay (cairo_surface_t *surface, target, &command->fill_path.path, command->fill_path.fill_rule, - command->fill_path.tolerance); + command->fill_path.tolerance, + &clip, + command->fill_path.antialias); if (status != CAIRO_INT_STATUS_UNSUPPORTED) break; diff --git a/src/cairo-pdf-surface.c b/src/cairo-pdf-surface.c index 197eea2c..89a4f8a1 100644 --- a/src/cairo-pdf-surface.c +++ b/src/cairo-pdf-surface.c @@ -1239,11 +1239,12 @@ _cairo_pdf_path_close_path (void *closure) static cairo_int_status_t _cairo_pdf_surface_fill_path (cairo_operator_t operator, - cairo_pattern_t *pattern, - void *abstract_dst, - cairo_path_fixed_t *path, + cairo_pattern_t *pattern, + void *abstract_dst, + cairo_path_fixed_t *path, cairo_fill_rule_t fill_rule, - double tolerance) + double tolerance, + cairo_antialias_t antialias) { cairo_pdf_surface_t *surface = abstract_dst; cairo_pdf_document_t *document = surface->document; diff --git a/src/cairo-ps-surface.c b/src/cairo-ps-surface.c index 6aa9ca78..7794e7cb 100644 --- a/src/cairo-ps-surface.c +++ b/src/cairo-ps-surface.c @@ -468,16 +468,31 @@ _cairo_ps_surface_fill_path (cairo_operator_t operator, void *abstract_dst, cairo_path_fixed_t *path, cairo_fill_rule_t fill_rule, - double tolerance) + double tolerance, + cairo_antialias_t antialias) { cairo_ps_surface_t *surface = abstract_dst; + /* XXX: This is rather fragile here. We want to call back up into + * cairo-surface in order for it to farm things out to the + * appropriate backend fill_path function. But that requires + * having a clip parameter. We take advantage of the fact that we + * "know" that the clip is only used for fallbacks and we "know" + * that the meta surface backend never uses a fallback for + * fill_path. + * + * Clearly there's an organizational problem here. + */ + assert (_cairo_surface_is_meta (surface->current_page)); + return _cairo_surface_fill_path (operator, pattern, surface->current_page, path, fill_rule, - tolerance); + tolerance, + NULL, /* See comment above. */ + antialias); } static const cairo_surface_backend_t cairo_ps_surface_backend = { @@ -1341,7 +1356,8 @@ _ps_output_fill_path (cairo_operator_t operator, void *abstract_dst, cairo_path_fixed_t *path, cairo_fill_rule_t fill_rule, - double tolerance) + double tolerance, + cairo_antialias_t antialias) { ps_output_surface_t *surface = abstract_dst; cairo_output_stream_t *stream = surface->parent->stream; diff --git a/src/cairo-surface.c b/src/cairo-surface.c index a05368da..79781af9 100644 --- a/src/cairo-surface.c +++ b/src/cairo-surface.c @@ -1063,21 +1063,64 @@ _cairo_surface_fill_rectangles (cairo_surface_t *surface, return _fallback_fill_rectangles (surface, operator, color, rects, num_rects); } -cairo_int_status_t +static cairo_status_t +_fallback_fill_path (cairo_operator_t operator, + cairo_pattern_t *pattern, + cairo_surface_t *dst, + cairo_path_fixed_t *path, + cairo_fill_rule_t fill_rule, + double tolerance, + cairo_clip_t *clip, + cairo_antialias_t antialias) +{ + cairo_status_t status; + cairo_traps_t traps; + + _cairo_traps_init (&traps); + + status = _cairo_path_fixed_fill_to_traps (path, + fill_rule, + tolerance, + &traps); + if (status) { + _cairo_traps_fini (&traps); + return status; + } + + status = _cairo_surface_clip_and_composite_trapezoids (pattern, + operator, + dst, + &traps, + clip, + antialias); + + _cairo_traps_fini (&traps); + + return status; +} + +cairo_status_t _cairo_surface_fill_path (cairo_operator_t operator, - cairo_pattern_t *pattern, - cairo_surface_t *dst, - cairo_path_fixed_t *path, + cairo_pattern_t *pattern, + cairo_surface_t *dst, + cairo_path_fixed_t *path, cairo_fill_rule_t fill_rule, - double tolerance) + double tolerance, + cairo_clip_t *clip, + cairo_antialias_t antialias) { - if (dst->backend->fill_path) - return dst->backend->fill_path (operator, pattern, dst, path, - fill_rule, tolerance); - else - return CAIRO_INT_STATUS_UNSUPPORTED; -} + cairo_status_t status; + + if (dst->backend->fill_path) { + status = dst->backend->fill_path (operator, pattern, dst, path, + fill_rule, tolerance, antialias); + if (status != CAIRO_INT_STATUS_UNSUPPORTED) + return status; + } + return _fallback_fill_path (operator, pattern, dst, path, + fill_rule, tolerance, clip, antialias); +} static cairo_status_t _fallback_composite_trapezoids (cairo_operator_t operator, diff --git a/src/cairoint.h b/src/cairoint.h index 9c64d1cf..3c7c57c9 100644 --- a/src/cairoint.h +++ b/src/cairoint.h @@ -711,11 +711,12 @@ struct _cairo_surface_backend { cairo_int_status_t (*fill_path) (cairo_operator_t operator, - cairo_pattern_t *pattern, - void *dst, - cairo_path_fixed_t *path, + cairo_pattern_t *pattern, + void *dst, + cairo_path_fixed_t *path, cairo_fill_rule_t fill_rule, - double tolerance); + double tolerance, + cairo_antialias_t antialias); void (*get_font_options) (void *surface, @@ -1544,13 +1545,15 @@ _cairo_surface_fill_rectangles (cairo_surface_t *surface, cairo_rectangle_t *rects, int num_rects); -cairo_private cairo_int_status_t +cairo_private cairo_status_t _cairo_surface_fill_path (cairo_operator_t operator, - cairo_pattern_t *pattern, - cairo_surface_t *dst, - cairo_path_fixed_t *path, + cairo_pattern_t *pattern, + cairo_surface_t *dst, + cairo_path_fixed_t *path, cairo_fill_rule_t fill_rule, - double tolerance); + double tolerance, + cairo_clip_t *clip, + cairo_antialias_t antialias); cairo_private cairo_status_t _cairo_surface_composite_trapezoids (cairo_operator_t operator, diff --git a/test/fill-and-stroke.c b/test/fill-and-stroke.c index 98931711..6765538b 100644 --- a/test/fill-and-stroke.c +++ b/test/fill-and-stroke.c @@ -30,7 +30,7 @@ cairo_test_t test = { "fill-and-stroke", - "Tests calls to various set_source functions", + "Tests using cairo_fill_preserve/cairo_stroke to fill/stroke the same path", 2 * SIZE + 4 * PAD, SIZE + 2 * PAD }; |