[cairo-commit] 2 commits - src/cairo-path-stroke.c

Chris Wilson ickle at kemper.freedesktop.org
Sun Oct 26 04:05:06 PDT 2008


 src/cairo-path-stroke.c |   58 +++++++++++++++++++++++++++++++++---------------
 1 file changed, 40 insertions(+), 18 deletions(-)

New commits:
commit 22e2dac819de3c082424ebf3ce8f64c9c4797e8a
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Sun Oct 26 10:21:37 2008 +0000

    [stroke] Ensure we record the first face for a dashed path.
    
    If the first face was outside the bounds then we skipped it, and so a
    close would incorrectly connect to the first visible face.

diff --git a/src/cairo-path-stroke.c b/src/cairo-path-stroke.c
index d8c94a8..efccbcf 100644
--- a/src/cairo-path-stroke.c
+++ b/src/cairo-path-stroke.c
@@ -878,6 +878,7 @@ _cairo_stroker_line_to_dashed (void *closure, cairo_point_t *point)
 
 	if (stroker->dash_on &&
 	    (fully_in_bounds ||
+	     (! stroker->has_first_face && stroker->dash_starts_on) ||
 	     _cairo_box_intersects_line_segment (&stroker->bounds, &segment)))
 	{
 	    status = _cairo_stroker_add_sub_edge (stroker,
commit 64fb3290f00bafc4a10e6432226f669a51fa0bc6
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Sun Oct 26 09:54:03 2008 +0000

    [stroke] _cairo_stroker_line_to_dashed() whitespace
    
    A couple of comment spelling mistakes and rearrange whitespace to more
    closely match CODING_STYLE.

diff --git a/src/cairo-path-stroke.c b/src/cairo-path-stroke.c
index 627c71e..d8c94a8 100644
--- a/src/cairo-path-stroke.c
+++ b/src/cairo-path-stroke.c
@@ -829,7 +829,6 @@ _cairo_stroker_line_to (void *closure, cairo_point_t *point)
 static cairo_status_t
 _cairo_stroker_line_to_dashed (void *closure, cairo_point_t *point)
 {
-    cairo_status_t status = CAIRO_STATUS_SUCCESS;
     cairo_stroker_t *stroker = closure;
     double mag, remain, step_length = 0;
     double slope_dx, slope_dy;
@@ -838,17 +837,19 @@ _cairo_stroker_line_to_dashed (void *closure, cairo_point_t *point)
     cairo_point_t *p1 = &stroker->current_point;
     cairo_point_t *p2 = point;
     cairo_slope_t dev_slope;
-    cairo_bool_t fully_in_bounds = TRUE;
     cairo_line_t segment;
+    cairo_bool_t fully_in_bounds;
+    cairo_status_t status;
 
     stroker->has_initial_sub_path = stroker->dash_starts_on;
 
     if (p1->x == p2->x && p1->y == p2->y)
 	return CAIRO_STATUS_SUCCESS;
 
+    fully_in_bounds = TRUE;
     if (stroker->has_bounds &&
-	(!_cairo_box_contains_point (&stroker->bounds, p1) ||
-	 !_cairo_box_contains_point (&stroker->bounds, p2)))
+	(! _cairo_box_contains_point (&stroker->bounds, p1) ||
+	 ! _cairo_box_contains_point (&stroker->bounds, p2)))
     {
 	fully_in_bounds = FALSE;
     }
@@ -858,8 +859,11 @@ _cairo_stroker_line_to_dashed (void *closure, cairo_point_t *point)
     slope_dx = _cairo_fixed_to_double (p2->x - p1->x);
     slope_dy = _cairo_fixed_to_double (p2->y - p1->y);
 
-    if (!_compute_normalized_device_slope (&slope_dx, &slope_dy, stroker->ctm_inverse, &mag))
+    if (! _compute_normalized_device_slope (&slope_dx, &slope_dy,
+					   stroker->ctm_inverse, &mag))
+    {
 	return CAIRO_STATUS_SUCCESS;
+    }
 
     remain = mag;
     segment.p1 = *p1;
@@ -876,17 +880,24 @@ _cairo_stroker_line_to_dashed (void *closure, cairo_point_t *point)
 	    (fully_in_bounds ||
 	     _cairo_box_intersects_line_segment (&stroker->bounds, &segment)))
 	{
-	    status = _cairo_stroker_add_sub_edge (stroker, &segment.p1, &segment.p2, &dev_slope, slope_dx, slope_dy, &sub_start, &sub_end);
+	    status = _cairo_stroker_add_sub_edge (stroker,
+						  &segment.p1, &segment.p2,
+						  &dev_slope,
+						  slope_dx, slope_dy,
+						  &sub_start, &sub_end);
 	    if (status)
 		return status;
 
 	    if (stroker->has_current_face) {
 		/* Join with final face from previous segment */
-		status = _cairo_stroker_join (stroker, &stroker->current_face, &sub_start);
-		stroker->has_current_face = FALSE;
+		status = _cairo_stroker_join (stroker,
+					      &stroker->current_face,
+					      &sub_start);
 		if (status)
 		    return status;
-	    } else if (!stroker->has_first_face && stroker->dash_starts_on) {
+
+		stroker->has_current_face = FALSE;
+	    } else if (! stroker->has_first_face && stroker->dash_starts_on) {
 		/* Save sub path's first face in case needed for closing join */
 		stroker->first_face = sub_start;
 		stroker->has_first_face = TRUE;
@@ -909,9 +920,11 @@ _cairo_stroker_line_to_dashed (void *closure, cairo_point_t *point)
 	} else {
 	    if (stroker->has_current_face) {
 		/* Cap final face from previous segment */
-		status = _cairo_stroker_add_trailing_cap (stroker, &stroker->current_face);
+		status = _cairo_stroker_add_trailing_cap (stroker,
+							  &stroker->current_face);
 		if (status)
 		    return status;
+
 		stroker->has_current_face = FALSE;
 	    }
 	}
@@ -920,24 +933,32 @@ _cairo_stroker_line_to_dashed (void *closure, cairo_point_t *point)
 	segment.p1 = segment.p2;
     }
 
-    if (stroker->dash_on && !stroker->has_current_face) {
+    if (stroker->dash_on && ! stroker->has_current_face) {
 	/* This segment ends on a transition to dash_on, compute a new face
-	 * and add cap for the begining of the next dash_on step.
+	 * and add cap for the beginning of the next dash_on step.
 	 *
 	 * Note: this will create a degenerate cap if this is not the last line
 	 * in the path. Whether this behaviour is desirable or not is debatable.
-	 * On one side these degnerate caps can not be reproduced with regular path stroking.
-	 * On the other side Acroread 7 also produces the degenerate caps. */
-	_compute_face (point, &dev_slope, slope_dx, slope_dy, stroker, &stroker->current_face);
-	stroker->has_current_face = TRUE;
-	status = _cairo_stroker_add_leading_cap (stroker, &stroker->current_face);
+	 * On one side these degenerate caps can not be reproduced with regular
+	 * path stroking.
+	 * On the other hand, Acroread 7 also produces the degenerate caps.
+	 */
+	_compute_face (point, &dev_slope,
+		       slope_dx, slope_dy,
+		       stroker,
+		       &stroker->current_face);
+
+	status = _cairo_stroker_add_leading_cap (stroker,
+						 &stroker->current_face);
 	if (status)
 	    return status;
+
+	stroker->has_current_face = TRUE;
     }
 
     stroker->current_point = *point;
 
-    return status;
+    return CAIRO_STATUS_SUCCESS;
 }
 
 static cairo_status_t


More information about the cairo-commit mailing list