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

Side by Side Diff: tests/PathOpsCubicLineIntersectionTest.cpp

Issue 131103009: update pathops to circle sort (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: disable old test that still fails on linux 32 release Created 6 years, 8 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
« 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 "PathOpsTestCommon.h"
8 #include "SkIntersections.h" 8 #include "SkIntersections.h"
9 #include "SkPathOpsCubic.h" 9 #include "SkPathOpsCubic.h"
10 #include "SkPathOpsLine.h" 10 #include "SkPathOpsLine.h"
11 #include "SkReduceOrder.h" 11 #include "SkReduceOrder.h"
12 #include "Test.h" 12 #include "Test.h"
13 13
14 static struct lineCubic { 14 static struct lineCubic {
15 SkDCubic cubic; 15 SkDCubic cubic;
16 SkDLine line; 16 SkDLine line;
17 } lineCubicTests[] = { 17 } lineCubicTests[] = {
18 {{{{421, 378}, {421, 380.209137f}, {418.761414f, 382}, {416, 382}}},
19 {{{320, 378}, {421, 378.000031f}}}},
20
21 {{{{416, 383}, {418.761414f, 383}, {421, 380.761414f}, {421, 378}}},
22 {{{320, 378}, {421, 378.000031f}}}},
23
18 {{{{154,715}, {151.238571,715}, {149,712.761414}, {149,710}}}, 24 {{{{154,715}, {151.238571,715}, {149,712.761414}, {149,710}}},
19 {{{149,675}, {149,710.001465}}}}, 25 {{{149,675}, {149,710.001465}}}},
20 26
21 {{{{0,1}, {1,6}, {4,1}, {4,3}}}, 27 {{{{0,1}, {1,6}, {4,1}, {4,3}}},
22 {{{6,1}, {1,4}}}}, 28 {{{6,1}, {1,4}}}},
23 29
24 {{{{0,1}, {2,6}, {4,1}, {5,4}}}, 30 {{{{0,1}, {2,6}, {4,1}, {5,4}}},
25 {{{6,2}, {1,4}}}}, 31 {{{6,2}, {1,4}}}},
26 32
27 {{{{0,4}, {3,4}, {6,2}, {5,2}}}, 33 {{{{0,4}, {3,4}, {6,2}, {5,2}}},
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 double tt1 = i[0][pt]; 72 double tt1 = i[0][pt];
67 SkDPoint xy1 = cubic.ptAtT(tt1); 73 SkDPoint xy1 = cubic.ptAtT(tt1);
68 double tt2 = i[1][pt]; 74 double tt2 = i[1][pt];
69 SkDPoint xy2 = line.ptAtT(tt2); 75 SkDPoint xy2 = line.ptAtT(tt2);
70 if (!xy1.approximatelyEqual(xy2)) { 76 if (!xy1.approximatelyEqual(xy2)) {
71 SkDebugf("%s [%d,%d] x!= t1=%g (%g,%g) t2=%g (%g,%g)\n", 77 SkDebugf("%s [%d,%d] x!= t1=%g (%g,%g) t2=%g (%g,%g)\n",
72 __FUNCTION__, iIndex, pt, tt1, xy1.fX, xy1.fY, tt2, xy2.fX, xy2.fY); 78 __FUNCTION__, iIndex, pt, tt1, xy1.fX, xy1.fY, tt2, xy2.fX, xy2.fY);
73 } 79 }
74 REPORTER_ASSERT(reporter, xy1.approximatelyEqual(xy2)); 80 REPORTER_ASSERT(reporter, xy1.approximatelyEqual(xy2));
75 } 81 }
82 #if ONE_OFF_DEBUG
83 double cubicT = i[0][0];
84 SkDPoint prev = cubic.ptAtT(cubicT * 2 - 1);
85 SkDPoint sect = cubic.ptAtT(cubicT);
86 double left[3] = { line.isLeft(prev), line.isLeft(sect), line.isLeft(cub ic[3]) };
87 SkDebugf("cubic=(%1.9g, %1.9g, %1.9g)\n", left[0], left[1], left[2]);
88 SkDebugf("{{%1.9g,%1.9g}, {%1.9g,%1.9g}},\n", prev.fX, prev.fY, sect.fX, sect.fY);
89 SkDebugf("{{%1.9g,%1.9g}, {%1.9g,%1.9g}},\n", sect.fX, sect.fY, cubic[3] .fX, cubic[3].fY);
90 SkDPoint prevL = line.ptAtT(i[1][0] - 0.0000007);
91 SkDebugf("{{%1.9g,%1.9g}, {%1.9g,%1.9g}},\n", prevL.fX, prevL.fY, i.pt(0 ).fX, i.pt(0).fY);
92 SkDPoint nextL = line.ptAtT(i[1][0] + 0.0000007);
93 SkDebugf("{{%1.9g,%1.9g}, {%1.9g,%1.9g}},\n", i.pt(0).fX, i.pt(0).fY, ne xtL.fX, nextL.fY);
94 SkDebugf("prevD=%1.9g dist=%1.9g nextD=%1.9g\n", prev.distance(nextL),
95 sect.distance(i.pt(0)), cubic[3].distance(prevL));
96 #endif
76 } 97 }
77 } 98 }
78 99
79 DEF_TEST(PathOpsCubicLineIntersection, reporter) { 100 DEF_TEST(PathOpsCubicLineIntersection, reporter) {
80 for (size_t index = 0; index < lineCubicTests_count; ++index) { 101 for (size_t index = 0; index < lineCubicTests_count; ++index) {
81 int iIndex = static_cast<int>(index); 102 int iIndex = static_cast<int>(index);
82 testOne(reporter, iIndex); 103 testOne(reporter, iIndex);
83 reporter->bumpTestCount(); 104 reporter->bumpTestCount();
84 } 105 }
85 } 106 }
86 107
87 DEF_TEST(PathOpsCubicLineIntersectionOneOff, reporter) { 108 DEF_TEST(PathOpsCubicLineIntersectionOneOff, reporter) {
88 int iIndex = 0; 109 int iIndex = 0;
89 testOne(reporter, iIndex); 110 testOne(reporter, iIndex);
90 const SkDCubic& cubic = lineCubicTests[iIndex].cubic; 111 const SkDCubic& cubic = lineCubicTests[iIndex].cubic;
91 const SkDLine& line = lineCubicTests[iIndex].line; 112 const SkDLine& line = lineCubicTests[iIndex].line;
92 SkIntersections i; 113 SkIntersections i;
93 i.intersect(cubic, line); 114 i.intersect(cubic, line);
94 SkASSERT(i.used() == 1); 115 SkASSERT(i.used() == 1);
95 #if ONE_OFF_DEBUG
96 double cubicT = i[0][0];
97 SkDPoint prev = cubic.ptAtT(cubicT * 2 - 1);
98 SkDPoint sect = cubic.ptAtT(cubicT);
99 double left[3] = { line.isLeft(prev), line.isLeft(sect), line.isLeft(cubic[3 ]) };
100 SkDebugf("cubic=(%1.9g, %1.9g, %1.9g)\n", left[0], left[1], left[2]);
101 SkDebugf("{{%1.9g,%1.9g}, {%1.9g,%1.9g}},\n", prev.fX, prev.fY, sect.fX, sec t.fY);
102 SkDebugf("{{%1.9g,%1.9g}, {%1.9g,%1.9g}},\n", sect.fX, sect.fY, cubic[3].fX, cubic[3].fY);
103 SkDPoint prevL = line.ptAtT(i[1][0] - 0.0000007);
104 SkDebugf("{{%1.9g,%1.9g}, {%1.9g,%1.9g}},\n", prevL.fX, prevL.fY, i.pt(0).fX , i.pt(0).fY);
105 SkDPoint nextL = line.ptAtT(i[1][0] + 0.0000007);
106 SkDebugf("{{%1.9g,%1.9g}, {%1.9g,%1.9g}},\n", i.pt(0).fX, i.pt(0).fY, nextL. fX, nextL.fY);
107 SkDebugf("prevD=%1.9g dist=%1.9g nextD=%1.9g\n", prev.distance(nextL),
108 sect.distance(i.pt(0)), cubic[3].distance(prevL));
109 #endif
110 } 116 }
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