diff options
author | Chris Wilson <chris@chris-wilson.co.uk> | 2012-11-01 08:37:01 +0000 |
---|---|---|
committer | Chris Wilson <chris@chris-wilson.co.uk> | 2012-11-01 08:37:01 +0000 |
commit | 03adea2f50aa10d49ff578389927e7b37e265918 (patch) | |
tree | 1c9a5983ec96d9c410eceeaee57f3ae06bdec53c | |
parent | dbc0d83f2a7a0e6658f3b97b5f9921c44ef6a11f (diff) | |
download | cairo-03adea2f50aa10d49ff578389927e7b37e265918.tar.gz |
stroke: Precompute the line half-width
As we regularly recompute stroke->line_width/2 we may as compute it once
during initialisation.
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
-rw-r--r-- | src/cairo-path-stroke.c | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/src/cairo-path-stroke.c b/src/cairo-path-stroke.c index 66ab3bd13..a81e3bc3d 100644 --- a/src/cairo-path-stroke.c +++ b/src/cairo-path-stroke.c @@ -52,6 +52,7 @@ typedef struct cairo_stroker { const cairo_matrix_t *ctm; const cairo_matrix_t *ctm_inverse; + double half_line_width; double tolerance; double ctm_determinant; cairo_bool_t ctm_det_positive; @@ -134,13 +135,13 @@ _cairo_stroker_init (cairo_stroker_t *stroker, stroker->ctm = ctm; stroker->ctm_inverse = ctm_inverse; stroker->tolerance = tolerance; + stroker->half_line_width = stroke_style->line_width / 2.0; stroker->ctm_determinant = _cairo_matrix_compute_determinant (stroker->ctm); stroker->ctm_det_positive = stroker->ctm_determinant >= 0.0; status = _cairo_pen_init (&stroker->pen, - stroke_style->line_width / 2.0, - tolerance, ctm); + stroker->half_line_width, tolerance, ctm); if (unlikely (status)) return status; @@ -637,8 +638,8 @@ _cairo_stroker_add_cap (cairo_stroker_t *stroker, dx = f->usr_vector.x; dy = f->usr_vector.y; - dx *= stroker->style.line_width / 2.0; - dy *= stroker->style.line_width / 2.0; + dx *= stroker->half_line_width; + dy *= stroker->half_line_width; cairo_matrix_transform_distance (stroker->ctm, &dx, &dy); fvector.dx = _cairo_fixed_from_double (dx); fvector.dy = _cairo_fixed_from_double (dy); @@ -776,13 +777,13 @@ _compute_face (const cairo_point_t *point, cairo_slope_t *dev_slope, */ if (stroker->ctm_det_positive) { - face_dx = - slope_dy * (stroker->style.line_width / 2.0); - face_dy = slope_dx * (stroker->style.line_width / 2.0); + face_dx = - slope_dy * stroker->half_line_width; + face_dy = slope_dx * stroker->half_line_width; } else { - face_dx = slope_dy * (stroker->style.line_width / 2.0); - face_dy = - slope_dx * (stroker->style.line_width / 2.0); + face_dx = slope_dy * stroker->half_line_width; + face_dy = - slope_dx * stroker->half_line_width; } /* back to device space */ |