diff options
author | Florin Malita <fmalita@chromium.org> | 2018-04-30 21:49:41 -0400 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2018-05-01 02:27:34 +0000 |
commit | c353ee211fc99c0bf2035f9e77f87fd67b3c19c5 (patch) | |
tree | d24124815de77799c3efe0f8fff4427c96b21bec /experimental/skottie/SkottieAnimator.cpp | |
parent | d5750b6b33bfe9c6ced5a98d2782099ff620b07a (diff) |
[skottie] Power-reduce paths (cubicTo -> lineTo)
For straight lines, Lottie exports control points conincident with the
vertices. We can detect this case and emit more efficient lineTo's.
One wrinkle: we can only apply this power-reduction post-interpolation
(otherwise the path verbs and point count would not be guaranteed to
match). Hence we store explicit shape data and defer the SkPath
conversion.
TBR=
Change-Id: I7818be464eabee6096d2078440843243a55c6e98
Reviewed-on: https://skia-review.googlesource.com/124800
Reviewed-by: Florin Malita <fmalita@chromium.org>
Commit-Queue: Florin Malita <fmalita@chromium.org>
Diffstat (limited to 'experimental/skottie/SkottieAnimator.cpp')
-rw-r--r-- | experimental/skottie/SkottieAnimator.cpp | 37 |
1 files changed, 1 insertions, 36 deletions
diff --git a/experimental/skottie/SkottieAnimator.cpp b/experimental/skottie/SkottieAnimator.cpp index 5f8d0db89e..34803e05b5 100644 --- a/experimental/skottie/SkottieAnimator.cpp +++ b/experimental/skottie/SkottieAnimator.cpp @@ -27,41 +27,6 @@ bool LogFail(const Json::Value& json, const char* msg) { return false; } -template <typename T> -static inline T lerp(const T&, const T&, float); - -template <> -ScalarValue lerp(const ScalarValue& v0, const ScalarValue& v1, float t) { - SkASSERT(t >= 0 && t <= 1); - return v0 + (v1 - v0) * t; -} - -template <> -VectorValue lerp(const VectorValue& v0, const VectorValue& v1, float t) { - SkASSERT(v0.size() == v1.size()); - - VectorValue v; - v.reserve(v0.size()); - - for (size_t i = 0; i < v0.size(); ++i) { - v.push_back(lerp(v0[i], v1[i], t)); - } - - return v; -} - -template <> -ShapeValue lerp(const ShapeValue& v0, const ShapeValue& v1, float t) { - SkASSERT(t >= 0 && t <= 1); - SkASSERT(v1.isInterpolatable(v0)); - - ShapeValue v; - SkAssertResult(v1.interpolate(v0, t, &v)); - v.setIsVolatile(true); - - return v; -} - class KeyframeAnimatorBase : public sksg::Animator { public: int count() const { return fRecs.count(); } @@ -264,7 +229,7 @@ private: const auto lt = this->localT(rec, t); const auto& v0 = fVs[rec.vidx0]; const auto& v1 = fVs[rec.vidx1]; - *v = lerp(v0, v1, lt); + *v = ValueTraits<T>::Lerp(v0, v1, lt); } } |