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/SkottieParser.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/SkottieParser.cpp')
-rw-r--r-- | experimental/skottie/SkottieParser.cpp | 26 |
1 files changed, 7 insertions, 19 deletions
diff --git a/experimental/skottie/SkottieParser.cpp b/experimental/skottie/SkottieParser.cpp index 24603bf828..36690036d2 100644 --- a/experimental/skottie/SkottieParser.cpp +++ b/experimental/skottie/SkottieParser.cpp @@ -12,6 +12,7 @@ #include "SkPath.h" #include "SkPoint.h" #include "SkString.h" +#include "SkottieValue.h" #include <vector> @@ -113,8 +114,8 @@ bool ParsePointVec(const Json::Value& jv, std::vector<SkPoint>* pts) { } // namespace template <> -bool Parse<SkPath>(const Json::Value& jv, SkPath* v) { - SkASSERT(v->isEmpty()); +bool Parse<ShapeValue>(const Json::Value& jv, ShapeValue* v) { + SkASSERT(v->fVertices.empty()); // Some versions wrap values as single-element arrays. if (jv.isArray() && jv.size() == 1) { @@ -135,24 +136,11 @@ bool Parse<SkPath>(const Json::Value& jv, SkPath* v) { return false; } - if (!verts.empty()) { - v->moveTo(verts.front()); - } - - const auto& addCubic = [&](size_t from, size_t to) { - v->cubicTo(verts[from] + outPts[from], - verts[to] + inPts[to], - verts[to]); - }; - - for (size_t i = 1; i < verts.size(); ++i) { - addCubic(i - 1, i); - } - - if (!verts.empty() && ParseDefault(jv["c"], false)) { - addCubic(verts.size() - 1, 0); - v->close(); + v->fVertices.reserve(inPts.size()); + for (size_t i = 0; i < inPts.size(); ++i) { + v->fVertices.push_back(BezierVertex({inPts[i], outPts[i], verts[i]})); } + v->fClosed = ParseDefault(jv["c"], false); return true; } |