From 21d0e8b0a6f4acd216cff32789b61bd15d6eec02 Mon Sep 17 00:00:00 2001 From: Florin Malita Date: Wed, 31 Jan 2018 17:25:14 -0500 Subject: [skottie] Clamp SkCubicMap results to [0,1] Looks like SkCubicMap can produce slightly out-of-range values. That's prolly some unimportant precision artifact, but since we're asserting t is in [0,1] down the line it'd be nice to not crash in debug. TBR= Change-Id: I048b691d1c0f0977556d5b25893a6dab2b9986cc Reviewed-on: https://skia-review.googlesource.com/102480 Reviewed-by: Florin Malita Commit-Queue: Florin Malita --- experimental/skottie/SkottieAnimator.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'experimental') diff --git a/experimental/skottie/SkottieAnimator.cpp b/experimental/skottie/SkottieAnimator.cpp index c5cea588eb..838bf2a9ec 100644 --- a/experimental/skottie/SkottieAnimator.cpp +++ b/experimental/skottie/SkottieAnimator.cpp @@ -95,9 +95,11 @@ protected: SkASSERT(!rec.isConstant()); SkASSERT(t > rec.t0 && t < rec.t1); - auto lt = (t -rec.t0) / (rec.t1 - rec.t0); + auto lt = (t - rec.t0) / (rec.t1 - rec.t0); - return rec.cmidx < 0 ? lt : fCubicMaps[rec.cmidx].computeYFromX(lt); + return rec.cmidx < 0 + ? lt + : SkTPin(fCubicMaps[rec.cmidx].computeYFromX(lt), 0.0f, 1.0f); } virtual int parseValue(const Json::Value&) = 0; -- cgit v1.2.3