diff options
author | Vladimir Vukicevic <vladimir@pobox.com> | 2008-02-06 13:01:52 -0800 |
---|---|---|
committer | Vladimir Vukicevic <vladimir@h-232.office.mozilla.org> | 2008-02-06 13:07:13 -0800 |
commit | bf1f7f70b61b5bb657b2531dab63c541ac8fb59d (patch) | |
tree | 4fd061561341162c7ea544c4382f72cbe597969c /src/cairo-stroke-style.c | |
parent | e104fcab1c8c8d9a7a7962a1dbea0c87867c8f9a (diff) | |
download | cairo-bf1f7f70b61b5bb657b2531dab63c541ac8fb59d.tar.gz |
Do correct calculation of pen dimensions for stroke optimization
Diffstat (limited to 'src/cairo-stroke-style.c')
-rw-r--r-- | src/cairo-stroke-style.c | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/src/cairo-stroke-style.c b/src/cairo-stroke-style.c index a7c17b2fd..3bc234e90 100644 --- a/src/cairo-stroke-style.c +++ b/src/cairo-stroke-style.c @@ -84,3 +84,20 @@ _cairo_stroke_style_fini (cairo_stroke_style_t *style) } style->num_dashes = 0; } + +/* + * For a stroke in the given style, compute the maximum distance + * from the path that vertices could be generated. In the case + * of rotation in the ctm, the distance will not be exact. + */ +void +_cairo_stroke_style_max_distance_from_path (const cairo_stroke_style_t *style, + const cairo_matrix_t *ctm, + double *dx, double *dy) +{ + double style_expansion = MAX(style->line_cap == CAIRO_LINE_CAP_SQUARE ? M_SQRT1_2 : 0.5, + style->line_join == CAIRO_LINE_JOIN_MITER ? style->miter_limit : 0.5); + + *dx = style->line_width * style_expansion * (fabs(ctm->xx) + fabs(ctm->xy)); + *dy = style->line_width * style_expansion * (fabs(ctm->yy) + fabs(ctm->yx)); +} |