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 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 self-intersecting cubics in two before proceeding |
203 // if the cubic is convex, it doesn't self intersect. | 203 // if the cubic is convex, it doesn't self intersect. |
204 SkScalar loopT; | 204 SkScalar loopT; |
205 if (SkDCubic::ComplexBreak(pointsPtr, &loopT)) { | 205 SkDCubic::CubicType cubicType; |
| 206 if (SkDCubic::ComplexBreak(pointsPtr, &loopT, &cubicType)) { |
206 SkPoint cubicPair[7]; | 207 SkPoint cubicPair[7]; |
207 SkChopCubicAt(pointsPtr, cubicPair, loopT); | 208 SkChopCubicAt(pointsPtr, cubicPair, loopT); |
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) { |
218 force_small_to_zero(&curve1[index]); | 219 force_small_to_zero(&curve1[index]); |
219 } | 220 } |
220 for (int index = 0; index < SkPathOpsVerbToPoints(v2); +
+index) { | 221 for (int index = 0; index < SkPathOpsVerbToPoints(v2); +
+index) { |
221 force_small_to_zero(&curve2[index]); | 222 force_small_to_zero(&curve2[index]); |
222 } | 223 } |
223 fCurrentContour->addCurve(v1, curve1, fAllocator); | 224 fCurrentContour->addCurve(v1, curve1, fAllocator)->setCu
bicType(cubicType); |
224 fCurrentContour->addCurve(v2, curve2, fAllocator); | 225 fCurrentContour->addCurve(v2, curve2, fAllocator)->setCu
bicType(cubicType); |
225 } else { | 226 } else { |
226 fCurrentContour->addCubic(pointsPtr, fAllocator); | 227 fCurrentContour->addCubic(pointsPtr, fAllocator); |
227 } | 228 } |
228 } else { | 229 } else { |
229 fCurrentContour->addCubic(pointsPtr, fAllocator); | 230 fCurrentContour->addCubic(pointsPtr, fAllocator); |
230 } | 231 } |
231 } break; | 232 } break; |
232 case SkPath::kClose_Verb: | 233 case SkPath::kClose_Verb: |
233 SkASSERT(fCurrentContour); | 234 SkASSERT(fCurrentContour); |
234 if (!close()) { | 235 if (!close()) { |
235 return false; | 236 return false; |
236 } | 237 } |
237 continue; | 238 continue; |
238 default: | 239 default: |
239 SkDEBUGFAIL("bad verb"); | 240 SkDEBUGFAIL("bad verb"); |
240 return false; | 241 return false; |
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 |