vcl/inc/impgraph.hxx        |   13 +++---
 vcl/source/gdi/impgraph.cxx |   92 +++++++++++++-------------------------------
 2 files changed, 35 insertions(+), 70 deletions(-)

New commits:
commit 4dd52211794adc7da2c19cb3defcdef16985c278
Author:     Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk>
AuthorDate: Tue Mar 12 12:07:33 2024 +0900
Commit:     Tomaž Vajngerl <qui...@gmail.com>
CommitDate: Fri Mar 22 05:50:07 2024 +0100

    vcl: simplify constructors of ImpGraphic
    
    Change-Id: I6df0da16d777549e6187327271868774498d073b
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/164694
    Tested-by: Jenkins
    Reviewed-by: Tomaž Vajngerl <qui...@gmail.com>

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)
 {
 }
 

Reply via email to