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

Side by Side Diff: tests/PathOpsCubicToQuadsTest.cpp

Issue 117863005: Get rid of DEFINE_TESTCLASS_SHORT() macro. (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Mike review Created 6 years, 11 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/PathOpsCubicReduceOrderTest.cpp ('k') | tests/PathOpsDCubicTest.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 "PathOpsCubicIntersectionTestData.h" 7 #include "PathOpsCubicIntersectionTestData.h"
8 #include "PathOpsQuadIntersectionTestData.h" 8 #include "PathOpsQuadIntersectionTestData.h"
9 #include "PathOpsTestCommon.h" 9 #include "PathOpsTestCommon.h"
10 #include "SkGeometry.h" 10 #include "SkGeometry.h"
11 #include "SkIntersections.h" 11 #include "SkIntersections.h"
12 #include "SkPathOpsRect.h" 12 #include "SkPathOpsRect.h"
13 #include "SkReduceOrder.h" 13 #include "SkReduceOrder.h"
14 #include "Test.h" 14 #include "Test.h"
15 #include "TestClassDef.h"
15 16
16 static void test(skiatest::Reporter* reporter, const SkDCubic* cubics, const cha r* name, 17 static void test(skiatest::Reporter* reporter, const SkDCubic* cubics, const cha r* name,
17 int firstTest, size_t testCount) { 18 int firstTest, size_t testCount) {
18 for (size_t index = firstTest; index < testCount; ++index) { 19 for (size_t index = firstTest; index < testCount; ++index) {
19 const SkDCubic& cubic = cubics[index]; 20 const SkDCubic& cubic = cubics[index];
20 SkASSERT(ValidCubic(cubic)); 21 SkASSERT(ValidCubic(cubic));
21 double precision = cubic.calcPrecision(); 22 double precision = cubic.calcPrecision();
22 SkTArray<SkDQuad, true> quads; 23 SkTArray<SkDQuad, true> quads;
23 CubicToQuads(cubic, precision, quads); 24 CubicToQuads(cubic, precision, quads);
24 if (quads.count() != 1 && quads.count() != 2) { 25 if (quads.count() != 1 && quads.count() != 2) {
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 int last = quads.count() - 1; 87 int last = quads.count() - 1;
87 if (!AlmostEqualUlps(cubic[3].fX, quads[last][2].fX) 88 if (!AlmostEqualUlps(cubic[3].fX, quads[last][2].fX)
88 || !AlmostEqualUlps(cubic[3].fY, quads[last][2].fY)) { 89 || !AlmostEqualUlps(cubic[3].fY, quads[last][2].fY)) {
89 SkDebugf("[%d][%d] unmatched end\n", static_cast<int>(index), id x2); 90 SkDebugf("[%d][%d] unmatched end\n", static_cast<int>(index), id x2);
90 REPORTER_ASSERT(reporter, 0); 91 REPORTER_ASSERT(reporter, 0);
91 } 92 }
92 } 93 }
93 } 94 }
94 } 95 }
95 96
96 static void CubicToQuads_Test(skiatest::Reporter* reporter) { 97 DEF_TEST(CubicToQuads, reporter) {
97 enum { 98 enum {
98 RunAll, 99 RunAll,
99 RunPointDegenerates, 100 RunPointDegenerates,
100 RunNotPointDegenerates, 101 RunNotPointDegenerates,
101 RunLines, 102 RunLines,
102 RunNotLines, 103 RunNotLines,
103 RunModEpsilonLines, 104 RunModEpsilonLines,
104 RunLessEpsilonLines, 105 RunLessEpsilonLines,
105 RunNegEpsilonLines, 106 RunNegEpsilonLines,
106 RunQuadraticLines, 107 RunQuadraticLines,
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
180 {static_cast<float>(cubic[3].fX), static_cast<float>(cubic[3].fY)}}; 181 {static_cast<float>(cubic[3].fX), static_cast<float>(cubic[3].fY)}};
181 SkScalar skinflect[2]; 182 SkScalar skinflect[2];
182 int skin = SkFindCubicInflections(skcubic, skinflect); 183 int skin = SkFindCubicInflections(skcubic, skinflect);
183 if (false) SkDebugf("%s %d %1.9g\n", __FUNCTION__, skin, skinflect[0]); 184 if (false) SkDebugf("%s %d %1.9g\n", __FUNCTION__, skin, skinflect[0]);
184 SkTArray<SkDQuad, true> quads; 185 SkTArray<SkDQuad, true> quads;
185 double precision = cubic.calcPrecision(); 186 double precision = cubic.calcPrecision();
186 CubicToQuads(cubic, precision, quads); 187 CubicToQuads(cubic, precision, quads);
187 if (false) SkDebugf("%s quads=%d\n", __FUNCTION__, quads.count()); 188 if (false) SkDebugf("%s quads=%d\n", __FUNCTION__, quads.count());
188 } 189 }
189 190
190 static void CubicsToQuadratics_OneOffTests(skiatest::Reporter* reporter) { 191 DEF_TEST(CubicsToQuadratics_OneOff_Loop, reporter) {
191 for (size_t x = 0; x < localsCount; ++x) { 192 for (size_t x = 0; x < localsCount; ++x) {
192 oneOff(reporter, x); 193 oneOff(reporter, x);
193 } 194 }
194 } 195 }
195 196
196 static void CubicsToQuadratics_OneOffTest(skiatest::Reporter* reporter) { 197 DEF_TEST(CubicsToQuadratics_OneOff_Single, reporter) {
197 oneOff(reporter, 0); 198 oneOff(reporter, 0);
198 } 199 }
199
200 static void PathOpsCubicToQuadsTest(skiatest::Reporter* reporter) {
201 CubicToQuads_Test(reporter);
202 CubicsToQuadratics_OneOffTest(reporter);
203 CubicsToQuadratics_OneOffTests(reporter);
204 }
205
206 #include "TestClassDef.h"
207 DEFINE_TESTCLASS_SHORT(PathOpsCubicToQuadsTest)
OLDNEW
« no previous file with comments | « tests/PathOpsCubicReduceOrderTest.cpp ('k') | tests/PathOpsDCubicTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698