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

Side by Side Diff: src/pathops/SkPathOpsCubic.cpp

Issue 2176733002: limit number of searched roots (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 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
« no previous file with comments | « no previous file | tests/PathOpsOpTest.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 "SkGeometry.h" 7 #include "SkGeometry.h"
8 #include "SkLineParameters.h" 8 #include "SkLineParameters.h"
9 #include "SkPathOpsConic.h" 9 #include "SkPathOpsConic.h"
10 #include "SkPathOpsCubic.h" 10 #include "SkPathOpsCubic.h"
(...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after
303 o1Pts[0] = &fPts[offset]; 303 o1Pts[0] = &fPts[offset];
304 o1Pts[1] = &fPts[++offset]; 304 o1Pts[1] = &fPts[++offset];
305 o1Pts[2] = &fPts[++offset]; 305 o1Pts[2] = &fPts[++offset];
306 } 306 }
307 307
308 int SkDCubic::searchRoots(double extremeTs[6], int extrema, double axisIntercept , 308 int SkDCubic::searchRoots(double extremeTs[6], int extrema, double axisIntercept ,
309 SearchAxis xAxis, double* validRoots) const { 309 SearchAxis xAxis, double* validRoots) const {
310 extrema += findInflections(&extremeTs[extrema]); 310 extrema += findInflections(&extremeTs[extrema]);
311 extremeTs[extrema++] = 0; 311 extremeTs[extrema++] = 0;
312 extremeTs[extrema] = 1; 312 extremeTs[extrema] = 1;
313 SkASSERT(extrema < 6);
313 SkTQSort(extremeTs, extremeTs + extrema); 314 SkTQSort(extremeTs, extremeTs + extrema);
314 int validCount = 0; 315 int validCount = 0;
315 for (int index = 0; index < extrema; ) { 316 for (int index = 0; index < extrema; ) {
316 double min = extremeTs[index]; 317 double min = extremeTs[index];
317 double max = extremeTs[++index]; 318 double max = extremeTs[++index];
318 if (min == max) { 319 if (min == max) {
319 continue; 320 continue;
320 } 321 }
321 double newT = binarySearch(min, max, axisIntercept, xAxis); 322 double newT = binarySearch(min, max, axisIntercept, xAxis);
322 if (newT >= 0) { 323 if (newT >= 0) {
324 if (validCount >= 3) {
325 return 0;
326 }
323 validRoots[validCount++] = newT; 327 validRoots[validCount++] = newT;
324 } 328 }
325 } 329 }
326 return validCount; 330 return validCount;
327 } 331 }
328 332
329 // cubic roots 333 // cubic roots
330 334
331 static const double PI = 3.141592653589793; 335 static const double PI = 3.141592653589793;
332 336
(...skipping 357 matching lines...) Expand 10 before | Expand all | Expand 10 after
690 for (int index = 0; index < roots; ++index) { 694 for (int index = 0; index < roots; ++index) {
691 double t = startT + (endT - startT) * extremeTs[index]; 695 double t = startT + (endT - startT) * extremeTs[index];
692 SkDPoint mid = dCurve.ptAtT(t); 696 SkDPoint mid = dCurve.ptAtT(t);
693 if (topPt->fY > mid.fY || (topPt->fY == mid.fY && topPt->fX > mid.fX)) { 697 if (topPt->fY > mid.fY || (topPt->fY == mid.fY && topPt->fX > mid.fX)) {
694 topT = t; 698 topT = t;
695 *topPt = mid; 699 *topPt = mid;
696 } 700 }
697 } 701 }
698 return topT; 702 return topT;
699 } 703 }
OLDNEW
« no previous file with comments | « no previous file | tests/PathOpsOpTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698