diff --git a/src/cairo.c b/src/cairo.c index 3011125f8..9535174c0 100644 --- a/src/cairo.c +++ b/src/cairo.c @@ -1879,8 +1879,8 @@ slim_hidden_def(cairo_close_path); * * Computes a bounding box in user-space coordinates covering the * points on the current path. If the current path is empty, returns - * an empty rectangle ((0,0), (0,0)). Stroke parameters, surface - * dimensions and clipping are not taken into account. + * an empty rectangle ((0,0), (0,0)). Stroke parameters, fill rule, + * surface dimensions and clipping are not taken into account. * * Contrast with cairo_fill_extents() and cairo_stroke_extents() which * return the extents of only the area that would be "inked" by diff --git a/test/get-path-extents.c b/test/get-path-extents.c index 5e82c1eac..12901fd05 100644 --- a/test/get-path-extents.c +++ b/test/get-path-extents.c @@ -244,6 +244,55 @@ draw (cairo_t *cr, int width, int height) cairo_new_path (cr2); cairo_restore (cr2); + cairo_save (cr2); + + cairo_set_line_width (cr2, 4); + + cairo_rectangle (cr2, 10, 10, 30, 30); + cairo_rectangle (cr2, 25, 10, 15, 30); + + cairo_set_fill_rule (cr2, CAIRO_FILL_RULE_EVEN_ODD); + phase = "EVEN_ODD overlapping rectangles"; + if (!check_extents (phase, cr2, FILL, EQUALS, 10, 10, 15, 30) || + !check_extents (phase, cr2, STROKE, EQUALS, 8, 8, 34, 34) || + !check_extents (phase, cr2, PATH, EQUALS, 10, 10, 30, 30)) + ret = CAIRO_TEST_FAILURE; + + /* Test other fill rule with the same path. */ + + cairo_set_fill_rule (cr2, CAIRO_FILL_RULE_WINDING); + phase = "WINDING overlapping rectangles"; + if (!check_extents (phase, cr2, FILL, EQUALS, 10, 10, 30, 30) || + !check_extents (phase, cr2, STROKE, EQUALS, 8, 8, 34, 34) || + !check_extents (phase, cr2, PATH, EQUALS, 10, 10, 30, 30)) + ret = CAIRO_TEST_FAILURE; + + /* Now, change the direction of the second rectangle and test both + * fill rules again. */ + cairo_new_path (cr2); + cairo_rectangle (cr2, 10, 10, 30, 30); + cairo_rectangle (cr2, 25, 40, 15, -30); + + cairo_set_fill_rule (cr2, CAIRO_FILL_RULE_EVEN_ODD); + phase = "EVEN_ODD overlapping rectangles"; + if (!check_extents (phase, cr2, FILL, EQUALS, 10, 10, 15, 30) || + !check_extents (phase, cr2, STROKE, EQUALS, 8, 8, 34, 34) || + !check_extents (phase, cr2, PATH, EQUALS, 10, 10, 30, 30)) + ret = CAIRO_TEST_FAILURE; + + /* Test other fill rule with the same path. */ + + cairo_set_fill_rule (cr2, CAIRO_FILL_RULE_WINDING); + phase = "WINDING overlapping rectangles"; + if (!check_extents (phase, cr2, FILL, EQUALS, 10, 10, 15, 30) || + !check_extents (phase, cr2, STROKE, EQUALS, 8, 8, 34, 34) || + !check_extents (phase, cr2, PATH, EQUALS, 10, 10, 30, 30)) + ret = CAIRO_TEST_FAILURE; + + cairo_new_path (cr2); + + cairo_restore (cr2); + /* http://bugs.freedesktop.org/show_bug.cgi?id=7245 */ phase = "Arc"; cairo_save (cr2);