From b5b1134c2c84996bd8e019d5908b18db876137dc Mon Sep 17 00:00:00 2001 From: M Joonas Pihlaja Date: Wed, 24 Sep 2008 17:39:33 +0100 Subject: [PATCH] [tessellator] Skip edges that lie outside the region of interest. We don't need to tessellate edges strictly above or below the the limits of the traps. --- src/cairo-bentley-ottmann.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/cairo-bentley-ottmann.c b/src/cairo-bentley-ottmann.c index b5c757e93..6e46476e1 100644 --- a/src/cairo-bentley-ottmann.c +++ b/src/cairo-bentley-ottmann.c @@ -1430,12 +1430,16 @@ _cairo_bentley_ottmann_tessellate_polygon (cairo_traps_t *traps, cairo_fixed_t ymin = 0x7FFFFFFF; cairo_fixed_t xmax = -0x80000000; cairo_fixed_t ymax = -0x80000000; + cairo_box_t limit; + cairo_bool_t has_limits; int num_bo_edges; int i; if (0 == polygon->num_edges) return CAIRO_STATUS_SUCCESS; + has_limits = _cairo_traps_get_limit (traps, &limit); + if (polygon->num_edges < ARRAY_LENGTH (stack_edges)) { edges = stack_edges; } else { @@ -1474,6 +1478,13 @@ _cairo_bentley_ottmann_tessellate_polygon (cairo_traps_t *traps, cairo_point_t top = polygon->edges[i].edge.p1; cairo_point_t bot = polygon->edges[i].edge.p2; + /* Discard the edge if it lies outside the limits of traps. */ + if (has_limits) { + /* Strictly above or below the limits? */ + if (bot.y <= limit.p1.y || top.y >= limit.p2.y) + continue; + } + /* Offset coordinates into the non-negative range. */ top.x -= xmin; top.y -= ymin;