diff --git a/modules/skottie/include/Skottie.h b/modules/skottie/include/Skottie.h index 1a27bd31ea..2375a2e639 100644 --- a/modules/skottie/include/Skottie.h +++ b/modules/skottie/include/Skottie.h @@ -83,7 +83,7 @@ public: private: Animation(const ResourceProvider&, SkString ver, const SkSize& size, SkScalar fps, - const skjson::ObjectValue&, Stats*); + SkScalar in, SkScalar out, const skjson::ObjectValue&, Stats*); SkString fVersion; SkSize fSize; diff --git a/modules/skottie/src/Skottie.cpp b/modules/skottie/src/Skottie.cpp index 04b1caa770..ccc2fedf38 100644 --- a/modules/skottie/src/Skottie.cpp +++ b/modules/skottie/src/Skottie.cpp @@ -1328,14 +1328,18 @@ sk_sp Animation::Make(const char* data, size_t data_len, const auto t1 = SkTime::GetMSecs(); stats->fJsonParseTimeMS = t1 - t0; - const auto version = ParseDefault(json["v"], SkString()); - const auto size = SkSize::Make(ParseDefault(json["w"], 0.0f), - ParseDefault(json["h"], 0.0f)); - const auto fps = ParseDefault(json["fr"], -1.0f); + const auto version = ParseDefault(json["v"], SkString()); + const auto size = SkSize::Make(ParseDefault(json["w"], 0.0f), + ParseDefault(json["h"], 0.0f)); + const auto fps = ParseDefault(json["fr"], -1.0f), + inPoint = ParseDefault(json["ip"], 0.0f), + outPoint = SkTMax(ParseDefault(json["op"], SK_ScalarMax), inPoint); - if (size.isEmpty() || version.isEmpty() || fps <= 0) { - LOG("!! invalid animation params (version: %s, size: [%f %f], frame rate: %f)", - version.c_str(), size.width(), size.height(), fps); + if (size.isEmpty() || version.isEmpty() || fps <= 0 || + !SkScalarIsFinite(inPoint) || !SkScalarIsFinite(outPoint)) { + LOG("!! invalid animation params (version: %s, size: [%f %f], frame rate: %f, " + "in-point: %f, out-point: %f)\n", + version.c_str(), size.width(), size.height(), fps, inPoint, outPoint); return nullptr; } @@ -1345,7 +1349,8 @@ sk_sp Animation::Make(const char* data, size_t data_len, NullResourceProvider null_provider; const auto anim = sk_sp(new Animation(provider ? *provider : null_provider, - std::move(version), size, fps, json, stats)); + std::move(version), size, fps, + inPoint, outPoint, json, stats)); const auto t2 = SkTime::GetMSecs(); stats->fSceneParseTimeMS = t2 - t1; stats->fTotalLoadTimeMS = t2 - t0; @@ -1383,13 +1388,14 @@ sk_sp Animation::MakeFromFile(const char path[], const ResourceProvid } Animation::Animation(const ResourceProvider& resources, - SkString version, const SkSize& size, SkScalar fps, + SkString version, const SkSize& size, + SkScalar fps, SkScalar in, SkScalar out, const skjson::ObjectValue& json, Stats* stats) : fVersion(std::move(version)) , fSize(size) , fFrameRate(fps) - , fInPoint(ParseDefault(json["ip"], 0.0f)) - , fOutPoint(SkTMax(ParseDefault(json["op"], SK_ScalarMax), fInPoint)) { + , fInPoint(in) + , fOutPoint(out) { internal::AssetMap assets; if (const skjson::ArrayValue* jassets = json["assets"]) {