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

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

Issue 2375053002: fix cubic linear test (Closed)
Patch Set: use quad code to check cubics Created 4 years, 2 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/SkOpBuilder.cpp ('k') | 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 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
205 bool SkDCubic::hullIntersects(const SkDQuad& quad, bool* isLinear) const { 205 bool SkDCubic::hullIntersects(const SkDQuad& quad, bool* isLinear) const {
206 return hullIntersects(quad.fPts, quad.kPointCount, isLinear); 206 return hullIntersects(quad.fPts, quad.kPointCount, isLinear);
207 } 207 }
208 208
209 bool SkDCubic::hullIntersects(const SkDConic& conic, bool* isLinear) const { 209 bool SkDCubic::hullIntersects(const SkDConic& conic, bool* isLinear) const {
210 210
211 return hullIntersects(conic.fPts, isLinear); 211 return hullIntersects(conic.fPts, isLinear);
212 } 212 }
213 213
214 bool SkDCubic::isLinear(int startIndex, int endIndex) const { 214 bool SkDCubic::isLinear(int startIndex, int endIndex) const {
215 if (fPts[0].approximatelyDEqual(fPts[3])) {
216 return ((const SkDQuad *) this)->isLinear(0, 2);
217 }
215 SkLineParameters lineParameters; 218 SkLineParameters lineParameters;
216 lineParameters.cubicEndPoints(*this, startIndex, endIndex); 219 lineParameters.cubicEndPoints(*this, startIndex, endIndex);
217 // FIXME: maybe it's possible to avoid this and compare non-normalized 220 // FIXME: maybe it's possible to avoid this and compare non-normalized
218 lineParameters.normalize(); 221 lineParameters.normalize();
219 double tiniest = SkTMin(SkTMin(SkTMin(SkTMin(SkTMin(SkTMin(SkTMin(fPts[0].fX , fPts[0].fY), 222 double tiniest = SkTMin(SkTMin(SkTMin(SkTMin(SkTMin(SkTMin(SkTMin(fPts[0].fX , fPts[0].fY),
220 fPts[1].fX), fPts[1].fY), fPts[2].fX), fPts[2].fY), fPts[3].fX), fPt s[3].fY); 223 fPts[1].fX), fPts[1].fY), fPts[2].fX), fPts[2].fY), fPts[3].fX), fPt s[3].fY);
221 double largest = SkTMax(SkTMax(SkTMax(SkTMax(SkTMax(SkTMax(SkTMax(fPts[0].fX , fPts[0].fY), 224 double largest = SkTMax(SkTMax(SkTMax(SkTMax(SkTMax(SkTMax(SkTMax(fPts[0].fX , fPts[0].fY),
222 fPts[1].fX), fPts[1].fY), fPts[2].fX), fPts[2].fY), fPts[3].fX), fPt s[3].fY); 225 fPts[1].fX), fPts[1].fY), fPts[2].fX), fPts[2].fY), fPts[3].fX), fPt s[3].fY);
223 largest = SkTMax(largest, -tiniest); 226 largest = SkTMax(largest, -tiniest);
224 double distance = lineParameters.controlPtDistance(*this, 1); 227 double distance = lineParameters.controlPtDistance(*this, 1);
(...skipping 469 matching lines...) Expand 10 before | Expand all | Expand 10 after
694 for (int index = 0; index < roots; ++index) { 697 for (int index = 0; index < roots; ++index) {
695 double t = startT + (endT - startT) * extremeTs[index]; 698 double t = startT + (endT - startT) * extremeTs[index];
696 SkDPoint mid = dCurve.ptAtT(t); 699 SkDPoint mid = dCurve.ptAtT(t);
697 if (topPt->fY > mid.fY || (topPt->fY == mid.fY && topPt->fX > mid.fX)) { 700 if (topPt->fY > mid.fY || (topPt->fY == mid.fY && topPt->fX > mid.fX)) {
698 topT = t; 701 topT = t;
699 *topPt = mid; 702 *topPt = mid;
700 } 703 }
701 } 704 }
702 return topT; 705 return topT;
703 } 706 }
OLDNEW
« no previous file with comments | « src/pathops/SkOpBuilder.cpp ('k') | tests/PathOpsOpTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698