diff options
Diffstat (limited to 'experimental')
-rw-r--r-- | experimental/skottie/SkottieAnimator.cpp | 12 | ||||
-rw-r--r-- | experimental/skottie/SkottiePriv.h | 7 |
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 |