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 "PathOpsTestCommon.h" |
8 #include "SkIntersections.h" | 8 #include "SkIntersections.h" |
9 #include "SkPathOpsCubic.h" | 9 #include "SkPathOpsCubic.h" |
10 #include "SkPathOpsQuad.h" | 10 #include "SkPathOpsQuad.h" |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
45 } | 45 } |
46 if (order2 != 3) { | 46 if (order2 != 3) { |
47 SkDebugf("[%d] quad order=%d\n", iIndex, order2); | 47 SkDebugf("[%d] quad order=%d\n", iIndex, order2); |
48 REPORTER_ASSERT(reporter, 0); | 48 REPORTER_ASSERT(reporter, 0); |
49 } | 49 } |
50 SkIntersections i; | 50 SkIntersections i; |
51 int roots = i.intersect(cubic, quad); | 51 int roots = i.intersect(cubic, quad); |
52 SkASSERT(roots == quadCubicTests[index].answerCount); | 52 SkASSERT(roots == quadCubicTests[index].answerCount); |
53 for (int pt = 0; pt < roots; ++pt) { | 53 for (int pt = 0; pt < roots; ++pt) { |
54 double tt1 = i[0][pt]; | 54 double tt1 = i[0][pt]; |
55 SkDPoint xy1 = cubic.xyAtT(tt1); | 55 SkDPoint xy1 = cubic.ptAtT(tt1); |
56 double tt2 = i[1][pt]; | 56 double tt2 = i[1][pt]; |
57 SkDPoint xy2 = quad.xyAtT(tt2); | 57 SkDPoint xy2 = quad.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__, iIndex, pt, tt1, xy1.fX, xy1.fY, tt2, xy2.fX,
xy2.fY); | 60 __FUNCTION__, iIndex, 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 bool found = false; | 63 bool found = false; |
64 for (int idx2 = 0; idx2 < quadCubicTests[index].answerCount; ++idx2)
{ | 64 for (int idx2 = 0; idx2 < quadCubicTests[index].answerCount; ++idx2)
{ |
65 found |= quadCubicTests[index].answers[idx2].approximatelyEqual(
xy1); | 65 found |= quadCubicTests[index].answers[idx2].approximatelyEqual(
xy1); |
66 } | 66 } |
67 REPORTER_ASSERT(reporter, found); | 67 REPORTER_ASSERT(reporter, found); |
68 } | 68 } |
69 reporter->bumpTestCount(); | 69 reporter->bumpTestCount(); |
70 } | 70 } |
71 } | 71 } |
72 | 72 |
73 #include "TestClassDef.h" | 73 #include "TestClassDef.h" |
74 DEFINE_TESTCLASS_SHORT(PathOpsCubicQuadIntersectionTest) | 74 DEFINE_TESTCLASS_SHORT(PathOpsCubicQuadIntersectionTest) |
OLD | NEW |