[skottie] Harden interpolation checks for shapes

The "closed" shape property cannot be interpolated -- so ensure we catch
different values in interpolation pre-checks.

Bug: skiai:8264
Change-Id: If2c7e09c1227b0013acba3833c314e0646715d52
Reviewed-on: https://skia-review.googlesource.com/147967
Reviewed-by: Kevin Lubick <kjlubick@google.com>
Commit-Queue: Florin Malita <fmalita@chromium.org>
diff --git a/modules/skottie/src/SkottieAnimator.cpp b/modules/skottie/src/SkottieAnimator.cpp
index e56271c..d1db812 100644
--- a/modules/skottie/src/SkottieAnimator.cpp
+++ b/modules/skottie/src/SkottieAnimator.cpp
@@ -199,8 +199,7 @@
 
     int parseValue(const skjson::Value& jv) override {
         T val;
-        if (!Parse<T>(jv, &val) || (!fVs.empty() &&
-                ValueTraits<T>::Cardinality(val) != ValueTraits<T>::Cardinality(fVs.back()))) {
+        if (!Parse<T>(jv, &val) || (!fVs.empty() && !ValueTraits<T>::CanLerp(val, fVs.back()))) {
             return -1;
         }
 
diff --git a/modules/skottie/src/SkottieValue.cpp b/modules/skottie/src/SkottieValue.cpp
index d327955..d564e51 100644
--- a/modules/skottie/src/SkottieValue.cpp
+++ b/modules/skottie/src/SkottieValue.cpp
@@ -15,8 +15,8 @@
 namespace  skottie {
 
 template <>
-size_t ValueTraits<ScalarValue>::Cardinality(const ScalarValue&) {
-    return 1;
+bool ValueTraits<ScalarValue>::CanLerp(const ScalarValue&, const ScalarValue&) {
+    return true;
 }
 
 template <>
@@ -33,8 +33,8 @@
 }
 
 template <>
-size_t ValueTraits<VectorValue>::Cardinality(const VectorValue& vec) {
-    return vec.size();
+bool ValueTraits<VectorValue>::CanLerp(const VectorValue& v1, const VectorValue& v2) {
+    return v1.size() == v2.size();
 }
 
 template <>
@@ -81,8 +81,9 @@
 }
 
 template <>
-size_t ValueTraits<ShapeValue>::Cardinality(const ShapeValue& shape) {
-    return shape.fVertices.size();
+bool ValueTraits<ShapeValue>::CanLerp(const ShapeValue& v1, const ShapeValue& v2) {
+    return v1.fVertices.size() == v2.fVertices.size()
+        && v1.fClosed == v2.fClosed;
 }
 
 static SkPoint lerp_point(const SkPoint& v0, const SkPoint& v1, const Sk2f& t) {
diff --git a/modules/skottie/src/SkottieValue.h b/modules/skottie/src/SkottieValue.h
index f8353a8..46e08cb 100644
--- a/modules/skottie/src/SkottieValue.h
+++ b/modules/skottie/src/SkottieValue.h
@@ -17,11 +17,10 @@
 
 template <typename T>
 struct ValueTraits {
-    static size_t Cardinality(const T&);
-
     template <typename U>
     static U As(const T&);
 
+    static bool CanLerp(const T&, const T&);
     static void Lerp(const T&, const T&, float, T*);
 };