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>
This commit is contained in:
Chris Wilson 2012-10-31 09:27:52 +00:00
parent 66625cb46c
commit d7f5a1bec4
4 changed files with 32 additions and 28 deletions

View file

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

Binary file not shown.

Before

Width:  |  Height:  |  Size: 502 B

After

Width:  |  Height:  |  Size: 464 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 54 KiB

After

Width:  |  Height:  |  Size: 53 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5 KiB

After

Width:  |  Height:  |  Size: 5 KiB