OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2013 Google Inc. | 2 * Copyright 2013 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 "PathOpsTestCommon.h" |
7 #include "SkOpSegment.h" | 8 #include "SkOpSegment.h" |
8 #include "SkTArray.h" | 9 #include "SkTArray.h" |
9 #include "Test.h" | 10 #include "Test.h" |
10 | 11 |
11 static const SkPoint cubics[][4] = { | 12 static const SkPoint cubics[][4] = { |
12 /* 0 */ {{0, 1}, {2, 6}, {4, 2}, {5, 3}}, | 13 /* 0 */ {{0, 1}, {2, 6}, {4, 2}, {5, 3}}, |
13 /* 1 */ {{10, 234}, {10, 229.581726f}, {13.5817204f, 226}, {18, 226}}, | 14 /* 1 */ {{10, 234}, {10, 229.581726f}, {13.5817204f, 226}, {18, 226}}, |
14 /* 2 */ {{132, 11419}, {130.89543151855469f, 11419}, {130, 11418.1044921875f}
, {130, 11417}}, | 15 /* 2 */ {{132, 11419}, {130.89543151855469f, 11419}, {130, 11418.1044921875f}
, {130, 11417}}, |
15 /* 3 */ {{130.04275512695312f, 11417.4130859375f}, {130.23307800292969f, 1141
8.3193359375f}, | 16 /* 3 */ {{130.04275512695312f, 11417.4130859375f}, {130.23307800292969f, 1141
8.3193359375f}, |
16 {131.03709411621094f, 11419}, {132, 11419}}, | 17 {131.03709411621094f, 11419}, {132, 11419}}, |
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
241 SkOpSegment* seg, int* ts, const SkPoint& startPt) { | 242 SkOpSegment* seg, int* ts, const SkPoint& startPt) { |
242 SkPoint start, end; | 243 SkPoint start, end; |
243 const SkPoint* data = set[idx].ptData; | 244 const SkPoint* data = set[idx].ptData; |
244 bool useIntersectPt = startPt.fX != 0 || startPt.fY != 0; | 245 bool useIntersectPt = startPt.fX != 0 || startPt.fY != 0; |
245 if (useIntersectPt) { | 246 if (useIntersectPt) { |
246 start = startPt; | 247 start = startPt; |
247 end = set[idx].endPt; | 248 end = set[idx].endPt; |
248 } | 249 } |
249 switch(set[idx].ptCount) { | 250 switch(set[idx].ptCount) { |
250 case 2: { | 251 case 2: { |
| 252 SkASSERT(ValidPoints(data, 2)); |
251 seg->addLine(data, false, false); | 253 seg->addLine(data, false, false); |
252 SkDLine dLine; | 254 SkDLine dLine; |
253 dLine.set(set[idx].ptData); | 255 dLine.set(set[idx].ptData); |
| 256 SkASSERT(ValidLine(dLine)); |
254 if (useIntersectPt) { | 257 if (useIntersectPt) { |
255 break; | 258 break; |
256 } | 259 } |
257 start = dLine.xyAtT(set[idx].tStart).asSkPoint(); | 260 start = dLine.xyAtT(set[idx].tStart).asSkPoint(); |
258 end = dLine.xyAtT(set[idx].tEnd).asSkPoint(); | 261 end = dLine.xyAtT(set[idx].tEnd).asSkPoint(); |
259 } break; | 262 } break; |
260 case 3: { | 263 case 3: { |
| 264 SkASSERT(ValidPoints(data, 3)); |
261 seg->addQuad(data, false, false); | 265 seg->addQuad(data, false, false); |
262 SkDQuad dQuad; | 266 SkDQuad dQuad; |
263 dQuad.set(set[idx].ptData); | 267 dQuad.set(set[idx].ptData); |
| 268 SkASSERT(ValidQuad(dQuad)); |
264 if (useIntersectPt) { | 269 if (useIntersectPt) { |
265 break; | 270 break; |
266 } | 271 } |
267 start = dQuad.xyAtT(set[idx].tStart).asSkPoint(); | 272 start = dQuad.xyAtT(set[idx].tStart).asSkPoint(); |
268 end = dQuad.xyAtT(set[idx].tEnd).asSkPoint(); | 273 end = dQuad.xyAtT(set[idx].tEnd).asSkPoint(); |
269 } break; | 274 } break; |
270 case 4: { | 275 case 4: { |
| 276 SkASSERT(ValidPoints(data, 4)); |
271 seg->addCubic(data, false, false); | 277 seg->addCubic(data, false, false); |
272 SkDCubic dCubic; | 278 SkDCubic dCubic; |
273 dCubic.set(set[idx].ptData); | 279 dCubic.set(set[idx].ptData); |
| 280 SkASSERT(ValidCubic(dCubic)); |
274 if (useIntersectPt) { | 281 if (useIntersectPt) { |
275 break; | 282 break; |
276 } | 283 } |
277 start = dCubic.xyAtT(set[idx].tStart).asSkPoint(); | 284 start = dCubic.xyAtT(set[idx].tStart).asSkPoint(); |
278 end = dCubic.xyAtT(set[idx].tEnd).asSkPoint(); | 285 end = dCubic.xyAtT(set[idx].tEnd).asSkPoint(); |
279 } break; | 286 } break; |
280 } | 287 } |
281 double tStart = set[idx].tStart; | 288 double tStart = set[idx].tStart; |
282 double tEnd = set[idx].tEnd; | 289 double tEnd = set[idx].tEnd; |
283 seg->addT(NULL, start, tStart); | 290 seg->addT(NULL, start, tStart); |
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
462 } | 469 } |
463 } | 470 } |
464 #endif | 471 #endif |
465 | 472 |
466 #include "TestClassDef.h" | 473 #include "TestClassDef.h" |
467 DEFINE_TESTCLASS_SHORT(PathOpsAngleTest) | 474 DEFINE_TESTCLASS_SHORT(PathOpsAngleTest) |
468 | 475 |
469 DEFINE_TESTCLASS_SHORT(PathOpsAngleTestOne) | 476 DEFINE_TESTCLASS_SHORT(PathOpsAngleTestOne) |
470 | 477 |
471 // DEFINE_TESTCLASS_SHORT(PathOpsAngleFindSlop) | 478 // DEFINE_TESTCLASS_SHORT(PathOpsAngleFindSlop) |
OLD | NEW |