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>
This commit is contained in:
Chris Wilson 2013-02-08 13:10:25 +00:00
parent 607a15db5d
commit 8cfbdf2f02

View file

@ -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) {