diff options
author | Chris Wilson <chris@chris-wilson.co.uk> | 2013-02-08 13:10:25 +0000 |
---|---|---|
committer | Chris Wilson <chris@chris-wilson.co.uk> | 2013-02-08 13:13:30 +0000 |
commit | 8cfbdf2f02ba01d5638a91c9f3f7fc228b402caa (patch) | |
tree | 52dbe3d5cb5eae7e79d1839e730cc1ca78606202 /src | |
parent | 607a15db5df04d10e5be6d06599ec4e9d98d2446 (diff) |
polygon: Only rely on the computed boundary intersections for crossing edges
If we need to extrapolate the edge to the boundary, then we run the risk
of an overflow for an immaterial result. So if the edge does not cross
the boundary, we can simply use the corresponding end-point and not emit
the boundary segment.
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=60489
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Diffstat (limited to 'src')
-rw-r--r-- | src/cairo-polygon.c | 35 |
1 files changed, 25 insertions, 10 deletions
diff --git a/src/cairo-polygon.c b/src/cairo-polygon.c index c714b32ad..4c5861df4 100644 --- a/src/cairo-polygon.c +++ b/src/cairo-polygon.c @@ -420,11 +420,14 @@ _add_clipped_edge (cairo_polygon_t *polygon, * inside the box if it is clipped to this vertical range. */ - top_left_to_bottom_right = (p1->x < p2->x) == (p1->y < p2->y); - + top_left_to_bottom_right = (p1->x <= p2->x) == (p1->y <= p2->y); if (top_left_to_bottom_right) { - if (_cairo_edge_compute_intersection_x_for_y (p1, p2, left_y) < limits->p1.x) - left_y++; + if (pleft >= limits->p1.x) { + left_y = top_y; + } else { + if (_cairo_edge_compute_intersection_x_for_y (p1, p2, left_y) < limits->p1.x) + left_y++; + } left_y = MIN (left_y, bot_y); if (top_y < left_y) { @@ -434,8 +437,12 @@ _add_clipped_edge (cairo_polygon_t *polygon, top_y = left_y; } - if (_cairo_edge_compute_intersection_x_for_y (p1, p2, right_y) > limits->p1.y) - right_y--; + if (pright <= limits->p2.x) { + right_y = bot_y; + } else { + if (_cairo_edge_compute_intersection_x_for_y (p1, p2, right_y) > limits->p2.x) + right_y--; + } right_y = MAX (right_y, top_y); if (bot_y > right_y) { @@ -445,8 +452,12 @@ _add_clipped_edge (cairo_polygon_t *polygon, bot_y = right_y; } } else { - if (_cairo_edge_compute_intersection_x_for_y (p1, p2, right_y) > limits->p2.x) - right_y++; + if (pright <= limits->p2.x) { + right_y = top_y; + } else { + if (_cairo_edge_compute_intersection_x_for_y (p1, p2, right_y) > limits->p2.x) + right_y++; + } right_y = MIN (right_y, bot_y); if (top_y < right_y) { @@ -456,8 +467,12 @@ _add_clipped_edge (cairo_polygon_t *polygon, top_y = right_y; } - if (_cairo_edge_compute_intersection_x_for_y (p1, p2, left_y) < limits->p1.x) - left_y--; + if (pleft >= limits->p1.x) { + left_y = bot_y; + } else { + if (_cairo_edge_compute_intersection_x_for_y (p1, p2, left_y) < limits->p1.x) + left_y--; + } left_y = MAX (left_y, top_y); if (bot_y > left_y) { |