[4fGradient] Fix degenerate vertical gradient assert
For vertical gradients, we rely on LinearIntervalProcessor to yield a
fAdvX == +inf, thanks to division by dx (== +/-0).
But certain degenerate values may cause the numerator to also collapse
to 0, resulting in fAdvX == NaN.
Instead or relying on float semantics, pin fAdvX to +inf explicitly for
vertical gradients.
BUG=skia:5912
Change-Id: Ia8007b99802a6b1e0b22f5618a0ca8959b0cfbb2
Reviewed-on: https://skia-review.googlesource.com/8223
Reviewed-by: Herb Derby <herb@google.com>
Commit-Queue: Florin Malita <fmalita@chromium.org>
diff --git a/src/effects/gradients/Sk4fLinearGradient.cpp b/src/effects/gradients/Sk4fLinearGradient.cpp
index 229bf82..ba4d3c6 100644
--- a/src/effects/gradients/Sk4fLinearGradient.cpp
+++ b/src/effects/gradients/Sk4fLinearGradient.cpp
@@ -295,7 +295,7 @@
SkScalar fx,
SkScalar dx,
bool is_vertical)
- : fAdvX((i->fP1 - fx) / dx)
+ : fAdvX(is_vertical ? SK_ScalarInfinity : (i->fP1 - fx) / dx)
, fFirstInterval(firstInterval)
, fLastInterval(lastInterval)
, fInterval(i)