summaryrefslogtreecommitdiff
path: root/src/cairo-path-stroke-polygon.c
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2012-03-09 14:06:58 +0000
committerChris Wilson <chris@chris-wilson.co.uk>2012-03-10 10:46:50 +0000
commitf7d4653c1b945c93d394541e5c32397c90c2c139 (patch)
tree1b642685bf807692f527df09842eaf22d02169d2 /src/cairo-path-stroke-polygon.c
parent5ff689c01771165d26cc272d65e01dfb1a1fd57e (diff)
downloadcairo-f7d4653c1b945c93d394541e5c32397c90c2c139.tar.gz
stroke: Do not initialise the pen if will not use it
The pen is only used for ensuring that we generate consist vertices around a fan used for end-capping or line-joining when set to ROUND. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Diffstat (limited to 'src/cairo-path-stroke-polygon.c')
-rw-r--r--src/cairo-path-stroke-polygon.c30
1 files changed, 19 insertions, 11 deletions
diff --git a/src/cairo-path-stroke-polygon.c b/src/cairo-path-stroke-polygon.c
index 5d121fac8..7978af027 100644
--- a/src/cairo-path-stroke-polygon.c
+++ b/src/cairo-path-stroke-polygon.c
@@ -163,6 +163,8 @@ add_fan (struct stroker *stroker,
{
int start, stop, step, i, npoints;
+ assert (stroker->pen.num_vertices);
+
if (clockwise) {
step = 1;
@@ -1357,16 +1359,21 @@ _cairo_path_fixed_stroke_to_polygon (const cairo_path_fixed_t *path,
stroker.ctm_det_positive =
_cairo_matrix_compute_determinant (ctm) >= 0.0;
- status = _cairo_pen_init (&stroker.pen,
- style->line_width / 2.0,
- tolerance, ctm);
- if (unlikely (status))
- return status;
-
- /* If the line width is so small that the pen is reduced to a
- single point, then we have nothing to do. */
- if (stroker.pen.num_vertices <= 1)
- return CAIRO_STATUS_SUCCESS;
+ stroker.pen.num_vertices = 0;
+ if (path->has_curve_to ||
+ style->line_join == CAIRO_LINE_JOIN_ROUND ||
+ style->line_cap == CAIRO_LINE_CAP_ROUND) {
+ status = _cairo_pen_init (&stroker.pen,
+ style->line_width / 2.0,
+ tolerance, ctm);
+ if (unlikely (status))
+ return status;
+
+ /* If the line width is so small that the pen is reduced to a
+ single point, then we have nothing to do. */
+ if (stroker.pen.num_vertices <= 1)
+ return CAIRO_STATUS_SUCCESS;
+ }
stroker.has_current_face = FALSE;
stroker.has_first_face = FALSE;
@@ -1396,7 +1403,8 @@ _cairo_path_fixed_stroke_to_polygon (const cairo_path_fixed_t *path,
_cairo_contour_fini (&stroker.cw.contour);
_cairo_contour_fini (&stroker.ccw.contour);
- _cairo_pen_fini (&stroker.pen);
+ if (stroker.pen.num_vertices)
+ _cairo_pen_fini (&stroker.pen);
#if DEBUG
{