Index: src/core/SkGeometry.cpp |
diff --git a/src/core/SkGeometry.cpp b/src/core/SkGeometry.cpp |
index a3ebfb38a892740aed025a08e31653f9a5585e5c..562169743a85f116f3704cd295f9740c9cdccbb8 100644 |
--- a/src/core/SkGeometry.cpp |
+++ b/src/core/SkGeometry.cpp |
@@ -1153,6 +1153,11 @@ int SkConic::computeQuadPOW2(SkScalar tol) const { |
return pow2; |
} |
+// returns true if (a <= b <= c) || (a >= b >= c) |
+static bool between(SkScalar a, SkScalar b, SkScalar c) { |
reed1
2016/09/20 17:33:25
This is super cool (assuming it works). Seems to w
caryclark
2016/09/21 14:37:48
It works. I've been testing it for years in pathop
|
+ return (a - b) * (c - b) <= 0; |
+} |
+ |
static SkPoint* subdivide(const SkConic& src, SkPoint pts[], int level) { |
SkASSERT(level >= 0); |
@@ -1162,6 +1167,17 @@ static SkPoint* subdivide(const SkConic& src, SkPoint pts[], int level) { |
} else { |
SkConic dst[2]; |
src.chop(dst); |
+ if (between(src.fPts[0].fY, src.fPts[1].fY, src.fPts[2].fY)) { |
reed1
2016/09/20 17:33:25
// Need to ensure that after a chop of a monotonic
caryclark
2016/09/21 14:37:48
Added comments.
|
+ if (!between(dst[0].fPts[0].fY, dst[0].fPts[1].fY, dst[0].fPts[2].fY)) { |
+ dst[0].fPts[1].fY = dst[0].fPts[0].fY; |
+ } |
+ if (!between(dst[0].fPts[1].fY, dst[1].fPts[0].fY, dst[1].fPts[1].fY)) { |
reed1
2016/09/20 17:33:25
Each of these 3 seem to be the same...
ensure_mon
caryclark
2016/09/21 14:37:48
The intention of moving it to one side was for con
|
+ dst[1].fPts[0].fY = dst[0].fPts[1].fY; |
+ } |
+ if (!between(dst[1].fPts[0].fY, dst[1].fPts[1].fY, dst[1].fPts[2].fY)) { |
+ dst[1].fPts[1].fY = dst[1].fPts[0].fY; |
+ } |
+ } |
--level; |
pts = subdivide(dst[0], pts, level); |
return subdivide(dst[1], pts, level); |