OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2015 Google Inc. | 2 * Copyright 2015 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 "SkPathOpsConic.h" | 9 #include "SkPathOpsConic.h" |
10 #include "SkPathOpsCubic.h" | 10 #include "SkPathOpsCubic.h" |
11 #include "SkReduceOrder.h" | 11 #include "SkReduceOrder.h" |
12 #include "Test.h" | 12 #include "Test.h" |
13 | 13 |
14 static struct cubicConic { | 14 static struct cubicConic { |
15 SkDCubic cubic; | 15 CubicPts cubic; |
16 SkDConic conic; | 16 ConicPts conic; |
17 } cubicConicTests[] = { | 17 } cubicConicTests[] = { |
18 {{{{188.60000610351562, 2041.5999755859375}, {188.60000610351562, 2065.39990
234375}, | 18 {{{{188.60000610351562, 2041.5999755859375}, {188.60000610351562, 2065.39990
234375}, |
19 {208, 2084.800048828125}, {231.80000305175781, 2084.800048828125}}}, | 19 {208, 2084.800048828125}, {231.80000305175781, 2084.800048828125}}}, |
20 {{{{231.80000305175781, 2084.800048828125}, {188.60000610351562, 2084.800048
828125}, | 20 {{{{231.80000305175781, 2084.800048828125}, {188.60000610351562, 2084.800048
828125}, |
21 {188.60000610351562, 2041.5999755859375}}}, 0.707107008f}}, | 21 {188.60000610351562, 2041.5999755859375}}}, 0.707107008f}}, |
22 | 22 |
23 {{{{231.80000305175781, 2084.800048828125}, {255.60000610351562, 2084.800048
828125}, | 23 {{{{231.80000305175781, 2084.800048828125}, {255.60000610351562, 2084.800048
828125}, |
24 {275, 2065.39990234375}, {275, 2041.5999755859375}}}, | 24 {275, 2065.39990234375}, {275, 2041.5999755859375}}}, |
25 {{{{275, 2041.5999755859375}, {275, 2084.800048828125}, | 25 {{{{275, 2041.5999755859375}, {275, 2084.800048828125}, |
26 {231.80000305175781, 2084.800048828125}}}, 0.707107008f}}, | 26 {231.80000305175781, 2084.800048828125}}}, 0.707107008f}}, |
27 }; | 27 }; |
28 | 28 |
29 static const int cubicConicTests_count = (int) SK_ARRAY_COUNT(cubicConicTests); | 29 static const int cubicConicTests_count = (int) SK_ARRAY_COUNT(cubicConicTests); |
30 | 30 |
31 static void cubicConicIntersection(skiatest::Reporter* reporter, int index) { | 31 static void cubicConicIntersection(skiatest::Reporter* reporter, int index) { |
32 const SkDCubic& cubic = cubicConicTests[index].cubic; | 32 const CubicPts& cu = cubicConicTests[index].cubic; |
| 33 SkDCubic cubic; |
| 34 cubic.debugSet(cu.fPts); |
33 SkASSERT(ValidCubic(cubic)); | 35 SkASSERT(ValidCubic(cubic)); |
34 const SkDConic& conic = cubicConicTests[index].conic; | 36 const ConicPts& co = cubicConicTests[index].conic; |
| 37 SkDConic conic; |
| 38 conic.debugSet(co.fPts.fPts, co.fWeight); |
35 SkASSERT(ValidConic(conic)); | 39 SkASSERT(ValidConic(conic)); |
36 SkReduceOrder reduce1; | 40 SkReduceOrder reduce1; |
37 SkReduceOrder reduce2; | 41 SkReduceOrder reduce2; |
38 int order1 = reduce1.reduce(cubic, SkReduceOrder::kNo_Quadratics); | 42 int order1 = reduce1.reduce(cubic, SkReduceOrder::kNo_Quadratics); |
39 int order2 = reduce2.reduce(conic.fPts); | 43 int order2 = reduce2.reduce(conic.fPts); |
40 if (order1 != 4) { | 44 if (order1 != 4) { |
41 SkDebugf("[%d] cubic order=%d\n", index, order1); | 45 SkDebugf("[%d] cubic order=%d\n", index, order1); |
42 REPORTER_ASSERT(reporter, 0); | 46 REPORTER_ASSERT(reporter, 0); |
43 } | 47 } |
44 if (order2 != 3) { | 48 if (order2 != 3) { |
(...skipping 19 matching lines...) Expand all Loading... |
64 DEF_TEST(PathOpsCubicConicIntersection, reporter) { | 68 DEF_TEST(PathOpsCubicConicIntersection, reporter) { |
65 for (int index = 0; index < cubicConicTests_count; ++index) { | 69 for (int index = 0; index < cubicConicTests_count; ++index) { |
66 cubicConicIntersection(reporter, index); | 70 cubicConicIntersection(reporter, index); |
67 reporter->bumpTestCount(); | 71 reporter->bumpTestCount(); |
68 } | 72 } |
69 } | 73 } |
70 | 74 |
71 DEF_TEST(PathOpsCubicConicIntersectionOneOff, reporter) { | 75 DEF_TEST(PathOpsCubicConicIntersectionOneOff, reporter) { |
72 cubicConicIntersection(reporter, 1); | 76 cubicConicIntersection(reporter, 1); |
73 } | 77 } |
OLD | NEW |