summaryrefslogtreecommitdiff
path: root/vcl/source
diff options
context:
space:
mode:
authorChris Sherlock <chris.sherlock79@gmail.com>2022-05-28 12:04:32 +1000
committerTomaž Vajngerl <quikee@gmail.com>2022-06-21 07:47:29 +0200
commita98b0037c6116ed7a0f4f426571bbb361cf2e62f (patch)
tree874fd33b812f1c0f4a2dce75449fab18ac869a61 /vcl/source
parent0dd712ff067115b0b53ba412c61a4f5329662550 (diff)
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 <quikee@gmail.com>
Diffstat (limited to 'vcl/source')
-rw-r--r--vcl/source/animate/Animation.cxx89
-rw-r--r--vcl/source/animate/AnimationRenderer.cxx (renamed from vcl/source/gdi/impanmvw.cxx)20
2 files changed, 58 insertions, 51 deletions
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
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;