Test and document that fill rule has no effect on cairo_path_extents

This commit is contained in:
Carl Worth 2008-01-21 16:45:41 -08:00
parent 1ca186f511
commit 47cf7ed769
2 changed files with 51 additions and 2 deletions

View file

@ -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

View file

@ -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);