Added tgs check

This commit is contained in:
Ilya Laktyushin 2019-07-07 17:12:31 +02:00
parent 1aa9c3d871
commit 7ff263736c
4 changed files with 15 additions and 2 deletions

View File

@ -423,6 +423,8 @@ public:
* @internal * @internal
*/ */
~Animation(); ~Animation();
bool isTgs() const;
private: private:
void setValue(Color_Type, Property, const std::string &, Color); void setValue(Color_Type, Property, const std::string &, Color);

View File

@ -47,7 +47,8 @@ public:
Surface render(size_t frameNo, const Surface &surface); Surface render(size_t frameNo, const Surface &surface);
std::future<Surface> renderAsync(size_t frameNo, Surface &&surface); std::future<Surface> renderAsync(size_t frameNo, Surface &&surface);
const LOTLayerNode * renderTree(size_t frameNo, const VSize &size); const LOTLayerNode * renderTree(size_t frameNo, const VSize &size);
bool isTgs() const { return mModel->isTgs(); }
const LayerInfoList &layerInfoList() const const LayerInfoList &layerInfoList() const
{ {
return mModel->layerInfoList(); return mModel->layerInfoList();
@ -266,6 +267,11 @@ std::unique_ptr<Animation> Animation::loadFromFile(const std::string &path)
return nullptr; return nullptr;
} }
bool Animation::isTgs() const
{
return d->isTgs();
}
void Animation::size(size_t &width, size_t &height) const void Animation::size(size_t &width, size_t &height) const
{ {
VSize sz = d->size(); VSize sz = d->size();

View File

@ -569,6 +569,7 @@ public:
VSize size() const {return mSize;} VSize size() const {return mSize;}
void processRepeaterObjects(); void processRepeaterObjects();
public: public:
int mTgs;
std::string mVersion; std::string mVersion;
VSize mSize; VSize mSize;
long mStartFrame{0}; long mStartFrame{0};
@ -954,6 +955,7 @@ public:
class LOTModel class LOTModel
{ {
public: public:
bool isTgs() const {return mRoot->mTgs == 1;}
bool isStatic() const {return mRoot->isStatic();} bool isStatic() const {return mRoot->isStatic();}
double duration() const {return mRoot->duration();} double duration() const {return mRoot->duration();}
size_t totalFrame() const {return mRoot->totalFrame();} size_t totalFrame() const {return mRoot->totalFrame();}

View File

@ -558,7 +558,10 @@ void LottieParserImpl::parseComposition()
LOTCompositionData *comp = sharedComposition.get(); LOTCompositionData *comp = sharedComposition.get();
compRef = comp; compRef = comp;
while (const char *key = NextObjectKey()) { while (const char *key = NextObjectKey()) {
if (0 == strcmp(key, "v")) { if (0 == strcmp(key, "tgs")) {
RAPIDJSON_ASSERT(PeekType() == kNumberType);
comp->mTgs = GetInt();
}else if (0 == strcmp(key, "v")) {
RAPIDJSON_ASSERT(PeekType() == kStringType); RAPIDJSON_ASSERT(PeekType() == kStringType);
comp->mVersion = std::string(GetString()); comp->mVersion = std::string(GetString());
} else if (0 == strcmp(key, "w")) { } else if (0 == strcmp(key, "w")) {