OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2015 Google Inc. | 2 * Copyright 2015 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #include "GrAAConvexTessellator.h" | 8 #include "GrAAConvexTessellator.h" |
9 #include "SkCanvas.h" | 9 #include "SkCanvas.h" |
10 #include "SkPath.h" | 10 #include "SkPath.h" |
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
194 // point two of the edges collapse and the process repeats on the new polygon. | 194 // point two of the edges collapse and the process repeats on the new polygon. |
195 // The polygon state is captured in the Ring class while the GrAAConvexTessellat
or | 195 // The polygon state is captured in the Ring class while the GrAAConvexTessellat
or |
196 // controls the iteration. The CandidateVerts holds the formative points for the | 196 // controls the iteration. The CandidateVerts holds the formative points for the |
197 // next ring. | 197 // next ring. |
198 bool GrAAConvexTessellator::tessellate(const SkMatrix& m, const SkPath& path) { | 198 bool GrAAConvexTessellator::tessellate(const SkMatrix& m, const SkPath& path) { |
199 if (!this->extractFromPath(m, path)) { | 199 if (!this->extractFromPath(m, path)) { |
200 return false; | 200 return false; |
201 } | 201 } |
202 | 202 |
203 SkScalar coverage = 1.0f; | 203 SkScalar coverage = 1.0f; |
| 204 SkScalar scaleFactor = 0.0f; |
204 if (fStrokeWidth >= 0.0f) { | 205 if (fStrokeWidth >= 0.0f) { |
| 206 SkASSERT(m.isSimilarity()); |
| 207 scaleFactor = m.getMaxScale(); // x and y scale are the same |
| 208 SkScalar effectiveStrokeWidth = scaleFactor * fStrokeWidth; |
205 Ring outerStrokeRing; | 209 Ring outerStrokeRing; |
206 this->createOuterRing(fInitialRing, fStrokeWidth / 2 - kAntialiasingRadi
us, coverage, | 210 this->createOuterRing(fInitialRing, effectiveStrokeWidth / 2 - kAntialia
singRadius, |
207 &outerStrokeRing); | 211 coverage, &outerStrokeRing); |
208 outerStrokeRing.init(*this); | 212 outerStrokeRing.init(*this); |
209 Ring outerAARing; | 213 Ring outerAARing; |
210 this->createOuterRing(outerStrokeRing, kAntialiasingRadius * 2, 0.0f, &o
uterAARing); | 214 this->createOuterRing(outerStrokeRing, kAntialiasingRadius * 2, 0.0f, &o
uterAARing); |
211 } else { | 215 } else { |
212 Ring outerAARing; | 216 Ring outerAARing; |
213 this->createOuterRing(fInitialRing, kAntialiasingRadius, 0.0f, &outerAAR
ing); | 217 this->createOuterRing(fInitialRing, kAntialiasingRadius, 0.0f, &outerAAR
ing); |
214 } | 218 } |
215 | 219 |
216 // the bisectors are only needed for the computation of the outer ring | 220 // the bisectors are only needed for the computation of the outer ring |
217 fBisectors.rewind(); | 221 fBisectors.rewind(); |
218 if (fStrokeWidth >= 0.0f && fInitialRing.numPts() > 2) { | 222 if (fStrokeWidth >= 0.0f && fInitialRing.numPts() > 2) { |
| 223 SkScalar effectiveStrokeWidth = scaleFactor * fStrokeWidth; |
219 Ring* insetStrokeRing; | 224 Ring* insetStrokeRing; |
220 SkScalar strokeDepth = fStrokeWidth / 2 - kAntialiasingRadius; | 225 SkScalar strokeDepth = effectiveStrokeWidth / 2 - kAntialiasingRadius; |
221 if (this->createInsetRings(fInitialRing, 0.0f, coverage, strokeDepth, co
verage, | 226 if (this->createInsetRings(fInitialRing, 0.0f, coverage, strokeDepth, co
verage, |
222 &insetStrokeRing)) { | 227 &insetStrokeRing)) { |
223 Ring* insetAARing; | 228 Ring* insetAARing; |
224 this->createInsetRings(*insetStrokeRing, strokeDepth, coverage, stro
keDepth + | 229 this->createInsetRings(*insetStrokeRing, strokeDepth, coverage, stro
keDepth + |
225 kAntialiasingRadius * 2, 0.0f, &insetAARing); | 230 kAntialiasingRadius * 2, 0.0f, &insetAARing); |
226 } | 231 } |
227 } else { | 232 } else { |
228 Ring* insetAARing; | 233 Ring* insetAARing; |
229 this->createInsetRings(fInitialRing, 0.0f, 0.5f, kAntialiasingRadius, 1.
0f, &insetAARing); | 234 this->createInsetRings(fInitialRing, 0.0f, 0.5f, kAntialiasingRadius, 1.
0f, &insetAARing); |
230 } | 235 } |
(...skipping 782 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1013 SkString num; | 1018 SkString num; |
1014 num.printf("%d", i); | 1019 num.printf("%d", i); |
1015 canvas->drawText(num.c_str(), num.size(), | 1020 canvas->drawText(num.c_str(), num.size(), |
1016 this->point(i).fX, this->point(i).fY+(kPointRadius/2.0f
), | 1021 this->point(i).fX, this->point(i).fY+(kPointRadius/2.0f
), |
1017 paint); | 1022 paint); |
1018 } | 1023 } |
1019 } | 1024 } |
1020 | 1025 |
1021 #endif | 1026 #endif |
1022 | 1027 |
OLD | NEW |