Bug 977880 - Handle ReleaseFence on tiled thebes layer r=cwiiis,nical,BenWa
[gecko.git] / gfx / cairo / on-edge.patch
blob85e328ad8c69cef7838fbb6ae43881ff2c206836
1 commit a26655b3144ed273940486fc15ccdac12b0562ec
2 Author: Jeff Muizelaar <jmuizelaar@mozilla.com>
3 Date: Tue Mar 17 15:08:50 2009 -0400
5 Jeff Muizelaar noted that the treatment of edges differed with firefox's
6 canvas definition, which considers a point on any edge as inside. The
7 current implementation has a similar definition to that of flash, for
8 which the top and right edges are outside. Arguably, firefox has the more
9 intuitive definition here...
11 diff --git a/src/cairo-path-in-fill.c b/src/cairo-path-in-fill.c
12 index 21cd0bd..e641654 100644
13 --- a/src/cairo-path-in-fill.c
14 +++ b/src/cairo-path-in-fill.c
15 @@ -41,6 +41,7 @@ typedef struct cairo_in_fill {
16 int winding;
18 cairo_fixed_t x, y;
19 + cairo_bool_t on_edge;
21 cairo_bool_t has_current_point;
22 cairo_point_t current_point;
23 @@ -58,6 +59,7 @@ _cairo_in_fill_init (cairo_in_fill_t *in_fill,
25 in_fill->x = _cairo_fixed_from_double (x);
26 in_fill->y = _cairo_fixed_from_double (y);
27 + in_fill->on_edge = FALSE;
29 in_fill->has_current_point = FALSE;
30 in_fill->current_point.x = 0;
31 @@ -103,6 +105,9 @@ _cairo_in_fill_add_edge (cairo_in_fill_t *in_fill,
33 int dir;
35 + if (in_fill->on_edge)
36 + return;
38 /* count the number of edge crossing to -∞ */
40 dir = 1;
41 @@ -116,6 +121,18 @@ _cairo_in_fill_add_edge (cairo_in_fill_t *in_fill,
42 dir = -1;
45 + /* First check whether the query is on an edge */
46 + if ((p1->x == in_fill->x && p1->x == in_fill->y) ||
47 + (p2->x == in_fill->x && p2->x == in_fill->y) ||
48 + (! (p2->y < in_fill->y || p1->y > in_fill->y) &&
49 + ! (p1->x > in_fill->x && p2->x > in_fill->x) &&
50 + ! (p1->x < in_fill->x && p2->x < in_fill->x) &&
51 + edge_compare_for_y_against_x (p1, p2, in_fill->y, in_fill->x) == 0))
52 + {
53 + in_fill->on_edge = TRUE;
54 + return;
55 + }
57 /* edge is entirely above or below, note the shortening rule */
58 if (p2->y <= in_fill->y || p1->y > in_fill->y)
59 return;
60 @@ -246,7 +263,9 @@ _cairo_path_fixed_in_fill (cairo_path_fixed_t *path,
62 _cairo_in_fill_close_path (&in_fill);
64 - switch (fill_rule) {
65 + if (in_fill.on_edge) {
66 + *is_inside = TRUE;
67 + } else switch (fill_rule) {
68 case CAIRO_FILL_RULE_EVEN_ODD:
69 *is_inside = in_fill.winding & 1;
70 break;