summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsubhransu mohanty <sub.mohanty@samsung.com>2017-12-20 10:53:47 +0900
committersubhransu mohanty <sub.mohanty@samsung.com>2018-04-12 13:51:52 +0900
commit33f6775b1548c8465dd77180a5e326df96344e9d (patch)
treecb6d73affdd8b3e293c6045fd625f299caa1e592
parent7a58aa46a91efb40e2868022626efd645a8cd357 (diff)
lotti: added a debug flag to debug the lottie parser
-rw-r--r--ssg/include/sgdebug.h4
-rw-r--r--ssg/src/lottie/lottieparser.cpp38
2 files changed, 38 insertions, 4 deletions
diff --git a/ssg/include/sgdebug.h b/ssg/include/sgdebug.h
index d922398187..8d863d8337 100644
--- a/ssg/include/sgdebug.h
+++ b/ssg/include/sgdebug.h
@@ -137,7 +137,7 @@ void initialize(NonGuaranteedLogger ngl, std::string const & log_directory,
137 137
138#define SGDEBUG_LOG(LEVEL) SGDebugServer() == SGDebug(LEVEL, __FILE__, __func__, __LINE__).debug() 138#define SGDEBUG_LOG(LEVEL) SGDebugServer() == SGDebug(LEVEL, __FILE__, __func__, __LINE__).debug()
139#define sgDebug is_logged(LogLevel::INFO) && SGDEBUG_LOG(LogLevel::INFO) 139#define sgDebug is_logged(LogLevel::INFO) && SGDEBUG_LOG(LogLevel::INFO)
140#define sgWarning is_logged(LogLevel::INFO) && SGDEBUG_LOG(LogLevel::WARN) 140#define sgWarning is_logged(LogLevel::WARN) && SGDEBUG_LOG(LogLevel::WARN)
141#define sgCritical is_logged(LogLevel::INFO) && SGDEBUG_LOG(LogLevel::CRIT) 141#define sgCritical is_logged(LogLevel::CRIT) && SGDEBUG_LOG(LogLevel::CRIT)
142 142
143#endif // SGDEBUG_H 143#endif // SGDEBUG_H
diff --git a/ssg/src/lottie/lottieparser.cpp b/ssg/src/lottie/lottieparser.cpp
index 6307692088..24ac701fec 100644
--- a/ssg/src/lottie/lottieparser.cpp
+++ b/ssg/src/lottie/lottieparser.cpp
@@ -3,6 +3,9 @@
3#include <iostream> 3#include <iostream>
4#include "lottiecomposition.h" 4#include "lottiecomposition.h"
5#include "lottiemodel.h" 5#include "lottiemodel.h"
6#include"sgelapsedtimer.h"
7
8#define DEBUG_PARSER
6 9
7RAPIDJSON_DIAG_PUSH 10RAPIDJSON_DIAG_PUSH
8#ifdef __GNUC__ 11#ifdef __GNUC__
@@ -210,7 +213,9 @@ const char* LottieParser::NextObjectKey() {
210 * so ignore those and don't put parser in the error state. 213 * so ignore those and don't put parser in the error state.
211 * */ 214 * */
212 if (st_ == kExitingArray || st_ == kEnteringObject ) { 215 if (st_ == kExitingArray || st_ == kEnteringObject ) {
213 sgDebug<<"O: Exiting nested loop"; 216#ifdef DEBUG_PARSER
217 sgDebug<<"Object: Exiting nested loop";
218#endif
214 return 0; 219 return 0;
215 } 220 }
216 221
@@ -234,7 +239,9 @@ bool LottieParser::NextArrayValue() {
234 * same as NextObjectKey() 239 * same as NextObjectKey()
235 */ 240 */
236 if (st_ == kExitingObject) { 241 if (st_ == kExitingObject) {
237 sgDebug<<"A: Exiting nested loop"; 242#ifdef DEBUG_PARSER
243 sgDebug<<"Array: Exiting nested loop";
244#endif
238 return 0; 245 return 0;
239 } 246 }
240 247
@@ -443,7 +450,9 @@ LottieComposition *LottieParser::parseComposition()
443 } else if (0 == strcmp(key, "layers")) { 450 } else if (0 == strcmp(key, "layers")) {
444 parseLayers(comp); 451 parseLayers(comp);
445 } else { 452 } else {
453#ifdef DEBUG_PARSER
446 sgWarning<<"Composition Attribute Skipped : "<<key; 454 sgWarning<<"Composition Attribute Skipped : "<<key;
455#endif
447 Skip(key); 456 Skip(key);
448 } 457 }
449 } 458 }
@@ -502,7 +511,9 @@ LottieLayer * LottieParser::parseLayer()
502 } else if (0 == strcmp(key, "shapes")) { 511 } else if (0 == strcmp(key, "shapes")) {
503 parseShapesAttr(layer); 512 parseShapesAttr(layer);
504 } else { 513 } else {
514#ifdef DEBUG_PARSER
505 sgWarning<<"Layer Attribute Skipped : "<<key; 515 sgWarning<<"Layer Attribute Skipped : "<<key;
516#endif
506 Skip(key); 517 Skip(key);
507 } 518 }
508 } 519 }
@@ -542,7 +553,9 @@ LottieParser::parseObjectTypeAttr()
542 } else if (0 == strcmp(type, "rp")) { 553 } else if (0 == strcmp(type, "rp")) {
543 return parseReapeaterObject(); 554 return parseReapeaterObject();
544 } else { 555 } else {
556#ifdef DEBUG_PARSER
545 sgDebug<<"The Object Type not yet handled = "<< type; 557 sgDebug<<"The Object Type not yet handled = "<< type;
558#endif
546 return nullptr; 559 return nullptr;
547 } 560 }
548} 561}
@@ -637,7 +650,9 @@ LottieParser::parseShapeObject()
637 } else if (0 == strcmp(key, "closed")) { 650 } else if (0 == strcmp(key, "closed")) {
638 obj->mClosed = GetBool(); 651 obj->mClosed = GetBool();
639 } else { 652 } else {
653#ifdef DEBUG_PARSER
640 sgDebug<<"Shape property ignored :"<<key; 654 sgDebug<<"Shape property ignored :"<<key;
655#endif
641 Skip(key); 656 Skip(key);
642 } 657 }
643 } 658 }
@@ -679,7 +694,9 @@ LottieParser::parseTrimObject()
679 } else if (0 == strcmp(key, "m")) { 694 } else if (0 == strcmp(key, "m")) {
680 obj->mTrimType = getTrimType(); 695 obj->mTrimType = getTrimType();
681 } else { 696 } else {
697#ifdef DEBUG_PARSER
682 sgDebug<<"Trim property ignored :"<<key; 698 sgDebug<<"Trim property ignored :"<<key;
699#endif
683 Skip(key); 700 Skip(key);
684 } 701 }
685 } 702 }
@@ -698,7 +715,9 @@ LottieParser::parseReapeaterObject()
698 } else if (0 == strcmp(key, "tr")) { 715 } else if (0 == strcmp(key, "tr")) {
699 obj->mTransform = parseTransformObject(); 716 obj->mTransform = parseTransformObject();
700 } else { 717 } else {
718#ifdef DEBUG_PARSER
701 sgDebug<<"Repeater property ignored :"<<key; 719 sgDebug<<"Repeater property ignored :"<<key;
720#endif
702 Skip(key); 721 Skip(key);
703 } 722 }
704 } 723 }
@@ -750,7 +769,9 @@ LottieParser::parseFillObject()
750 } else if (0 == strcmp(key, "fillEnabled")) { 769 } else if (0 == strcmp(key, "fillEnabled")) {
751 obj->mEnabled = GetBool(); 770 obj->mEnabled = GetBool();
752 } else { 771 } else {
772#ifdef DEBUG_PARSER
753 sgWarning<<"Fill property skipped = "<<key; 773 sgWarning<<"Fill property skipped = "<<key;
774#endif
754 Skip(key); 775 Skip(key);
755 } 776 }
756 } 777 }
@@ -819,7 +840,9 @@ LottieParser::parseStrokeObject()
819 RAPIDJSON_ASSERT(PeekType() == kNumberType); 840 RAPIDJSON_ASSERT(PeekType() == kNumberType);
820 obj->mMeterLimit = GetDouble(); 841 obj->mMeterLimit = GetDouble();
821 } else { 842 } else {
843#ifdef DEBUG_PARSER
822 sgWarning<<"Stroke property skipped = "<<key; 844 sgWarning<<"Stroke property skipped = "<<key;
845#endif
823 Skip(key); 846 Skip(key);
824 } 847 }
825 } 848 }
@@ -1025,7 +1048,9 @@ void LottieParser::parseKeyFrame(LottieAnimInfo<T> &obj)
1025 getValue(keyframe.mOutTangent); 1048 getValue(keyframe.mOutTangent);
1026 continue; 1049 continue;
1027 } else { 1050 } else {
1051#ifdef DEBUG_PARSER
1028 sgDebug<<"key frame property skipped = "<<key; 1052 sgDebug<<"key frame property skipped = "<<key;
1053#endif
1029 Skip(key); 1054 Skip(key);
1030 } 1055 }
1031 } 1056 }
@@ -1078,7 +1103,9 @@ LottieParser::parseShapeProperty(LottieAnimatable<LottieShape> &obj)
1078 getValue(obj.mValue); 1103 getValue(obj.mValue);
1079 } 1104 }
1080 } else { 1105 } else {
1106#ifdef DEBUG_PARSER
1081 sgDebug<<"shape property ignored = "<<key; 1107 sgDebug<<"shape property ignored = "<<key;
1108#endif
1082 Skip(nullptr); 1109 Skip(nullptr);
1083 } 1110 }
1084 } 1111 }
@@ -1189,14 +1216,21 @@ public:
1189 1216
1190SGJson::SGJson(const char *data) 1217SGJson::SGJson(const char *data)
1191{ 1218{
1219 SGElapsedTimer t;
1220 t.start();
1192 LottieParser r(const_cast<char *>(data)); 1221 LottieParser r(const_cast<char *>(data));
1193 1222
1194 LottieComposition *comp = r.parseComposition(); 1223 LottieComposition *comp = r.parseComposition();
1224#ifdef DEBUG_PARSER
1195 LottieObjectInspector inspector; 1225 LottieObjectInspector inspector;
1196 comp->accept(&inspector); 1226 comp->accept(&inspector);
1227#endif
1197 comp->processRepeaterObjects(); 1228 comp->processRepeaterObjects();
1229#ifdef DEBUG_PARSER
1198 sgDebug<<"******** After Repeater Processing **********"; 1230 sgDebug<<"******** After Repeater Processing **********";
1199 comp->accept(&inspector); 1231 comp->accept(&inspector);
1232#endif
1233 sgCritical<<"Parsing time = "<<t.elapsed()<<" ms";
1200} 1234}
1201 1235
1202RAPIDJSON_DIAG_POP 1236RAPIDJSON_DIAG_POP