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

Unified Diff: src/pathops/SkPathOpsQuad.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, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/pathops/SkPathOpsQuad.h ('k') | src/pathops/SkPathOpsRect.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/pathops/SkPathOpsQuad.cpp
diff --git a/src/pathops/SkPathOpsQuad.cpp b/src/pathops/SkPathOpsQuad.cpp
index 397a3ce98ab1023ea2ff5a1baeb4ba9ca6e10839..66f191bb0e5c9aba158109b3609c4b1043f60a7c 100644
--- a/src/pathops/SkPathOpsQuad.cpp
+++ b/src/pathops/SkPathOpsQuad.cpp
@@ -240,6 +240,10 @@ static double interp_quad_coords(const double* src, double t) {
return abc;
}
+bool SkDQuad::monotonicInX() const {
+ return between(fPts[0].fX, fPts[1].fX, fPts[2].fX);
+}
+
bool SkDQuad::monotonicInY() const {
return between(fPts[0].fY, fPts[1].fY, fPts[2].fY);
}
@@ -323,28 +327,6 @@ SkDPoint SkDQuad::subDivide(const SkDPoint& a, const SkDPoint& c, double t1, dou
return b;
}
-SkDPoint SkDQuad::top(double startT, double endT, double* topT) const {
- SkDQuad sub = subDivide(startT, endT);
- SkDPoint topPt = sub[0];
- *topT = startT;
- if (topPt.fY > sub[2].fY || (topPt.fY == sub[2].fY && topPt.fX > sub[2].fX)) {
- *topT = endT;
- topPt = sub[2];
- }
- if (!between(sub[0].fY, sub[1].fY, sub[2].fY)) {
- double extremeT;
- if (FindExtrema(sub[0].fY, sub[1].fY, sub[2].fY, &extremeT)) {
- extremeT = startT + (endT - startT) * extremeT;
- SkDPoint test = ptAtT(extremeT);
- if (topPt.fY > test.fY || (topPt.fY == test.fY && topPt.fX > test.fX)) {
- *topT = extremeT;
- topPt = test;
- }
- }
- }
- return topPt;
-}
-
/* classic one t subdivision */
static void interp_quad_coords(const double* src, double* dst, double t) {
double ab = SkDInterp(src[0], src[2], t);
@@ -397,10 +379,13 @@ static int valid_unit_divide(double numer, double denom, double* ratio)
B = 2(b - a)
Solve for t, only if it fits between 0 < t < 1
*/
-int SkDQuad::FindExtrema(double a, double b, double c, double tValue[1]) {
+int SkDQuad::FindExtrema(const double src[], double tValue[1]) {
/* At + B == 0
t = -B / A
*/
+ double a = src[0];
+ double b = src[2];
+ double c = src[4];
return valid_unit_divide(a - b, a - b - b + c, tValue);
}
« no previous file with comments | « src/pathops/SkPathOpsQuad.h ('k') | src/pathops/SkPathOpsRect.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698