| OLD | NEW |
| 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 "PathOpsExtendedTest.h" | 7 #include "PathOpsExtendedTest.h" |
| 8 #include "PathOpsTestCommon.h" | 8 #include "PathOpsTestCommon.h" |
| 9 #include "SkIntersections.h" | 9 #include "SkIntersections.h" |
| 10 #include "SkPathOpsConic.h" | 10 #include "SkPathOpsConic.h" |
| 11 #include "SkPathOpsLine.h" | 11 #include "SkPathOpsLine.h" |
| 12 #include "SkReduceOrder.h" | 12 #include "SkReduceOrder.h" |
| 13 #include "Test.h" | 13 #include "Test.h" |
| 14 | 14 |
| 15 static struct lineConic { | 15 static struct lineConic { |
| 16 SkDConic conic; | 16 SkDConic conic; |
| 17 SkDLine line; | 17 SkDLine line; |
| 18 int result; | 18 int result; |
| 19 SkDPoint expected[2]; | 19 SkDPoint expected[2]; |
| 20 } lineConicTests[] = { | 20 } lineConicTests[] = { |
| 21 { | 21 { |
| 22 {{{{30.6499996,25.6499996}, {30.6499996,20.6499996}, {25.6499996,20.6499996
}}}, 0.707107008f}, | 22 {{{{30.6499996,25.6499996}, {30.6499996,20.6499996}, {25.6499996,20.6499996
}}}, 0.707107008f}, |
| 23 {{{25.6499996,20.6499996}, {45.6500015,20.6499996}}}, | 23 {{{25.6499996,20.6499996}, {45.6500015,20.6499996}}}, |
| 24 1, | 24 1, |
| 25 {{25.6499996,20.6499996}, {0,0}} | 25 {{25.6499996,20.6499996}, {0,0}} |
| 26 }, | 26 }, |
| 27 }; | 27 }; |
| 28 | 28 |
| 29 static size_t lineConicTests_count = SK_ARRAY_COUNT(lineConicTests); | 29 static size_t lineConicTests_count = SK_ARRAY_COUNT(lineConicTests); |
| 30 | 30 |
| 31 static int doIntersect(SkIntersections& intersections, const SkDConic& conic, co
nst SkDLine& line, | 31 static int doIntersect(SkIntersections& intersections, const SkDConic& conic, co
nst SkDLine& line, |
| 32 bool& flipped) { | 32 bool& flipped) { |
| 33 int result; | 33 int result; |
| 34 flipped = false; | 34 flipped = false; |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 93 } | 93 } |
| 94 | 94 |
| 95 DEF_TEST(PathOpsConicLineIntersection, reporter) { | 95 DEF_TEST(PathOpsConicLineIntersection, reporter) { |
| 96 for (size_t index = 0; index < lineConicTests_count; ++index) { | 96 for (size_t index = 0; index < lineConicTests_count; ++index) { |
| 97 int iIndex = static_cast<int>(index); | 97 int iIndex = static_cast<int>(index); |
| 98 const SkDConic& conic = lineConicTests[index].conic; | 98 const SkDConic& conic = lineConicTests[index].conic; |
| 99 SkASSERT(ValidConic(conic)); | 99 SkASSERT(ValidConic(conic)); |
| 100 const SkDLine& line = lineConicTests[index].line; | 100 const SkDLine& line = lineConicTests[index].line; |
| 101 SkASSERT(ValidLine(line)); | 101 SkASSERT(ValidLine(line)); |
| 102 SkReduceOrder reducer; | 102 SkReduceOrder reducer; |
| 103 SkPoint pts[3] = { conic.fPts.fPts[0].asSkPoint(), conic.fPts.fPts[1].as
SkPoint(), | 103 SkPoint pts[3] = { conic.fPts.fPts[0].asSkPoint(), conic.fPts.fPts[1].as
SkPoint(), |
| 104 conic.fPts.fPts[2].asSkPoint() }; | 104 conic.fPts.fPts[2].asSkPoint() }; |
| 105 SkPoint reduced[3]; | 105 SkPoint reduced[3]; |
| 106 SkPath::Verb order1 = SkReduceOrder::Conic(pts, conic.fWeight, reduced); | 106 SkPath::Verb order1 = SkReduceOrder::Conic(pts, conic.fWeight, reduced); |
| 107 if (order1 != SkPath::kConic_Verb) { | 107 if (order1 != SkPath::kConic_Verb) { |
| 108 SkDebugf("%s [%d] conic verb=%d\n", __FUNCTION__, iIndex, order1); | 108 SkDebugf("%s [%d] conic verb=%d\n", __FUNCTION__, iIndex, order1); |
| 109 REPORTER_ASSERT(reporter, 0); | 109 REPORTER_ASSERT(reporter, 0); |
| 110 } | 110 } |
| 111 int order2 = reducer.reduce(line); | 111 int order2 = reducer.reduce(line); |
| 112 if (order2 < 2) { | 112 if (order2 < 2) { |
| 113 SkDebugf("%s [%d] line order=%d\n", __FUNCTION__, iIndex, order2); | 113 SkDebugf("%s [%d] line order=%d\n", __FUNCTION__, iIndex, order2); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 134 } | 134 } |
| 135 if (!t1.approximatelyEqual(lineConicTests[index].expected[0]) | 135 if (!t1.approximatelyEqual(lineConicTests[index].expected[0]) |
| 136 && (lineConicTests[index].result == 1 | 136 && (lineConicTests[index].result == 1 |
| 137 || !t1.approximatelyEqual(lineConicTests[index].expected[1])
)) { | 137 || !t1.approximatelyEqual(lineConicTests[index].expected[1])
)) { |
| 138 SkDebugf("%s t1=(%1.9g,%1.9g)\n", __FUNCTION__, t1.fX, t1.fY); | 138 SkDebugf("%s t1=(%1.9g,%1.9g)\n", __FUNCTION__, t1.fX, t1.fY); |
| 139 REPORTER_ASSERT(reporter, 0); | 139 REPORTER_ASSERT(reporter, 0); |
| 140 } | 140 } |
| 141 } | 141 } |
| 142 } | 142 } |
| 143 } | 143 } |
| OLD | NEW |