gfx/cairo/on-edge.patch

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

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

mercurial