parser: Fix the keyframe cache logic.
authorSubhransu Mohanty <sub.mohanty@samsung.com>
Tue, 11 Aug 2020 04:40:49 +0000 (13:40 +0900)
committerJongmin Lee <jm105.lee@samsung.com>
Mon, 17 Aug 2020 22:22:02 +0000 (07:22 +0900)
For some keyframes the cache function was not getting called.
so move the cache logic to outer function and call it when the property
is fully parsed.

src/lottie/lottiemodel.h
src/lottie/lottieparser.cpp

index 6365887454cb3c5778821edd7ecd59b11600fac0..234d9211fb6947d8a9bf2b98939bd2bf3a2a7229 100644 (file)
@@ -165,8 +165,8 @@ struct Value<VPointF> {
     VPointF mEndValue;
     VPointF mInTangent;
     VPointF mOutTangent;
-    float   mBezierLength;
-    bool    mPathKeyFrame = false;
+    float   mBezierLength{0};
+    bool    mPathKeyFrame{false};
 
     void cache() {
         if (mPathKeyFrame) {
@@ -267,6 +267,8 @@ public:
                  (last < prevFrame && last < curFrame));
     }
 
+    void cache() {  for (auto &e : mKeyFrames) e.mValue.cache(); }
+
 public:
     std::vector<KeyFrame<T>> mKeyFrames;
 };
@@ -358,6 +360,7 @@ public:
         return isStatic() ? false : animation().changed(prevFrame, curFrame);
     }
 
+    void cache() { if (!isStatic()) animation().cache();}
 private:
     template <typename Tp>
     void construct(Tp &member, Tp &&val)
index 1d54e18316d1e52bd0f1d92704cad4fd283257a6..c53d06040b00209185eba8c52c9e0d574ca7d2f1 100644 (file)
@@ -2078,8 +2078,7 @@ void LottieParserImpl::parseKeyFrame(model::DynamicProperty<T> &obj)
             inTangent, outTangent, std::move(parsed.interpolatorKey));
         list.push_back(std::move(keyframe));
     } else {
-        // Last frame. cache some computaion
-        for (auto &e : list) e.mValue.cache();
+        // Last frame ignore
     }
 }
 
@@ -2116,6 +2115,7 @@ void LottieParserImpl::parseShapeProperty(model::Property<model::PathData> &obj)
             Skip(nullptr);
         }
     }
+    obj.cache();
 }
 
 template <typename T>
@@ -2155,6 +2155,7 @@ void LottieParserImpl::parsePropertyHelper(model::Property<T> &obj)
                 break;
             }
         }
+        obj.cache();
     }
 }