diff options
author | Chris Wilson <chris@chris-wilson.co.uk> | 2009-08-28 10:06:04 +0100 |
---|---|---|
committer | Chris Wilson <chris@chris-wilson.co.uk> | 2009-08-29 08:08:38 +0100 |
commit | ab035ab2c7bec254fc94d6391398905b5039e777 (patch) | |
tree | 49312efc13ca5778e7c09c1e17de987b74ca89c1 /src/cairo-path-fill.c | |
parent | d7b0c3b784faba756b10b66b9757e6e4c3fce38c (diff) | |
download | cairo-ab035ab2c7bec254fc94d6391398905b5039e777.tar.gz |
[tessellate] Rectangular special case
Add an even simpler sweep-line tessellator for rectangular trapezoids (as
produced by the rectilinear stoker and box filler).
This is so simple it even outperforms pixman's region validation code for the
purposes of path-to-region conversion.
Diffstat (limited to 'src/cairo-path-fill.c')
-rw-r--r-- | src/cairo-path-fill.c | 40 |
1 files changed, 14 insertions, 26 deletions
diff --git a/src/cairo-path-fill.c b/src/cairo-path-fill.c index 3daf24614..870a987fd 100644 --- a/src/cairo-path-fill.c +++ b/src/cairo-path-fill.c @@ -356,6 +356,9 @@ _cairo_path_fixed_fill_rectilinear_to_traps (const cairo_path_fixed_t *path, cairo_box_t box; cairo_status_t status; + traps->is_rectilinear = TRUE; + traps->is_rectangular = TRUE; + if (_cairo_path_fixed_is_box (path, &box)) { if (box.p1.x > box.p2.x) { cairo_fixed_t t; @@ -374,24 +377,11 @@ _cairo_path_fixed_fill_rectilinear_to_traps (const cairo_path_fixed_t *path, } return _cairo_traps_tessellate_rectangle (traps, &box.p1, &box.p2); - } else if (fill_rule == CAIRO_FILL_RULE_WINDING) { + } else { cairo_path_fixed_iter_t iter; - int last_cw = -1; _cairo_path_fixed_iter_init (&iter, path); while (_cairo_path_fixed_iter_is_fill_box (&iter, &box)) { - int cw = 0; - - if (box.p1.x > box.p2.x) { - cairo_fixed_t t; - - t = box.p1.x; - box.p1.x = box.p2.x; - box.p2.x = t; - - cw = ! cw; - } - if (box.p1.y > box.p2.y) { cairo_fixed_t t; @@ -399,25 +389,23 @@ _cairo_path_fixed_fill_rectilinear_to_traps (const cairo_path_fixed_t *path, box.p1.y = box.p2.y; box.p2.y = t; - cw = ! cw; + t = box.p1.x; + box.p1.x = box.p2.x; + box.p2.x = t; } - if (last_cw < 0) - last_cw = cw; - else if (last_cw != cw) - goto out; - status = _cairo_traps_tessellate_rectangle (traps, &box.p1, &box.p2); - if (unlikely (status)) + if (unlikely (status)) { + _cairo_traps_clear (traps); return status; + } } if (_cairo_path_fixed_iter_at_end (&iter)) - return CAIRO_STATUS_SUCCESS; - } + return _cairo_bentley_ottmann_tessellate_rectangular_traps (traps, fill_rule); - out: - _cairo_traps_clear (traps); - return CAIRO_INT_STATUS_UNSUPPORTED; + _cairo_traps_clear (traps); + return CAIRO_INT_STATUS_UNSUPPORTED; + } } |