From f2c0f544d5d8b0e63e22e657dbccd881c181b25b Mon Sep 17 00:00:00 2001 From: Andrea Canciani Date: Thu, 9 Jun 2011 10:39:58 +0200 Subject: [PATCH] path-bounder: Fix empty extents computation Fix long-standing bug in computation of path extents. Fixes get-path-extents, (test-from-38079). See https://bugs.freedesktop.org/show_bug.cgi?id=38079 --- KNOWN_ISSUES | 6 ------ src/cairo-path-bounds.c | 12 ++++++++++++ test/get-path-extents.c | 6 ++---- 3 files changed, 14 insertions(+), 10 deletions(-) diff --git a/KNOWN_ISSUES b/KNOWN_ISSUES index 5fda683..65fbf12 100644 --- a/KNOWN_ISSUES +++ b/KNOWN_ISSUES @@ -2,9 +2,3 @@ There are a few known bugs in 1.10 that have been fixed in master, but appear to be non-trivial to backport without fear of causing other regressions. The impact of these bugs is considered to be less than of a risk than rewriting the code. - -Zero Path Extents ------------------ -A closed degenerate path is reported as having extents (0, 0) x (0, 0), -whereas the expected value is (x, y) x (0, 0). This regression has existed -since at least 1.2. diff --git a/src/cairo-path-bounds.c b/src/cairo-path-bounds.c index 2e7b6bd..61d2f69 100644 --- a/src/cairo-path-bounds.c +++ b/src/cairo-path-bounds.c @@ -114,6 +114,11 @@ _cairo_path_bounder_curve_to (void *closure, { cairo_path_bounder_t *bounder = closure; + if (bounder->has_initial_point) { + _cairo_path_bounder_add_point (bounder, &bounder->current_point); + bounder->has_initial_point = FALSE; + } + /* If the bbox of the control points is entirely inside, then we * do not need to further evaluate the spline. */ @@ -140,6 +145,13 @@ _cairo_path_bounder_curve_to (void *closure, static cairo_status_t _cairo_path_bounder_close_path (void *closure) { + cairo_path_bounder_t *bounder = closure; + + if (bounder->has_initial_point) { + _cairo_path_bounder_add_point (bounder, &bounder->current_point); + bounder->has_initial_point = FALSE; + } + return CAIRO_STATUS_SUCCESS; } diff --git a/test/get-path-extents.c b/test/get-path-extents.c index 3a05eff..5bd3eb7 100644 --- a/test/get-path-extents.c +++ b/test/get-path-extents.c @@ -148,16 +148,14 @@ 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); - /*XXX: I'd expect these extents to be oriented at 200, 400 */ - errors += !check_extents (ctx, phase, cr2, PATH, EQUALS, 0, 0, 0, 0); + errors += !check_extents (ctx, phase, cr2, PATH, EQUALS, 200, 400, 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); - /*XXX: I'd expect these extents to be oriented at 200, 400 */ - errors += !check_extents (ctx, phase, cr2, PATH, EQUALS, 0, 0, 0, 0); + errors += !check_extents (ctx, phase, cr2, PATH, EQUALS, 210, 400, 0, 0); cairo_new_path (cr2); cairo_restore (cr2); -- 1.7.5.2