include/vcl/animate/Animation.hxx | 1 vcl/source/animate/Animation.cxx | 92 ++++++++++++++++++-------------------- 2 files changed, 46 insertions(+), 47 deletions(-)
New commits: commit 91bc1e6a8c92a7c895f0ba9dcad9ac4d35f3f791 Author: Chris Sherlock <[email protected]> AuthorDate: Sat Jun 25 10:21:17 2022 +1000 Commit: Tomaž Vajngerl <[email protected]> CommitDate: Fri Oct 28 11:09:32 2022 +0200 vcl: extract function Animation::RenderNextFrameInAllRenderers() Change-Id: Iaccf12b251ffe06e24813c48ba3a169d0eaaa61c Reviewed-on: https://gerrit.libreoffice.org/c/core/+/76416 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl <[email protected]> diff --git a/include/vcl/animate/Animation.hxx b/include/vcl/animate/Animation.hxx index b9d9d69e401f..307fed73c222 100644 --- a/include/vcl/animate/Animation.hxx +++ b/include/vcl/animate/Animation.hxx @@ -112,6 +112,7 @@ private: SAL_DLLPRIVATE std::vector<std::unique_ptr<AnimationData>> CreateAnimationDataItems(); SAL_DLLPRIVATE void PopulateRenderers(); + SAL_DLLPRIVATE void RenderNextFrameInAllRenderers(); SAL_DLLPRIVATE void ImplRestartTimer(sal_uLong nTimeout); DECL_DLLPRIVATE_LINK(ImplTimeoutHdl, Timer*, void); diff --git a/vcl/source/animate/Animation.cxx b/vcl/source/animate/Animation.cxx index 4ae010c54332..c6547f9e7852 100644 --- a/vcl/source/animate/Animation.cxx +++ b/vcl/source/animate/Animation.cxx @@ -317,6 +317,50 @@ void Animation::PopulateRenderers() } } +void Animation::RenderNextFrameInAllRenderers() +{ + AnimationFrame* pCurrentFrameBmp + = (++mnFrameIndex < maFrames.size()) ? maFrames[mnFrameIndex].get() : nullptr; + + if (!pCurrentFrameBmp) + { + if (mnLoops == 1) + { + Stop(); + mbLoopTerminated = true; + mnFrameIndex = mnAnimCount - 1; + maBitmapEx = maFrames[mnFrameIndex]->maBitmapEx; + return; + } + else + { + if (mnLoops) + mnLoops--; + + mnFrameIndex = 0; + pCurrentFrameBmp = maFrames[mnFrameIndex].get(); + } + } + + // Paint all views. + std::for_each(maRenderers.cbegin(), maRenderers.cend(), + [this](const auto& pRenderer) { pRenderer->draw(mnFrameIndex); }); + /* + * If a view is marked, remove the view, because + * area of output lies out of display area of window. + * Mark state is set from view itself. + */ + auto removeStart = std::remove_if(maRenderers.begin(), maRenderers.end(), + [](const auto& pRenderer) { return pRenderer->isMarked(); }); + maRenderers.erase(removeStart, maRenderers.cend()); + + // stop or restart timer + if (maRenderers.empty()) + Stop(); + else + ImplRestartTimer(pCurrentFrameBmp->mnWait); +} + IMPL_LINK_NOARG(Animation, ImplTimeoutHdl, Timer*, void) { const size_t nAnimCount = maFrames.size(); @@ -346,57 +390,11 @@ IMPL_LINK_NOARG(Animation, ImplTimeoutHdl, Timer*, void) } if (maRenderers.empty()) - { Stop(); - } else if (bGlobalPause) - { ImplRestartTimer(10); - } else - { - AnimationFrame* pCurrentFrameBmp - = (++mnFrameIndex < maFrames.size()) ? maFrames[mnFrameIndex].get() : nullptr; - - if (!pCurrentFrameBmp) - { - if (mnLoops == 1) - { - Stop(); - mbLoopTerminated = true; - mnFrameIndex = nAnimCount - 1; - maBitmapEx = maFrames[mnFrameIndex]->maBitmapEx; - return; - } - else - { - if (mnLoops) - mnLoops--; - - mnFrameIndex = 0; - pCurrentFrameBmp = maFrames[mnFrameIndex].get(); - } - } - - // Paint all views. - std::for_each(maRenderers.cbegin(), maRenderers.cend(), - [this](const auto& pRenderer) { pRenderer->draw(mnFrameIndex); }); - /* - * If a view is marked, remove the view, because - * area of output lies out of display area of window. - * Mark state is set from view itself. - */ - auto removeStart - = std::remove_if(maRenderers.begin(), maRenderers.end(), - [](const auto& pRenderer) { return pRenderer->isMarked(); }); - maRenderers.erase(removeStart, maRenderers.cend()); - - // stop or restart timer - if (maRenderers.empty()) - Stop(); - else - ImplRestartTimer(pCurrentFrameBmp->mnWait); - } + RenderNextFrameInAllRenderers(); } else Stop();
