lottie: fixed a missing slot overriding update.

the Lottie scene should be updated when the slot overriding
is updated. Previously, it only depended on the frame update.

issue: https://github.com/thorvg/thorvg/issues/2303
This commit is contained in:
Hermet Park 2024-05-23 15:05:35 +09:00
parent 1c66b5fa3d
commit 9b89178ae9
3 changed files with 11 additions and 6 deletions

View file

@ -42,6 +42,7 @@ void LottieLoader::run(unsigned tid)
comp = parser.comp; comp = parser.comp;
builder->build(comp); builder->build(comp);
} }
rebuild = false;
} }
@ -294,14 +295,14 @@ bool LottieLoader::override(const char* slot)
if (idx < 1) success = false; if (idx < 1) success = false;
free(temp); free(temp);
overriden = success; rebuild = overriden = success;
//reset slots //reset slots
} else if (overriden) { } else if (overriden) {
for (auto s = comp->slots.begin(); s < comp->slots.end(); ++s) { for (auto s = comp->slots.begin(); s < comp->slots.end(); ++s) {
(*s)->reset(); (*s)->reset();
} }
overriden = false; overriden = false;
rebuild = true;
} }
return success; return success;
} }
@ -361,6 +362,8 @@ float LottieLoader::duration()
void LottieLoader::sync() void LottieLoader::sync()
{ {
this->done(); this->done();
if (rebuild) run(0);
} }

View file

@ -44,7 +44,8 @@ public:
char* dirName = nullptr; //base resource directory char* dirName = nullptr; //base resource directory
bool copy = false; //"content" is owned by this loader bool copy = false; //"content" is owned by this loader
bool overriden = false; //overridden properties with slots. bool overriden = false; //overridden properties with slots
bool rebuild = false; //require building the lottie scene
LottieLoader(); LottieLoader();
~LottieLoader(); ~LottieLoader();

View file

@ -29,7 +29,9 @@
RenderUpdateFlag Picture::Impl::load() RenderUpdateFlag Picture::Impl::load()
{ {
if (loader) { if (loader) {
if (!paint) { if (paint) {
loader->sync();
} else {
paint = loader->paint(); paint = loader->paint();
if (paint) { if (paint) {
if (w != loader->w || h != loader->h) { if (w != loader->w || h != loader->h) {
@ -42,8 +44,7 @@ RenderUpdateFlag Picture::Impl::load()
} }
return RenderUpdateFlag::None; return RenderUpdateFlag::None;
} }
} else loader->sync(); }
if (!surface) { if (!surface) {
if ((surface = loader->bitmap())) { if ((surface = loader->bitmap())) {
return RenderUpdateFlag::Image; return RenderUpdateFlag::Image;