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>
This commit is contained in:
Noel Grandin 2019-07-05 12:46:49 +02:00
parent a2c665e4dd
commit 6469b6134e
8 changed files with 30 additions and 109 deletions

View file

@ -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;

View file

@ -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;

View file

@ -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 \

View file

@ -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: */

View file

@ -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();

View file

@ -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 )

View file

@ -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: */

View file

@ -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