lottie loader: implement the necessary interaces.

This commit is contained in:
Hermet Park 2023-07-18 18:51:13 +09:00 committed by Hermet Park
parent 73a8792eae
commit 193a9833a8

View file

@ -65,8 +65,8 @@ static int _str2float(const char* str, int len)
void LottieLoader::clear() void LottieLoader::clear()
{ {
//TODO: Clear all used resources
if (copy) free((char*)content); if (copy) free((char*)content);
size = 0; size = 0;
content = nullptr; content = nullptr;
copy = false; copy = false;
@ -279,9 +279,15 @@ unique_ptr<Paint> LottieLoader::paint()
bool LottieLoader::frame(uint32_t frameNo) bool LottieLoader::frame(uint32_t frameNo)
{ {
if (this->frameNo == frameNo) return true;
this->done(); this->done();
return true; if (!comp || frameNo >= comp->frameCnt()) return false;
this->frameNo = frameNo;
return builder->update(comp, frameNo);
} }
@ -289,7 +295,8 @@ uint32_t LottieLoader::totalFrame()
{ {
this->done(); this->done();
return 0; if (!comp) return 0;
return comp->frameCnt();
} }
@ -305,5 +312,6 @@ float LottieLoader::duration()
{ {
this->done(); this->done();
return 0; if (!comp) return 0;
return comp->duration();
} }