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

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

Issue 1920663002: pathops: Split loop type cubics only when there is a self-intersection. (Closed) Base URL: https://skia.googlesource.com/skia.git/@master
Patch Set: Remove documentation change of complex break in edge builder. Created 4 years, 7 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 | no next file » | 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 222 matching lines...) Expand 10 before | Expand all | Expand 10 after
233 SkScalar d[3]; 233 SkScalar d[3];
234 SkCubicType cubicType = SkClassifyCubic(pointsPtr, d); 234 SkCubicType cubicType = SkClassifyCubic(pointsPtr, d);
235 if (cubicType == kLoop_SkCubicType) { 235 if (cubicType == kLoop_SkCubicType) {
236 // crib code from gpu path utils that finds t values where loop self-int ersects 236 // crib code from gpu path utils that finds t values where loop self-int ersects
237 // use it to find mid of t values which should be a friendly place to ch op 237 // use it to find mid of t values which should be a friendly place to ch op
238 SkScalar tempSqrt = SkScalarSqrt(4.f * d[0] * d[2] - 3.f * d[1] * d[1]); 238 SkScalar tempSqrt = SkScalarSqrt(4.f * d[0] * d[2] - 3.f * d[1] * d[1]);
239 SkScalar ls = d[1] - tempSqrt; 239 SkScalar ls = d[1] - tempSqrt;
240 SkScalar lt = 2.f * d[0]; 240 SkScalar lt = 2.f * d[0];
241 SkScalar ms = d[1] + tempSqrt; 241 SkScalar ms = d[1] + tempSqrt;
242 SkScalar mt = 2.f * d[0]; 242 SkScalar mt = 2.f * d[0];
243 if (between(0, ls, lt) || between(0, ms, mt)) { 243 if (roughly_between(0, ls, lt) && roughly_between(0, ms, mt)) {
244 ls = ls / lt; 244 ls = ls / lt;
245 ms = ms / mt; 245 ms = ms / mt;
246 SkScalar smaller = SkTMax(0.f, SkTMin(ls, ms)); 246 SkASSERT(roughly_between(0, ls, 1) && roughly_between(0, ms, 1));
247 SkScalar larger = SkTMin(1.f, SkTMax(ls, ms)); 247 *t = (ls + ms) / 2;
248 *t = (smaller + larger) / 2; 248 SkASSERT(roughly_between(0, *t, 1));
249 return *t > 0 && *t < 1; 249 return *t > 0 && *t < 1;
250 } 250 }
251 } else if (kSerpentine_SkCubicType == cubicType || kCusp_SkCubicType == cubi cType) { 251 } else if (kSerpentine_SkCubicType == cubicType || kCusp_SkCubicType == cubi cType) {
252 SkDCubic cubic; 252 SkDCubic cubic;
253 cubic.set(pointsPtr); 253 cubic.set(pointsPtr);
254 double inflectionTs[2]; 254 double inflectionTs[2];
255 int infTCount = cubic.findInflections(inflectionTs); 255 int infTCount = cubic.findInflections(inflectionTs);
256 if (infTCount == 2) { 256 if (infTCount == 2) {
257 double maxCurvature[3]; 257 double maxCurvature[3];
258 int roots = cubic.findMaxCurvature(maxCurvature); 258 int roots = cubic.findMaxCurvature(maxCurvature);
(...skipping 430 matching lines...) Expand 10 before | Expand all | Expand 10 after
689 for (int index = 0; index < roots; ++index) { 689 for (int index = 0; index < roots; ++index) {
690 double t = startT + (endT - startT) * extremeTs[index]; 690 double t = startT + (endT - startT) * extremeTs[index];
691 SkDPoint mid = dCurve.ptAtT(t); 691 SkDPoint mid = dCurve.ptAtT(t);
692 if (topPt->fY > mid.fY || (topPt->fY == mid.fY && topPt->fX > mid.fX)) { 692 if (topPt->fY > mid.fY || (topPt->fY == mid.fY && topPt->fX > mid.fX)) {
693 topT = t; 693 topT = t;
694 *topPt = mid; 694 *topPt = mid;
695 } 695 }
696 } 696 }
697 return topT; 697 return topT;
698 } 698 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698