summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsubhransu mohanty <sub.mohanty@samsung.com>2018-04-10 13:02:40 +0900
committersubhransu mohanty <sub.mohanty@samsung.com>2018-04-12 13:51:53 +0900
commitf62e2ccccd0716312fcb8489c76bcd84fd47f6d4 (patch)
tree6837dd2c6416a04ba716b28d43918de23fa357d7
parentaafee9ecb7294a739cc477c59bf80773e0dfc7d4 (diff)
lottie: updated example and lottie parser
-rw-r--r--ssg/example/main.cpp7
-rw-r--r--ssg/include/lottiemodel.h9
-rw-r--r--ssg/src/lottie/lottiemodel.cpp9
-rw-r--r--ssg/src/lottie/lottieparser.cpp4
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)
130 Evas *e; 130 Evas *e;
131 Efl_VG *circle; 131 Efl_VG *circle;
132 Efl_VG *root; 132 Efl_VG *root;
133 unsigned int i;
134 133
135 if (!ecore_evas_init()) 134 if (!ecore_evas_init())
136 return -1; 135 return -1;
@@ -171,16 +170,14 @@ main(void)
171 filepath += "LightBulb.json"; 170 filepath += "LightBulb.json";
172 initialize(GuaranteedLogger(), "/tmp/", "ssglog", 1); 171 initialize(GuaranteedLogger(), "/tmp/", "ssglog", 1);
173 set_log_level(LogLevel::INFO); 172 set_log_level(LogLevel::INFO);
174 //SGJson json; 173
175 std::ifstream file; 174 std::ifstream file;
176 file.open(filepath); 175 file.open(filepath);
177 std::stringstream buffer; 176 std::stringstream buffer;
178 buffer << file.rdbuf(); 177 buffer << file.rdbuf();
179 //std::cout <<"file size = "<< buffer.str().size()<<std::endl; 178
180 //std::cout << buffer.str().data();
181 SGJson json(buffer.str().data()); 179 SGJson json(buffer.str().data());
182 file.close(); 180 file.close();
183 std::cout<<"sizeof float :"<<sizeof(float)<<" size of double :"<<sizeof(double)<<std::endl;
184 181
185 std::unique_ptr<VGDrawable> DrawableRoot = createCustomTree(json.mComposition); 182 std::unique_ptr<VGDrawable> DrawableRoot = createCustomTree(json.mComposition);
186 183
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:
61 mInTangent(), 61 mInTangent(),
62 mOutTangent(), 62 mOutTangent(),
63 mPathKeyFrame(false){} 63 mPathKeyFrame(false){}
64 bool containsProgress(float progress);
65
64public: 66public:
65 T mStartValue; 67 T mStartValue;
66 T mEndValue; 68 T mEndValue;
@@ -167,6 +169,11 @@ public:
167 void accept(LottieObjectVisitor *visitor) override 169 void accept(LottieObjectVisitor *visitor) override
168 {visitor->visit(this); visitor->visitChildren(this);} 170 {visitor->visit(this); visitor->visitChildren(this);}
169 LottieComposition():LottieGroupObject(LottieObject::Type::Composition){} 171 LottieComposition():LottieGroupObject(LottieObject::Type::Composition){}
172 float getFrameDuration()const{return mEndFrame - mStartFrame;}
173 float getDuration()const;
174 long startFrame() const {return mStartFrame;}
175 long endFrame() const {return mEndFrame;}
176
170public: 177public:
171 SGRect mBound; 178 SGRect mBound;
172 bool mAnimation = false; 179 bool mAnimation = false;
@@ -174,7 +181,6 @@ public:
174 long mEndFrame = 0; 181 long mEndFrame = 0;
175 float mFrameRate; 182 float mFrameRate;
176 LottieBlendMode mBlendMode; 183 LottieBlendMode mBlendMode;
177 float mTimeStreatch;
178 std::unordered_map<std::string, 184 std::unordered_map<std::string,
179 std::shared_ptr<SGInterpolator>> mInterpolatorCache; 185 std::shared_ptr<SGInterpolator>> mInterpolatorCache;
180}; 186};
@@ -196,6 +202,7 @@ public:
196 long mStartTime; 202 long mStartTime;
197 LottieBlendMode mBlendMode; 203 LottieBlendMode mBlendMode;
198 float mTimeStreatch; 204 float mTimeStreatch;
205 LottieAnimatable<float> mTimeRemap; /* "tm" */
199 std::shared_ptr<LottieObject> mTransform; 206 std::shared_ptr<LottieObject> mTransform;
200}; 207};
201 208
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()
158} 158}
159 159
160/* 160/*
161 * returns the animation duration in millisec
162 */
163float LottieComposition::getDuration() const
164{
165 float frameDuration = mEndFrame - mStartFrame;
166 return (frameDuration / mFrameRate) * 1000;
167}
168
169/*
161 * Convert the AE shape format to 170 * Convert the AE shape format to
162 * list of bazier curves 171 * list of bazier curves
163 */ 172 */
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()
502 }else if (0 == strcmp(key, "sr")) { // "Layer Time Stretching" 502 }else if (0 == strcmp(key, "sr")) { // "Layer Time Stretching"
503 RAPIDJSON_ASSERT(PeekType() == kNumberType); 503 RAPIDJSON_ASSERT(PeekType() == kNumberType);
504 layer->mTimeStreatch = GetDouble(); 504 layer->mTimeStreatch = GetDouble();
505 } else if (0 == strcmp(key, "ip")) { 505 } else if (0 == strcmp(key, "tm")) { // time remapping
506 parseProperty(layer->mTimeRemap);
507 }else if (0 == strcmp(key, "ip")) {
506 RAPIDJSON_ASSERT(PeekType() == kNumberType); 508 RAPIDJSON_ASSERT(PeekType() == kNumberType);
507 layer->mStartFrame = GetDouble(); 509 layer->mStartFrame = GetDouble();
508 } else if (0 == strcmp(key, "op")) { 510 } else if (0 == strcmp(key, "op")) {