mirror of
https://github.com/thorvg/thorvg.git
synced 2025-06-08 05:33:36 +00:00
examples: do not update canvases when frame numbers haven't been changed.
This commit is contained in:
parent
992891e6a8
commit
86467481d1
2 changed files with 15 additions and 10 deletions
|
@ -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());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Add table
Reference in a new issue