diff options
author | subhransu mohanty <sub.mohanty@samsung.com> | 2018-04-10 13:02:40 +0900 |
---|---|---|
committer | subhransu mohanty <sub.mohanty@samsung.com> | 2018-04-12 13:51:53 +0900 |
commit | f62e2ccccd0716312fcb8489c76bcd84fd47f6d4 (patch) | |
tree | 6837dd2c6416a04ba716b28d43918de23fa357d7 | |
parent | aafee9ecb7294a739cc477c59bf80773e0dfc7d4 (diff) | |
download | efl-f62e2ccccd0716312fcb8489c76bcd84fd47f6d4.tar.gz |
lottie: updated example and lottie parser
-rw-r--r-- | ssg/example/main.cpp | 7 | ||||
-rw-r--r-- | ssg/include/lottiemodel.h | 9 | ||||
-rw-r--r-- | ssg/src/lottie/lottiemodel.cpp | 9 | ||||
-rw-r--r-- | ssg/src/lottie/lottieparser.cpp | 4 |
4 files changed, 22 insertions, 7 deletions
diff --git a/ssg/example/main.cpp b/ssg/example/main.cpp index 2e470d7d71..59847d1e5f 100644 --- a/ssg/example/main.cpp +++ b/ssg/example/main.cpp @@ -130,7 +130,6 @@ main(void) Evas *e; Efl_VG *circle; Efl_VG *root; - unsigned int i; if (!ecore_evas_init()) return -1; @@ -171,16 +170,14 @@ main(void) filepath += "LightBulb.json"; initialize(GuaranteedLogger(), "/tmp/", "ssglog", 1); set_log_level(LogLevel::INFO); - //SGJson json; + std::ifstream file; file.open(filepath); std::stringstream buffer; buffer << file.rdbuf(); - //std::cout <<"file size = "<< buffer.str().size()<<std::endl; - //std::cout << buffer.str().data(); + SGJson json(buffer.str().data()); file.close(); - std::cout<<"sizeof float :"<<sizeof(float)<<" size of double :"<<sizeof(double)<<std::endl; std::unique_ptr<VGDrawable> DrawableRoot = createCustomTree(json.mComposition); diff --git a/ssg/include/lottiemodel.h b/ssg/include/lottiemodel.h index 713adcc90c..a013844d8b 100644 --- a/ssg/include/lottiemodel.h +++ b/ssg/include/lottiemodel.h @@ -61,6 +61,8 @@ public: mInTangent(), mOutTangent(), mPathKeyFrame(false){} + bool containsProgress(float progress); + public: T mStartValue; T mEndValue; @@ -167,6 +169,11 @@ public: void accept(LottieObjectVisitor *visitor) override {visitor->visit(this); visitor->visitChildren(this);} LottieComposition():LottieGroupObject(LottieObject::Type::Composition){} + float getFrameDuration()const{return mEndFrame - mStartFrame;} + float getDuration()const; + long startFrame() const {return mStartFrame;} + long endFrame() const {return mEndFrame;} + public: SGRect mBound; bool mAnimation = false; @@ -174,7 +181,6 @@ public: long mEndFrame = 0; float mFrameRate; LottieBlendMode mBlendMode; - float mTimeStreatch; std::unordered_map<std::string, std::shared_ptr<SGInterpolator>> mInterpolatorCache; }; @@ -196,6 +202,7 @@ public: long mStartTime; LottieBlendMode mBlendMode; float mTimeStreatch; + LottieAnimatable<float> mTimeRemap; /* "tm" */ std::shared_ptr<LottieObject> mTransform; }; diff --git a/ssg/src/lottie/lottiemodel.cpp b/ssg/src/lottie/lottiemodel.cpp index 21c21e893b..e1f5aba0b5 100644 --- a/ssg/src/lottie/lottiemodel.cpp +++ b/ssg/src/lottie/lottiemodel.cpp @@ -158,6 +158,15 @@ void LottieComposition::processPaintOperatorObjects() } /* + * returns the animation duration in millisec + */ +float LottieComposition::getDuration() const +{ + float frameDuration = mEndFrame - mStartFrame; + return (frameDuration / mFrameRate) * 1000; +} + +/* * Convert the AE shape format to * list of bazier curves */ diff --git a/ssg/src/lottie/lottieparser.cpp b/ssg/src/lottie/lottieparser.cpp index bb3c34bf86..add86e0f94 100644 --- a/ssg/src/lottie/lottieparser.cpp +++ b/ssg/src/lottie/lottieparser.cpp @@ -502,7 +502,9 @@ LottieParser::parseLayer() }else if (0 == strcmp(key, "sr")) { // "Layer Time Stretching" RAPIDJSON_ASSERT(PeekType() == kNumberType); layer->mTimeStreatch = GetDouble(); - } else if (0 == strcmp(key, "ip")) { + } else if (0 == strcmp(key, "tm")) { // time remapping + parseProperty(layer->mTimeRemap); + }else if (0 == strcmp(key, "ip")) { RAPIDJSON_ASSERT(PeekType() == kNumberType); layer->mStartFrame = GetDouble(); } else if (0 == strcmp(key, "op")) { |