diff options
-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 c714b32a..4c5861df 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) { |