Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(140)

Side by Side Diff: tests/PathOpsQuadLineIntersectionTest.cpp

Issue 19374003: harden and speed up path op unit tests (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: rename threaded to single Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « tests/PathOpsQuadIntersectionTest.cpp ('k') | tests/PathOpsSimplifyDegenerateThreadedTest.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "SkIntersections.h" 9 #include "SkIntersections.h"
9 #include "SkPathOpsLine.h" 10 #include "SkPathOpsLine.h"
10 #include "SkPathOpsQuad.h" 11 #include "SkPathOpsQuad.h"
11 #include "SkReduceOrder.h" 12 #include "SkReduceOrder.h"
12 #include "Test.h" 13 #include "Test.h"
13 14
14 static struct lineQuad { 15 static struct lineQuad {
15 SkDQuad quad; 16 SkDQuad quad;
16 SkDLine line; 17 SkDLine line;
17 int result; 18 int result;
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 {{{{369.848602, 145.680267}, {382.360413, 121.298294}, {406.207703, 121.2982 94}}}, 66 {{{{369.848602, 145.680267}, {382.360413, 121.298294}, {406.207703, 121.2982 94}}},
66 {{{406.207703, 121.298294}, {348.781738, 123.864815}}}}, 67 {{{406.207703, 121.298294}, {348.781738, 123.864815}}}},
67 }; 68 };
68 69
69 static size_t oneOffs_count = SK_ARRAY_COUNT(oneOffs); 70 static size_t oneOffs_count = SK_ARRAY_COUNT(oneOffs);
70 71
71 static void testOneOffs(skiatest::Reporter* reporter) { 72 static void testOneOffs(skiatest::Reporter* reporter) {
72 bool flipped = false; 73 bool flipped = false;
73 for (size_t index = 0; index < oneOffs_count; ++index) { 74 for (size_t index = 0; index < oneOffs_count; ++index) {
74 const SkDQuad& quad = oneOffs[index].quad; 75 const SkDQuad& quad = oneOffs[index].quad;
76 SkASSERT(ValidQuad(quad));
75 const SkDLine& line = oneOffs[index].line; 77 const SkDLine& line = oneOffs[index].line;
78 SkASSERT(ValidLine(line));
76 SkIntersections intersections; 79 SkIntersections intersections;
77 int result = doIntersect(intersections, quad, line, flipped); 80 int result = doIntersect(intersections, quad, line, flipped);
78 for (int inner = 0; inner < result; ++inner) { 81 for (int inner = 0; inner < result; ++inner) {
79 double quadT = intersections[0][inner]; 82 double quadT = intersections[0][inner];
80 SkDPoint quadXY = quad.xyAtT(quadT); 83 SkDPoint quadXY = quad.xyAtT(quadT);
81 double lineT = intersections[1][inner]; 84 double lineT = intersections[1][inner];
82 SkDPoint lineXY = line.xyAtT(lineT); 85 SkDPoint lineXY = line.xyAtT(lineT);
83 REPORTER_ASSERT(reporter, quadXY.approximatelyEqual(lineXY)); 86 REPORTER_ASSERT(reporter, quadXY.approximatelyEqual(lineXY));
84 } 87 }
85 } 88 }
86 } 89 }
87 90
88 static void PathOpsQuadLineIntersectionTestOne(skiatest::Reporter* reporter) { 91 static void PathOpsQuadLineIntersectionTestOne(skiatest::Reporter* reporter) {
89 testOneOffs(reporter); 92 testOneOffs(reporter);
90 } 93 }
91 94
92 static void PathOpsQuadLineIntersectionTest(skiatest::Reporter* reporter) { 95 static void PathOpsQuadLineIntersectionTest(skiatest::Reporter* reporter) {
93 for (size_t index = 0; index < lineQuadTests_count; ++index) { 96 for (size_t index = 0; index < lineQuadTests_count; ++index) {
94 int iIndex = static_cast<int>(index); 97 int iIndex = static_cast<int>(index);
95 const SkDQuad& quad = lineQuadTests[index].quad; 98 const SkDQuad& quad = lineQuadTests[index].quad;
99 SkASSERT(ValidQuad(quad));
96 const SkDLine& line = lineQuadTests[index].line; 100 const SkDLine& line = lineQuadTests[index].line;
101 SkASSERT(ValidLine(line));
97 SkReduceOrder reducer1, reducer2; 102 SkReduceOrder reducer1, reducer2;
98 int order1 = reducer1.reduce(quad, SkReduceOrder::kFill_Style); 103 int order1 = reducer1.reduce(quad, SkReduceOrder::kFill_Style);
99 int order2 = reducer2.reduce(line); 104 int order2 = reducer2.reduce(line);
100 if (order1 < 3) { 105 if (order1 < 3) {
101 SkDebugf("%s [%d] quad order=%d\n", __FUNCTION__, iIndex, order1); 106 SkDebugf("%s [%d] quad order=%d\n", __FUNCTION__, iIndex, order1);
102 REPORTER_ASSERT(reporter, 0); 107 REPORTER_ASSERT(reporter, 0);
103 } 108 }
104 if (order2 < 2) { 109 if (order2 < 2) {
105 SkDebugf("%s [%d] line order=%d\n", __FUNCTION__, iIndex, order2); 110 SkDebugf("%s [%d] line order=%d\n", __FUNCTION__, iIndex, order2);
106 REPORTER_ASSERT(reporter, 0); 111 REPORTER_ASSERT(reporter, 0);
(...skipping 24 matching lines...) Expand all
131 REPORTER_ASSERT(reporter, 0); 136 REPORTER_ASSERT(reporter, 0);
132 } 137 }
133 } 138 }
134 } 139 }
135 } 140 }
136 141
137 #include "TestClassDef.h" 142 #include "TestClassDef.h"
138 DEFINE_TESTCLASS_SHORT(PathOpsQuadLineIntersectionTest) 143 DEFINE_TESTCLASS_SHORT(PathOpsQuadLineIntersectionTest)
139 144
140 DEFINE_TESTCLASS_SHORT(PathOpsQuadLineIntersectionTestOne) 145 DEFINE_TESTCLASS_SHORT(PathOpsQuadLineIntersectionTestOne)
OLDNEW
« no previous file with comments | « tests/PathOpsQuadIntersectionTest.cpp ('k') | tests/PathOpsSimplifyDegenerateThreadedTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698