From 52bab3047b50c388b33a55faa42bf55df2a3d814 Mon Sep 17 00:00:00 2001 From: Florin Malita Date: Wed, 8 Feb 2017 17:03:56 -0500 Subject: [PATCH] [4fLinearGradient] Avoid NaNs for degenerate perspectives BUG=skia:6211 Change-Id: I92148497b29860b3844fe35c2985070a197e4085 Reviewed-on: https://skia-review.googlesource.com/8229 Commit-Queue: Florin Malita Reviewed-by: Mike Reed --- src/effects/gradients/Sk4fLinearGradient.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/effects/gradients/Sk4fLinearGradient.cpp b/src/effects/gradients/Sk4fLinearGradient.cpp index ba4d3c6..4953ce2 100644 --- a/src/effects/gradients/Sk4fLinearGradient.cpp +++ b/src/effects/gradients/Sk4fLinearGradient.cpp @@ -465,7 +465,9 @@ LinearGradient4fContext::mapTs(int x, int y, SkScalar ts[], int count) const { } else { for (int i = 0; i < count; ++i) { fDstToPosProc(fDstToPos, sx, sy, &pt); - ts[i] = pt.x(); + // Perspective may yield NaN values. + // Short of a better idea, drop to 0. + ts[i] = SkScalarIsNaN(pt.x()) ? 0 : pt.x(); sx += SK_Scalar1; } } -- 2.7.4