Convert SkClassifyCubic to double precision
Even though it's in homogeneous coordinates, we still get unfortunate
artifacts if this math is not done in double precision. Prioritizing
correctness for now; we can revisit in the future as the need for
performance dictates.
Bug: skia:
Change-Id: If416ef6b70291f1454fcb9f7630d1108644ac2a5
Reviewed-on: https://skia-review.googlesource.com/19501
Commit-Queue: Chris Dalton <csmartdalton@google.com>
Reviewed-by: Greg Daniel <egdaniel@google.com>
diff --git a/src/pathops/SkPathOpsCubic.cpp b/src/pathops/SkPathOpsCubic.cpp
index d7b905c..5c672fa 100644
--- a/src/pathops/SkPathOpsCubic.cpp
+++ b/src/pathops/SkPathOpsCubic.cpp
@@ -248,14 +248,14 @@
if (cubic.monotonicInX() && cubic.monotonicInY()) {
return 0;
}
- SkScalar tt[2], ss[2];
+ double tt[2], ss[2];
SkCubicType cubicType = SkClassifyCubic(pointsPtr, tt, ss);
switch (cubicType) {
case SkCubicType::kLoop: {
- const SkScalar &td = tt[0], &te = tt[1], &sd = ss[0], &se = ss[1];
+ const double &td = tt[0], &te = tt[1], &sd = ss[0], &se = ss[1];
if (roughly_between(0, td, sd) && roughly_between(0, te, se)) {
SkASSERT(roughly_between(0, td/sd, 1) && roughly_between(0, te/se, 1));
- t[0] = (td * se + te * sd) / (2 * sd * se);
+ t[0] = static_cast<SkScalar>((td * se + te * sd) / (2 * sd * se));
SkASSERT(roughly_between(0, *t, 1));
return (int) (t[0] > 0 && t[0] < 1);
}