OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2014 Google Inc. | 2 * Copyright 2014 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 "SkIntersections.h" | 8 #include "SkIntersections.h" |
8 #include "SkTDArray.h" | 9 #include "SkTDArray.h" |
9 #include "Test.h" | 10 #include "Test.h" |
10 | 11 |
11 // check intersections for consistency | 12 // check intersections for consistency |
12 | 13 |
13 struct Curve { | 14 struct Curve { |
14 int ptCount; | 15 int ptCount; |
15 SkDCubic curve; // largest can hold lines / quads/ cubics | 16 CubicPts curve; // largest can hold lines / quads/ cubics |
16 }; | 17 }; |
17 | 18 |
18 static const Curve testSet0[] = { // extracted from skpClip2 | 19 static const Curve testSet0[] = { // extracted from skpClip2 |
19 {4, {{{134,11414}, {131.990234,11414}, {130.32666,11415.4824}, {130.042755,1
1417.4131}}} }, | 20 {4, {{{134,11414}, {131.990234,11414}, {130.32666,11415.4824}, {130.042755,1
1417.4131}}} }, |
20 {4, {{{130.042755,11417.4131}, {130.233124,11418.3193}, {131.037079,11419},
{132,11419}}} }, | 21 {4, {{{130.042755,11417.4131}, {130.233124,11418.3193}, {131.037079,11419},
{132,11419}}} }, |
21 {4, {{{132,11419}, {130.895432,11419}, {130,11418.1045}, {130,11417}}} }, | 22 {4, {{{132,11419}, {130.895432,11419}, {130,11418.1045}, {130,11417}}} }, |
22 }; | 23 }; |
23 | 24 |
24 static const Curve testSet1[] = { // extracted from cubicOp85i | 25 static const Curve testSet1[] = { // extracted from cubicOp85i |
25 {4, {{{3,4}, {1,5}, {4,3}, {6,4}}} }, | 26 {4, {{{3,4}, {1,5}, {4,3}, {6,4}}} }, |
(...skipping 16 matching lines...) Expand all Loading... |
42 const TestSet& testSet = testSets[index]; | 43 const TestSet& testSet = testSets[index]; |
43 int testCount = testSet.testCount; | 44 int testCount = testSet.testCount; |
44 SkASSERT(testCount > 1); | 45 SkASSERT(testCount > 1); |
45 SkTDArray<SkIntersections> combos; | 46 SkTDArray<SkIntersections> combos; |
46 for (int outer = 0; outer < testCount - 1; ++outer) { | 47 for (int outer = 0; outer < testCount - 1; ++outer) { |
47 const Curve& oTest = testSet.tests[outer]; | 48 const Curve& oTest = testSet.tests[outer]; |
48 for (int inner = outer + 1; inner < testCount; ++inner) { | 49 for (int inner = outer + 1; inner < testCount; ++inner) { |
49 const Curve& iTest = testSet.tests[inner]; | 50 const Curve& iTest = testSet.tests[inner]; |
50 SkIntersections* i = combos.append(); | 51 SkIntersections* i = combos.append(); |
51 sk_bzero(i, sizeof(SkIntersections)); | 52 sk_bzero(i, sizeof(SkIntersections)); |
52 SkDLine oLine = {{ oTest.curve[0], oTest.curve[1] }}; | 53 SkDLine oLine = {{ oTest.curve.fPts[0], oTest.curve.fPts[1] }}; |
53 SkDLine iLine = {{ iTest.curve[0], iTest.curve[1] }}; | 54 SkDLine iLine = {{ iTest.curve.fPts[0], iTest.curve.fPts[1] }}; |
| 55 SkDCubic iCurve, oCurve; |
| 56 iCurve.debugSet(iTest.curve.fPts); |
| 57 oCurve.debugSet(oTest.curve.fPts); |
54 if (oTest.ptCount == 1 && iTest.ptCount == 1) { | 58 if (oTest.ptCount == 1 && iTest.ptCount == 1) { |
55 i->intersect(oLine, iLine); | 59 i->intersect(oLine, iLine); |
56 } else if (oTest.ptCount == 1 && iTest.ptCount == 4) { | 60 } else if (oTest.ptCount == 1 && iTest.ptCount == 4) { |
57 i->intersect(iTest.curve, oLine); | 61 i->intersect(iCurve, oLine); |
58 } else if (oTest.ptCount == 4 && iTest.ptCount == 1) { | 62 } else if (oTest.ptCount == 4 && iTest.ptCount == 1) { |
59 i->intersect(oTest.curve, iLine); | 63 i->intersect(oCurve, iLine); |
60 } else if (oTest.ptCount == 4 && iTest.ptCount == 4) { | 64 } else if (oTest.ptCount == 4 && iTest.ptCount == 4) { |
61 i->intersect(oTest.curve, iTest.curve); | 65 i->intersect(oCurve, iCurve); |
62 } else { | 66 } else { |
63 SkASSERT(0); | 67 SkASSERT(0); |
64 } | 68 } |
65 // i->dump(); | 69 // i->dump(); |
66 } | 70 } |
67 } | 71 } |
68 } | 72 } |
69 | 73 |
70 DEF_TEST(PathOpsThreeWay, reporter) { | 74 DEF_TEST(PathOpsThreeWay, reporter) { |
71 for (int index = 0; index < testSetsCount; ++index) { | 75 for (int index = 0; index < testSetsCount; ++index) { |
72 testSetTest(reporter, index); | 76 testSetTest(reporter, index); |
73 reporter->bumpTestCount(); | 77 reporter->bumpTestCount(); |
74 } | 78 } |
75 } | 79 } |
76 | 80 |
77 DEF_TEST(PathOpsThreeWayOneOff, reporter) { | 81 DEF_TEST(PathOpsThreeWayOneOff, reporter) { |
78 int index = 0; | 82 int index = 0; |
79 testSetTest(reporter, index); | 83 testSetTest(reporter, index); |
80 } | 84 } |
OLD | NEW |