Rev 1892 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 1892 | Rev 3959 | ||
---|---|---|---|
Line 84... | Line 84... | ||
84 | } |
84 | } |
Line 85... | Line 85... | ||
85 | 85 | ||
86 | void |
86 | void |
87 | _cairo_stroke_style_fini (cairo_stroke_style_t *style) |
87 | _cairo_stroke_style_fini (cairo_stroke_style_t *style) |
88 | { |
- | |
89 | if (style->dash) { |
88 | { |
90 | free (style->dash); |
89 | free (style->dash); |
91 | style->dash = NULL; |
90 | style->dash = NULL; |
92 | } |
91 | |
Line 93... | Line 92... | ||
93 | style->num_dashes = 0; |
92 | style->num_dashes = 0; |
94 | 93 | ||
Line 100... | Line 99... | ||
100 | * from the path that vertices could be generated. In the case |
99 | * from the path that vertices could be generated. In the case |
101 | * of rotation in the ctm, the distance will not be exact. |
100 | * of rotation in the ctm, the distance will not be exact. |
102 | */ |
101 | */ |
103 | void |
102 | void |
104 | _cairo_stroke_style_max_distance_from_path (const cairo_stroke_style_t *style, |
103 | _cairo_stroke_style_max_distance_from_path (const cairo_stroke_style_t *style, |
- | 104 | const cairo_path_fixed_t *path, |
|
105 | const cairo_matrix_t *ctm, |
105 | const cairo_matrix_t *ctm, |
106 | double *dx, double *dy) |
106 | double *dx, double *dy) |
107 | { |
107 | { |
108 | double style_expansion = 0.5; |
108 | double style_expansion = 0.5; |
Line 109... | Line 109... | ||
109 | 109 | ||
110 | if (style->line_cap == CAIRO_LINE_CAP_SQUARE) |
110 | if (style->line_cap == CAIRO_LINE_CAP_SQUARE) |
Line 111... | Line 111... | ||
111 | style_expansion = M_SQRT1_2; |
111 | style_expansion = M_SQRT1_2; |
- | 112 | ||
112 | 113 | if (style->line_join == CAIRO_LINE_JOIN_MITER && |
|
113 | if (style->line_join == CAIRO_LINE_JOIN_MITER && |
114 | ! path->stroke_is_rectilinear && |
114 | style_expansion < M_SQRT2 * style->miter_limit) |
115 | style_expansion < M_SQRT2 * style->miter_limit) |
115 | { |
116 | { |
Line 116... | Line 117... | ||
116 | style_expansion = M_SQRT2 * style->miter_limit; |
117 | style_expansion = M_SQRT2 * style->miter_limit; |
Line -... | Line 118... | ||
- | 118 | } |
|
- | 119 | ||
- | 120 | style_expansion *= style->line_width; |
|
117 | } |
121 | |
118 | 122 | if (_cairo_matrix_has_unity_scale (ctm)) { |
|
119 | style_expansion *= style->line_width; |
123 | *dx = *dy = style_expansion; |
- | 124 | } else { |
|
Line -... | Line 125... | ||
- | 125 | *dx = style_expansion * hypot (ctm->xx, ctm->xy); |
|
- | 126 | *dy = style_expansion * hypot (ctm->yy, ctm->yx); |
|
- | 127 | } |
|
- | 128 | } |
|
- | 129 | ||
- | 130 | void |
|
- | 131 | _cairo_stroke_style_max_line_distance_from_path (const cairo_stroke_style_t *style, |
|
- | 132 | const cairo_path_fixed_t *path, |
|
- | 133 | const cairo_matrix_t *ctm, |
|
- | 134 | double *dx, double *dy) |
|
- | 135 | { |
|
- | 136 | double style_expansion = 0.5 * style->line_width; |
|
- | 137 | if (_cairo_matrix_has_unity_scale (ctm)) { |
|
- | 138 | *dx = *dy = style_expansion; |
|
- | 139 | } else { |
|
- | 140 | *dx = style_expansion * hypot (ctm->xx, ctm->xy); |
|
- | 141 | *dy = style_expansion * hypot (ctm->yy, ctm->yx); |
|
- | 142 | } |
|
- | 143 | } |
|
- | 144 | ||
- | 145 | void |
|
- | 146 | _cairo_stroke_style_max_join_distance_from_path (const cairo_stroke_style_t *style, |
|
- | 147 | const cairo_path_fixed_t *path, |
|
- | 148 | const cairo_matrix_t *ctm, |
|
- | 149 | double *dx, double *dy) |
|
- | 150 | { |
|
- | 151 | double style_expansion = 0.5; |
|
- | 152 | ||
- | 153 | if (style->line_join == CAIRO_LINE_JOIN_MITER && |
|
- | 154 | ! path->stroke_is_rectilinear && |
|
- | 155 | style_expansion < M_SQRT2 * style->miter_limit) |
|
- | 156 | { |
|
- | 157 | style_expansion = M_SQRT2 * style->miter_limit; |
|
- | 158 | } |
|
- | 159 | ||
- | 160 | style_expansion *= style->line_width; |
|
- | 161 | ||
- | 162 | if (_cairo_matrix_has_unity_scale (ctm)) { |
|
- | 163 | *dx = *dy = style_expansion; |
|
120 | 164 | } else { |
|
121 | *dx = style_expansion * hypot (ctm->xx, ctm->xy); |
165 | *dx = style_expansion * hypot (ctm->xx, ctm->xy); |
122 | *dy = style_expansion * hypot (ctm->yy, ctm->yx); |
166 | *dy = style_expansion * hypot (ctm->yy, ctm->yx); |
123 | } |
167 | } |
124 | 168 | } |
|
Line 189... | Line 233... | ||
189 | for (i = 0; i < style->num_dashes; i++) |
233 | for (i = 0; i < style->num_dashes; i++) |
190 | stroked += style->dash[i] + cap_scale * MIN (style->dash[i], style->line_width); |
234 | stroked += style->dash[i] + cap_scale * MIN (style->dash[i], style->line_width); |
191 | } else { |
235 | } else { |
192 | /* Even (0, 2, ...) dashes are on and simply counted for the coverage, odd dashes are off, thus |
236 | /* Even (0, 2, ...) dashes are on and simply counted for the coverage, odd dashes are off, thus |
193 | * their coverage is approximated based on the area covered by the caps of adjacent on dases. */ |
237 | * their coverage is approximated based on the area covered by the caps of adjacent on dases. */ |
194 | for (i = 0; i < style->num_dashes; i+=2) |
238 | for (i = 0; i + 1 < style->num_dashes; i += 2) |
195 | stroked += style->dash[i] + cap_scale * MIN (style->dash[i+1], style->line_width); |
239 | stroked += style->dash[i] + cap_scale * MIN (style->dash[i+1], style->line_width); |
196 | } |
240 | } |
Line 197... | Line 241... | ||
197 | 241 | ||
198 | return stroked; |
242 | return stroked; |