OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2012 Google Inc. | 2 * Copyright 2012 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 #include "SkGeometry.h" | 7 #include "SkGeometry.h" |
8 #include "SkOpEdgeBuilder.h" | 8 #include "SkOpEdgeBuilder.h" |
9 #include "SkReduceOrder.h" | 9 #include "SkReduceOrder.h" |
10 | 10 |
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
192 case SkPath::kLine_Verb: | 192 case SkPath::kLine_Verb: |
193 fCurrentContour->addLine(pointsPtr, fAllocator); | 193 fCurrentContour->addLine(pointsPtr, fAllocator); |
194 break; | 194 break; |
195 case SkPath::kQuad_Verb: | 195 case SkPath::kQuad_Verb: |
196 fCurrentContour->addQuad(pointsPtr, fAllocator); | 196 fCurrentContour->addQuad(pointsPtr, fAllocator); |
197 break; | 197 break; |
198 case SkPath::kConic_Verb: | 198 case SkPath::kConic_Verb: |
199 fCurrentContour->addConic(pointsPtr, *weightPtr++, fAllocator); | 199 fCurrentContour->addConic(pointsPtr, *weightPtr++, fAllocator); |
200 break; | 200 break; |
201 case SkPath::kCubic_Verb: { | 201 case SkPath::kCubic_Verb: { |
202 // split self-intersecting cubics in two before proceeding | 202 // Split complex cubics (such as self-intersecting curves or |
203 // if the cubic is convex, it doesn't self intersect. | 203 // ones with difficult curvature) in two before proceeding. |
204 SkScalar loopT; | 204 // This can be required for intersection to succeed. |
205 if (SkDCubic::ComplexBreak(pointsPtr, &loopT)) { | 205 SkScalar splitT; |
206 SkPoint cubicPair[7]; | 206 if (SkDCubic::ComplexBreak(pointsPtr, &splitT)) { |
207 SkChopCubicAt(pointsPtr, cubicPair, loopT); | 207 SkPoint cubicPair[7]; |
| 208 SkChopCubicAt(pointsPtr, cubicPair, splitT); |
208 if (!SkScalarsAreFinite(&cubicPair[0].fX, SK_ARRAY_COUNT(cub
icPair) * 2)) { | 209 if (!SkScalarsAreFinite(&cubicPair[0].fX, SK_ARRAY_COUNT(cub
icPair) * 2)) { |
209 return false; | 210 return false; |
210 } | 211 } |
211 SkPoint cStorage[2][4]; | 212 SkPoint cStorage[2][4]; |
212 SkPath::Verb v1 = SkReduceOrder::Cubic(&cubicPair[0], cStora
ge[0]); | 213 SkPath::Verb v1 = SkReduceOrder::Cubic(&cubicPair[0], cStora
ge[0]); |
213 SkPath::Verb v2 = SkReduceOrder::Cubic(&cubicPair[3], cStora
ge[1]); | 214 SkPath::Verb v2 = SkReduceOrder::Cubic(&cubicPair[3], cStora
ge[1]); |
214 if (v1 != SkPath::kMove_Verb && v2 != SkPath::kMove_Verb) { | 215 if (v1 != SkPath::kMove_Verb && v2 != SkPath::kMove_Verb) { |
215 SkPoint* curve1 = v1 == SkPath::kCubic_Verb ? &cubicPair
[0] : cStorage[0]; | 216 SkPoint* curve1 = v1 == SkPath::kCubic_Verb ? &cubicPair
[0] : cStorage[0]; |
216 SkPoint* curve2 = v2 == SkPath::kCubic_Verb ? &cubicPair
[3] : cStorage[1]; | 217 SkPoint* curve2 = v2 == SkPath::kCubic_Verb ? &cubicPair
[3] : cStorage[1]; |
217 for (int index = 0; index < SkPathOpsVerbToPoints(v1); +
+index) { | 218 for (int index = 0; index < SkPathOpsVerbToPoints(v1); +
+index) { |
(...skipping 23 matching lines...) Expand all Loading... |
241 } | 242 } |
242 SkASSERT(fCurrentContour); | 243 SkASSERT(fCurrentContour); |
243 fCurrentContour->debugValidate(); | 244 fCurrentContour->debugValidate(); |
244 pointsPtr += SkPathOpsVerbToPoints(verb); | 245 pointsPtr += SkPathOpsVerbToPoints(verb); |
245 } | 246 } |
246 if (fCurrentContour && fCurrentContour->count() &&!fAllowOpenContours && !clo
se()) { | 247 if (fCurrentContour && fCurrentContour->count() &&!fAllowOpenContours && !clo
se()) { |
247 return false; | 248 return false; |
248 } | 249 } |
249 return true; | 250 return true; |
250 } | 251 } |
OLD | NEW |