[cairo-commit] src/cairo-polygon.c

Chris Wilson ickle at kemper.freedesktop.org
Fri Feb 8 05:14:30 PST 2013


 src/cairo-polygon.c |   35 +++++++++++++++++++++++++----------
 1 file changed, 25 insertions(+), 10 deletions(-)

New commits:
commit 8cfbdf2f02ba01d5638a91c9f3f7fc228b402caa
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Fri Feb 8 13:10:25 2013 +0000

    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 at chris-wilson.co.uk>

diff --git a/src/cairo-polygon.c b/src/cairo-polygon.c
index c714b32..4c5861d 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) {


More information about the cairo-commit mailing list