From 95448a90c1e168f5d36abab40dc762b2602ba75a Mon Sep 17 00:00:00 2001 From: Florin Malita Date: Mon, 8 Jan 2018 10:15:12 -0500 Subject: [skotty] More flexible property parsing Older Json versions don't tag properties wih an "a" animation marker, but appear to instead rely on a try-and-see-what-sticks approach. TBR= Change-Id: I8a3a7e43576c590aa5ac168891574ceb4811ad49 Reviewed-on: https://skia-review.googlesource.com/91861 Reviewed-by: Florin Malita Commit-Queue: Florin Malita --- experimental/skotty/Skotty.cpp | 34 +++++++++++++++++++++------------- 1 file changed, 21 insertions(+), 13 deletions(-) (limited to 'experimental') diff --git a/experimental/skotty/Skotty.cpp b/experimental/skotty/Skotty.cpp index 84cc08051f..b331547316 100644 --- a/experimental/skotty/Skotty.cpp +++ b/experimental/skotty/Skotty.cpp @@ -60,26 +60,34 @@ bool AttachProperty(const Json::Value& jprop, AttachContext* ctx, const sk_sp()); + return true; } - apply(node, val.template as()); - } else { - // Keyframe property. - using AnimatorT = Animator; - auto animator = AnimatorT::Make(jprop["k"], node, std::move(apply)); - - if (!animator) { - return LogFail(jprop, "Could not instantiate keyframe animator"); + if (!jpropA.isNull()) { + return LogFail(jprop, "Could not parse (explicit) static property"); } + } + + // Keyframe property. + using AnimatorT = Animator; + auto animator = AnimatorT::Make(jpropK, node, std::move(apply)); - ctx->fAnimators.push_back(std::move(animator)); + if (!animator) { + return LogFail(jprop, "Could not parse keyframed property"); } + ctx->fAnimators.push_back(std::move(animator)); + return true; } -- cgit v1.2.3