michael@0: commit a26655b3144ed273940486fc15ccdac12b0562ec michael@0: Author: Jeff Muizelaar michael@0: Date: Tue Mar 17 15:08:50 2009 -0400 michael@0: michael@0: Jeff Muizelaar noted that the treatment of edges differed with firefox's michael@0: canvas definition, which considers a point on any edge as inside. The michael@0: current implementation has a similar definition to that of flash, for michael@0: which the top and right edges are outside. Arguably, firefox has the more michael@0: intuitive definition here... michael@0: michael@0: diff --git a/src/cairo-path-in-fill.c b/src/cairo-path-in-fill.c michael@0: index 21cd0bd..e641654 100644 michael@0: --- a/src/cairo-path-in-fill.c michael@0: +++ b/src/cairo-path-in-fill.c michael@0: @@ -41,6 +41,7 @@ typedef struct cairo_in_fill { michael@0: int winding; michael@0: michael@0: cairo_fixed_t x, y; michael@0: + cairo_bool_t on_edge; michael@0: michael@0: cairo_bool_t has_current_point; michael@0: cairo_point_t current_point; michael@0: @@ -58,6 +59,7 @@ _cairo_in_fill_init (cairo_in_fill_t *in_fill, michael@0: michael@0: in_fill->x = _cairo_fixed_from_double (x); michael@0: in_fill->y = _cairo_fixed_from_double (y); michael@0: + in_fill->on_edge = FALSE; michael@0: michael@0: in_fill->has_current_point = FALSE; michael@0: in_fill->current_point.x = 0; michael@0: @@ -103,6 +105,9 @@ _cairo_in_fill_add_edge (cairo_in_fill_t *in_fill, michael@0: { michael@0: int dir; michael@0: michael@0: + if (in_fill->on_edge) michael@0: + return; michael@0: + michael@0: /* count the number of edge crossing to -∞ */ michael@0: michael@0: dir = 1; michael@0: @@ -116,6 +121,18 @@ _cairo_in_fill_add_edge (cairo_in_fill_t *in_fill, michael@0: dir = -1; michael@0: } michael@0: michael@0: + /* First check whether the query is on an edge */ michael@0: + if ((p1->x == in_fill->x && p1->x == in_fill->y) || michael@0: + (p2->x == in_fill->x && p2->x == in_fill->y) || michael@0: + (! (p2->y < in_fill->y || p1->y > in_fill->y) && michael@0: + ! (p1->x > in_fill->x && p2->x > in_fill->x) && michael@0: + ! (p1->x < in_fill->x && p2->x < in_fill->x) && michael@0: + edge_compare_for_y_against_x (p1, p2, in_fill->y, in_fill->x) == 0)) michael@0: + { michael@0: + in_fill->on_edge = TRUE; michael@0: + return; michael@0: + } michael@0: + michael@0: /* edge is entirely above or below, note the shortening rule */ michael@0: if (p2->y <= in_fill->y || p1->y > in_fill->y) michael@0: return; michael@0: @@ -246,7 +263,9 @@ _cairo_path_fixed_in_fill (cairo_path_fixed_t *path, michael@0: michael@0: _cairo_in_fill_close_path (&in_fill); michael@0: michael@0: - switch (fill_rule) { michael@0: + if (in_fill.on_edge) { michael@0: + *is_inside = TRUE; michael@0: + } else switch (fill_rule) { michael@0: case CAIRO_FILL_RULE_EVEN_ODD: michael@0: *is_inside = in_fill.winding & 1; michael@0: break;