diff options
author | Florin Malita <fmalita@chromium.org> | 2018-08-20 10:02:12 -0400 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2018-08-20 14:20:16 +0000 |
commit | cc9c45d2e09fb77e52f5585beb84a5bfedc72454 (patch) | |
tree | 2ddcbae13f9c16945410a9d2b0c378b40bc2e252 /modules | |
parent | f45d69f55d80c0f69167f09faa1e67dd35ee0a1d (diff) | |
download | skqp-cc9c45d2e09fb77e52f5585beb84a5bfedc72454.tar.gz |
[skottie] Pre-flight animation in-point, out-point
Bug: skia:8264
Change-Id: Icde0e9d76f51e96f7e5246f1f87e5fa6f32d0a14
Reviewed-on: https://skia-review.googlesource.com/148020
Commit-Queue: Florin Malita <fmalita@chromium.org>
Commit-Queue: Kevin Lubick <kjlubick@google.com>
Auto-Submit: Florin Malita <fmalita@chromium.org>
Reviewed-by: Kevin Lubick <kjlubick@google.com>
Diffstat (limited to 'modules')
-rw-r--r-- | modules/skottie/include/Skottie.h | 2 | ||||
-rw-r--r-- | modules/skottie/src/Skottie.cpp | 30 |
2 files changed, 19 insertions, 13 deletions
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> Animation::Make(const char* data, size_t data_len, const auto t1 = SkTime::GetMSecs(); stats->fJsonParseTimeMS = t1 - t0; - const auto version = ParseDefault<SkString>(json["v"], SkString()); - const auto size = SkSize::Make(ParseDefault<float>(json["w"], 0.0f), - ParseDefault<float>(json["h"], 0.0f)); - const auto fps = ParseDefault<float>(json["fr"], -1.0f); - - 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); + const auto version = ParseDefault<SkString>(json["v"], SkString()); + const auto size = SkSize::Make(ParseDefault<float>(json["w"], 0.0f), + ParseDefault<float>(json["h"], 0.0f)); + const auto fps = ParseDefault<float>(json["fr"], -1.0f), + inPoint = ParseDefault<float>(json["ip"], 0.0f), + outPoint = SkTMax(ParseDefault<float>(json["op"], SK_ScalarMax), inPoint); + + 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> Animation::Make(const char* data, size_t data_len, NullResourceProvider null_provider; const auto anim = sk_sp<Animation>(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> 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<float>(json["ip"], 0.0f)) - , fOutPoint(SkTMax(ParseDefault<float>(json["op"], SK_ScalarMax), fInPoint)) { + , fInPoint(in) + , fOutPoint(out) { internal::AssetMap assets; if (const skjson::ArrayValue* jassets = json["assets"]) { |