[cairo-commit] Branch '1.10' - src/cairo-path-bounds.c test/get-path-extents.c

Jeff Muizelaar jrmuizel at kemper.freedesktop.org
Wed Nov 10 10:52:03 PST 2010


 src/cairo-path-bounds.c |    4 +++-
 test/get-path-extents.c |   40 ++++++++++++++++++++++++++++++++--------
 2 files changed, 35 insertions(+), 9 deletions(-)

New commits:
commit e9bb70d2dee4ef7a54e3971f09a08df30c2b5287
Author: Jeff Muizelaar <jmuizelaar at mozilla.com>
Date:   Fri Nov 5 11:40:00 2010 -0400

    Fix degenerate vertical path bounds.
    
    6b77567b6ef28710c7707ab82c7fa95c810152d1 made vertical
    path bounds with no area return extents of 0,0. This fixes
    the problem by not assuming degenerate path bounds are 0,0

diff --git a/src/cairo-path-bounds.c b/src/cairo-path-bounds.c
index d32c260..75308c6 100644
--- a/src/cairo-path-bounds.c
+++ b/src/cairo-path-bounds.c
@@ -331,7 +331,9 @@ _cairo_path_fixed_extents (const cairo_path_fixed_t *path,
 
     if (! path->has_curve_to) {
 	*box = path->extents;
-	return path->extents.p1.x < path->extents.p2.x;
+	/* empty extents should still have an origin and should not
+	 * be {0, 0, 0, 0} */
+	return path->extents.p1.x <= path->extents.p2.x;
     }
 
     _cairo_path_bounder_init (&bounder);
diff --git a/test/get-path-extents.c b/test/get-path-extents.c
index a3e9554..3a05eff 100644
--- a/test/get-path-extents.c
+++ b/test/get-path-extents.c
@@ -61,10 +61,6 @@ check_extents (const cairo_test_context_t *ctx,
     if (cairo_status (cr))
 	return 1;
 
-    /* let empty rects match */
-    if ((ext_x1 == ext_x2 || ext_y1 == ext_y2) && (width == 0 || height == 0))
-        return 1;
-
     switch (relation) {
     default:
     case EQUALS:
@@ -152,14 +148,16 @@ draw (cairo_t *cr, int width, int height)
     phase = "Degenerate arc (R=0)";
     errors += !check_extents (ctx, phase, cr2, FILL, EQUALS, 0, 0, 0, 0);
     errors += !check_extents (ctx, phase, cr2, STROKE, EQUALS, 0, 0, 0, 0);
-    errors += !check_extents (ctx, phase, cr2, PATH, EQUALS, 200, 400, 0, 0);
+    /*XXX: I'd expect these extents to be oriented at 200, 400 */
+    errors += !check_extents (ctx, phase, cr2, PATH, EQUALS, 0, 0, 0, 0);
 
     cairo_new_path (cr2);
     cairo_arc (cr2, 200, 400, 10., 0, 0);
     phase = "Degenerate arc (Θ=0)";
     errors += !check_extents (ctx, phase, cr2, FILL, EQUALS, 0, 0, 0, 0);
     errors += !check_extents (ctx, phase, cr2, STROKE, EQUALS, 0, 0, 0, 0);
-    errors += !check_extents (ctx, phase, cr2, PATH, EQUALS, 200, 400, 0, 0);
+    /*XXX: I'd expect these extents to be oriented at 200, 400 */
+    errors += !check_extents (ctx, phase, cr2, PATH, EQUALS, 0, 0, 0, 0);
 
     cairo_new_path (cr2);
     cairo_restore (cr2);
@@ -191,7 +189,7 @@ draw (cairo_t *cr, int width, int height)
     cairo_restore (cr2);
 
     /* http://bugs.freedesktop.org/show_bug.cgi?id=7965 */
-    phase = "A vertical, open path";
+    phase = "A horizontal, open path";
     cairo_save (cr2);
     cairo_set_line_cap (cr2, CAIRO_LINE_CAP_ROUND);
     cairo_set_line_join (cr2, CAIRO_LINE_JOIN_ROUND);
@@ -199,7 +197,33 @@ draw (cairo_t *cr, int width, int height)
     cairo_line_to (cr2, 750, 180);
     errors += !check_extents (ctx, phase, cr2, FILL, EQUALS, 0, 0, 0, 0);
     errors += !check_extents (ctx, phase, cr2, STROKE, EQUALS, -5, 175, 760, 10);
-    errors += !check_extents (ctx, phase, cr2, PATH, EQUALS, 0, 180, 755, 0);
+    errors += !check_extents (ctx, phase, cr2, PATH, EQUALS, 0, 180, 750, 0);
+    cairo_new_path (cr2);
+    cairo_restore (cr2);
+
+    phase = "A vertical, open path";
+    cairo_save (cr2);
+    cairo_set_line_cap (cr2, CAIRO_LINE_CAP_ROUND);
+    cairo_set_line_join (cr2, CAIRO_LINE_JOIN_ROUND);
+    cairo_new_path (cr2);
+    cairo_move_to (cr2, 180, 0);
+    cairo_line_to (cr2, 180, 750);
+    errors += !check_extents (ctx, phase, cr2, FILL, EQUALS, 0, 0, 0, 0);
+    errors += !check_extents (ctx, phase, cr2, STROKE, EQUALS, 175, -5, 10, 760);
+    errors += !check_extents (ctx, phase, cr2, PATH, EQUALS, 180, 0, 0, 750);
+    cairo_new_path (cr2);
+    cairo_restore (cr2);
+
+    phase = "A degenerate open path";
+    cairo_save (cr2);
+    cairo_set_line_cap (cr2, CAIRO_LINE_CAP_ROUND);
+    cairo_set_line_join (cr2, CAIRO_LINE_JOIN_ROUND);
+    cairo_new_path (cr2);
+    cairo_move_to (cr2, 180, 0);
+    cairo_line_to (cr2, 180, 0);
+    errors += !check_extents (ctx, phase, cr2, FILL, EQUALS, 0, 0, 0, 0);
+    errors += !check_extents (ctx, phase, cr2, STROKE, EQUALS, 175, -5, 10, 10);
+    errors += !check_extents (ctx, phase, cr2, PATH, EQUALS, 180, 0, 0, 0);
     cairo_new_path (cr2);
     cairo_restore (cr2);
 


More information about the cairo-commit mailing list