diff options
author | Chris Wilson <chris@chris-wilson.co.uk> | 2008-11-05 23:48:52 +0000 |
---|---|---|
committer | Chris Wilson <chris@chris-wilson.co.uk> | 2008-11-06 00:27:23 +0000 |
commit | f5965cb7d6559e051c2581fe446d0b9f40427eb2 (patch) | |
tree | d2e6bb9f68b2e062a81d14b0f9c7f9c972668361 /src/cairo-gstate.c | |
parent | 0ac98461597420d3dfe52e405c6b3322d32f4854 (diff) |
[in-fill] Avoid tessellation by counting number of edge crossing to -∞
Benjamin Otte reports that in one particular benchmark cairo_in_fill() is
a hotspot in the profile. Currently we tessellate the entire path and then
search for a containing trapezoid. This is very expensive compared to the
simple method of counting the number of edge crossing between the point of
interest and x=-∞. For example, this speeds tessellate-256 up by almost 3
orders of magnitude.
Diffstat (limited to 'src/cairo-gstate.c')
-rw-r--r-- | src/cairo-gstate.c | 30 |
1 files changed, 5 insertions, 25 deletions
diff --git a/src/cairo-gstate.c b/src/cairo-gstate.c index 5b8c87d7..1d532c71 100644 --- a/src/cairo-gstate.c +++ b/src/cairo-gstate.c @@ -1071,33 +1071,13 @@ _cairo_gstate_in_fill (cairo_gstate_t *gstate, double y, cairo_bool_t *inside_ret) { - cairo_status_t status; - cairo_box_t limit; - cairo_traps_t traps; - _cairo_gstate_user_to_backend (gstate, &x, &y); - limit.p1.x = _cairo_fixed_from_double (x) - 1; - limit.p1.y = _cairo_fixed_from_double (y) - 1; - limit.p2.x = limit.p1.x + 2; - limit.p2.y = limit.p1.y + 2; - - _cairo_traps_init (&traps); - _cairo_traps_limit (&traps, &limit); - - status = _cairo_path_fixed_fill_to_traps (path, - gstate->fill_rule, - gstate->tolerance, - &traps); - if (status) - goto BAIL; - - *inside_ret = _cairo_traps_contain (&traps, x, y); - -BAIL: - _cairo_traps_fini (&traps); - - return status; + return _cairo_path_fixed_in_fill (path, + gstate->fill_rule, + gstate->tolerance, + x, y, + inside_ret); } cairo_status_t |