examples: do not update canvases when frame numbers haven't been changed.

This commit is contained in:
Hermet Park 2023-08-29 12:36:51 +09:00
parent 992891e6a8
commit 86467481d1
2 changed files with 15 additions and 10 deletions

View file

@ -32,10 +32,13 @@ void tvgUpdateCmds(tvg::Canvas* canvas, tvg::Animation* animation, float progres
{
if (!canvas) return;
//Update animation frame
animation->frame(roundf(animation->totalFrame() * progress));
//Update animation frame only when it's changed
auto frame = lroundf(animation->totalFrame() * progress);
canvas->update(animation->picture());
if (frame != animation->curFrame()) {
animation->frame(frame);
canvas->update(animation->picture());
}
}

View file

@ -92,18 +92,20 @@ void lottieDirCallback(const char* name, const char* path, void* data)
void tvgUpdateCmds(Elm_Transit_Effect *effect, Elm_Transit* transit, double progress)
{
auto before = ecore_time_get();
auto animation = static_cast<tvg::Animation*>(effect);
//Update animation frame
animation->frame(roundf(animation->totalFrame() * progress));
//Update animation frame only when it's changed
auto frame = lroundf(animation->totalFrame() * progress);
swCanvas->update(animation->picture());
if (frame != animation->curFrame()) {
auto before = ecore_time_get();
auto after = ecore_time_get();
animation->frame(frame);
swCanvas->update(animation->picture());
updateTime += after - before;
auto after = ecore_time_get();
updateTime += after - before;
}
}
void tvgSwTest(uint32_t* buffer)