include/vcl/animate/Animation.hxx | 4 - solenv/clang-format/excludelist | 4 - vcl/CppunitTest_vcl_animation.mk | 2 vcl/Library_vcl.mk | 2 vcl/inc/animate/AnimationRenderer.hxx | 15 ++--- vcl/qa/cppunit/animationrenderer.cxx | 46 ++++++++-------- vcl/source/animate/Animation.cxx | 89 ++++++++++++++++--------------- vcl/source/animate/AnimationRenderer.cxx | 20 +++--- 8 files changed, 93 insertions(+), 89 deletions(-)
New commits: commit a98b0037c6116ed7a0f4f426571bbb361cf2e62f Author: Chris Sherlock <chris.sherloc...@gmail.com> AuthorDate: Sat May 28 12:04:32 2022 +1000 Commit: Tomaž Vajngerl <qui...@gmail.com> CommitDate: Tue Jun 21 07:47:29 2022 +0200 vcl: rename ImplAnimView to AnimationRenderer An ImplAnimView is actually just a way of rendering an animation to an OutputDevice (RenderContext). Each instance has a unique ID (called mnExraData, which is quite misleading). ImplAnimView doesn't really mean much so hence the rename to make this a bit more clear. In the process, also rename local variables pView to pRenderer in Animation functions. Change-Id: Ib70f41052c5266acd7f2460001ce5be75b74d5a7 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/76402 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl <qui...@gmail.com> diff --git a/include/vcl/animate/Animation.hxx b/include/vcl/animate/Animation.hxx index 809b8eac434d..57f1c9d6227e 100644 --- a/include/vcl/animate/Animation.hxx +++ b/include/vcl/animate/Animation.hxx @@ -27,7 +27,7 @@ #define ANIMATION_TIMEOUT_ON_CLICK 2147483647L -class ImplAnimView; +class AnimationRenderer; class VCL_DLLPUBLIC Animation { @@ -97,7 +97,7 @@ private: SAL_DLLPRIVATE static sal_uLong mnAnimCount; std::vector<std::unique_ptr<AnimationBitmap>> maFrames; - std::vector<std::unique_ptr<ImplAnimView>> maViewList; + std::vector<std::unique_ptr<AnimationRenderer>> maRenderers; Link<Animation*, void> maNotifyLink; BitmapEx maBitmapEx; diff --git a/solenv/clang-format/excludelist b/solenv/clang-format/excludelist index 9b508e79ec69..2b91f820013d 100644 --- a/solenv/clang-format/excludelist +++ b/solenv/clang-format/excludelist @@ -14300,6 +14300,7 @@ vcl/inc/WidgetThemeLibraryTypes.hxx vcl/inc/bitmap/bmpfast.hxx vcl/inc/accel.hxx vcl/inc/accmgr.hxx +vcl/inc/animate/AnimationRenderer.hxx vcl/inc/brdwin.hxx vcl/inc/bubblewindow.hxx vcl/inc/calendar.hxx @@ -14330,7 +14331,6 @@ vcl/inc/helpwin.hxx vcl/inc/hyperlabel.hxx vcl/inc/image.h vcl/inc/imagerepository.hxx -vcl/inc/impanmvw.hxx vcl/inc/impdel.hxx vcl/inc/impfont.hxx vcl/inc/impfontcache.hxx @@ -14655,6 +14655,7 @@ vcl/quartz/salgdi.cxx vcl/quartz/salgdicommon.cxx vcl/quartz/salvd.cxx vcl/quartz/utils.cxx +vcl/source/animate/AnimationRenderer.cxx vcl/source/app/IconThemeInfo.cxx vcl/source/app/IconThemeScanner.cxx vcl/source/app/IconThemeSelector.cxx @@ -14840,7 +14841,6 @@ vcl/source/gdi/gradient.cxx vcl/source/gdi/graph.cxx vcl/source/gdi/graphictools.cxx vcl/source/gdi/hatch.cxx -vcl/source/gdi/impanmvw.cxx vcl/source/gdi/impgraph.cxx vcl/source/gdi/impvect.hxx vcl/source/gdi/jobset.cxx diff --git a/vcl/CppunitTest_vcl_animation.mk b/vcl/CppunitTest_vcl_animation.mk index 659fdbe819ce..3881005e6d4b 100644 --- a/vcl/CppunitTest_vcl_animation.mk +++ b/vcl/CppunitTest_vcl_animation.mk @@ -15,7 +15,7 @@ $(eval $(call gb_CppunitTest_set_include,vcl_animation,\ )) $(eval $(call gb_CppunitTest_add_exception_objects,vcl_animation, \ - vcl/qa/cppunit/implanimview \ + vcl/qa/cppunit/animationrenderer \ vcl/qa/cppunit/animation \ )) diff --git a/vcl/Library_vcl.mk b/vcl/Library_vcl.mk index 6910927bfde0..5688f1f22ecc 100644 --- a/vcl/Library_vcl.mk +++ b/vcl/Library_vcl.mk @@ -101,6 +101,7 @@ $(eval $(call gb_Library_add_exception_objects,vcl,\ vcl/skia/SkiaHelper \ vcl/source/animate/Animation \ vcl/source/animate/AnimationBitmap \ + vcl/source/animate/AnimationRenderer \ vcl/source/cnttype/mcnttfactory \ vcl/source/cnttype/mcnttype \ vcl/source/printer/Options \ @@ -275,7 +276,6 @@ $(eval $(call gb_Library_add_exception_objects,vcl,\ vcl/source/gdi/graph \ vcl/source/gdi/graphictools \ vcl/source/gdi/hatch \ - vcl/source/gdi/impanmvw \ vcl/source/gdi/impglyphitem \ vcl/source/gdi/impgraph \ vcl/source/gdi/jobset \ diff --git a/vcl/inc/impanmvw.hxx b/vcl/inc/animate/AnimationRenderer.hxx similarity index 89% rename from vcl/inc/impanmvw.hxx rename to vcl/inc/animate/AnimationRenderer.hxx index 5323afbccebc..a9fc425e20bb 100644 --- a/vcl/inc/impanmvw.hxx +++ b/vcl/inc/animate/AnimationRenderer.hxx @@ -17,8 +17,7 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ -#ifndef INCLUDED_VCL_SOURCE_GDI_IMPANMVW_HXX -#define INCLUDED_VCL_SOURCE_GDI_IMPANMVW_HXX +#pragma once #include <vcl/dllapi.h> #include <vcl/animate/Animation.hxx> @@ -34,7 +33,7 @@ struct AInfo Point aStartOrg; Size aStartSize; VclPtr<OutputDevice> pOutDev; - void* pViewData; + void* pRendererData; tools::Long nExtraData; bool bPause; @@ -42,7 +41,7 @@ struct AInfo }; -class VCL_DLLPUBLIC ImplAnimView +class VCL_DLLPUBLIC AnimationRenderer { private: @@ -69,11 +68,11 @@ private: bool mbIsMirroredVertically; public: - ImplAnimView( Animation* pParent, OutputDevice* pOut, + AnimationRenderer( Animation* pParent, OutputDevice* pOut, const Point& rPt, const Size& rSz, sal_uLong nExtraData, OutputDevice* pFirstFrameOutDev = nullptr ); - ImplAnimView(ImplAnimView&&) = delete; - ~ImplAnimView(); + AnimationRenderer(AnimationRenderer&&) = delete; + ~AnimationRenderer(); bool matches(const OutputDevice* pOut, tools::Long nExtraData) const; void drawToPos( sal_uLong nPos ); @@ -94,6 +93,4 @@ public: bool isMarked() const { return mbIsMarked; } }; -#endif - /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/qa/cppunit/implanimview.cxx b/vcl/qa/cppunit/animationrenderer.cxx similarity index 66% rename from vcl/qa/cppunit/implanimview.cxx rename to vcl/qa/cppunit/animationrenderer.cxx index 01386fac048d..25dfdc44dab5 100644 --- a/vcl/qa/cppunit/implanimview.cxx +++ b/vcl/qa/cppunit/animationrenderer.cxx @@ -14,7 +14,7 @@ #include <vcl/outdev.hxx> #include <vcl/virdev.hxx> -#include <impanmvw.hxx> +#include <animate/AnimationRenderer.hxx> namespace { @@ -33,10 +33,10 @@ public: }; } -class VclImplAnimViewTest : public test::BootstrapFixture +class VclAnimationRendererTest : public test::BootstrapFixture { public: - VclImplAnimViewTest() + VclAnimationRendererTest() : BootstrapFixture(true, false) { } @@ -45,7 +45,7 @@ public: void testDrawToPos(); void testGetPosSizeWindow(); - CPPUNIT_TEST_SUITE(VclImplAnimViewTest); + CPPUNIT_TEST_SUITE(VclAnimationRendererTest); CPPUNIT_TEST(testMatching); CPPUNIT_TEST(testDrawToPos); CPPUNIT_TEST(testGetPosSizeWindow); @@ -55,54 +55,54 @@ private: Animation createAnimation(); }; -void VclImplAnimViewTest::testMatching() +void VclAnimationRendererTest::testMatching() { Animation aTestAnim = createAnimation(); ScopedVclPtrInstance<TestRenderingContext> pTestRC; - ImplAnimView* pImplAnimView - = new ImplAnimView(&aTestAnim, pTestRC, Point(0, 0), Size(10, 10), 5); - CPPUNIT_ASSERT(pImplAnimView->matches(pTestRC, 5)); - CPPUNIT_ASSERT(!pImplAnimView->matches(pTestRC, 10)); + AnimationRenderer* pAnimationRenderer + = new AnimationRenderer(&aTestAnim, pTestRC, Point(0, 0), Size(10, 10), 5); + CPPUNIT_ASSERT(pAnimationRenderer->matches(pTestRC, 5)); + CPPUNIT_ASSERT(!pAnimationRenderer->matches(pTestRC, 10)); // caller ID of 0 only matches the OutputDevice - CPPUNIT_ASSERT(pImplAnimView->matches(pTestRC, 0)); + CPPUNIT_ASSERT(pAnimationRenderer->matches(pTestRC, 0)); } -void VclImplAnimViewTest::testDrawToPos() +void VclAnimationRendererTest::testDrawToPos() { Animation aTestAnim = createAnimation(); ScopedVclPtrInstance<VirtualDevice> pTestRC; - ImplAnimView* pImplAnimView - = new ImplAnimView(&aTestAnim, pTestRC.get(), Point(0, 0), Size(10, 10), 5); - pImplAnimView->drawToPos(0); - pImplAnimView->drawToPos(1); - pImplAnimView->drawToPos(2); - pImplAnimView->drawToPos(10); + AnimationRenderer* pAnimationRenderer + = new AnimationRenderer(&aTestAnim, pTestRC.get(), Point(0, 0), Size(10, 10), 5); + pAnimationRenderer->drawToPos(0); + pAnimationRenderer->drawToPos(1); + pAnimationRenderer->drawToPos(2); + pAnimationRenderer->drawToPos(10); CPPUNIT_ASSERT_EQUAL(Size(1, 1), pTestRC->GetOutputSizePixel()); } -void VclImplAnimViewTest::testGetPosSizeWindow() +void VclAnimationRendererTest::testGetPosSizeWindow() { Animation aTestAnim = createAnimation(); ScopedVclPtrInstance<TestRenderingContext> pTestRC; - ImplAnimView* pImplAnimView - = new ImplAnimView(&aTestAnim, pTestRC, Point(0, 0), Size(10, 10), 5); + AnimationRenderer* pAnimationRenderer + = new AnimationRenderer(&aTestAnim, pTestRC, Point(0, 0), Size(10, 10), 5); AnimationBitmap aAnimBmp(BitmapEx(Size(3, 4), vcl::PixelFormat::N24_BPP), Point(0, 0), Size(10, 10)); Point aPos; Size aSize; - pImplAnimView->getPosSize(aAnimBmp, aPos, aSize); + pAnimationRenderer->getPosSize(aAnimBmp, aPos, aSize); CPPUNIT_ASSERT_EQUAL(Point(0, 0), aPos); CPPUNIT_ASSERT_EQUAL(Size(10, 10), aSize); } -Animation VclImplAnimViewTest::createAnimation() +Animation VclAnimationRendererTest::createAnimation() { Animation aAnimation; @@ -114,7 +114,7 @@ Animation VclImplAnimViewTest::createAnimation() return aAnimation; } -CPPUNIT_TEST_SUITE_REGISTRATION(VclImplAnimViewTest); +CPPUNIT_TEST_SUITE_REGISTRATION(VclAnimationRendererTest); CPPUNIT_PLUGIN_IMPLEMENT(); diff --git a/vcl/source/animate/Animation.cxx b/vcl/source/animate/Animation.cxx index e1086cd8d3eb..04a52cfd79cb 100644 --- a/vcl/source/animate/Animation.cxx +++ b/vcl/source/animate/Animation.cxx @@ -29,7 +29,7 @@ #include <vcl/dibtools.hxx> #include <vcl/BitmapColorQuantizationFilter.hxx> -#include <impanmvw.hxx> +#include <animate/AnimationRenderer.hxx> sal_uLong Animation::mnAnimCount = 0; @@ -103,7 +103,7 @@ void Animation::Clear() maGlobalSize = Size(); maBitmapEx.SetEmpty(); maFrames.clear(); - maViewList.clear(); + maRenderers.clear(); } bool Animation::IsTransparent() const @@ -174,12 +174,12 @@ bool Animation::Start(OutputDevice& rOut, const Point& rDestPt, const Size& rDes bool differs = true; auto itAnimView = std::find_if( - maViewList.begin(), maViewList.end(), - [&rOut, nExtraData](const std::unique_ptr<ImplAnimView>& pAnimView) -> bool { + maRenderers.begin(), maRenderers.end(), + [&rOut, nExtraData](const std::unique_ptr<AnimationRenderer>& pAnimView) -> bool { return pAnimView->matches(&rOut, nExtraData); }); - if (itAnimView != maViewList.end()) + if (itAnimView != maRenderers.end()) { if ((*itAnimView)->getOutPos() == rDestPt && (*itAnimView)->getOutSizePix() == rOut.LogicToPixel(rDestSz)) @@ -188,10 +188,10 @@ bool Animation::Start(OutputDevice& rOut, const Point& rDestPt, const Size& rDes differs = false; } else - maViewList.erase(itAnimView); + maRenderers.erase(itAnimView); } - if (maViewList.empty()) + if (maRenderers.empty()) { maTimer.Stop(); mbIsInAnimation = false; @@ -199,8 +199,8 @@ bool Animation::Start(OutputDevice& rOut, const Point& rDestPt, const Size& rDes } if (differs) - maViewList.emplace_back( - new ImplAnimView(this, &rOut, rDestPt, rDestSz, nExtraData, pFirstFrameOutDev)); + maRenderers.emplace_back(new AnimationRenderer(this, &rOut, rDestPt, rDestSz, + nExtraData, pFirstFrameOutDev)); if (!mbIsInAnimation) { @@ -219,13 +219,14 @@ bool Animation::Start(OutputDevice& rOut, const Point& rDestPt, const Size& rDes void Animation::Stop(const OutputDevice* pOut, tools::Long nExtraData) { - maViewList.erase(std::remove_if(maViewList.begin(), maViewList.end(), - [=](const std::unique_ptr<ImplAnimView>& pAnimView) -> bool { - return pAnimView->matches(pOut, nExtraData); - }), - maViewList.end()); - - if (maViewList.empty()) + maRenderers.erase( + std::remove_if(maRenderers.begin(), maRenderers.end(), + [=](const std::unique_ptr<AnimationRenderer>& pAnimView) -> bool { + return pAnimView->matches(pOut, nExtraData); + }), + maRenderers.end()); + + if (maRenderers.empty()) { maTimer.Stop(); mbIsInAnimation = false; @@ -257,7 +258,7 @@ void Animation::Draw(OutputDevice& rOut, const Point& rDestPt, const Size& rDest const_cast<Animation*>(this)->mnPos = nCount - 1; { - ImplAnimView{ const_cast<Animation*>(this), &rOut, rDestPt, rDestSz, 0 }; + AnimationRenderer{ const_cast<Animation*>(this), &rOut, rDestPt, rDestSz, 0 }; } const_cast<Animation*>(this)->mnPos = nOldPos; @@ -287,7 +288,7 @@ IMPL_LINK_NOARG(Animation, ImplTimeoutHdl, Timer*, void) { std::vector<std::unique_ptr<AInfo>> aAInfoList; // create AInfo-List - for (auto const& i : maViewList) + for (auto const& i : maRenderers) aAInfoList.emplace_back(i->createAInfo()); maNotifyLink.Call(this); @@ -295,39 +296,44 @@ IMPL_LINK_NOARG(Animation, ImplTimeoutHdl, Timer*, void) // set view state from AInfo structure for (auto& pAInfo : aAInfoList) { - ImplAnimView* pView = nullptr; - if (!pAInfo->pViewData) + AnimationRenderer* pRenderer = nullptr; + if (!pAInfo->pRendererData) { - pView = new ImplAnimView(this, pAInfo->pOutDev, pAInfo->aStartOrg, - pAInfo->aStartSize, pAInfo->nExtraData); + pRenderer = new AnimationRenderer(this, pAInfo->pOutDev, pAInfo->aStartOrg, + pAInfo->aStartSize, pAInfo->nExtraData); - maViewList.push_back(std::unique_ptr<ImplAnimView>(pView)); + maRenderers.push_back(std::unique_ptr<AnimationRenderer>(pRenderer)); } else - pView = static_cast<ImplAnimView*>(pAInfo->pViewData); + pRenderer = static_cast<AnimationRenderer*>(pAInfo->pRendererData); - pView->pause(pAInfo->bPause); - pView->setMarked(true); + pRenderer->pause(pAInfo->bPause); + pRenderer->setMarked(true); } // delete all unmarked views - auto removeStart = std::remove_if(maViewList.begin(), maViewList.end(), - [](const auto& pView) { return !pView->isMarked(); }); - maViewList.erase(removeStart, maViewList.cend()); + auto removeStart + = std::remove_if(maRenderers.begin(), maRenderers.end(), + [](const auto& pRenderer) { return !pRenderer->isMarked(); }); + maRenderers.erase(removeStart, maRenderers.cend()); // check if every remaining view is paused - bGlobalPause = std::all_of(maViewList.cbegin(), maViewList.cend(), - [](const auto& pView) { return pView->isPause(); }); + bGlobalPause = std::all_of(maRenderers.cbegin(), maRenderers.cend(), + [](const auto& pRenderer) { return pRenderer->isPause(); }); // reset marked state - std::for_each(maViewList.cbegin(), maViewList.cend(), - [](const auto& pView) { pView->setMarked(false); }); + std::for_each(maRenderers.cbegin(), maRenderers.cend(), + [](const auto& pRenderer) { pRenderer->setMarked(false); }); } - if (maViewList.empty()) + if (maRenderers.empty()) + { Stop(); + } else if (bGlobalPause) + { ImplRestartTimer(10); + } else { AnimationBitmap* pStepBmp @@ -354,19 +360,20 @@ IMPL_LINK_NOARG(Animation, ImplTimeoutHdl, Timer*, void) } // Paint all views. - std::for_each(maViewList.cbegin(), maViewList.cend(), - [this](const auto& pView) { pView->draw(mnPos); }); + std::for_each(maRenderers.cbegin(), maRenderers.cend(), + [this](const auto& pRenderer) { pRenderer->draw(mnPos); }); /* * 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(maViewList.begin(), maViewList.end(), - [](const auto& pView) { return pView->isMarked(); }); - maViewList.erase(removeStart, maViewList.cend()); + 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 (maViewList.empty()) + if (maRenderers.empty()) Stop(); else ImplRestartTimer(pStepBmp->mnWait); @@ -669,7 +676,7 @@ SvStream& ReadAnimation(SvStream& rIStm, Animation& rAnimation) AInfo::AInfo() : pOutDev(nullptr) - , pViewData(nullptr) + , pRendererData(nullptr) , nExtraData(0) , bPause(false) { diff --git a/vcl/source/gdi/impanmvw.cxx b/vcl/source/animate/AnimationRenderer.cxx similarity index 94% rename from vcl/source/gdi/impanmvw.cxx rename to vcl/source/animate/AnimationRenderer.cxx index 00a02912abc1..77faf0205255 100644 --- a/vcl/source/gdi/impanmvw.cxx +++ b/vcl/source/animate/AnimationRenderer.cxx @@ -18,7 +18,7 @@ */ #include <memory> -#include <impanmvw.hxx> +#include <animate/AnimationRenderer.hxx> #include <vcl/virdev.hxx> #include <vcl/window.hxx> @@ -26,7 +26,7 @@ #include <window.h> -ImplAnimView::ImplAnimView( Animation* pParent, OutputDevice* pOut, +AnimationRenderer::AnimationRenderer( Animation* pParent, OutputDevice* pOut, const Point& rPt, const Size& rSz, sal_uLong nExtraData, OutputDevice* pFirstFrameOutDev ) : @@ -89,7 +89,7 @@ ImplAnimView::ImplAnimView( Animation* pParent, OutputDevice* pOut, } } -ImplAnimView::~ImplAnimView() +AnimationRenderer::~AnimationRenderer() { mpBackground.disposeAndClear(); mpRestore.disposeAndClear(); @@ -97,12 +97,12 @@ ImplAnimView::~ImplAnimView() Animation::ImplDecAnimCount(); } -bool ImplAnimView::matches(const OutputDevice* pOut, tools::Long nExtraData) const +bool AnimationRenderer::matches(const OutputDevice* pOut, tools::Long nExtraData) const { return (!pOut || pOut == mpRenderContext) && (nExtraData == 0 || nExtraData == mnExtraData); } -void ImplAnimView::getPosSize( const AnimationBitmap& rAnimationBitmap, Point& rPosPix, Size& rSizePix ) +void AnimationRenderer::getPosSize( const AnimationBitmap& rAnimationBitmap, Point& rPosPix, Size& rSizePix ) { const Size& rAnmSize = mpParent->GetDisplaySizePixel(); Point aPt2( rAnimationBitmap.maPositionPixel.X() + rAnimationBitmap.maSizePixel.Width() - 1, @@ -139,7 +139,7 @@ void ImplAnimView::getPosSize( const AnimationBitmap& rAnimationBitmap, Point& r rPosPix.setY( maSzPix.Height() - 1 - aPt2.Y() ); } -void ImplAnimView::drawToPos( sal_uLong nPos ) +void AnimationRenderer::drawToPos( sal_uLong nPos ) { VclPtr<vcl::RenderContext> pRenderContext = mpRenderContext; @@ -173,7 +173,7 @@ void ImplAnimView::drawToPos( sal_uLong nPos ) pRenderContext->SetClipRegion(*xOldClip); } -void ImplAnimView::draw( sal_uLong nPos, VirtualDevice* pVDev ) +void AnimationRenderer::draw( sal_uLong nPos, VirtualDevice* pVDev ) { VclPtr<vcl::RenderContext> pRenderContext = mpRenderContext; @@ -296,7 +296,7 @@ void ImplAnimView::draw( sal_uLong nPos, VirtualDevice* pVDev ) } } -void ImplAnimView::repaint() +void AnimationRenderer::repaint() { const bool bOldPause = mbIsPaused; @@ -307,14 +307,14 @@ void ImplAnimView::repaint() mbIsPaused = bOldPause; } -AInfo* ImplAnimView::createAInfo() const +AInfo* AnimationRenderer::createAInfo() const { AInfo* pAInfo = new AInfo; pAInfo->aStartOrg = maPt; pAInfo->aStartSize = maSz; pAInfo->pOutDev = mpRenderContext; - pAInfo->pViewData = const_cast<ImplAnimView *>(this); + pAInfo->pRendererData = const_cast<AnimationRenderer *>(this); pAInfo->nExtraData = mnExtraData; pAInfo->bPause = mbIsPaused;