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

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

Issue 1322413002: remove unused fields from SkOpSegment (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 3 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 | « src/pathops/SkPathOpsCubic.h ('k') | tests/PathOpsCubicIntersectionTest.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 211 matching lines...) Expand 10 before | Expand all | Expand 10 after
222 fPts[1].fX), fPts[1].fY), fPts[2].fX), fPts[2].fY), fPts[3].fX), fPt s[3].fY); 222 fPts[1].fX), fPts[1].fY), fPts[2].fX), fPts[2].fY), fPts[3].fX), fPt s[3].fY);
223 largest = SkTMax(largest, -tiniest); 223 largest = SkTMax(largest, -tiniest);
224 double distance = lineParameters.controlPtDistance(*this, 1); 224 double distance = lineParameters.controlPtDistance(*this, 1);
225 if (!approximately_zero_when_compared_to(distance, largest)) { 225 if (!approximately_zero_when_compared_to(distance, largest)) {
226 return false; 226 return false;
227 } 227 }
228 distance = lineParameters.controlPtDistance(*this, 2); 228 distance = lineParameters.controlPtDistance(*this, 2);
229 return approximately_zero_when_compared_to(distance, largest); 229 return approximately_zero_when_compared_to(distance, largest);
230 } 230 }
231 231
232 bool SkDCubic::ComplexBreak(const SkPoint pointsPtr[4], SkScalar* t, CubicType* resultType) { 232 bool SkDCubic::ComplexBreak(const SkPoint pointsPtr[4], SkScalar* t) {
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 (between(0, ls, lt) || 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 SkScalar smaller = SkTMax(0.f, SkTMin(ls, ms));
247 SkScalar larger = SkTMin(1.f, SkTMax(ls, ms)); 247 SkScalar larger = SkTMin(1.f, SkTMax(ls, ms));
248 *t = (smaller + larger) / 2; 248 *t = (smaller + larger) / 2;
249 *resultType = kSplitAtLoop_SkDCubicType;
250 return *t > 0 && *t < 1; 249 return *t > 0 && *t < 1;
251 } 250 }
252 } else if (kSerpentine_SkCubicType == cubicType || kCusp_SkCubicType == cubi cType) { 251 } else if (kSerpentine_SkCubicType == cubicType || kCusp_SkCubicType == cubi cType) {
253 SkDCubic cubic; 252 SkDCubic cubic;
254 cubic.set(pointsPtr); 253 cubic.set(pointsPtr);
255 double inflectionTs[2]; 254 double inflectionTs[2];
256 int infTCount = cubic.findInflections(inflectionTs); 255 int infTCount = cubic.findInflections(inflectionTs);
257 if (infTCount == 2) { 256 if (infTCount == 2) {
258 double maxCurvature[3]; 257 double maxCurvature[3];
259 int roots = cubic.findMaxCurvature(maxCurvature); 258 int roots = cubic.findMaxCurvature(maxCurvature);
(...skipping 11 matching lines...) Expand all
271 SkDebugf("maxCurvature[%d]=%1.9g ", index, maxCurvature[index]); 270 SkDebugf("maxCurvature[%d]=%1.9g ", index, maxCurvature[index]);
272 SkDPoint pt = cubic.ptAtT(maxCurvature[index]); 271 SkDPoint pt = cubic.ptAtT(maxCurvature[index]);
273 SkDVector dPt = cubic.dxdyAtT(maxCurvature[index]); 272 SkDVector dPt = cubic.dxdyAtT(maxCurvature[index]);
274 SkDLine perp = {{pt - dPt, pt + dPt}}; 273 SkDLine perp = {{pt - dPt, pt + dPt}};
275 perp.dump(); 274 perp.dump();
276 } 275 }
277 #endif 276 #endif
278 for (int index = 0; index < roots; ++index) { 277 for (int index = 0; index < roots; ++index) {
279 if (between(inflectionTs[0], maxCurvature[index], inflectionTs[1 ])) { 278 if (between(inflectionTs[0], maxCurvature[index], inflectionTs[1 ])) {
280 *t = maxCurvature[index]; 279 *t = maxCurvature[index];
281 *resultType = kSplitAtMaxCurvature_SkDCubicType;
282 return true; 280 return true;
283 } 281 }
284 } 282 }
285 } else if (infTCount == 1) { 283 } else if (infTCount == 1) {
286 *t = inflectionTs[0]; 284 *t = inflectionTs[0];
287 *resultType = kSplitAtInflection_SkDCubicType;
288 return *t > 0 && *t < 1; 285 return *t > 0 && *t < 1;
289 } 286 }
290 } 287 }
291 return false; 288 return false;
292 } 289 }
293 290
294 bool SkDCubic::monotonicInX() const { 291 bool SkDCubic::monotonicInX() const {
295 return precisely_between(fPts[0].fX, fPts[1].fX, fPts[3].fX) 292 return precisely_between(fPts[0].fX, fPts[1].fX, fPts[3].fX)
296 && precisely_between(fPts[0].fX, fPts[2].fX, fPts[3].fX); 293 && precisely_between(fPts[0].fX, fPts[2].fX, fPts[3].fX);
297 } 294 }
(...skipping 394 matching lines...) Expand 10 before | Expand all | Expand 10 after
692 for (int index = 0; index < roots; ++index) { 689 for (int index = 0; index < roots; ++index) {
693 double t = startT + (endT - startT) * extremeTs[index]; 690 double t = startT + (endT - startT) * extremeTs[index];
694 SkDPoint mid = dCurve.ptAtT(t); 691 SkDPoint mid = dCurve.ptAtT(t);
695 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)) {
696 topT = t; 693 topT = t;
697 *topPt = mid; 694 *topPt = mid;
698 } 695 }
699 } 696 }
700 return topT; 697 return topT;
701 } 698 }
OLDNEW
« no previous file with comments | « src/pathops/SkPathOpsCubic.h ('k') | tests/PathOpsCubicIntersectionTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698