| 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 {{{{973, 507}, {973, 508.24264526367187}, {972.12158203125, 509.121612548828
12}}}, |
| 62 {{{930, 467}, {973, 510}}}}, |
| 61 {{{{369.848602, 145.680267}, {382.360413, 121.298294}, {406.207703, 121.2982
94}}}, | 63 {{{{369.848602, 145.680267}, {382.360413, 121.298294}, {406.207703, 121.2982
94}}}, |
| 62 {{{406.207703, 121.298294}, {348.781738, 123.864815}}}} | 64 {{{406.207703, 121.298294}, {348.781738, 123.864815}}}} |
| 63 }; | 65 }; |
| 64 | 66 |
| 65 static size_t oneOffs_count = SK_ARRAY_COUNT(oneOffs); | 67 static size_t oneOffs_count = SK_ARRAY_COUNT(oneOffs); |
| 66 | 68 |
| 67 static void testOneOffs(skiatest::Reporter* reporter) { | 69 static void testOneOffs(skiatest::Reporter* reporter) { |
| 68 SkIntersections intersections; | |
| 69 bool flipped = false; | 70 bool flipped = false; |
| 70 for (size_t index = 0; index < oneOffs_count; ++index) { | 71 for (size_t index = 0; index < oneOffs_count; ++index) { |
| 71 const SkDQuad& quad = oneOffs[index].quad; | 72 const SkDQuad& quad = oneOffs[index].quad; |
| 72 const SkDLine& line = oneOffs[index].line; | 73 const SkDLine& line = oneOffs[index].line; |
| 74 SkIntersections intersections; |
| 73 int result = doIntersect(intersections, quad, line, flipped); | 75 int result = doIntersect(intersections, quad, line, flipped); |
| 74 for (int inner = 0; inner < result; ++inner) { | 76 for (int inner = 0; inner < result; ++inner) { |
| 75 double quadT = intersections[0][inner]; | 77 double quadT = intersections[0][inner]; |
| 76 SkDPoint quadXY = quad.xyAtT(quadT); | 78 SkDPoint quadXY = quad.xyAtT(quadT); |
| 77 double lineT = intersections[1][inner]; | 79 double lineT = intersections[1][inner]; |
| 78 SkDPoint lineXY = line.xyAtT(lineT); | 80 SkDPoint lineXY = line.xyAtT(lineT); |
| 79 REPORTER_ASSERT(reporter, quadXY.approximatelyEqual(lineXY)); | 81 REPORTER_ASSERT(reporter, quadXY.approximatelyEqual(lineXY)); |
| 80 } | 82 } |
| 81 } | 83 } |
| 82 } | 84 } |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 122 || !t1.approximatelyEqual(lineQuadTests[index].expected[1]))
) { | 124 || !t1.approximatelyEqual(lineQuadTests[index].expected[1]))
) { |
| 123 SkDebugf("%s t1=(%1.9g,%1.9g)\n", __FUNCTION__, t1.fX, t1.fY); | 125 SkDebugf("%s t1=(%1.9g,%1.9g)\n", __FUNCTION__, t1.fX, t1.fY); |
| 124 REPORTER_ASSERT(reporter, 0); | 126 REPORTER_ASSERT(reporter, 0); |
| 125 } | 127 } |
| 126 } | 128 } |
| 127 } | 129 } |
| 128 } | 130 } |
| 129 | 131 |
| 130 #include "TestClassDef.h" | 132 #include "TestClassDef.h" |
| 131 DEFINE_TESTCLASS_SHORT(PathOpsQuadLineIntersectionTest) | 133 DEFINE_TESTCLASS_SHORT(PathOpsQuadLineIntersectionTest) |
| OLD | NEW |