From 577ed366b4a2684f836580cbcea06109f0447102 Mon Sep 17 00:00:00 2001 From: Leon Styhre Date: Mon, 26 Sep 2022 19:00:59 +0200 Subject: [PATCH] Frame advances no longer take place for GIF and Lottie animations unless update() has been called. --- es-core/src/components/GIFAnimComponent.cpp | 11 ++++++++--- es-core/src/components/LottieAnimComponent.cpp | 11 ++++++++--- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/es-core/src/components/GIFAnimComponent.cpp b/es-core/src/components/GIFAnimComponent.cpp index 0ac60e580..28f6ca231 100644 --- a/es-core/src/components/GIFAnimComponent.cpp +++ b/es-core/src/components/GIFAnimComponent.cpp @@ -37,7 +37,7 @@ GIFAnimComponent::GIFAnimComponent() , mTimeAccumulator {0} , mLastRenderedFrame {-1} , mSkippedFrames {0} - , mHoldFrame {false} + , mHoldFrame {true} , mPause {false} , mExternalPause {false} , mAlternate {false} @@ -344,7 +344,7 @@ void GIFAnimComponent::applyTheme(const std::shared_ptr& theme, void GIFAnimComponent::update(int deltaTime) { - if (!isVisible() || mThemeOpacity == 0.0f || mAnimation == nullptr) + if (mAnimation == nullptr || !isVisible() || mOpacity == 0.0f || mThemeOpacity == 0.0f) return; if (mWindow->getAllowFileAnimation()) { @@ -356,6 +356,9 @@ void GIFAnimComponent::update(int deltaTime) return; } + // Make sure no frames are advanced unless update() has been called. + mHoldFrame = false; + // If the time accumulator value is really high something must have happened such as the // application having been suspended. Reset it to zero in this case as it would otherwise // never recover. @@ -392,7 +395,7 @@ void GIFAnimComponent::update(int deltaTime) void GIFAnimComponent::render(const glm::mat4& parentTrans) { - if (!isVisible() || mThemeOpacity == 0.0f || mAnimation == nullptr) + if (mAnimation == nullptr || !isVisible() || mOpacity == 0.0f || mThemeOpacity == 0.0f) return; glm::mat4 trans {parentTrans * getTransform()}; @@ -498,4 +501,6 @@ void GIFAnimComponent::render(const glm::mat4& parentTrans) // Render it. mRenderer->drawTriangleStrips(&vertices[0], 4); } + + mHoldFrame = true; } diff --git a/es-core/src/components/LottieAnimComponent.cpp b/es-core/src/components/LottieAnimComponent.cpp index e4b1badc5..2fb5c73eb 100644 --- a/es-core/src/components/LottieAnimComponent.cpp +++ b/es-core/src/components/LottieAnimComponent.cpp @@ -32,7 +32,7 @@ LottieAnimComponent::LottieAnimComponent() , mTimeAccumulator {0} , mLastRenderedFrame {-1} , mSkippedFrames {0} - , mHoldFrame {false} + , mHoldFrame {true} , mPause {false} , mExternalPause {false} , mAlternate {false} @@ -298,7 +298,7 @@ void LottieAnimComponent::applyTheme(const std::shared_ptr& theme, void LottieAnimComponent::update(int deltaTime) { - if (mAnimation == nullptr) + if (mAnimation == nullptr || !isVisible() || mOpacity == 0.0f || mThemeOpacity == 0.0f) return; if (mWindow->getAllowFileAnimation()) { @@ -310,6 +310,9 @@ void LottieAnimComponent::update(int deltaTime) return; } + // Make sure no frames are advanced unless update() has been called. + mHoldFrame = false; + // If the time accumulator value is really high something must have happened such as the // application having been suspended. Reset it to zero in this case as it would otherwise // never recover. @@ -346,7 +349,7 @@ void LottieAnimComponent::update(int deltaTime) void LottieAnimComponent::render(const glm::mat4& parentTrans) { - if (!isVisible() || mThemeOpacity == 0.0f || mAnimation == nullptr) + if (mAnimation == nullptr || !isVisible() || mOpacity == 0.0f || mThemeOpacity == 0.0f) return; glm::mat4 trans {parentTrans * getTransform()}; @@ -489,4 +492,6 @@ void LottieAnimComponent::render(const glm::mat4& parentTrans) // Render it. mRenderer->drawTriangleStrips(&vertices[0], 4); } + + mHoldFrame = true; }