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

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

Issue 1107353004: align top and bounds computations (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: clean up code Created 5 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 | « src/pathops/SkPathOpsConic.h ('k') | src/pathops/SkPathOpsCubic.h » ('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 2015 Google Inc. 2 * Copyright 2015 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 "SkIntersections.h" 7 #include "SkIntersections.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 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 SkDConic dst = {{{{ax / az, ay / az}, {bx / bz, by / bz}, {cx / cz, cy / cz} }}, w }; 104 SkDConic dst = {{{{ax / az, ay / az}, {bx / bz, by / bz}, {cx / cz, cy / cz} }}, w };
105 return dst; 105 return dst;
106 } 106 }
107 107
108 SkDPoint SkDConic::subDivide(const SkDPoint& a, const SkDPoint& c, double t1, do uble t2, 108 SkDPoint SkDConic::subDivide(const SkDPoint& a, const SkDPoint& c, double t1, do uble t2,
109 SkScalar* weight) const { 109 SkScalar* weight) const {
110 SkDConic chopped = this->subDivide(t1, t2); 110 SkDConic chopped = this->subDivide(t1, t2);
111 *weight = chopped.fWeight; 111 *weight = chopped.fWeight;
112 return chopped[1]; 112 return chopped[1];
113 } 113 }
114
115 SkDPoint SkDConic::top(double startT, double endT, double* topT) const {
116 SkDConic sub = subDivide(startT, endT);
117 SkDPoint topPt = sub[0];
118 *topT = startT;
119 if (topPt.fY > sub[2].fY || (topPt.fY == sub[2].fY && topPt.fX > sub[2].fX)) {
120 *topT = endT;
121 topPt = sub[2];
122 }
123 if (!between(sub[0].fY, sub[1].fY, sub[2].fY)) {
124 double extremeT;
125 if (FindExtrema(&sub[0].fY, sub.fWeight, &extremeT)) {
126 extremeT = startT + (endT - startT) * extremeT;
127 SkDPoint test = ptAtT(extremeT);
128 if (topPt.fY > test.fY || (topPt.fY == test.fY && topPt.fX > test.fX )) {
129 *topT = extremeT;
130 topPt = test;
131 }
132 }
133 }
134 return topPt;
135 }
OLDNEW
« no previous file with comments | « src/pathops/SkPathOpsConic.h ('k') | src/pathops/SkPathOpsCubic.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698