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

Side by Side Diff: tests/PathOpsAngleTest.cpp

Issue 2426173002: fix fuzzers (Closed)
Patch Set: fix dm Created 4 years, 1 month 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/PathOpsAngleIdeas.cpp ('k') | tests/PathOpsConicIntersectionTest.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 2013 Google Inc. 2 * Copyright 2013 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 "SkOpContour.h" 9 #include "SkOpContour.h"
10 #include "SkOpSegment.h" 10 #include "SkOpSegment.h"
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 for (int index = 0; index < 100000; ++index) { 74 for (int index = 0; index < 100000; ++index) {
75 SkDLine line = {{{0, 0}, {ran.nextRangeF(0.0001f, 1000), ran.nextRangeF( 0.0001f, 1000)}}}; 75 SkDLine line = {{{0, 0}, {ran.nextRangeF(0.0001f, 1000), ran.nextRangeF( 0.0001f, 1000)}}};
76 float t = ran.nextRangeF(0.0001f, 1); 76 float t = ran.nextRangeF(0.0001f, 1);
77 SkDPoint dPt = line.ptAtT(t); 77 SkDPoint dPt = line.ptAtT(t);
78 float t2 = ran.nextRangeF(0.0001f, 1); 78 float t2 = ran.nextRangeF(0.0001f, 1);
79 SkDPoint qPt = line.ptAtT(t2); 79 SkDPoint qPt = line.ptAtT(t2);
80 float t3 = ran.nextRangeF(0.0001f, 1); 80 float t3 = ran.nextRangeF(0.0001f, 1);
81 SkDPoint qPt2 = line.ptAtT(t3); 81 SkDPoint qPt2 = line.ptAtT(t3);
82 qPt.fX += qPt2.fY; 82 qPt.fX += qPt2.fY;
83 qPt.fY -= qPt2.fX; 83 qPt.fY -= qPt2.fX;
84 SkDQuad quad = {{line[0], dPt, qPt}}; 84 QuadPts q = {{line[0], dPt, qPt}};
85 SkDQuad quad;
86 quad.debugSet(q.fPts);
85 // binary search for maximum movement of quad[1] towards test that still has 1 intersection 87 // binary search for maximum movement of quad[1] towards test that still has 1 intersection
86 double moveT = 0.5f; 88 double moveT = 0.5f;
87 double deltaT = moveT / 2; 89 double deltaT = moveT / 2;
88 SkDPoint last; 90 SkDPoint last;
89 do { 91 do {
90 last = quad[1]; 92 last = quad[1];
91 quad[1].fX = dPt.fX - line[1].fY * moveT; 93 quad[1].fX = dPt.fX - line[1].fY * moveT;
92 quad[1].fY = dPt.fY + line[1].fX * moveT; 94 quad[1].fY = dPt.fY + line[1].fX * moveT;
93 SkIntersections i; 95 SkIntersections i;
94 i.intersect(quad, line); 96 i.intersect(quad, line);
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
216 }; 218 };
217 219
218 class PathOpsSegmentTester { 220 class PathOpsSegmentTester {
219 public: 221 public:
220 static void DebugReset(SkOpSegment* segment) { 222 static void DebugReset(SkOpSegment* segment) {
221 segment->debugReset(); 223 segment->debugReset();
222 } 224 }
223 }; 225 };
224 226
225 struct CircleData { 227 struct CircleData {
226 const SkDCubic fPts; 228 const CubicPts fPts;
227 const int fPtCount; 229 const int fPtCount;
228 SkPoint fShortPts[4]; 230 SkPoint fShortPts[4];
229 }; 231 };
230 232
231 static CircleData circleDataSet[] = { 233 static CircleData circleDataSet[] = {
232 { {{{313.0155029296875, 207.90290832519531}, {320.05078125, 227.587432861328 12}}}, 2, {} }, 234 { {{{313.0155029296875, 207.90290832519531}, {320.05078125, 227.587432861328 12}}}, 2, {} },
233 { {{{313.0155029296875, 207.90290832519531}, {313.98246891063195, 219.336152 03830394}, 235 { {{{313.0155029296875, 207.90290832519531}, {313.98246891063195, 219.336152 03830394},
234 {320.05078125, 227.58743286132812}}}, 3, {} }, 236 {320.05078125, 227.58743286132812}}}, 3, {} },
235 }; 237 };
236 238
(...skipping 22 matching lines...) Expand all
259 } 261 }
260 } 262 }
261 SkOpSegment* first = contour.first(); 263 SkOpSegment* first = contour.first();
262 first->debugAddAngle(0, 1); 264 first->debugAddAngle(0, 1);
263 SkOpSegment* next = first->next(); 265 SkOpSegment* next = first->next();
264 next->debugAddAngle(0, 1); 266 next->debugAddAngle(0, 1);
265 PathOpsAngleTester::Orderable(*first->debugLastAngle(), *next->debugLastAngl e()); 267 PathOpsAngleTester::Orderable(*first->debugLastAngle(), *next->debugLastAngl e());
266 } 268 }
267 269
268 struct IntersectData { 270 struct IntersectData {
269 const SkDCubic fPts; 271 const CubicPts fPts;
270 const int fPtCount; 272 const int fPtCount;
271 double fTStart; 273 double fTStart;
272 double fTEnd; 274 double fTEnd;
273 SkPoint fShortPts[4]; 275 SkPoint fShortPts[4];
274 }; 276 };
275 277
276 static IntersectData intersectDataSet1[] = { 278 static IntersectData intersectDataSet1[] = {
277 { {{{322.935669,231.030273}, {312.832214,220.393295}, {312.832214,203.454178 }}}, 3, 279 { {{{322.935669,231.030273}, {312.832214,220.393295}, {312.832214,203.454178 }}}, 3,
278 0.865309956, 0.154740299, {} }, 280 0.865309956, 0.154740299, {} },
279 { {{{322.12738,233.397751}, {295.718353,159.505829}}}, 2, 281 { {{{322.12738,233.397751}, {295.718353,159.505829}}}, 2,
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after
518 SkOpSegment* first = contour.first(); 520 SkOpSegment* first = contour.first();
519 first->debugAddAngle(0, 1); 521 first->debugAddAngle(0, 1);
520 SkOpSegment* next = first->next(); 522 SkOpSegment* next = first->next();
521 next->debugAddAngle(0, 1); 523 next->debugAddAngle(0, 1);
522 /* int result = */ 524 /* int result = */
523 PathOpsAngleTester::AllOnOneSide(*first->debugLastAngle(), *next->de bugLastAngle()); 525 PathOpsAngleTester::AllOnOneSide(*first->debugLastAngle(), *next->de bugLastAngle());
524 // SkDebugf("i=%d result=%d\n", i , result); 526 // SkDebugf("i=%d result=%d\n", i , result);
525 // SkDebugf(""); 527 // SkDebugf("");
526 } 528 }
527 } 529 }
OLDNEW
« no previous file with comments | « tests/PathOpsAngleIdeas.cpp ('k') | tests/PathOpsConicIntersectionTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698