aboutsummaryrefslogtreecommitdiffhomepage
path: root/experimental
diff options
context:
space:
mode:
authorGravatar Florin Malita <fmalita@chromium.org>2018-01-22 23:27:21 -0500
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2018-01-23 04:46:45 +0000
commitad335bbfafbc5326c62a84342f4e3792e79df8f9 (patch)
tree19903a290a7e6733f9a65cd6b8725fb04d342209 /experimental
parent055b0f5cb0b1eba1cfa7736642dd5b08e97e2045 (diff)
[skottie] Improved animation params parsing
Some BM versions wrap the Bezier animation params into arrays. TBR= Change-Id: I376b1ed2079105066413b513c3df33a61440cf41 Reviewed-on: https://skia-review.googlesource.com/98580 Reviewed-by: Florin Malita <fmalita@chromium.org> Commit-Queue: Florin Malita <fmalita@chromium.org>
Diffstat (limited to 'experimental')
-rw-r--r--experimental/skottie/SkottieAnimator.cpp12
-rw-r--r--experimental/skottie/SkottiePriv.h7
2 files changed, 12 insertions, 7 deletions
diff --git a/experimental/skottie/SkottieAnimator.cpp b/experimental/skottie/SkottieAnimator.cpp
index 296a96b1fd..6568d1b183 100644
--- a/experimental/skottie/SkottieAnimator.cpp
+++ b/experimental/skottie/SkottieAnimator.cpp
@@ -16,6 +16,18 @@ SkScalar lerp_scalar(float v0, float v1, float t) {
return v0 * (1 - t) + v1 * t;
}
+static inline SkPoint ParsePoint(const Json::Value& v, const SkPoint& defaultValue) {
+ if (!v.isObject())
+ return defaultValue;
+
+ const auto& vx = v["x"];
+ const auto& vy = v["y"];
+
+ // Some BM versions seem to store x/y as single-element arrays.
+ return SkPoint::Make(ParseScalar(vx.isArray() ? vx[0] : vx, defaultValue.x()),
+ ParseScalar(vy.isArray() ? vy[0] : vy, defaultValue.y()));
+}
+
} // namespace
bool KeyframeIntervalBase::parse(const Json::Value& k, KeyframeIntervalBase* prev) {
diff --git a/experimental/skottie/SkottiePriv.h b/experimental/skottie/SkottiePriv.h
index 0d047c5d37..663a3f3d4c 100644
--- a/experimental/skottie/SkottiePriv.h
+++ b/experimental/skottie/SkottiePriv.h
@@ -37,13 +37,6 @@ static inline bool ParseBool(const Json::Value& v, bool defaultValue) {
? v.asBool() : defaultValue;
}
-static inline SkPoint ParsePoint(const Json::Value& v, const SkPoint& defaultValue) {
- return v.isObject()
- ? SkPoint::Make(ParseScalar(v["x"], defaultValue.x()),
- ParseScalar(v["y"], defaultValue.y()))
- : defaultValue;
-}
-
} // namespace
#endif // SkottiePriv_DEFINED