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

Side by Side Diff: tests/PathOpsCubicToQuadsTest.cpp

Issue 15338003: path ops -- rewrite angle sort (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: Created 7 years, 6 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/PathOpsCubicIntersectionTest.cpp ('k') | tests/PathOpsExtendedTest.h » ('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 15
16 static void test(skiatest::Reporter* reporter, const SkDCubic* cubics, const cha r* name, 16 static void test(skiatest::Reporter* reporter, const SkDCubic* cubics, const cha r* name,
17 int firstTest, size_t testCount) { 17 int firstTest, size_t testCount) {
18 for (size_t index = firstTest; index < testCount; ++index) { 18 for (size_t index = firstTest; index < testCount; ++index) {
19 const SkDCubic& cubic = cubics[index]; 19 const SkDCubic& cubic = cubics[index];
20 double precision = cubic.calcPrecision(); 20 double precision = cubic.calcPrecision();
21 SkTDArray<SkDQuad> quads; 21 SkTDArray<SkDQuad> quads;
22 CubicToQuads(cubic, precision, quads); 22 CubicToQuads(cubic, precision, quads);
23 if (quads.count() != 1) { 23 if (quads.count() != 1 && quads.count() != 2) {
24 SkDebugf("%s [%d] cubic to quadratics failed count=%d\n", name, stat ic_cast<int>(index), 24 SkDebugf("%s [%d] cubic to quadratics failed count=%d\n", name, stat ic_cast<int>(index),
25 quads.count()); 25 quads.count());
26 } 26 }
27 REPORTER_ASSERT(reporter, quads.count() == 1); 27 REPORTER_ASSERT(reporter, quads.count() == 1);
28 } 28 }
29 } 29 }
30 30
31 static void test(skiatest::Reporter* reporter, const SkDQuad* quadTests, const c har* name, 31 static void test(skiatest::Reporter* reporter, const SkDQuad* quadTests, const c har* name,
32 int firstTest, size_t testCount) { 32 int firstTest, size_t testCount) {
33 for (size_t index = firstTest; index < testCount; ++index) { 33 for (size_t index = firstTest; index < testCount; ++index) {
34 const SkDQuad& quad = quadTests[index]; 34 const SkDQuad& quad = quadTests[index];
35 SkDCubic cubic = quad.toCubic(); 35 SkDCubic cubic = quad.toCubic();
36 double precision = cubic.calcPrecision(); 36 double precision = cubic.calcPrecision();
37 SkTDArray<SkDQuad> quads; 37 SkTDArray<SkDQuad> quads;
38 CubicToQuads(cubic, precision, quads); 38 CubicToQuads(cubic, precision, quads);
39 if (quads.count() != 1) { 39 if (quads.count() != 1 && quads.count() != 2) {
40 SkDebugf("%s [%d] cubic to quadratics failed count=%d\n", name, stat ic_cast<int>(index), 40 SkDebugf("%s [%d] cubic to quadratics failed count=%d\n", name, stat ic_cast<int>(index),
41 quads.count()); 41 quads.count());
42 } 42 }
43 REPORTER_ASSERT(reporter, quads.count() == 1); 43 REPORTER_ASSERT(reporter, quads.count() <= 2);
44 } 44 }
45 } 45 }
46 46
47 static void testC(skiatest::Reporter* reporter, const SkDCubic* cubics, const ch ar* name, 47 static void testC(skiatest::Reporter* reporter, const SkDCubic* cubics, const ch ar* name,
48 int firstTest, size_t testCount) { 48 int firstTest, size_t testCount) {
49 // test if computed line end points are valid 49 // test if computed line end points are valid
50 for (size_t index = firstTest; index < testCount; ++index) { 50 for (size_t index = firstTest; index < testCount; ++index) {
51 const SkDCubic& cubic = cubics[index]; 51 const SkDCubic& cubic = cubics[index];
52 double precision = cubic.calcPrecision(); 52 double precision = cubic.calcPrecision();
53 SkTDArray<SkDQuad> quads; 53 SkTDArray<SkDQuad> quads;
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
193 } 193 }
194 194
195 static void PathOpsCubicToQuadsTest(skiatest::Reporter* reporter) { 195 static void PathOpsCubicToQuadsTest(skiatest::Reporter* reporter) {
196 CubicToQuads_Test(reporter); 196 CubicToQuads_Test(reporter);
197 CubicsToQuadratics_OneOffTest(reporter); 197 CubicsToQuadratics_OneOffTest(reporter);
198 CubicsToQuadratics_OneOffTests(reporter); 198 CubicsToQuadratics_OneOffTests(reporter);
199 } 199 }
200 200
201 #include "TestClassDef.h" 201 #include "TestClassDef.h"
202 DEFINE_TESTCLASS_SHORT(PathOpsCubicToQuadsTest) 202 DEFINE_TESTCLASS_SHORT(PathOpsCubicToQuadsTest)
OLDNEW
« no previous file with comments | « tests/PathOpsCubicIntersectionTest.cpp ('k') | tests/PathOpsExtendedTest.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698