| 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 "SkIntersections.h" | 8 #include "SkIntersections.h" |
| 9 #include "SkPathOpsLine.h" | 9 #include "SkPathOpsLine.h" |
| 10 #include "SkPathOpsQuad.h" | 10 #include "SkPathOpsQuad.h" |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 51 intersections.intersect(quad, line); | 51 intersections.intersect(quad, line); |
| 52 result = intersections.used(); | 52 result = intersections.used(); |
| 53 } | 53 } |
| 54 return result; | 54 return result; |
| 55 } | 55 } |
| 56 | 56 |
| 57 static struct oneLineQuad { | 57 static struct oneLineQuad { |
| 58 SkDQuad quad; | 58 SkDQuad quad; |
| 59 SkDLine line; | 59 SkDLine line; |
| 60 } oneOffs[] = { | 60 } oneOffs[] = { |
| 61 {{{{1101, 10}, {1101, 8.3431453704833984}, {1099.828857421875, 7.17119979858
39844}}}, |
| 62 {{{1099.828857421875,7.1711711883544922}, {1099.121337890625,7.878678321
8383789}}}}, |
| 61 {{{{973, 507}, {973, 508.24264526367187}, {972.12158203125, 509.121612548828
12}}}, | 63 {{{{973, 507}, {973, 508.24264526367187}, {972.12158203125, 509.121612548828
12}}}, |
| 62 {{{930, 467}, {973, 510}}}}, | 64 {{{930, 467}, {973, 510}}}}, |
| 63 {{{{369.848602, 145.680267}, {382.360413, 121.298294}, {406.207703, 121.2982
94}}}, | 65 {{{{369.848602, 145.680267}, {382.360413, 121.298294}, {406.207703, 121.2982
94}}}, |
| 64 {{{406.207703, 121.298294}, {348.781738, 123.864815}}}} | 66 {{{406.207703, 121.298294}, {348.781738, 123.864815}}}}, |
| 65 }; | 67 }; |
| 66 | 68 |
| 67 static size_t oneOffs_count = SK_ARRAY_COUNT(oneOffs); | 69 static size_t oneOffs_count = SK_ARRAY_COUNT(oneOffs); |
| 68 | 70 |
| 69 static void testOneOffs(skiatest::Reporter* reporter) { | 71 static void testOneOffs(skiatest::Reporter* reporter) { |
| 70 bool flipped = false; | 72 bool flipped = false; |
| 71 for (size_t index = 0; index < oneOffs_count; ++index) { | 73 for (size_t index = 0; index < oneOffs_count; ++index) { |
| 72 const SkDQuad& quad = oneOffs[index].quad; | 74 const SkDQuad& quad = oneOffs[index].quad; |
| 73 const SkDLine& line = oneOffs[index].line; | 75 const SkDLine& line = oneOffs[index].line; |
| 74 SkIntersections intersections; | 76 SkIntersections intersections; |
| 75 int result = doIntersect(intersections, quad, line, flipped); | 77 int result = doIntersect(intersections, quad, line, flipped); |
| 76 for (int inner = 0; inner < result; ++inner) { | 78 for (int inner = 0; inner < result; ++inner) { |
| 77 double quadT = intersections[0][inner]; | 79 double quadT = intersections[0][inner]; |
| 78 SkDPoint quadXY = quad.xyAtT(quadT); | 80 SkDPoint quadXY = quad.xyAtT(quadT); |
| 79 double lineT = intersections[1][inner]; | 81 double lineT = intersections[1][inner]; |
| 80 SkDPoint lineXY = line.xyAtT(lineT); | 82 SkDPoint lineXY = line.xyAtT(lineT); |
| 81 REPORTER_ASSERT(reporter, quadXY.approximatelyEqual(lineXY)); | 83 REPORTER_ASSERT(reporter, quadXY.approximatelyEqual(lineXY)); |
| 82 } | 84 } |
| 83 } | 85 } |
| 84 } | 86 } |
| 85 | 87 |
| 88 static void PathOpsQuadLineIntersectionTestOne(skiatest::Reporter* reporter) { |
| 89 testOneOffs(reporter); |
| 90 } |
| 91 |
| 86 static void PathOpsQuadLineIntersectionTest(skiatest::Reporter* reporter) { | 92 static void PathOpsQuadLineIntersectionTest(skiatest::Reporter* reporter) { |
| 87 testOneOffs(reporter); | |
| 88 for (size_t index = 0; index < lineQuadTests_count; ++index) { | 93 for (size_t index = 0; index < lineQuadTests_count; ++index) { |
| 89 int iIndex = static_cast<int>(index); | 94 int iIndex = static_cast<int>(index); |
| 90 const SkDQuad& quad = lineQuadTests[index].quad; | 95 const SkDQuad& quad = lineQuadTests[index].quad; |
| 91 const SkDLine& line = lineQuadTests[index].line; | 96 const SkDLine& line = lineQuadTests[index].line; |
| 92 SkReduceOrder reducer1, reducer2; | 97 SkReduceOrder reducer1, reducer2; |
| 93 int order1 = reducer1.reduce(quad, SkReduceOrder::kFill_Style); | 98 int order1 = reducer1.reduce(quad, SkReduceOrder::kFill_Style); |
| 94 int order2 = reducer2.reduce(line); | 99 int order2 = reducer2.reduce(line); |
| 95 if (order1 < 3) { | 100 if (order1 < 3) { |
| 96 SkDebugf("%s [%d] quad order=%d\n", __FUNCTION__, iIndex, order1); | 101 SkDebugf("%s [%d] quad order=%d\n", __FUNCTION__, iIndex, order1); |
| 97 REPORTER_ASSERT(reporter, 0); | 102 REPORTER_ASSERT(reporter, 0); |
| (...skipping 26 matching lines...) Expand all Loading... |
| 124 || !t1.approximatelyEqual(lineQuadTests[index].expected[1]))
) { | 129 || !t1.approximatelyEqual(lineQuadTests[index].expected[1]))
) { |
| 125 SkDebugf("%s t1=(%1.9g,%1.9g)\n", __FUNCTION__, t1.fX, t1.fY); | 130 SkDebugf("%s t1=(%1.9g,%1.9g)\n", __FUNCTION__, t1.fX, t1.fY); |
| 126 REPORTER_ASSERT(reporter, 0); | 131 REPORTER_ASSERT(reporter, 0); |
| 127 } | 132 } |
| 128 } | 133 } |
| 129 } | 134 } |
| 130 } | 135 } |
| 131 | 136 |
| 132 #include "TestClassDef.h" | 137 #include "TestClassDef.h" |
| 133 DEFINE_TESTCLASS_SHORT(PathOpsQuadLineIntersectionTest) | 138 DEFINE_TESTCLASS_SHORT(PathOpsQuadLineIntersectionTest) |
| 139 |
| 140 DEFINE_TESTCLASS_SHORT(PathOpsQuadLineIntersectionTestOne) |
| OLD | NEW |