summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2019-07-05 12:46:49 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2019-07-06 08:23:06 +0200
commit6469b6134e71f6fc2debd8c8812e2dc9ad8e60c3 (patch)
treef0737df448a342df972947e7e969042e69407bce
parenta2c665e4dd73007fe7f0eda2de31db8b768f1df9 (diff)
simplify and flatten OutDevStateStack
Change-Id: Ic2ee5c2e122244e11770ab5fb73f65800828439a Reviewed-on: https://gerrit.libreoffice.org/75128 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
-rw-r--r--include/vcl/outdev.hxx4
-rw-r--r--include/vcl/outdevstate.hxx4
-rw-r--r--vcl/Library_vcl.mk1
-rw-r--r--vcl/inc/outdevstatestack.hxx31
-rw-r--r--vcl/source/outdev/outdev.cxx12
-rw-r--r--vcl/source/outdev/outdevstate.cxx48
-rw-r--r--vcl/source/outdev/outdevstatestack.cxx38
-rw-r--r--vcl/source/outdev/vclreferencebase.cxx1
8 files changed, 30 insertions, 109 deletions
diff --git a/include/vcl/outdev.hxx b/include/vcl/outdev.hxx
index cf1d5c09c685..b3159396f9a4 100644
--- a/include/vcl/outdev.hxx
+++ b/include/vcl/outdev.hxx
@@ -322,8 +322,8 @@ private:
mutable std::shared_ptr<PhysicalFontCollection> mxFontCollection;
mutable std::unique_ptr<ImplDeviceFontList> mpDeviceFontList;
mutable std::unique_ptr<ImplDeviceFontSizeList> mpDeviceFontSizeList;
- std::unique_ptr<OutDevStateStack> mpOutDevStateStack;
- std::unique_ptr<ImplOutDevData> mpOutDevData;
+ std::vector<OutDevState> maOutDevStateStack;
+ std::unique_ptr<ImplOutDevData> mpOutDevData;
std::vector< VCLXGraphics* >* mpUnoGraphicsList;
vcl::ExtOutDevData* mpExtOutDevData;
diff --git a/include/vcl/outdevstate.hxx b/include/vcl/outdevstate.hxx
index d3c469eff513..493855248db0 100644
--- a/include/vcl/outdevstate.hxx
+++ b/include/vcl/outdevstate.hxx
@@ -75,10 +75,10 @@ namespace o3tl {
template<> struct typed_flags<ComplexTextLayoutFlags> : is_typed_flags<ComplexTextLayoutFlags, 0x000f> {};
}
-class OutDevState
+struct OutDevState
{
-public:
OutDevState();
+ OutDevState(OutDevState&&);
~OutDevState();
boost::optional<MapMode> mpMapMode;
diff --git a/vcl/Library_vcl.mk b/vcl/Library_vcl.mk
index 7d03373b3797..3540606d4b07 100644
--- a/vcl/Library_vcl.mk
+++ b/vcl/Library_vcl.mk
@@ -219,7 +219,6 @@ $(eval $(call gb_Library_add_exception_objects,vcl,\
vcl/source/toolkit/morebtn \
vcl/source/outdev/outdev \
vcl/source/outdev/outdevstate \
- vcl/source/outdev/outdevstatestack \
vcl/source/outdev/clipping \
vcl/source/outdev/polygon \
vcl/source/outdev/transparent \
diff --git a/vcl/inc/outdevstatestack.hxx b/vcl/inc/outdevstatestack.hxx
deleted file mode 100644
index 0d83f5978b18..000000000000
--- a/vcl/inc/outdevstatestack.hxx
+++ /dev/null
@@ -1,31 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*
- * This file is part of the LibreOffice project.
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- */
-
-#ifndef INCLUDED_VCL_OUTDEVSTATESTACK_HXX
-#define INCLUDED_VCL_OUTDEVSTATESTACK_HXX
-
-#include <vcl/outdevstate.hxx>
-#include <memory>
-#include <deque>
-
-class OutDevStateStack
-{
- std::deque<std::unique_ptr<OutDevState>> maData;
-
-public:
- bool empty() const;
- size_t size() const;
- void push_back( OutDevState* p );
- void pop_back();
- OutDevState& back();
-};
-
-#endif
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/source/outdev/outdev.cxx b/vcl/source/outdev/outdev.cxx
index a7fa60287a29..803fd6746db9 100644
--- a/vcl/source/outdev/outdev.cxx
+++ b/vcl/source/outdev/outdev.cxx
@@ -33,7 +33,6 @@
#include <svdata.hxx>
#include <window.h>
#include <outdev.h>
-#include <outdevstatestack.hxx>
#include <PhysicalFontCollection.hxx>
#ifdef DISABLE_DYNLOADING
@@ -63,7 +62,6 @@ OutputDevice::OutputDevice(OutDevType eOutDevType) :
mpFontInstance = nullptr;
mpDeviceFontList = nullptr;
mpDeviceFontSizeList = nullptr;
- mpOutDevStateStack.reset(new OutDevStateStack);
mpAlphaVDev = nullptr;
mpExtOutDevData = nullptr;
mnOutOffX = 0;
@@ -160,15 +158,9 @@ void OutputDevice::dispose()
mpOutDevData.reset();
// for some reason, we haven't removed state from the stack properly
- if ( !mpOutDevStateStack->empty() )
- {
+ if ( !maOutDevStateStack.empty() )
SAL_WARN( "vcl.gdi", "OutputDevice::~OutputDevice(): OutputDevice::Push() calls != OutputDevice::Pop() calls" );
- while ( !mpOutDevStateStack->empty() )
- {
- mpOutDevStateStack->pop_back();
- }
- }
- mpOutDevStateStack.reset();
+ maOutDevStateStack.clear();
// release the active font instance
mpFontInstance.clear();
diff --git a/vcl/source/outdev/outdevstate.cxx b/vcl/source/outdev/outdevstate.cxx
index d3a9fb5b6c14..21da20adaac6 100644
--- a/vcl/source/outdev/outdevstate.cxx
+++ b/vcl/source/outdev/outdevstate.cxx
@@ -29,7 +29,6 @@
#include <outdev.h>
#include <outdata.hxx>
-#include <outdevstatestack.hxx>
#include <salgdi.hxx>
OutDevState::OutDevState()
@@ -42,6 +41,8 @@ OutDevState::OutDevState()
{
}
+OutDevState::OutDevState(OutDevState&&) = default;
+
OutDevState::~OutDevState()
{
mpLineColor.reset();
@@ -62,58 +63,57 @@ void OutputDevice::Push( PushFlags nFlags )
if ( mpMetaFile )
mpMetaFile->AddAction( new MetaPushAction( nFlags ) );
- OutDevState* pState = new OutDevState;
+ maOutDevStateStack.emplace_back();
+ OutDevState& rState = maOutDevStateStack.back();
- pState->mnFlags = nFlags;
+ rState.mnFlags = nFlags;
if (nFlags & PushFlags::LINECOLOR && mbLineColor)
{
- pState->mpLineColor = maLineColor;
+ rState.mpLineColor = maLineColor;
}
if (nFlags & PushFlags::FILLCOLOR && mbFillColor)
{
- pState->mpFillColor = maFillColor;
+ rState.mpFillColor = maFillColor;
}
if ( nFlags & PushFlags::FONT )
- pState->mpFont.reset( new vcl::Font( maFont ) );
+ rState.mpFont.reset( new vcl::Font( maFont ) );
if ( nFlags & PushFlags::TEXTCOLOR )
- pState->mpTextColor = GetTextColor();
+ rState.mpTextColor = GetTextColor();
if (nFlags & PushFlags::TEXTFILLCOLOR && IsTextFillColor())
{
- pState->mpTextFillColor = GetTextFillColor();
+ rState.mpTextFillColor = GetTextFillColor();
}
if (nFlags & PushFlags::TEXTLINECOLOR && IsTextLineColor())
{
- pState->mpTextLineColor = GetTextLineColor();
+ rState.mpTextLineColor = GetTextLineColor();
}
if (nFlags & PushFlags::OVERLINECOLOR && IsOverlineColor())
{
- pState->mpOverlineColor = GetOverlineColor();
+ rState.mpOverlineColor = GetOverlineColor();
}
if ( nFlags & PushFlags::TEXTALIGN )
- pState->meTextAlign = GetTextAlign();
+ rState.meTextAlign = GetTextAlign();
if( nFlags & PushFlags::TEXTLAYOUTMODE )
- pState->mnTextLayoutMode = GetLayoutMode();
+ rState.mnTextLayoutMode = GetLayoutMode();
if( nFlags & PushFlags::TEXTLANGUAGE )
- pState->meTextLanguage = GetDigitLanguage();
+ rState.meTextLanguage = GetDigitLanguage();
if ( nFlags & PushFlags::RASTEROP )
- pState->meRasterOp = GetRasterOp();
+ rState.meRasterOp = GetRasterOp();
if ( nFlags & PushFlags::MAPMODE )
{
- pState->mpMapMode = maMapMode;
- pState->mbMapActive = mbMap;
+ rState.mpMapMode = maMapMode;
+ rState.mbMapActive = mbMap;
}
if (nFlags & PushFlags::CLIPREGION && mbClipRegion)
{
- pState->mpClipRegion.reset( new vcl::Region( maRegion ) );
+ rState.mpClipRegion.reset( new vcl::Region( maRegion ) );
}
if (nFlags & PushFlags::REFPOINT && mbRefPoint)
{
- pState->mpRefPoint = maRefPoint;
+ rState.mpRefPoint = maRefPoint;
}
- mpOutDevStateStack->push_back( pState );
-
if( mpAlphaVDev )
mpAlphaVDev->Push();
}
@@ -127,12 +127,12 @@ void OutputDevice::Pop()
GDIMetaFile* pOldMetaFile = mpMetaFile;
mpMetaFile = nullptr;
- if ( mpOutDevStateStack->empty() )
+ if ( maOutDevStateStack.empty() )
{
SAL_WARN( "vcl.gdi", "OutputDevice::Pop() without OutputDevice::Push()" );
return;
}
- const OutDevState& rState = mpOutDevStateStack->back();
+ const OutDevState& rState = maOutDevStateStack.back();
if( mpAlphaVDev )
mpAlphaVDev->Pop();
@@ -215,14 +215,14 @@ void OutputDevice::Pop()
SetRefPoint();
}
- mpOutDevStateStack->pop_back();
+ maOutDevStateStack.pop_back();
mpMetaFile = pOldMetaFile;
}
sal_uInt32 OutputDevice::GetGCStackDepth() const
{
- return mpOutDevStateStack->size();
+ return maOutDevStateStack.size();
}
void OutputDevice::EnableOutput( bool bEnable )
diff --git a/vcl/source/outdev/outdevstatestack.cxx b/vcl/source/outdev/outdevstatestack.cxx
deleted file mode 100644
index a5209439920f..000000000000
--- a/vcl/source/outdev/outdevstatestack.cxx
+++ /dev/null
@@ -1,38 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*
- * This file is part of the LibreOffice project.
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- */
-
-#include <memory>
-#include <outdevstatestack.hxx>
-
-bool OutDevStateStack::empty() const
-{
- return maData.empty();
-}
-
-size_t OutDevStateStack::size() const
-{
- return maData.size();
-}
-
-void OutDevStateStack::push_back( OutDevState* p )
-{
- maData.push_back(std::unique_ptr<OutDevState>(p));
-}
-
-void OutDevStateStack::pop_back()
-{
- maData.pop_back();
-}
-
-OutDevState& OutDevStateStack::back()
-{
- return *maData.back();
-}
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/source/outdev/vclreferencebase.cxx b/vcl/source/outdev/vclreferencebase.cxx
index 94a2a2fc9539..6866931ebe77 100644
--- a/vcl/source/outdev/vclreferencebase.cxx
+++ b/vcl/source/outdev/vclreferencebase.cxx
@@ -21,7 +21,6 @@
#include <svdata.hxx>
#include <window.h>
#include <outdev.h>
-#include <outdevstatestack.hxx>
VclReferenceBase::VclReferenceBase() :
mnRefCnt(1), // cf. VclPtrInstance and README.lifecycle