diff --git a/src/examples/Animation.cpp b/src/examples/Animation.cpp index 3c550cdd..7d57339d 100644 --- a/src/examples/Animation.cpp +++ b/src/examples/Animation.cpp @@ -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()); + } } diff --git a/src/examples/Lottie.cpp b/src/examples/Lottie.cpp index 5cad33fc..8f46abef 100644 --- a/src/examples/Lottie.cpp +++ b/src/examples/Lottie.cpp @@ -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(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)