diff options
author | M Joonas Pihlaja <jpihlaja@cc.helsinki.fi> | 2008-12-23 03:14:38 +0200 |
---|---|---|
committer | M Joonas Pihlaja <jpihlaja@cc.helsinki.fi> | 2008-12-23 03:32:07 +0200 |
commit | 1f894033f077731485e1228f7e071e75c37a9947 (patch) | |
tree | f98eeae08da315a6605a5c6e35a78b042fadc27d /src/cairo-spans.c | |
parent | 0aa34c6435eaa260292cf10d270ebbf3314c7924 (diff) | |
download | cairo-1f894033f077731485e1228f7e071e75c37a9947.tar.gz |
[spans] Close open subpaths when filling with a scan converter.
As reported by Christian Persch, open subpaths weren't being
closed when rendering to an image surface:
http://bugs.freedesktop.org/show_bug.cgi?id=19240
Diffstat (limited to 'src/cairo-spans.c')
-rw-r--r-- | src/cairo-spans.c | 53 |
1 files changed, 31 insertions, 22 deletions
diff --git a/src/cairo-spans.c b/src/cairo-spans.c index 807eea961..a30da6182 100644 --- a/src/cairo-spans.c +++ b/src/cairo-spans.c @@ -30,6 +30,7 @@ typedef struct { cairo_scan_converter_t *converter; cairo_point_t current_point; cairo_point_t first_point; + cairo_bool_t has_first_point; } scan_converter_filler_t; static void @@ -40,6 +41,30 @@ scan_converter_filler_init (scan_converter_filler_t *filler, filler->current_point.x = 0; filler->current_point.y = 0; filler->first_point = filler->current_point; + filler->has_first_point = FALSE; +} + +static cairo_status_t +scan_converter_filler_close_path (void *closure) +{ + scan_converter_filler_t *filler = closure; + cairo_status_t status; + + filler->has_first_point = FALSE; + + if (filler->first_point.x == filler->current_point.x && + filler->first_point.y == filler->current_point.y) + { + return CAIRO_STATUS_SUCCESS; + } + + status = filler->converter->add_edge ( + filler->converter, + filler->current_point.x, filler->current_point.y, + filler->first_point.x, filler->first_point.y); + + filler->current_point = filler->first_point; + return status; } static cairo_status_t @@ -47,9 +72,15 @@ scan_converter_filler_move_to (void *closure, const cairo_point_t *p) { scan_converter_filler_t *filler = closure; + if (filler->has_first_point) { + cairo_status_t status = scan_converter_filler_close_path (closure); + if (status) + return status; + } filler->current_point.x = p->x; filler->current_point.y = p->y; filler->first_point = filler->current_point; + filler->has_first_point = TRUE; return CAIRO_STATUS_SUCCESS; } @@ -75,28 +106,6 @@ scan_converter_filler_line_to (void *closure, } static cairo_status_t -scan_converter_filler_close_path (void *closure) -{ - scan_converter_filler_t *filler = closure; - cairo_status_t status; - - if (filler->first_point.x == filler->current_point.x && - filler->first_point.y == filler->current_point.y) - { - return CAIRO_STATUS_SUCCESS; - } - - status = filler->converter->add_edge ( - filler->converter, - filler->current_point.x, filler->current_point.y, - filler->first_point.x, filler->first_point.y); - - filler->current_point = filler->first_point; - - return status; -} - -static cairo_status_t _cairo_path_fixed_fill_to_scan_converter ( cairo_path_fixed_t *path, double tolerance, |