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

Unified Diff: src/core/SkGeometry.cpp

Issue 1113963002: use pathops utils to improve precision of cubic chopping in scan converter (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: use LineCubicIntersect utility for more robustness 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/core/SkGeometry.h ('k') | src/pathops/SkDCubicLineIntersection.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkGeometry.cpp
diff --git a/src/core/SkGeometry.cpp b/src/core/SkGeometry.cpp
index b9366f3dd916195c2ef332c59ca96c4e22b78be2..671a1eacc39e1138cf4c7fc9877f39ac49620e61 100644
--- a/src/core/SkGeometry.cpp
+++ b/src/core/SkGeometry.cpp
@@ -916,6 +916,33 @@ int SkChopCubicAtMaxCurvature(const SkPoint src[4], SkPoint dst[13],
return count + 1;
}
+#include "../pathops/SkPathOpsCubic.h"
+
+typedef int (SkDCubic::*InterceptProc)(double intercept, double roots[3]) const;
+
+static bool cubic_dchop_at_intercept(const SkPoint src[4], SkScalar intercept, SkPoint dst[7],
+ InterceptProc method) {
+ SkDCubic cubic;
+ double roots[3];
+ int count = (cubic.set(src).*method)(intercept, roots);
+ if (count > 0) {
+ SkDCubicPair pair = cubic.chopAt(roots[0]);
+ for (int i = 0; i < 7; ++i) {
+ dst[i] = pair.pts[i].asSkPoint();
+ }
+ return true;
+ }
+ return false;
+}
+
+bool SkChopMonoCubicAtY(SkPoint src[4], SkScalar y, SkPoint dst[7]) {
+ return cubic_dchop_at_intercept(src, y, dst, &SkDCubic::horizontalIntersect);
+}
+
+bool SkChopMonoCubicAtX(SkPoint src[4], SkScalar x, SkPoint dst[7]) {
+ return cubic_dchop_at_intercept(src, x, dst, &SkDCubic::verticalIntersect);
+}
+
///////////////////////////////////////////////////////////////////////////////
/* Find t value for quadratic [a, b, c] = d.
« no previous file with comments | « src/core/SkGeometry.h ('k') | src/pathops/SkDCubicLineIntersection.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698