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

View file

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