summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsubhransu mohanty <sub.mohanty@samsung.com>2017-12-20 17:09:22 +0900
committersubhransu mohanty <sub.mohanty@samsung.com>2018-04-12 13:51:52 +0900
commitf27b25b4e68b38fb1399b17d5b0c21d07f231422 (patch)
tree134c26464411e0db8aba9bfe3f7a0ec7bf111bef
parent48fa47e5ffbc3502d6c031159373e43450d310e1 (diff)
lottie: add path operation to the lottie tree
-rw-r--r--ssg/src/lottie/lottiemodel.cpp66
-rw-r--r--ssg/src/lottie/lottiemodel.h5
-rw-r--r--ssg/src/lottie/lottieparser.cpp2
3 files changed, 69 insertions, 4 deletions
diff --git a/ssg/src/lottie/lottiemodel.cpp b/ssg/src/lottie/lottiemodel.cpp
index 3e5c7bd62d..e79f122aa4 100644
--- a/ssg/src/lottie/lottiemodel.cpp
+++ b/ssg/src/lottie/lottiemodel.cpp
@@ -1,4 +1,5 @@
1#include "lottiemodel.h" 1#include "lottiemodel.h"
2#include<stack>
2 3
3 4
4class LottieRepeaterProcesser : public LottieObjectVisitor 5class LottieRepeaterProcesser : public LottieObjectVisitor
@@ -44,6 +45,65 @@ public:
44 bool mRepeaterFound; 45 bool mRepeaterFound;
45}; 46};
46 47
48class LottiePathOperationProcesser : public LottieObjectVisitor
49{
50public:
51 LottiePathOperationProcesser():mPathOperator(false), mPaintNode(false), mPathOperationCount(0){}
52 void visit(LottieComposition *obj) {}
53 void visit(LottieLayer *obj) {}
54 void visit(LottieTransform *) {}
55 void visit(LottieShapeGroup *obj) {}
56 void visit(LottieShapeObject *) {mPaintNode = true;}
57 void visit(LottieRectObject *) {mPaintNode = true;}
58 void visit(LottieEllipseObject *) { mPaintNode = true;}
59 void visit(LottieTrimObject *) {
60 mPathOperator = true;
61 }
62 void visit(LottieRepeaterObject *) {}
63 void visit(LottieFillObject *) {}
64 void visit(LottieStrokeObject *) {}
65 void visitChildren(LottieGroupObject *obj) {
66 mPathOperator = false;
67 mPaintNode = false;
68 mPathOperationList.push_back(std::vector<std::shared_ptr<LottieObject>>());
69 for (auto i = obj->mChildren.rbegin(); i != obj->mChildren.rend(); ++i) {
70 auto child = *i;
71 child.get()->accept(this);
72 if (mPathOperator) {
73 mPathOperationList.back().push_back(child);
74 mPathOperationCount++;
75 }
76 if (mPaintNode && mPathOperationCount) {
77 // put it in the list
78 updatePaintObject(static_cast<LottieDrawableObject *>(child.get()));
79 }
80 mPathOperator = false;
81 mPaintNode = false;
82 }
83 mPathOperationCount -= mPathOperationList.back().size();
84 mPathOperationList.pop_back();
85 }
86
87 void updatePaintObject(LottieDrawableObject *drawable) {
88 sgDebug<<"For each path START";
89 for (auto i = mPathOperationList.rbegin(); i != mPathOperationList.rend(); ++i) {
90 auto trimList = *i;
91 sgDebug<<"For each level START";
92 for (auto j = trimList.rbegin(); j != trimList.rend(); ++j) {
93 drawable->mPathOperations.push_back(*j);
94 sgDebug<<"Added path operaton to ";
95 }
96 sgDebug<<"For each level END";
97 }
98 sgDebug<<"For each path END";
99 }
100public:
101 bool mPathOperator;
102 bool mPaintNode;
103 std::vector<std::vector<std::shared_ptr<LottieObject>>> mPathOperationList;
104 int mPathOperationCount;
105};
106
47 107
48void LottieComposition::processRepeaterObjects() 108void LottieComposition::processRepeaterObjects()
49{ 109{
@@ -51,6 +111,12 @@ void LottieComposition::processRepeaterObjects()
51 accept(&visitor); 111 accept(&visitor);
52} 112}
53 113
114void LottieComposition::processPathOperatorObjects()
115{
116 LottiePathOperationProcesser visitor;
117 accept(&visitor);
118}
119
54/* 120/*
55 * makes a deep copy of the object as well as all its children 121 * makes a deep copy of the object as well as all its children
56 * 122 *
diff --git a/ssg/src/lottie/lottiemodel.h b/ssg/src/lottie/lottiemodel.h
index 8b6c562207..48be5e92bc 100644
--- a/ssg/src/lottie/lottiemodel.h
+++ b/ssg/src/lottie/lottiemodel.h
@@ -147,10 +147,6 @@ class LottieGroupObject: public LottieObject
147public: 147public:
148 LottieGroupObject(LottieObject::Type type):LottieObject(type){} 148 LottieGroupObject(LottieObject::Type type):LottieObject(type){}
149 LottieGroupObject(const LottieGroupObject &other); 149 LottieGroupObject(const LottieGroupObject &other);
150// ~LottieGroupObject() {
151// for(auto child : mChildren)
152// delete child;
153// }
154public: 150public:
155 std::vector<std::shared_ptr<LottieObject>> mChildren; 151 std::vector<std::shared_ptr<LottieObject>> mChildren;
156}; 152};
@@ -169,6 +165,7 @@ class LottieTransform;
169class LottieComposition : public LottieGroupObject 165class LottieComposition : public LottieGroupObject
170{ 166{
171public: 167public:
168 void processPathOperatorObjects();
172 void processRepeaterObjects(); 169 void processRepeaterObjects();
173 void accept(LottieObjectVisitor *visitor) override 170 void accept(LottieObjectVisitor *visitor) override
174 {visitor->visit(this); visitor->visitChildren(this);} 171 {visitor->visit(this); visitor->visitChildren(this);}
diff --git a/ssg/src/lottie/lottieparser.cpp b/ssg/src/lottie/lottieparser.cpp
index 725d9b88ff..561e860c40 100644
--- a/ssg/src/lottie/lottieparser.cpp
+++ b/ssg/src/lottie/lottieparser.cpp
@@ -1301,7 +1301,9 @@ SGJson::SGJson(const char *data)
1301 LottieObjectInspector inspector; 1301 LottieObjectInspector inspector;
1302 comp.get()->accept(&inspector); 1302 comp.get()->accept(&inspector);
1303#endif 1303#endif
1304 comp.get()->processPathOperatorObjects();
1304 comp.get()->processRepeaterObjects(); 1305 comp.get()->processRepeaterObjects();
1306
1305#ifdef DEBUG_PARSER 1307#ifdef DEBUG_PARSER
1306 sgDebug<<"******** After Repeater Processing **********"; 1308 sgDebug<<"******** After Repeater Processing **********";
1307 comp.get()->accept(&inspector); 1309 comp.get()->accept(&inspector);