summaryrefslogtreecommitdiff
path: root/vcl
diff options
context:
space:
mode:
authorTomaž Vajngerl <tomaz.vajngerl@collabora.co.uk>2024-03-12 12:07:33 +0900
committerTomaž Vajngerl <quikee@gmail.com>2024-03-22 05:50:07 +0100
commit4dd52211794adc7da2c19cb3defcdef16985c278 (patch)
tree8a3ad67af83d5dd830f4444f80b9266944042ce9 /vcl
parent805dd6bee49164d9a77de4ea9e0d53b416daca7a (diff)
vcl: simplify constructors of ImpGraphic
Change-Id: I6df0da16d777549e6187327271868774498d073b Reviewed-on: https://gerrit.libreoffice.org/c/core/+/164694 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
Diffstat (limited to 'vcl')
-rw-r--r--vcl/inc/impgraph.hxx13
-rw-r--r--vcl/source/gdi/impgraph.cxx92
2 files changed, 35 insertions, 70 deletions
diff --git a/vcl/inc/impgraph.hxx b/vcl/inc/impgraph.hxx
index 15d68d00157c..9ef10d19061d 100644
--- a/vcl/inc/impgraph.hxx
+++ b/vcl/inc/impgraph.hxx
@@ -73,19 +73,20 @@ private:
std::shared_ptr<GraphicReader> mpContext;
std::shared_ptr<ImpSwapFile> mpSwapFile;
std::shared_ptr<GfxLink> mpGfxLink;
- GraphicType meType;
- mutable sal_uLong mnSizeBytes;
- bool mbSwapOut;
- bool mbDummyContext;
std::shared_ptr<VectorGraphicData> maVectorGraphicData;
+
+ GraphicType meType = GraphicType::NONE;
+ mutable sal_uLong mnSizeBytes = 0;
+ bool mbSwapOut = false;
+ bool mbDummyContext = false;
// cache checksum computation
mutable BitmapChecksum mnChecksum = 0;
std::optional<GraphicID> mxGraphicID;
GraphicExternalLink maGraphicExternalLink;
- std::chrono::high_resolution_clock::time_point maLastUsed;
- bool mbPrepared;
+ mutable std::chrono::high_resolution_clock::time_point maLastUsed = std::chrono::high_resolution_clock::now();
+ bool mbPrepared = false;
public:
ImpGraphic();
diff --git a/vcl/source/gdi/impgraph.cxx b/vcl/source/gdi/impgraph.cxx
index 7150aab6b0e6..2c9f03f3a02e 100644
--- a/vcl/source/gdi/impgraph.cxx
+++ b/vcl/source/gdi/impgraph.cxx
@@ -81,13 +81,7 @@ SvStream* ImpGraphic::getSwapFileStream() const
return nullptr;
}
-ImpGraphic::ImpGraphic() :
- meType ( GraphicType::NONE ),
- mnSizeBytes ( 0 ),
- mbSwapOut ( false ),
- mbDummyContext ( false ),
- maLastUsed (std::chrono::high_resolution_clock::now()),
- mbPrepared ( false )
+ImpGraphic::ImpGraphic()
{
}
@@ -98,18 +92,18 @@ ImpGraphic::ImpGraphic(const ImpGraphic& rImpGraphic)
, mpContext(rImpGraphic.mpContext)
, mpSwapFile(rImpGraphic.mpSwapFile)
, mpGfxLink(rImpGraphic.mpGfxLink)
+ , maVectorGraphicData(rImpGraphic.maVectorGraphicData)
, meType(rImpGraphic.meType)
, mnSizeBytes(rImpGraphic.mnSizeBytes)
, mbSwapOut(rImpGraphic.mbSwapOut)
, mbDummyContext(rImpGraphic.mbDummyContext)
- , maVectorGraphicData(rImpGraphic.maVectorGraphicData)
, maGraphicExternalLink(rImpGraphic.maGraphicExternalLink)
- , maLastUsed (std::chrono::high_resolution_clock::now())
- , mbPrepared (rImpGraphic.mbPrepared)
+ , mbPrepared(rImpGraphic.mbPrepared)
{
- if( rImpGraphic.mpAnimation )
+ // Special case for animations
+ if (rImpGraphic.mpAnimation)
{
- mpAnimation = std::make_unique<Animation>( *rImpGraphic.mpAnimation );
+ mpAnimation = std::make_unique<Animation>(*rImpGraphic.mpAnimation);
maBitmapEx = mpAnimation->GetBitmapEx();
}
}
@@ -122,13 +116,12 @@ ImpGraphic::ImpGraphic(ImpGraphic&& rImpGraphic) noexcept
, mpContext(std::move(rImpGraphic.mpContext))
, mpSwapFile(std::move(rImpGraphic.mpSwapFile))
, mpGfxLink(std::move(rImpGraphic.mpGfxLink))
+ , maVectorGraphicData(std::move(rImpGraphic.maVectorGraphicData))
, meType(rImpGraphic.meType)
, mnSizeBytes(rImpGraphic.mnSizeBytes)
, mbSwapOut(rImpGraphic.mbSwapOut)
, mbDummyContext(rImpGraphic.mbDummyContext)
- , maVectorGraphicData(std::move(rImpGraphic.maVectorGraphicData))
, maGraphicExternalLink(rImpGraphic.maGraphicExternalLink)
- , maLastUsed (std::chrono::high_resolution_clock::now())
, mbPrepared (rImpGraphic.mbPrepared)
{
rImpGraphic.clear();
@@ -138,11 +131,7 @@ ImpGraphic::ImpGraphic(ImpGraphic&& rImpGraphic) noexcept
ImpGraphic::ImpGraphic(std::shared_ptr<GfxLink> xGfxLink, sal_Int32 nPageIndex)
: mpGfxLink(std::move(xGfxLink))
, meType(GraphicType::Bitmap)
- , mnSizeBytes(0)
, mbSwapOut(true)
- , mbDummyContext(false)
- , maLastUsed (std::chrono::high_resolution_clock::now())
- , mbPrepared (false)
{
maSwapInfo.mbIsTransparent = true;
maSwapInfo.mbIsAlpha = true;
@@ -152,59 +141,34 @@ ImpGraphic::ImpGraphic(std::shared_ptr<GfxLink> xGfxLink, sal_Int32 nPageIndex)
maSwapInfo.mnPageIndex = nPageIndex;
}
-ImpGraphic::ImpGraphic(GraphicExternalLink aGraphicExternalLink) :
- meType ( GraphicType::Default ),
- mnSizeBytes ( 0 ),
- mbSwapOut ( false ),
- mbDummyContext ( false ),
- maGraphicExternalLink(std::move(aGraphicExternalLink)),
- maLastUsed (std::chrono::high_resolution_clock::now()),
- mbPrepared (false)
+ImpGraphic::ImpGraphic(GraphicExternalLink aGraphicExternalLink)
+ : meType(GraphicType::Default)
+ , maGraphicExternalLink(std::move(aGraphicExternalLink))
{
}
-ImpGraphic::ImpGraphic( const BitmapEx& rBitmapEx ) :
- maBitmapEx ( rBitmapEx ),
- meType ( !rBitmapEx.IsEmpty() ? GraphicType::Bitmap : GraphicType::NONE ),
- mnSizeBytes ( 0 ),
- mbSwapOut ( false ),
- mbDummyContext ( false ),
- maLastUsed (std::chrono::high_resolution_clock::now()),
- mbPrepared (false)
+ImpGraphic::ImpGraphic(const BitmapEx& rBitmapEx)
+ : maBitmapEx(rBitmapEx)
+ , meType(!rBitmapEx.IsEmpty() ? GraphicType::Bitmap : GraphicType::NONE)
{
}
ImpGraphic::ImpGraphic(const std::shared_ptr<VectorGraphicData>& rVectorGraphicDataPtr)
-: meType( rVectorGraphicDataPtr ? GraphicType::Bitmap : GraphicType::NONE ),
- mnSizeBytes( 0 ),
- mbSwapOut( false ),
- mbDummyContext ( false ),
- maVectorGraphicData(rVectorGraphicDataPtr),
- maLastUsed (std::chrono::high_resolution_clock::now()),
- mbPrepared (false)
-{
-}
-
-ImpGraphic::ImpGraphic( const Animation& rAnimation ) :
- maBitmapEx ( rAnimation.GetBitmapEx() ),
- mpAnimation ( std::make_unique<Animation>( rAnimation ) ),
- meType ( GraphicType::Bitmap ),
- mnSizeBytes ( 0 ),
- mbSwapOut ( false ),
- mbDummyContext ( false ),
- maLastUsed (std::chrono::high_resolution_clock::now()),
- mbPrepared (false)
-{
-}
-
-ImpGraphic::ImpGraphic( const GDIMetaFile& rMtf ) :
- maMetaFile ( rMtf ),
- meType ( GraphicType::GdiMetafile ),
- mnSizeBytes ( 0 ),
- mbSwapOut ( false ),
- mbDummyContext ( false ),
- maLastUsed (std::chrono::high_resolution_clock::now()),
- mbPrepared (false)
+ : maVectorGraphicData(rVectorGraphicDataPtr)
+ , meType(rVectorGraphicDataPtr ? GraphicType::Bitmap : GraphicType::NONE)
+{
+}
+
+ImpGraphic::ImpGraphic(const Animation& rAnimation)
+ : maBitmapEx(rAnimation.GetBitmapEx())
+ , mpAnimation(std::make_unique<Animation>(rAnimation))
+ , meType(GraphicType::Bitmap)
+{
+}
+
+ImpGraphic::ImpGraphic(const GDIMetaFile& rMetafile)
+ : maMetaFile(rMetafile)
+ , meType(GraphicType::GdiMetafile)
{
}