diff options
author | Chris Wilson <chris@chris-wilson.co.uk> | 2012-10-31 09:27:52 +0000 |
---|---|---|
committer | Chris Wilson <chris@chris-wilson.co.uk> | 2012-10-31 09:27:52 +0000 |
commit | d7f5a1bec421d6c7b92d16daae681fa31ac7c212 (patch) | |
tree | 70f6f4b7bd7040ac32f6c4dfa8b51943f05b0730 | |
parent | 66625cb46c985321c46b79d2163a4d676d6700ba (diff) | |
download | cairo-d7f5a1bec421d6c7b92d16daae681fa31ac7c212.tar.gz |
pen: First check whether the in/out edges lie within the single pen vertex
In order to prevent underflow when searching for the closing pen vertex,
we first need to be sure that it does not simply lie next to the opening
pen vertex. As a result we were missing many cases that should have been
a bevel (in == out) and generating almost complete round caps instead.
Reported-by: Dominik Röttsches <dominik.rottsches@intel.com>
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=56432
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
-rw-r--r-- | src/cairo-pen.c | 60 | ||||
-rw-r--r-- | test/reference/arc-looping-dash.ref.png | bin | 502 -> 464 bytes | |||
-rw-r--r-- | test/reference/caps-tails-curve.ref.png | bin | 54750 -> 54314 bytes | |||
-rw-r--r-- | test/reference/reflected-stroke.ref.png | bin | 5139 -> 5116 bytes |
4 files changed, 32 insertions, 28 deletions
diff --git a/src/cairo-pen.c b/src/cairo-pen.c index ea9e36a5e..b4b643c28 100644 --- a/src/cairo-pen.c +++ b/src/cairo-pen.c @@ -412,21 +412,23 @@ _cairo_pen_find_active_cw_vertices (const cairo_pen_t *pen, i = 0; *start = i; - lo = i; - hi = i + pen->num_vertices; - i = (lo + hi) >> 1; - do { - int j = i; - if (j >= pen->num_vertices) - j -= pen->num_vertices; - if (_cairo_slope_compare (&pen->vertices[j].slope_cw, out) > 0) - hi = i; - else - lo = i; + if (_cairo_slope_compare (out, &pen->vertices[i].slope_ccw) > 0) { + lo = i; + hi = i + pen->num_vertices; i = (lo + hi) >> 1; - } while (hi - lo > 1); - if (i >= pen->num_vertices) - i -= pen->num_vertices; + do { + int j = i; + if (j >= pen->num_vertices) + j -= pen->num_vertices; + if (_cairo_slope_compare (&pen->vertices[j].slope_cw, out) > 0) + hi = i; + else + lo = i; + i = (lo + hi) >> 1; + } while (hi - lo > 1); + if (i >= pen->num_vertices) + i -= pen->num_vertices; + } *stop = i; } @@ -452,20 +454,22 @@ _cairo_pen_find_active_ccw_vertices (const cairo_pen_t *pen, i = 0; *start = i; - lo = i; - hi = i + pen->num_vertices; - i = (lo + hi) >> 1; - do { - int j = i; - if (j >= pen->num_vertices) - j -= pen->num_vertices; - if (_cairo_slope_compare (out, &pen->vertices[j].slope_ccw) > 0) - hi = i; - else - lo = i; + if (_cairo_slope_compare (&pen->vertices[i].slope_cw, out) < 0) { + lo = i; + hi = i + pen->num_vertices; i = (lo + hi) >> 1; - } while (hi - lo > 1); - if (i >= pen->num_vertices) - i -= pen->num_vertices; + do { + int j = i; + if (j >= pen->num_vertices) + j -= pen->num_vertices; + if (_cairo_slope_compare (out, &pen->vertices[j].slope_ccw) > 0) + hi = i; + else + lo = i; + i = (lo + hi) >> 1; + } while (hi - lo > 1); + if (i >= pen->num_vertices) + i -= pen->num_vertices; + } *stop = i; } diff --git a/test/reference/arc-looping-dash.ref.png b/test/reference/arc-looping-dash.ref.png Binary files differindex 6d0c5cf15..516e66ce0 100644 --- a/test/reference/arc-looping-dash.ref.png +++ b/test/reference/arc-looping-dash.ref.png diff --git a/test/reference/caps-tails-curve.ref.png b/test/reference/caps-tails-curve.ref.png Binary files differindex f23d5dc2b..ac97c82aa 100644 --- a/test/reference/caps-tails-curve.ref.png +++ b/test/reference/caps-tails-curve.ref.png diff --git a/test/reference/reflected-stroke.ref.png b/test/reference/reflected-stroke.ref.png Binary files differindex 131880639..c05eb96f6 100644 --- a/test/reference/reflected-stroke.ref.png +++ b/test/reference/reflected-stroke.ref.png |