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

Side by Side Diff: tests/PathOpsCubicLineIntersectionTest.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/PathOpsCubicIntersectionTest.cpp ('k') | tests/PathOpsCubicQuadIntersectionTest.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 "PathOpsTestCommon.h"
7 #include "SkIntersections.h" 8 #include "SkIntersections.h"
8 #include "SkPathOpsCubic.h" 9 #include "SkPathOpsCubic.h"
9 #include "SkPathOpsLine.h" 10 #include "SkPathOpsLine.h"
10 #include "SkReduceOrder.h" 11 #include "SkReduceOrder.h"
11 #include "Test.h" 12 #include "Test.h"
12 13
13 static struct lineCubic { 14 static struct lineCubic {
14 SkDCubic cubic; 15 SkDCubic cubic;
15 SkDLine line; 16 SkDLine line;
16 } lineCubicTests[] = { 17 } lineCubicTests[] = {
17 #if 0 18 #if 0
18 {{{{258, 122}, {260.761414, 122}, { 263, 124.238579}, {263, 127}}}, 19 {{{{258, 122}, {260.761414, 122}, { 263, 124.238579}, {263, 127}}},
19 {{{259.82843, 125.17157}, {261.535522, 123.46447}}}}, 20 {{{259.82843, 125.17157}, {261.535522, 123.46447}}}},
20 #endif 21 #endif
21 {{{{1006.6951293945312,291}, {1023.263671875,291}, {1033.8402099609375,304.4 3145751953125}, 22 {{{{1006.6951293945312,291}, {1023.263671875,291}, {1033.8402099609375,304.4 3145751953125},
22 {1030.318359375,321}}}, 23 {1030.318359375,321}}},
23 {{{979.30487060546875,561}, {1036.695068359375,291}}}}, 24 {{{979.30487060546875,561}, {1036.695068359375,291}}}},
24 {{{{259.30487060546875,561}, {242.73631286621094,561}, {232.15980529785156,5 47.56854248046875}, 25 {{{{259.30487060546875,561}, {242.73631286621094,561}, {232.15980529785156,5 47.56854248046875},
25 {235.68154907226562,531}}}, 26 {235.68154907226562,531}}},
26 {{{286.69512939453125,291}, {229.30485534667969,561}}}}, 27 {{{286.69512939453125,291}, {229.30485534667969,561}}}},
27 {{{{1, 2}, {2, 6}, {2, 0}, {1, 0}}}, {{{1, 0}, {1, 2}}}}, 28 {{{{1, 2}, {2, 6}, {2, 0}, {1, 0}}}, {{{1, 0}, {1, 2}}}},
28 {{{{0, 0}, {0, 1}, {0, 1}, {1, 1}}}, {{{0, 1}, {1, 0}}}}, 29 {{{{0, 0}, {0, 1}, {0, 1}, {1, 1}}}, {{{0, 1}, {1, 0}}}},
29 }; 30 };
30 31
31 static const size_t lineCubicTests_count = SK_ARRAY_COUNT(lineCubicTests); 32 static const size_t lineCubicTests_count = SK_ARRAY_COUNT(lineCubicTests);
32 33
33 static void testOne(skiatest::Reporter* reporter, int iIndex) { 34 static void testOne(skiatest::Reporter* reporter, int iIndex) {
34 const SkDCubic& cubic = lineCubicTests[iIndex].cubic; 35 const SkDCubic& cubic = lineCubicTests[iIndex].cubic;
36 SkASSERT(ValidCubic(cubic));
35 const SkDLine& line = lineCubicTests[iIndex].line; 37 const SkDLine& line = lineCubicTests[iIndex].line;
38 SkASSERT(ValidLine(line));
36 SkReduceOrder reduce1; 39 SkReduceOrder reduce1;
37 SkReduceOrder reduce2; 40 SkReduceOrder reduce2;
38 int order1 = reduce1.reduce(cubic, SkReduceOrder::kNo_Quadratics, 41 int order1 = reduce1.reduce(cubic, SkReduceOrder::kNo_Quadratics,
39 SkReduceOrder::kFill_Style); 42 SkReduceOrder::kFill_Style);
40 int order2 = reduce2.reduce(line); 43 int order2 = reduce2.reduce(line);
41 if (order1 < 4) { 44 if (order1 < 4) {
42 SkDebugf("[%d] cubic order=%d\n", iIndex, order1); 45 SkDebugf("[%d] cubic order=%d\n", iIndex, order1);
43 REPORTER_ASSERT(reporter, 0); 46 REPORTER_ASSERT(reporter, 0);
44 } 47 }
45 if (order2 < 2) { 48 if (order2 < 2) {
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 SkDebugf("{{%1.9g,%1.9g}, {%1.9g,%1.9g}},\n", i.pt(0).fX, i.pt(0).fY, nextL. fX, nextL.fY); 96 SkDebugf("{{%1.9g,%1.9g}, {%1.9g,%1.9g}},\n", i.pt(0).fX, i.pt(0).fY, nextL. fX, nextL.fY);
94 SkDebugf("prevD=%1.9g dist=%1.9g nextD=%1.9g\n", prev.distance(nextL), 97 SkDebugf("prevD=%1.9g dist=%1.9g nextD=%1.9g\n", prev.distance(nextL),
95 sect.distance(i.pt(0)), cubic[3].distance(prevL)); 98 sect.distance(i.pt(0)), cubic[3].distance(prevL));
96 #endif 99 #endif
97 } 100 }
98 101
99 #include "TestClassDef.h" 102 #include "TestClassDef.h"
100 DEFINE_TESTCLASS_SHORT(PathOpsCubicLineIntersectionTest) 103 DEFINE_TESTCLASS_SHORT(PathOpsCubicLineIntersectionTest)
101 104
102 DEFINE_TESTCLASS_SHORT(PathOpsCubicLineIntersectionOneOffTest) 105 DEFINE_TESTCLASS_SHORT(PathOpsCubicLineIntersectionOneOffTest)
OLDNEW
« no previous file with comments | « tests/PathOpsCubicIntersectionTest.cpp ('k') | tests/PathOpsCubicQuadIntersectionTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698