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

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

View File

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

View File

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

View File

@ -558,7 +558,10 @@ void LottieParserImpl::parseComposition()
LOTCompositionData *comp = sharedComposition.get();
compRef = comp;
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);
comp->mVersion = std::string(GetString());
} else if (0 == strcmp(key, "w")) {