Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(6)

Side by Side Diff: tests/PathOpsCubicIntersectionTest.cpp

Issue 19543005: turn off debugging printfs (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: remove unused code Created 7 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « tests/PathOpsAngleTest.cpp ('k') | tests/PathOpsCubicLineIntersectionTest.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "PathOpsCubicIntersectionTestData.h" 7 #include "PathOpsCubicIntersectionTestData.h"
8 #include "PathOpsTestCommon.h" 8 #include "PathOpsTestCommon.h"
9 #include "SkIntersections.h" 9 #include "SkIntersections.h"
10 #include "SkPathOpsRect.h" 10 #include "SkPathOpsRect.h"
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 continue; 45 continue;
46 } 46 }
47 if (tIntersections.isCoincident(0)) { 47 if (tIntersections.isCoincident(0)) {
48 if (showSkipped) { 48 if (showSkipped) {
49 SkDebugf("%s [%d] coincident\n", __FUNCTION__, iIndex); 49 SkDebugf("%s [%d] coincident\n", __FUNCTION__, iIndex);
50 } 50 }
51 continue; 51 continue;
52 } 52 }
53 for (int pt = 0; pt < tIntersections.used(); ++pt) { 53 for (int pt = 0; pt < tIntersections.used(); ++pt) {
54 double tt1 = tIntersections[0][pt]; 54 double tt1 = tIntersections[0][pt];
55 SkDPoint xy1 = cubic1.xyAtT(tt1); 55 SkDPoint xy1 = cubic1.ptAtT(tt1);
56 double tt2 = tIntersections[1][pt]; 56 double tt2 = tIntersections[1][pt];
57 SkDPoint xy2 = cubic2.xyAtT(tt2); 57 SkDPoint xy2 = cubic2.ptAtT(tt2);
58 if (!xy1.approximatelyEqual(xy2)) { 58 if (!xy1.approximatelyEqual(xy2)) {
59 SkDebugf("%s [%d,%d] x!= t1=%g (%g,%g) t2=%g (%g,%g)\n", 59 SkDebugf("%s [%d,%d] x!= t1=%g (%g,%g) t2=%g (%g,%g)\n",
60 __FUNCTION__, (int)index, pt, tt1, xy1.fX, xy1.fY, tt2, xy2. fX, xy2.fY); 60 __FUNCTION__, (int)index, pt, tt1, xy1.fX, xy1.fY, tt2, xy2. fX, xy2.fY);
61 } 61 }
62 REPORTER_ASSERT(reporter, xy1.approximatelyEqual(xy2)); 62 REPORTER_ASSERT(reporter, xy1.approximatelyEqual(xy2));
63 } 63 }
64 } 64 }
65 } 65 }
66 66
67 static const SkDCubic testSet[] = { 67 static const SkDCubic testSet[] = {
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
156 156
157 {{{18.1312339, 31.6473732}, {95.5711034, 63.5350219}, {92.3283165, 62.0158945}, 157 {{{18.1312339, 31.6473732}, {95.5711034, 63.5350219}, {92.3283165, 62.0158945},
158 {18.5656052, 32.1268808}}}, 158 {18.5656052, 32.1268808}}},
159 {{{97.402018, 35.7169972}, {33.1127443, 25.8935163}, {1.13970027, 54.9424981}, 159 {{{97.402018, 35.7169972}, {33.1127443, 25.8935163}, {1.13970027, 54.9424981},
160 {56.4860195, 60.529264}}}, 160 {56.4860195, 60.529264}}},
161 }; 161 };
162 162
163 const size_t testSetCount = SK_ARRAY_COUNT(testSet); 163 const size_t testSetCount = SK_ARRAY_COUNT(testSet);
164 164
165 static const SkDCubic newTestSet[] = { 165 static const SkDCubic newTestSet[] = {
166 {{{3, 4}, {1, 5}, {4, 3}, {6, 4}}},
167 {{{3, 4}, {4, 6}, {4, 3}, {5, 1}}},
168
169 {{{130.04275512695312, 11417.413085937500 },
170 {130.23312377929687, 11418.319335937500 },
171 {131.03707885742187, 11419.000000000000 },
172 {132.00000000000000, 11419.000000000000 }}},
173
174 {{{132.00000000000000, 11419.000000000000 },
175 {130.89543151855469, 11419.000000000000 },
176 {130.00000000000000, 11418.104492187500 },
177 {130.00000000000000, 11417.000000000000 }}},
178
166 {{{1.0516976506771041, 2.9684399028541346 }, 179 {{{1.0516976506771041, 2.9684399028541346 },
167 {1.0604363140895228, 2.9633503074444141 }, 180 {1.0604363140895228, 2.9633503074444141 },
168 {1.0692548215065762, 2.9580354426587459 }, 181 {1.0692548215065762, 2.9580354426587459 },
169 {1.0781560339512140, 2.9525043684031349 }}}, 182 {1.0781560339512140, 2.9525043684031349 }}},
170 183
171 {{{1.0523038101345104, 2.9523755204833737 }, 184 {{{1.0523038101345104, 2.9523755204833737 },
172 {1.0607035288264237, 2.9580853881628375 }, 185 {1.0607035288264237, 2.9580853881628375 },
173 {1.0690530472271964, 2.9633896794787749 }, 186 {1.0690530472271964, 2.9633896794787749 },
174 {1.0773566568712512, 2.9682969775000219 }}}, 187 {1.0773566568712512, 2.9682969775000219 }}},
175 188
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
298 SkDebugf(" {{%1.9g,%1.9g}, {%1.9g,%1.9g}, {%1.9g,%1.9g}},\n", q[0].fX, q[0].fY, 311 SkDebugf(" {{%1.9g,%1.9g}, {%1.9g,%1.9g}, {%1.9g,%1.9g}},\n", q[0].fX, q[0].fY,
299 q[1].fX, q[1].fY, q[2].fX, q[2].fY); 312 q[1].fX, q[1].fY, q[2].fX, q[2].fY);
300 } 313 }
301 #endif 314 #endif
302 SkIntersections intersections; 315 SkIntersections intersections;
303 intersections.intersect(cubic1, cubic2); 316 intersections.intersect(cubic1, cubic2);
304 double tt1, tt2; 317 double tt1, tt2;
305 SkDPoint xy1, xy2; 318 SkDPoint xy1, xy2;
306 for (int pt3 = 0; pt3 < intersections.used(); ++pt3) { 319 for (int pt3 = 0; pt3 < intersections.used(); ++pt3) {
307 tt1 = intersections[0][pt3]; 320 tt1 = intersections[0][pt3];
308 xy1 = cubic1.xyAtT(tt1); 321 xy1 = cubic1.ptAtT(tt1);
309 tt2 = intersections[1][pt3]; 322 tt2 = intersections[1][pt3];
310 xy2 = cubic2.xyAtT(tt2); 323 xy2 = cubic2.ptAtT(tt2);
311 const SkDPoint& iPt = intersections.pt(pt3); 324 const SkDPoint& iPt = intersections.pt(pt3);
312 #if ONE_OFF_DEBUG 325 #if ONE_OFF_DEBUG
313 SkDebugf("%s t1=%1.9g (%1.9g, %1.9g) (%1.9g, %1.9g) (%1.9g, %1.9g) t2=%1 .9g\n", 326 SkDebugf("%s t1=%1.9g (%1.9g, %1.9g) (%1.9g, %1.9g) (%1.9g, %1.9g) t2=%1 .9g\n",
314 __FUNCTION__, tt1, xy1.fX, xy1.fY, iPt.fX, 327 __FUNCTION__, tt1, xy1.fX, xy1.fY, iPt.fX,
315 iPt.fY, xy2.fX, xy2.fY, tt2); 328 iPt.fY, xy2.fX, xy2.fY, tt2);
316 #endif 329 #endif
317 REPORTER_ASSERT(reporter, xy1.approximatelyEqual(iPt)); 330 REPORTER_ASSERT(reporter, xy1.approximatelyEqual(iPt));
318 REPORTER_ASSERT(reporter, xy2.approximatelyEqual(iPt)); 331 REPORTER_ASSERT(reporter, xy2.approximatelyEqual(iPt));
319 REPORTER_ASSERT(reporter, xy1.approximatelyEqual(xy2)); 332 REPORTER_ASSERT(reporter, xy1.approximatelyEqual(xy2));
320 } 333 }
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
384 if (!boundsIntersect && newIntersects) { 397 if (!boundsIntersect && newIntersects) {
385 #if DEBUG_CRASH 398 #if DEBUG_CRASH
386 SkDebugf("%s %d unexpected intersection boundsIntersect=%d " 399 SkDebugf("%s %d unexpected intersection boundsIntersect=%d "
387 " newIntersects=%d\n%s %s\n", __FUNCTION__, test, boundsInte rsect, 400 " newIntersects=%d\n%s %s\n", __FUNCTION__, test, boundsInte rsect,
388 newIntersects, __FUNCTION__, str); 401 newIntersects, __FUNCTION__, str);
389 #endif 402 #endif
390 REPORTER_ASSERT(reporter, 0); 403 REPORTER_ASSERT(reporter, 0);
391 } 404 }
392 for (int pt = 0; pt < intersections2.used(); ++pt) { 405 for (int pt = 0; pt < intersections2.used(); ++pt) {
393 double tt1 = intersections2[0][pt]; 406 double tt1 = intersections2[0][pt];
394 SkDPoint xy1 = cubic1.xyAtT(tt1); 407 SkDPoint xy1 = cubic1.ptAtT(tt1);
395 double tt2 = intersections2[1][pt]; 408 double tt2 = intersections2[1][pt];
396 SkDPoint xy2 = cubic2.xyAtT(tt2); 409 SkDPoint xy2 = cubic2.ptAtT(tt2);
397 REPORTER_ASSERT(reporter, xy1.approximatelyEqual(xy2)); 410 REPORTER_ASSERT(reporter, xy1.approximatelyEqual(xy2));
398 } 411 }
399 } 412 }
400 } 413 }
401 414
402 static void intersectionFinder(int index0, int index1, double t1Seed, double t2S eed, 415 static void intersectionFinder(int index0, int index1, double t1Seed, double t2S eed,
403 double t1Step, double t2Step) { 416 double t1Step, double t2Step) {
404 const SkDCubic& cubic1 = newTestSet[index0]; 417 const SkDCubic& cubic1 = newTestSet[index0];
405 const SkDCubic& cubic2 = newTestSet[index1]; 418 const SkDCubic& cubic2 = newTestSet[index1];
406 SkDPoint t1[3], t2[3]; 419 SkDPoint t1[3], t2[3];
407 bool toggle = true; 420 bool toggle = true;
408 do { 421 do {
409 t1[0] = cubic1.xyAtT(t1Seed - t1Step); 422 t1[0] = cubic1.ptAtT(t1Seed - t1Step);
410 t1[1] = cubic1.xyAtT(t1Seed); 423 t1[1] = cubic1.ptAtT(t1Seed);
411 t1[2] = cubic1.xyAtT(t1Seed + t1Step); 424 t1[2] = cubic1.ptAtT(t1Seed + t1Step);
412 t2[0] = cubic2.xyAtT(t2Seed - t2Step); 425 t2[0] = cubic2.ptAtT(t2Seed - t2Step);
413 t2[1] = cubic2.xyAtT(t2Seed); 426 t2[1] = cubic2.ptAtT(t2Seed);
414 t2[2] = cubic2.xyAtT(t2Seed + t2Step); 427 t2[2] = cubic2.ptAtT(t2Seed + t2Step);
415 double dist[3][3]; 428 double dist[3][3];
416 dist[1][1] = t1[1].distance(t2[1]); 429 dist[1][1] = t1[1].distance(t2[1]);
417 int best_i = 1, best_j = 1; 430 int best_i = 1, best_j = 1;
418 for (int i = 0; i < 3; ++i) { 431 for (int i = 0; i < 3; ++i) {
419 for (int j = 0; j < 3; ++j) { 432 for (int j = 0; j < 3; ++j) {
420 if (i == 1 && j == 1) { 433 if (i == 1 && j == 1) {
421 continue; 434 continue;
422 } 435 }
423 dist[i][j] = t1[i].distance(t2[j]); 436 dist[i][j] = t1[i].distance(t2[j]);
424 if (dist[best_i][best_j] > dist[i][j]) { 437 if (dist[best_i][best_j] > dist[i][j]) {
(...skipping 20 matching lines...) Expand all
445 } 458 }
446 } 459 }
447 } while (!t1[1].approximatelyEqual(t2[1])); 460 } while (!t1[1].approximatelyEqual(t2[1]));
448 t1Step = t2Step = 0.1; 461 t1Step = t2Step = 0.1;
449 double t10 = t1Seed - t1Step * 2; 462 double t10 = t1Seed - t1Step * 2;
450 double t12 = t1Seed + t1Step * 2; 463 double t12 = t1Seed + t1Step * 2;
451 double t20 = t2Seed - t2Step * 2; 464 double t20 = t2Seed - t2Step * 2;
452 double t22 = t2Seed + t2Step * 2; 465 double t22 = t2Seed + t2Step * 2;
453 SkDPoint test; 466 SkDPoint test;
454 while (!approximately_zero(t1Step)) { 467 while (!approximately_zero(t1Step)) {
455 test = cubic1.xyAtT(t10); 468 test = cubic1.ptAtT(t10);
456 t10 += t1[1].approximatelyEqual(test) ? -t1Step : t1Step; 469 t10 += t1[1].approximatelyEqual(test) ? -t1Step : t1Step;
457 t1Step /= 2; 470 t1Step /= 2;
458 } 471 }
459 t1Step = 0.1; 472 t1Step = 0.1;
460 while (!approximately_zero(t1Step)) { 473 while (!approximately_zero(t1Step)) {
461 test = cubic1.xyAtT(t12); 474 test = cubic1.ptAtT(t12);
462 t12 -= t1[1].approximatelyEqual(test) ? -t1Step : t1Step; 475 t12 -= t1[1].approximatelyEqual(test) ? -t1Step : t1Step;
463 t1Step /= 2; 476 t1Step /= 2;
464 } 477 }
465 while (!approximately_zero(t2Step)) { 478 while (!approximately_zero(t2Step)) {
466 test = cubic2.xyAtT(t20); 479 test = cubic2.ptAtT(t20);
467 t20 += t2[1].approximatelyEqual(test) ? -t2Step : t2Step; 480 t20 += t2[1].approximatelyEqual(test) ? -t2Step : t2Step;
468 t2Step /= 2; 481 t2Step /= 2;
469 } 482 }
470 t2Step = 0.1; 483 t2Step = 0.1;
471 while (!approximately_zero(t2Step)) { 484 while (!approximately_zero(t2Step)) {
472 test = cubic2.xyAtT(t22); 485 test = cubic2.ptAtT(t22);
473 t22 -= t2[1].approximatelyEqual(test) ? -t2Step : t2Step; 486 t22 -= t2[1].approximatelyEqual(test) ? -t2Step : t2Step;
474 t2Step /= 2; 487 t2Step /= 2;
475 } 488 }
476 #if ONE_OFF_DEBUG 489 #if ONE_OFF_DEBUG
477 SkDebugf("%s t1=(%1.9g<%1.9g<%1.9g) t2=(%1.9g<%1.9g<%1.9g)\n", __FUNCTION__, 490 SkDebugf("%s t1=(%1.9g<%1.9g<%1.9g) t2=(%1.9g<%1.9g<%1.9g)\n", __FUNCTION__,
478 t10, t1Seed, t12, t20, t2Seed, t22); 491 t10, t1Seed, t12, t20, t2Seed, t22);
479 SkDPoint p10 = cubic1.xyAtT(t10); 492 SkDPoint p10 = cubic1.ptAtT(t10);
480 SkDPoint p1Seed = cubic1.xyAtT(t1Seed); 493 SkDPoint p1Seed = cubic1.ptAtT(t1Seed);
481 SkDPoint p12 = cubic1.xyAtT(t12); 494 SkDPoint p12 = cubic1.ptAtT(t12);
482 SkDebugf("%s p1=(%1.9g,%1.9g)<(%1.9g,%1.9g)<(%1.9g,%1.9g)\n", __FUNCTION__, 495 SkDebugf("%s p1=(%1.9g,%1.9g)<(%1.9g,%1.9g)<(%1.9g,%1.9g)\n", __FUNCTION__,
483 p10.fX, p10.fY, p1Seed.fX, p1Seed.fY, p12.fX, p12.fY); 496 p10.fX, p10.fY, p1Seed.fX, p1Seed.fY, p12.fX, p12.fY);
484 SkDPoint p20 = cubic2.xyAtT(t20); 497 SkDPoint p20 = cubic2.ptAtT(t20);
485 SkDPoint p2Seed = cubic2.xyAtT(t2Seed); 498 SkDPoint p2Seed = cubic2.ptAtT(t2Seed);
486 SkDPoint p22 = cubic2.xyAtT(t22); 499 SkDPoint p22 = cubic2.ptAtT(t22);
487 SkDebugf("%s p2=(%1.9g,%1.9g)<(%1.9g,%1.9g)<(%1.9g,%1.9g)\n", __FUNCTION__, 500 SkDebugf("%s p2=(%1.9g,%1.9g)<(%1.9g,%1.9g)<(%1.9g,%1.9g)\n", __FUNCTION__,
488 p20.fX, p20.fY, p2Seed.fX, p2Seed.fY, p22.fX, p22.fY); 501 p20.fX, p20.fY, p2Seed.fX, p2Seed.fY, p22.fX, p22.fY);
489 #endif 502 #endif
490 } 503 }
491 504
492 static void CubicIntersection_IntersectionFinder() { 505 static void CubicIntersection_IntersectionFinder() {
493 // double t1Seed = 0.87; 506 // double t1Seed = 0.87;
494 // double t2Seed = 0.87; 507 // double t2Seed = 0.87;
495 double t1Step = 0.000001; 508 double t1Step = 0.000001;
496 double t2Step = 0.000001; 509 double t2Step = 0.000001;
497 intersectionFinder(0, 1, 0.855895664, 0.864850875, t1Step, t2Step); 510 intersectionFinder(0, 1, 0.855895664, 0.864850875, t1Step, t2Step);
498 intersectionFinder(0, 1, 0.865207906, 0.865207887, t1Step, t2Step); 511 intersectionFinder(0, 1, 0.865207906, 0.865207887, t1Step, t2Step);
499 intersectionFinder(0, 1, 0.865213351, 0.865208087, t1Step, t2Step); 512 intersectionFinder(0, 1, 0.865213351, 0.865208087, t1Step, t2Step);
500 } 513 }
501 514
515 static const SkDCubic selfSet[] = {
516 {{{2, 3}, {0, 4}, {3, 2}, {5, 3}}},
517 {{{3, 6}, {2, 3}, {4, 0}, {3, 2}}},
518 {{{0, 2}, {2, 3}, {5, 1}, {3, 2}}},
519 {{{0, 2}, {3, 5}, {5, 0}, {4, 2}}},
520 {{{3.34, 8.98}, {1.95, 10.27}, {3.76, 7.65}, {4.96, 10.64}}},
521 {{{3.13, 2.74}, {1.08, 4.62}, {3.71, 0.94}, {2.01, 3.81}}},
522 {{{6.71, 3.14}, {7.99, 2.75}, {8.27, 1.96}, {6.35, 3.57}}},
523 {{{12.81, 7.27}, {7.22, 6.98}, {12.49, 8.97}, {11.42, 6.18}}},
524 };
525 size_t selfSetCount = SK_ARRAY_COUNT(selfSet);
526
527 static void selfOneOff(skiatest::Reporter* reporter, int index) {
528 const SkDCubic& cubic = selfSet[index];
529 #if ONE_OFF_DEBUG
530 int idx2;
531 double max[3];
532 int ts = cubic.findMaxCurvature(max);
533 for (idx2 = 0; idx2 < ts; ++idx2) {
534 SkDebugf("%s max[%d]=%1.9g (%1.9g, %1.9g)\n", __FUNCTION__, idx2,
535 max[idx2], cubic.ptAtT(max[idx2]).fX, cubic.ptAtT(max[idx2]).fY) ;
536 }
537 SkTArray<double, true> ts1;
538 SkTArray<SkDQuad, true> quads1;
539 cubic.toQuadraticTs(cubic.calcPrecision(), &ts1);
540 for (idx2 = 0; idx2 < ts1.count(); ++idx2) {
541 SkDebugf("%s t[%d]=%1.9g\n", __FUNCTION__, idx2, ts1[idx2]);
542 }
543 CubicToQuads(cubic, cubic.calcPrecision(), quads1);
544 for (idx2 = 0; idx2 < quads1.count(); ++idx2) {
545 const SkDQuad& q = quads1[idx2];
546 SkDebugf(" {{{%1.9g,%1.9g}, {%1.9g,%1.9g}, {%1.9g,%1.9g}}},\n",
547 q[0].fX, q[0].fY, q[1].fX, q[1].fY, q[2].fX, q[2].fY);
548 }
549 SkDebugf("\n");
550 #endif
551 SkIntersections i;
552 int result = i.intersect(cubic);
553 REPORTER_ASSERT(reporter, result == 1);
554 REPORTER_ASSERT(reporter, i.used() == 1);
555 REPORTER_ASSERT(reporter, !approximately_equal(i[0][0], i[1][0]));
556 SkDPoint pt1 = cubic.ptAtT(i[0][0]);
557 SkDPoint pt2 = cubic.ptAtT(i[1][0]);
558 REPORTER_ASSERT(reporter, pt1.approximatelyEqual(pt2));
559 }
560
502 static void cubicIntersectionSelfTest(skiatest::Reporter* reporter) { 561 static void cubicIntersectionSelfTest(skiatest::Reporter* reporter) {
503 const SkDCubic selfSet[] = { 562 size_t firstFail = 0;
504 {{{0, 2}, {2, 3}, {5, 1}, {3, 2}}},
505 {{{0, 2}, {3, 5}, {5, 0}, {4, 2}}},
506 {{{3.34, 8.98}, {1.95, 10.27}, {3.76, 7.65}, {4.96, 10.64}}},
507 {{{3.13, 2.74}, {1.08, 4.62}, {3.71, 0.94}, {2.01, 3.81}}},
508 {{{6.71, 3.14}, {7.99, 2.75}, {8.27, 1.96}, {6.35, 3.57}}},
509 {{{12.81, 7.27}, {7.22, 6.98}, {12.49, 8.97}, {11.42, 6.18}}},
510 };
511 size_t selfSetCount = SK_ARRAY_COUNT(selfSet);
512 size_t firstFail = 1;
513 for (size_t index = firstFail; index < selfSetCount; ++index) { 563 for (size_t index = firstFail; index < selfSetCount; ++index) {
514 const SkDCubic& cubic = selfSet[index]; 564 selfOneOff(reporter, index);
515 #if ONE_OFF_DEBUG
516 int idx2;
517 double max[3];
518 int ts = cubic.findMaxCurvature(max);
519 for (idx2 = 0; idx2 < ts; ++idx2) {
520 SkDebugf("%s max[%d]=%1.9g (%1.9g, %1.9g)\n", __FUNCTION__, idx2,
521 max[idx2], cubic.xyAtT(max[idx2]).fX, cubic.xyAtT(max[idx2]) .fY);
522 }
523 SkTArray<double, true> ts1;
524 SkTArray<SkDQuad, true> quads1;
525 cubic.toQuadraticTs(cubic.calcPrecision(), &ts1);
526 for (idx2 = 0; idx2 < ts1.count(); ++idx2) {
527 SkDebugf("%s t[%d]=%1.9g\n", __FUNCTION__, idx2, ts1[idx2]);
528 }
529 CubicToQuads(cubic, cubic.calcPrecision(), quads1);
530 for (idx2 = 0; idx2 < quads1.count(); ++idx2) {
531 const SkDQuad& q = quads1[idx2];
532 SkDebugf(" {{{%1.9g,%1.9g}, {%1.9g,%1.9g}, {%1.9g,%1.9g}}},\n",
533 q[0].fX, q[0].fY, q[1].fX, q[1].fY, q[2].fX, q[2].fY);
534 }
535 SkDebugf("\n");
536 #endif
537 SkIntersections i;
538 int result = i.intersect(cubic);
539 REPORTER_ASSERT(reporter, result == 1);
540 REPORTER_ASSERT(reporter, i.used() == 1);
541 REPORTER_ASSERT(reporter, !approximately_equal(i[0][0], i[1][0]));
542 SkDPoint pt1 = cubic.xyAtT(i[0][0]);
543 SkDPoint pt2 = cubic.xyAtT(i[1][0]);
544 REPORTER_ASSERT(reporter, pt1.approximatelyEqual(pt2));
545 } 565 }
546 } 566 }
547 567
548 static void PathOpsCubicIntersectionOneOffTest(skiatest::Reporter* reporter) { 568 static void PathOpsCubicIntersectionOneOffTest(skiatest::Reporter* reporter) {
549 newOneOff(reporter, 6, 7); 569 newOneOff(reporter, 0, 1);
570 }
571
572 static void PathOpsCubicSelfOneOffTest(skiatest::Reporter* reporter) {
573 selfOneOff(reporter, 0);
550 } 574 }
551 575
552 static void PathOpsCubicIntersectionTest(skiatest::Reporter* reporter) { 576 static void PathOpsCubicIntersectionTest(skiatest::Reporter* reporter) {
553 oneOffTests(reporter); 577 oneOffTests(reporter);
554 cubicIntersectionSelfTest(reporter); 578 cubicIntersectionSelfTest(reporter);
555 standardTestCases(reporter); 579 standardTestCases(reporter);
556 if (false) CubicIntersection_IntersectionFinder(); 580 if (false) CubicIntersection_IntersectionFinder();
557 if (false) CubicIntersection_RandTest(reporter); 581 if (false) CubicIntersection_RandTest(reporter);
558 } 582 }
559 583
560 #include "TestClassDef.h" 584 #include "TestClassDef.h"
561 DEFINE_TESTCLASS_SHORT(PathOpsCubicIntersectionTest) 585 DEFINE_TESTCLASS_SHORT(PathOpsCubicIntersectionTest)
562 586
563 DEFINE_TESTCLASS_SHORT(PathOpsCubicIntersectionOneOffTest) 587 DEFINE_TESTCLASS_SHORT(PathOpsCubicIntersectionOneOffTest)
588
589 DEFINE_TESTCLASS_SHORT(PathOpsCubicSelfOneOffTest)
OLDNEW
« no previous file with comments | « tests/PathOpsAngleTest.cpp ('k') | tests/PathOpsCubicLineIntersectionTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698