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

Chris Wilson ickle at kemper.freedesktop.org
Wed Jul 27 09:33:46 PDT 2011


 src/cairo-polygon.c |   11 ++++-------
 1 file changed, 4 insertions(+), 7 deletions(-)

New commits:
commit cac96c8083214f8e5aa65e9a527f9fa3e813b149
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Wed Jul 27 17:02:53 2011 +0100

    polygon: Fix clipping of edges outside of their range
    
    Uli Schlachter analysed the error behind the polygon reduction and
    discovered that it was due to the clipping of a line which intersects
    the clip box (p1, p2) but is range limited by (top, bottom) to be inside
    the clip box.
    
    Fixes hatching
    
    Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>

diff --git a/src/cairo-polygon.c b/src/cairo-polygon.c
index 5f2cc31..82a5819 100644
--- a/src/cairo-polygon.c
+++ b/src/cairo-polygon.c
@@ -359,7 +359,7 @@ _add_clipped_edge (cairo_polygon_t *polygon,
 	    p2_y = bottom;
 
 	    if (left_y < right_y) {
-		if (p1->x < limits->p1.x && left_y > limits->p1.y) {
+		if (p1->x < limits->p1.x && left_y > top) {
 		    p[0].x = limits->p1.x;
 		    p[0].y = limits->p1.y;
 		    top_y = p1_y;
@@ -377,7 +377,7 @@ _add_clipped_edge (cairo_polygon_t *polygon,
 		    p1_y = bot_y;
 		}
 
-		if (p2->x > limits->p2.x && right_y < limits->p2.y) {
+		if (p2->x > limits->p2.x && right_y < bottom) {
 		    p[0].x = limits->p2.x;
 		    p[0].y = limits->p1.y;
 		    top_y = right_y;
@@ -395,7 +395,7 @@ _add_clipped_edge (cairo_polygon_t *polygon,
 		    p2_y = top_y;
 		}
 	    } else {
-		if (p1->x > limits->p2.x && right_y > limits->p1.y) {
+		if (p1->x > limits->p2.x && right_y > top) {
 		    p[0].x = limits->p2.x;
 		    p[0].y = limits->p1.y;
 		    top_y = p1_y;
@@ -413,7 +413,7 @@ _add_clipped_edge (cairo_polygon_t *polygon,
 		    p1_y = bot_y;
 		}
 
-		if (p2->x < limits->p1.x && left_y < limits->p2.y) {
+		if (p2->x < limits->p1.x && left_y < bottom) {
 		    p[0].x = limits->p1.x;
 		    p[0].y = limits->p1.y;
 		    top_y = left_y;
commit 030de5144d6c84b2b690e178ecc03a9bddb52181
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Wed Jul 27 17:00:48 2011 +0100

    polygon: Don't skip clipped horizontal edges
    
    As Andrea Canciani pointed out even if it is horizontal within the clip
    box, it may still have vertical extents outside of the clip box for
    which we need to project onto the clip boundary  in order to maintain
    the correct polygon winding.
    
    Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>

diff --git a/src/cairo-polygon.c b/src/cairo-polygon.c
index cc9faae..5f2cc31 100644
--- a/src/cairo-polygon.c
+++ b/src/cairo-polygon.c
@@ -355,9 +355,6 @@ _add_clipped_edge (cairo_polygon_t *polygon,
 	    right_y = _cairo_edge_compute_intersection_y_for_x (p1, p2,
 								limits->p2.x);
 
-	    if (left_y == right_y) /* horizontal within bounds */
-		continue;
-
 	    p1_y = top;
 	    p2_y = bottom;
 


More information about the cairo-commit mailing list