[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>
This commit is contained in:
Florin Malita 2018-01-31 17:25:14 -05:00 committed by Skia Commit-Bot
parent 51012ce332
commit 21d0e8b0a6

View File

@ -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;