diff options
Diffstat (limited to 'experimental/skottie/SkottieProperties.cpp')
-rw-r--r-- | experimental/skottie/SkottieProperties.cpp | 101 |
1 files changed, 2 insertions, 99 deletions
diff --git a/experimental/skottie/SkottieProperties.cpp b/experimental/skottie/SkottieProperties.cpp index b9535c428c..0816e15bca 100644 --- a/experimental/skottie/SkottieProperties.cpp +++ b/experimental/skottie/SkottieProperties.cpp @@ -8,7 +8,7 @@ #include "SkottieProperties.h" #include "SkColor.h" -#include "SkottiePriv.h" +#include "SkJSONCPP.h" #include "SkPath.h" #include "SkSGColor.h" #include "SkSGGradient.h" @@ -22,26 +22,6 @@ namespace skottie { namespace { -using PointArray = SkSTArray<64, SkPoint, true>; - -bool ParsePoints(const Json::Value& v, PointArray* pts) { - if (!v.isArray()) { - return false; - } - - for (Json::ArrayIndex i = 0; i < v.size(); ++i) { - const auto& pt = v[i]; - if (!pt.isArray() || pt.size() != 2 || - !pt[0].isConvertibleTo(Json::realValue) || - !pt[1].isConvertibleTo(Json::realValue)) { - return false; - } - - pts->push_back(SkPoint::Make(ParseScalar(pt[0], 0), ParseScalar(pt[1], 0))); - } - return true; -} - SkColor VecToColor(const float* v, size_t size) { // best effort to turn this into a color const auto r = size > 0 ? v[0] : 0, @@ -58,20 +38,6 @@ SkColor VecToColor(const float* v, size_t size) { } // namespace template <> -bool ValueTraits<ScalarValue>::Parse(const Json::Value& v, ScalarValue* scalar) { - // Some files appear to wrap keyframes in arrays for no reason. - if (v.isArray() && v.size() == 1) { - return Parse(v[0], scalar); - } - - if (v.isNull() || !v.isConvertibleTo(Json::realValue)) - return false; - - *scalar = v.asFloat(); - return true; -} - -template <> size_t ValueTraits<ScalarValue>::Cardinality(const ScalarValue&) { return 1; } @@ -83,24 +49,6 @@ SkScalar ValueTraits<ScalarValue>::As<SkScalar>(const ScalarValue& v) { } template <> -bool ValueTraits<VectorValue>::Parse(const Json::Value& v, VectorValue* vec) { - SkASSERT(vec->empty()); - - if (!v.isArray()) - return false; - - for (Json::ArrayIndex i = 0; i < v.size(); ++i) { - ScalarValue scalar; - if (!ValueTraits<ScalarValue>::Parse(v[i], &scalar)) - return false; - - vec->push_back(std::move(scalar)); - } - - return true; -} - -template <> size_t ValueTraits<VectorValue>::Cardinality(const VectorValue& vec) { return vec.size(); } @@ -127,51 +75,6 @@ SkSize ValueTraits<VectorValue>::As<SkSize>(const VectorValue& vec) { return SkSize::Make(pt.x(), pt.y()); } -template<> -bool ValueTraits<ShapeValue>::Parse(const Json::Value& v, ShapeValue* shape) { - PointArray inPts, // Cubic Bezier "in" control points, relative to vertices. - outPts, // Cubic Bezier "out" control points, relative to vertices. - verts; // Cubic Bezier vertices. - - // Some files appear to wrap keyframes in arrays for no reason. - if (v.isArray() && v.size() == 1) { - return Parse(v[0], shape); - } - - if (!v.isObject() || - !ParsePoints(v["i"], &inPts) || - !ParsePoints(v["o"], &outPts) || - !ParsePoints(v["v"], &verts) || - inPts.count() != outPts.count() || - inPts.count() != verts.count()) { - - return false; - } - - SkASSERT(shape->isEmpty()); - - if (!verts.empty()) { - shape->moveTo(verts.front()); - } - - const auto& addCubic = [&](int from, int to) { - shape->cubicTo(verts[from] + outPts[from], - verts[to] + inPts[to], - verts[to]); - }; - - for (int i = 1; i < verts.count(); ++i) { - addCubic(i - 1, i); - } - - if (!verts.empty() && ParseBool(v["c"], false)) { - addCubic(verts.count() - 1, 0); - shape->close(); - } - - return true; -} - template <> size_t ValueTraits<ShapeValue>::Cardinality(const ShapeValue& path) { return SkTo<size_t>(path.countVerbs()); @@ -252,7 +155,7 @@ void CompositeGradient::apply() { // |fColorStops| holds |fStopCount| x [ pos, r, g, g ] + ? x [ pos, alpha ] if (fColorStops.size() < fStopCount * 4 || ((fColorStops.size() - fStopCount * 4) % 2)) { - LOG("!! Invalid gradient stop array size: %zu", fColorStops.size()); + SkDebugf("!! Invalid gradient stop array size: %zu", fColorStops.size()); return; } |