summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsubhransu mohanty <sub.mohanty@samsung.com>2017-12-26 10:45:18 +0900
committersubhransu mohanty <sub.mohanty@samsung.com>2018-04-12 13:51:53 +0900
commitd97dd720783f23abb63a77fc770728d93cd1acfe (patch)
tree74e2d3ca032f5a5dbae13d2cd60d8e54df93070b
parent115919f1fa1e467955241524229b95c890b31913 (diff)
lottie: rename drawable to path object.
-rw-r--r--ssg/src/lottie/lottiemodel.cpp41
-rw-r--r--ssg/src/lottie/lottiemodel.h18
-rw-r--r--ssg/src/lottie/lottieparser.cpp9
3 files changed, 37 insertions, 31 deletions
diff --git a/ssg/src/lottie/lottiemodel.cpp b/ssg/src/lottie/lottiemodel.cpp
index 5852d433b1..6c58e470a7 100644
--- a/ssg/src/lottie/lottiemodel.cpp
+++ b/ssg/src/lottie/lottiemodel.cpp
@@ -48,14 +48,14 @@ public:
48class LottiePathOperationProcesser : public LottieObjectVisitor 48class LottiePathOperationProcesser : public LottieObjectVisitor
49{ 49{
50public: 50public:
51 LottiePathOperationProcesser():mPathOperator(false), mDrawableNode(false){} 51 LottiePathOperationProcesser():mPathOperator(false), mPathNode(false){}
52 void visit(LottieComposition *obj) {} 52 void visit(LottieComposition *obj) {}
53 void visit(LottieLayer *obj) {} 53 void visit(LottieLayer *obj) {}
54 void visit(LottieTransform *) {} 54 void visit(LottieTransform *) {}
55 void visit(LottieShapeGroup *obj) {} 55 void visit(LottieShapeGroup *obj) {}
56 void visit(LottieShapeObject *) {mDrawableNode = true;} 56 void visit(LottieShapeObject *) {mPathNode = true;}
57 void visit(LottieRectObject *) {mDrawableNode = true;} 57 void visit(LottieRectObject *) {mPathNode = true;}
58 void visit(LottieEllipseObject *) { mDrawableNode = true;} 58 void visit(LottieEllipseObject *) { mPathNode = true;}
59 void visit(LottieTrimObject *) { mPathOperator = true;} 59 void visit(LottieTrimObject *) { mPathOperator = true;}
60 void visit(LottieRepeaterObject *) {} 60 void visit(LottieRepeaterObject *) {}
61 void visit(LottieFillObject *) {} 61 void visit(LottieFillObject *) {}
@@ -63,7 +63,7 @@ public:
63 void visitChildren(LottieGroupObject *obj) { 63 void visitChildren(LottieGroupObject *obj) {
64 int curOpCount = mPathOperationList.size(); 64 int curOpCount = mPathOperationList.size();
65 mPathOperator = false; 65 mPathOperator = false;
66 mDrawableNode = false; 66 mPathNode = false;
67 for (auto i = obj->mChildren.rbegin(); i != obj->mChildren.rend(); ++i) { 67 for (auto i = obj->mChildren.rbegin(); i != obj->mChildren.rend(); ++i) {
68 auto child = *i; 68 auto child = *i;
69 child.get()->accept(this); 69 child.get()->accept(this);
@@ -71,38 +71,37 @@ public:
71 mPathOperationList.push_back(child); 71 mPathOperationList.push_back(child);
72 obj->mChildren.erase(std::next(i).base()); 72 obj->mChildren.erase(std::next(i).base());
73 } 73 }
74 if (mDrawableNode) { 74 if (mPathNode) {
75 // put it in the list 75 updatePathObject(static_cast<LottiePathObject *>(child.get()));
76 updateDrawableObject(static_cast<LottieDrawableObject *>(child.get()));
77 } 76 }
78 mPathOperator = false; 77 mPathOperator = false;
79 mDrawableNode = false; 78 mPathNode = false;
80 } 79 }
81 mPathOperationList.erase(mPathOperationList.begin() + curOpCount, mPathOperationList.end()); 80 mPathOperationList.erase(mPathOperationList.begin() + curOpCount, mPathOperationList.end());
82 } 81 }
83 82
84 void updateDrawableObject(LottieDrawableObject *drawable) { 83 void updatePathObject(LottiePathObject *drawable) {
85 for (auto i = mPathOperationList.rbegin(); i != mPathOperationList.rend(); ++i) { 84 for (auto i = mPathOperationList.rbegin(); i != mPathOperationList.rend(); ++i) {
86 drawable->mPathOperations.push_back(*i); 85 drawable->mPathOperations.push_back(*i);
87 } 86 }
88 } 87 }
89public: 88public:
90 bool mPathOperator; 89 bool mPathOperator;
91 bool mDrawableNode; 90 bool mPathNode;
92 std::vector<std::shared_ptr<LottieObject>> mPathOperationList; 91 std::vector<std::shared_ptr<LottieObject>> mPathOperationList;
93}; 92};
94 93
95class LottiePaintOperationProcesser : public LottieObjectVisitor 94class LottiePaintOperationProcesser : public LottieObjectVisitor
96{ 95{
97public: 96public:
98 LottiePaintOperationProcesser():mPaintOperator(false), mDrawableNode(false){} 97 LottiePaintOperationProcesser():mPaintOperator(false), mPathNode(false){}
99 void visit(LottieComposition *obj) {} 98 void visit(LottieComposition *obj) {}
100 void visit(LottieLayer *obj) {} 99 void visit(LottieLayer *obj) {}
101 void visit(LottieTransform *) {} 100 void visit(LottieTransform *) {}
102 void visit(LottieShapeGroup *obj) {} 101 void visit(LottieShapeGroup *obj) {}
103 void visit(LottieShapeObject *) {mDrawableNode = true;} 102 void visit(LottieShapeObject *) {mPathNode = true;}
104 void visit(LottieRectObject *) {mDrawableNode = true;} 103 void visit(LottieRectObject *) {mPathNode = true;}
105 void visit(LottieEllipseObject *) { mDrawableNode = true;} 104 void visit(LottieEllipseObject *) { mPathNode = true;}
106 void visit(LottieTrimObject *) {} 105 void visit(LottieTrimObject *) {}
107 void visit(LottieRepeaterObject *) {} 106 void visit(LottieRepeaterObject *) {}
108 void visit(LottieFillObject *) { mPaintOperator = true;} 107 void visit(LottieFillObject *) { mPaintOperator = true;}
@@ -110,7 +109,7 @@ public:
110 void visitChildren(LottieGroupObject *obj) { 109 void visitChildren(LottieGroupObject *obj) {
111 int curOpCount = mPaintOperationList.size(); 110 int curOpCount = mPaintOperationList.size();
112 mPaintOperator = false; 111 mPaintOperator = false;
113 mDrawableNode = false; 112 mPathNode = false;
114 for (auto i = obj->mChildren.rbegin(); i != obj->mChildren.rend(); ++i) { 113 for (auto i = obj->mChildren.rbegin(); i != obj->mChildren.rend(); ++i) {
115 auto child = *i; 114 auto child = *i;
116 child.get()->accept(this); 115 child.get()->accept(this);
@@ -118,24 +117,24 @@ public:
118 mPaintOperationList.push_back(child); 117 mPaintOperationList.push_back(child);
119 obj->mChildren.erase(std::next(i).base()); 118 obj->mChildren.erase(std::next(i).base());
120 } 119 }
121 if (mDrawableNode) { 120 if (mPathNode) {
122 // put it in the list 121 // put it in the list
123 updateDrawableObject(static_cast<LottieDrawableObject *>(child.get())); 122 updatePathObject(static_cast<LottiePathObject *>(child.get()));
124 } 123 }
125 mPaintOperator = false; 124 mPaintOperator = false;
126 mDrawableNode = false; 125 mPathNode = false;
127 } 126 }
128 mPaintOperationList.erase(mPaintOperationList.begin() + curOpCount, mPaintOperationList.end()); 127 mPaintOperationList.erase(mPaintOperationList.begin() + curOpCount, mPaintOperationList.end());
129 } 128 }
130 129
131 void updateDrawableObject(LottieDrawableObject *drawable) { 130 void updatePathObject(LottiePathObject *drawable) {
132 for (auto i = mPaintOperationList.begin(); i != mPaintOperationList.end(); ++i) { 131 for (auto i = mPaintOperationList.begin(); i != mPaintOperationList.end(); ++i) {
133 drawable->mPaintOperations.push_back(*i); 132 drawable->mPaintOperations.push_back(*i);
134 } 133 }
135 } 134 }
136public: 135public:
137 bool mPaintOperator; 136 bool mPaintOperator;
138 bool mDrawableNode; 137 bool mPathNode;
139 std::vector<std::shared_ptr<LottieObject>> mPaintOperationList; 138 std::vector<std::shared_ptr<LottieObject>> mPaintOperationList;
140}; 139};
141 140
diff --git a/ssg/src/lottie/lottiemodel.h b/ssg/src/lottie/lottiemodel.h
index 623285c155..eae688b1f9 100644
--- a/ssg/src/lottie/lottiemodel.h
+++ b/ssg/src/lottie/lottiemodel.h
@@ -156,6 +156,8 @@ public:
156 {visitor->visit(this); visitor->visitChildren(this);} 156 {visitor->visit(this); visitor->visitChildren(this);}
157 157
158 LottieShapeGroup():LottieGroupObject(LottieObject::Type::ShapeGroup){} 158 LottieShapeGroup():LottieGroupObject(LottieObject::Type::ShapeGroup){}
159public:
160 std::shared_ptr<LottieObject> mTransform;
159}; 161};
160 162
161class LottieTransform; 163class LottieTransform;
@@ -269,33 +271,33 @@ public:
269 std::shared_ptr<LottieShapeData> mShapeData; 271 std::shared_ptr<LottieShapeData> mShapeData;
270}; 272};
271 273
272class LottieDrawableObject : public LottieObject 274class LottiePathObject : public LottieObject
273{ 275{
274public: 276public:
275 LottieDrawableObject(LottieObject::Type type):LottieObject(type){} 277 LottiePathObject(LottieObject::Type type):LottieObject(type){}
276public: 278public:
277 std::vector<std::shared_ptr<LottieObject>> mPathOperations; 279 std::vector<std::shared_ptr<LottieObject>> mPathOperations;
278 std::vector<std::shared_ptr<LottieObject>> mPaintOperations; 280 std::vector<std::shared_ptr<LottieObject>> mPaintOperations;
279}; 281};
280 282
281class LottieShapeObject : public LottieDrawableObject 283class LottieShapeObject : public LottiePathObject
282{ 284{
283public: 285public:
284 void accept(LottieObjectVisitor *visitor) final 286 void accept(LottieObjectVisitor *visitor) final
285 {visitor->visit(this);} 287 {visitor->visit(this);}
286 void process(); 288 void process();
287 LottieShapeObject():LottieDrawableObject(LottieObject::Type::Shape){} 289 LottieShapeObject():LottiePathObject(LottieObject::Type::Shape){}
288public: 290public:
289 LottieAnimatable<LottieShape> mShape; 291 LottieAnimatable<LottieShape> mShape;
290 bool mClosed = false; 292 bool mClosed = false;
291}; 293};
292 294
293class LottieRectObject : public LottieDrawableObject 295class LottieRectObject : public LottiePathObject
294{ 296{
295public: 297public:
296 void accept(LottieObjectVisitor *visitor) final 298 void accept(LottieObjectVisitor *visitor) final
297 {visitor->visit(this);} 299 {visitor->visit(this);}
298 LottieRectObject():LottieDrawableObject(LottieObject::Type::Rect), 300 LottieRectObject():LottiePathObject(LottieObject::Type::Rect),
299 mPos(SGPointF(0,0)), 301 mPos(SGPointF(0,0)),
300 mSize(SGPointF(0,0)), 302 mSize(SGPointF(0,0)),
301 mRound(0){} 303 mRound(0){}
@@ -305,12 +307,12 @@ public:
305 LottieAnimatable<float> mRound; 307 LottieAnimatable<float> mRound;
306}; 308};
307 309
308class LottieEllipseObject : public LottieDrawableObject 310class LottieEllipseObject : public LottiePathObject
309{ 311{
310public: 312public:
311 void accept(LottieObjectVisitor *visitor) final 313 void accept(LottieObjectVisitor *visitor) final
312 {visitor->visit(this);} 314 {visitor->visit(this);}
313 LottieEllipseObject():LottieDrawableObject(LottieObject::Type::Ellipse), 315 LottieEllipseObject():LottiePathObject(LottieObject::Type::Ellipse),
314 mPos(SGPointF(0,0)), 316 mPos(SGPointF(0,0)),
315 mSize(SGPointF(0,0)){} 317 mSize(SGPointF(0,0)){}
316public: 318public:
diff --git a/ssg/src/lottie/lottieparser.cpp b/ssg/src/lottie/lottieparser.cpp
index 6fe3e3d159..53d6d97085 100644
--- a/ssg/src/lottie/lottieparser.cpp
+++ b/ssg/src/lottie/lottieparser.cpp
@@ -588,8 +588,9 @@ LottieParser::parseObject(LottieGroupObject *parent)
588 while (const char* key = NextObjectKey()) { 588 while (const char* key = NextObjectKey()) {
589 if (0 == strcmp(key, "ty")) { 589 if (0 == strcmp(key, "ty")) {
590 auto child = parseObjectTypeAttr(); 590 auto child = parseObjectTypeAttr();
591 if (child) 591 if (child) {
592 parent->mChildren.push_back(child); 592 parent->mChildren.push_back(child);
593 }
593 } else { 594 } else {
594 Skip(key); 595 Skip(key);
595 } 596 }
@@ -610,6 +611,8 @@ LottieParser::parseGroupObject()
610 RAPIDJSON_ASSERT(PeekType() == kObjectType); 611 RAPIDJSON_ASSERT(PeekType() == kObjectType);
611 parseObject(group); 612 parseObject(group);
612 } 613 }
614 group->mTransform = group->mChildren.back();
615 group->mChildren.pop_back();
613 } else { 616 } else {
614 Skip(key); 617 Skip(key);
615 } 618 }
@@ -618,7 +621,9 @@ LottieParser::parseGroupObject()
618 for (auto child : group->mChildren) { 621 for (auto child : group->mChildren) {
619 staticFlag &= child.get()->isStatic(); 622 staticFlag &= child.get()->isStatic();
620 } 623 }
621 group->setStatic(staticFlag); 624
625 group->setStatic(staticFlag &&
626 group->mTransform->isStatic());
622 627
623 return sharedGroup; 628 return sharedGroup;
624} 629}