summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsubhransu mohanty <sub.mohanty@samsung.com>2017-12-20 12:05:12 +0900
committersubhransu mohanty <sub.mohanty@samsung.com>2018-04-12 13:51:52 +0900
commit1a021f700c63315955d65eb87a6170e920a1f5f7 (patch)
tree27f81dd851b46ca70582de6891faf79cd7afef9f
parent33f6775b1548c8465dd77180a5e326df96344e9d (diff)
lottie: compute static property of lottie node.
-rw-r--r--ssg/src/lottie/lottiemodel.cpp4
-rw-r--r--ssg/src/lottie/lottiemodel.h7
-rw-r--r--ssg/src/lottie/lottieparser.cpp94
3 files changed, 78 insertions, 27 deletions
diff --git a/ssg/src/lottie/lottiemodel.cpp b/ssg/src/lottie/lottiemodel.cpp
index 8ca0f69c92..0a3dffe30b 100644
--- a/ssg/src/lottie/lottiemodel.cpp
+++ b/ssg/src/lottie/lottiemodel.cpp
@@ -29,6 +29,10 @@ public:
29 for(auto cpChild :obj->mChildren) { 29 for(auto cpChild :obj->mChildren) {
30 if (cpChild == child) 30 if (cpChild == child)
31 break; 31 break;
32 // we shouldn't copy the trim as trim operation is
33 // already applied to the objects.
34 if (cpChild->type() == LottieObject::Type::Trim)
35 continue;
32 shapeGroup->mChildren.push_back(cpChild->copy()); 36 shapeGroup->mChildren.push_back(cpChild->copy());
33 } 37 }
34 mRepeaterFound = false; 38 mRepeaterFound = false;
diff --git a/ssg/src/lottie/lottiemodel.h b/ssg/src/lottie/lottiemodel.h
index 609d502c8c..52fd1e30a7 100644
--- a/ssg/src/lottie/lottiemodel.h
+++ b/ssg/src/lottie/lottiemodel.h
@@ -133,10 +133,12 @@ public:
133 inline LottieObject::Type type() const {return mType;} 133 inline LottieObject::Type type() const {return mType;}
134 virtual void accept(LottieObjectVisitor *){} 134 virtual void accept(LottieObjectVisitor *){}
135 virtual ~LottieObject(){} 135 virtual ~LottieObject(){}
136 LottieObject(LottieObject::Type type): mType(type){} 136 LottieObject(LottieObject::Type type): mStatic(true), mType(type){}
137 bool isStatic(); 137 bool isStatic() {return mStatic;}
138 void setStatic(bool value) {mStatic = value;}
138 virtual LottieObject *copy() = 0; 139 virtual LottieObject *copy() = 0;
139public: 140public:
141 bool mStatic;
140 LottieObject::Type mType; 142 LottieObject::Type mType;
141}; 143};
142 144
@@ -178,7 +180,6 @@ public:
178 long mStartFrame = 0; 180 long mStartFrame = 0;
179 long mEndFrame = 0; 181 long mEndFrame = 0;
180 float mFrameRate; 182 float mFrameRate;
181 long mStartTime;
182 LottieBlendMode mBlendMode; 183 LottieBlendMode mBlendMode;
183 float mTimeStreatch; 184 float mTimeStreatch;
184 std::unordered_map<std::string, 185 std::unordered_map<std::string,
diff --git a/ssg/src/lottie/lottieparser.cpp b/ssg/src/lottie/lottieparser.cpp
index 24ac701fec..0335babcd3 100644
--- a/ssg/src/lottie/lottieparser.cpp
+++ b/ssg/src/lottie/lottieparser.cpp
@@ -456,6 +456,12 @@ LottieComposition *LottieParser::parseComposition()
456 Skip(key); 456 Skip(key);
457 } 457 }
458 } 458 }
459 // update the static property of Composition
460 bool staticFlag = true;
461 for (auto child : comp->mChildren) {
462 staticFlag &= child->isStatic();
463 }
464 comp->setStatic(staticFlag);
459 return comp; 465 return comp;
460} 466}
461 467
@@ -511,13 +517,22 @@ LottieLayer * LottieParser::parseLayer()
511 } else if (0 == strcmp(key, "shapes")) { 517 } else if (0 == strcmp(key, "shapes")) {
512 parseShapesAttr(layer); 518 parseShapesAttr(layer);
513 } else { 519 } else {
514#ifdef DEBUG_PARSER 520 #ifdef DEBUG_PARSER
515 sgWarning<<"Layer Attribute Skipped : "<<key; 521 sgWarning<<"Layer Attribute Skipped : "<<key;
516#endif 522 #endif
517 Skip(key); 523 Skip(key);
518 } 524 }
519 } 525 }
520 return layer; 526 // update the static property of layer
527 bool staticFlag = true;
528 for (auto child : layer->mChildren) {
529 staticFlag &= child->isStatic();
530 }
531
532 layer->setStatic(staticFlag &&
533 layer->mTransform->isStatic());
534
535 return layer;
521} 536}
522 537
523void LottieParser::parseShapesAttr(LottieLayer *layer) 538void LottieParser::parseShapesAttr(LottieLayer *layer)
@@ -592,7 +607,12 @@ LottieParser::parseGroupObject()
592 Skip(key); 607 Skip(key);
593 } 608 }
594 } 609 }
595 return group; 610 bool staticFlag = true;
611 for (auto child : group->mChildren) {
612 staticFlag &= child->isStatic();
613 }
614 group->setStatic(staticFlag);
615 return group;
596} 616}
597 617
598/* 618/*
@@ -615,6 +635,9 @@ LottieParser::parseRectObject()
615 Skip(key); 635 Skip(key);
616 } 636 }
617 } 637 }
638 obj->setStatic(obj->mPos.isStatic() &&
639 obj->mSize.isStatic() &&
640 obj->mRound.isStatic());
618 return obj; 641 return obj;
619} 642}
620 643
@@ -634,6 +657,8 @@ LottieParser::parseEllipseObject()
634 Skip(key); 657 Skip(key);
635 } 658 }
636 } 659 }
660 obj->setStatic(obj->mPos.isStatic() &&
661 obj->mSize.isStatic());
637 return obj; 662 return obj;
638} 663}
639 664
@@ -657,6 +682,7 @@ LottieParser::parseShapeObject()
657 } 682 }
658 } 683 }
659 obj->process(); 684 obj->process();
685 obj->setStatic(obj->mShape.isStatic());
660 return obj; 686 return obj;
661} 687}
662 688
@@ -700,6 +726,9 @@ LottieParser::parseTrimObject()
700 Skip(key); 726 Skip(key);
701 } 727 }
702 } 728 }
729 obj->setStatic(obj->mStart.isStatic() &&
730 obj->mEnd.isStatic() &&
731 obj->mOffset.isStatic());
703 return obj; 732 return obj;
704} 733}
705 734
@@ -721,6 +750,9 @@ LottieParser::parseReapeaterObject()
721 Skip(key); 750 Skip(key);
722 } 751 }
723 } 752 }
753 obj->setStatic(obj->mCopies.isStatic() &&
754 obj->mOffset.isStatic() &&
755 obj->mTransform->isStatic());
724 return obj; 756 return obj;
725} 757}
726 758
@@ -751,6 +783,13 @@ LottieParser::parseTransformObject()
751 Skip(key); 783 Skip(key);
752 } 784 }
753 } 785 }
786 obj->setStatic(obj->mAnchor.isStatic() &&
787 obj->mPosition.isStatic() &&
788 obj->mRotation.isStatic() &&
789 obj->mScale.isStatic() &&
790 obj->mSkew.isStatic() &&
791 obj->mSkewAxis.isStatic() &&
792 obj->mOpacity.isStatic() );
754 return obj; 793 return obj;
755} 794}
756 795
@@ -775,6 +814,8 @@ LottieParser::parseFillObject()
775 Skip(key); 814 Skip(key);
776 } 815 }
777 } 816 }
817 obj->setStatic(obj->mColor.isStatic() &&
818 obj->mOpacity.isStatic());
778 return obj; 819 return obj;
779} 820}
780 821
@@ -846,6 +887,9 @@ LottieParser::parseStrokeObject()
846 Skip(key); 887 Skip(key);
847 } 888 }
848 } 889 }
890 obj->setStatic(obj->mColor.isStatic() &&
891 obj->mOpacity.isStatic() &&
892 obj->mWidth.isStatic());
849 return obj; 893 return obj;
850} 894}
851 895
@@ -1160,37 +1204,39 @@ class LottieObjectInspector : public LottieObjectVisitor
1160{ 1204{
1161public: 1205public:
1162 void visit(LottieComposition *obj) { 1206 void visit(LottieComposition *obj) {
1163 sgDebug<<"[COMP: START]"; 1207 sgDebug<<"[COMP: START: static: "<<obj->isStatic()<<"[{ stFm endFm fmRate } { "<<obj->mStartFrame<<" "<<obj->mEndFrame<<" }]";
1164 } 1208 }
1165 void visit(LottieLayer *obj) { 1209 void visit(LottieLayer *obj) {
1166 sgDebug<<"[LAYER: "<<"type: "<<obj->mGroupType<<" id: "<<obj->mId<<" parent: "<<obj->mParentId; 1210 sgDebug<<"[LAYER: "<<"type: "<<obj->mGroupType<<" id: "<<obj->mId<<" parent: "<<obj->mParentId
1211 <<" static:"<<obj->isStatic()<<"[{ stFm endFm stTm tmStrch } { "
1212 <<obj->mStartFrame<<" "<<obj->mEndFrame<<" "<<obj->mStartTime<<" "<<obj->mTimeStreatch <<" }]";
1167 } 1213 }
1168 void visit(LottieTransform *) { 1214 void visit(LottieTransform *t) {
1169 sgDebug<<"[TRANSFORM: ]"; 1215 sgDebug<<"[TRANSFORM: static: "<<t->isStatic()<<" ]";
1170 } 1216 }
1171 void visit(LottieShapeGroup *obj) { 1217 void visit(LottieShapeGroup *o) {
1172 sgDebug<<"[SHAPE GROP: START]"; 1218 sgDebug<<"[SHAPEGROP: START : static: "<<o->isStatic()<<" ]";
1173 } 1219 }
1174 void visit(LottieShapeObject *) { 1220 void visit(LottieShapeObject *s) {
1175 sgDebug<<"[SHAPEGROUP: ]"; 1221 sgDebug<<"[SHAPE: static: "<<s->isStatic()<<" ]";
1176 } 1222 }
1177 void visit(LottieRectObject *) { 1223 void visit(LottieRectObject *r) {
1178 sgDebug<<"[RECT: ]"; 1224 sgDebug<<"[RECT: static: "<<r->isStatic()<<" ]";
1179 } 1225 }
1180 void visit(LottieEllipseObject *) { 1226 void visit(LottieEllipseObject *e) {
1181 sgDebug<<"[ELLIPSE: ]"; 1227 sgDebug<<"[ELLIPSE: static: "<<e->isStatic()<<" ]";
1182 } 1228 }
1183 void visit(LottieTrimObject *) { 1229 void visit(LottieTrimObject *t) {
1184 sgDebug<<"[TRIM: ]"; 1230 sgDebug<<"[TRIM: static: "<<t->isStatic()<<" ]";
1185 } 1231 }
1186 void visit(LottieRepeaterObject *) { 1232 void visit(LottieRepeaterObject *r) {
1187 sgDebug<<"[REPEATER: ]"; 1233 sgDebug<<"[REPEATER: static: "<<r->isStatic()<<" ]";
1188 } 1234 }
1189 void visit(LottieFillObject *) { 1235 void visit(LottieFillObject *f) {
1190 sgDebug<<"[FILL: ]"; 1236 sgDebug<<"[FILL: static: "<<f->isStatic()<<" ]";
1191 } 1237 }
1192 void visit(LottieStrokeObject *) { 1238 void visit(LottieStrokeObject *s) {
1193 sgDebug<<"[STROKE: ]"; 1239 sgDebug<<"[STROKE: static: "<<s->isStatic()<<" ]";
1194 } 1240 }
1195 void visitChildren(LottieGroupObject *obj) { 1241 void visitChildren(LottieGroupObject *obj) {
1196 for(auto child :obj->mChildren) 1242 for(auto child :obj->mChildren)