diff options
author | Florin Malita <fmalita@chromium.org> | 2018-01-31 17:25:14 -0500 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2018-01-31 22:47:15 +0000 |
commit | 21d0e8b0a6f4acd216cff32789b61bd15d6eec02 (patch) | |
tree | 4a0a39162062db5b03c0654c2ed5ce37d1ce5fe1 /experimental | |
parent | 51012ce332016cca5160b5a63b91a04b6cb56899 (diff) |
[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 <fmalita@chromium.org>
Commit-Queue: Florin Malita <fmalita@chromium.org>
Diffstat (limited to 'experimental')
-rw-r--r-- | experimental/skottie/SkottieAnimator.cpp | 6 |
1 files changed, 4 insertions, 2 deletions
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; |