vcl/headless/svpbmp.cxx      |    5 -----
 vcl/inc/headless/svpbmp.hxx  |    4 +---
 vcl/inc/salbmp.hxx           |   14 +++-----------
 vcl/inc/skia/salbmp.hxx      |    5 +----
 vcl/inc/win/salbmp.h         |    4 +---
 vcl/skia/salbmp.cxx          |    5 -----
 vcl/source/bitmap/bitmap.cxx |    4 +---
 vcl/source/bitmap/salbmp.cxx |    6 ------
 vcl/win/gdi/salbmp.cxx       |    6 ------
 9 files changed, 7 insertions(+), 46 deletions(-)

New commits:
commit ae8d0bb2d559bdae981ed2bfa0265d9cea11c1e1
Author:     Noel Grandin <noelgran...@gmail.com>
AuthorDate: Thu Apr 24 09:02:15 2025 +0200
Commit:     Noel Grandin <noelgran...@gmail.com>
CommitDate: Fri Apr 25 10:58:58 2025 +0200

    simplify SalBitmap SystemDependentDataHolder usage
    
    given that we are largely caching SalBitmap here, and none of the subclasses
    want to do anything more sophisticated, we can do the implementation in
    the base class.
    
    Change-Id: I5211933e9a431c8ff46625ef30666c89106ce7ad
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/184529
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk>

diff --git a/vcl/headless/svpbmp.cxx b/vcl/headless/svpbmp.cxx
index cd7aa0d34ff5..9066791db1f1 100644
--- a/vcl/headless/svpbmp.cxx
+++ b/vcl/headless/svpbmp.cxx
@@ -259,9 +259,4 @@ bool SvpSalBitmap::Replace( const ::Color& 
/*rSearchColor*/, const ::Color& /*rR
     return false;
 }
 
-const basegfx::SystemDependentDataHolder* 
SvpSalBitmap::accessSystemDependentDataHolder() const
-{
-    return this;
-}
-
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/inc/headless/svpbmp.hxx b/vcl/inc/headless/svpbmp.hxx
index a7cc058b3e1d..e60f8ce91690 100644
--- a/vcl/inc/headless/svpbmp.hxx
+++ b/vcl/inc/headless/svpbmp.hxx
@@ -25,7 +25,7 @@
 #include <basegfx/utils/systemdependentdata.hxx>
 #include <optional>
 
-class VCL_DLLPUBLIC SvpSalBitmap final : public SalBitmap, public 
basegfx::SystemDependentDataHolder // MM02
+class VCL_DLLPUBLIC SvpSalBitmap final : public SalBitmap
 {
     std::optional<BitmapBuffer> moDIB;
 public:
@@ -65,8 +65,6 @@ public:
     SAL_DLLPRIVATE virtual bool            ScalingSupported() const override;
     SAL_DLLPRIVATE virtual bool            Scale( const double& rScaleX, const 
double& rScaleY, BmpScaleFlag nScaleFlag ) override;
     SAL_DLLPRIVATE virtual bool            Replace( const Color& rSearchColor, 
const Color& rReplaceColor, sal_uInt8 nTol ) override;
-
-    SAL_DLLPRIVATE virtual const basegfx::SystemDependentDataHolder* 
accessSystemDependentDataHolder() const override;
 };
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/inc/salbmp.hxx b/vcl/inc/salbmp.hxx
index b948f4e38c52..7ea7f9c3758b 100644
--- a/vcl/inc/salbmp.hxx
+++ b/vcl/inc/salbmp.hxx
@@ -47,7 +47,7 @@ extern const sal_uLong nVCLBLut[ 6 ];
 extern const sal_uLong nVCLDitherLut[ 256 ];
 extern const sal_uLong nVCLLut[ 256 ];
 
-class VCL_PLUGIN_PUBLIC SalBitmap
+class VCL_PLUGIN_PUBLIC SalBitmap : public basegfx::SystemDependentDataHolder
 {
 public:
 
@@ -155,25 +155,17 @@ protected:
         BitConvert type );
 
 public:
-    // access to SystemDependentDataHolder, to support overload in derived 
class(es)
-    virtual const basegfx::SystemDependentDataHolder* 
accessSystemDependentDataHolder() const;
-
     // exclusive management op's for SystemDependentData at SalBitmap
     template<class T>
     std::shared_ptr<T> getSystemDependentData(basegfx::SDD_Type aType) const
     {
-        const basegfx::SystemDependentDataHolder* 
pDataHolder(accessSystemDependentDataHolder());
-        if(pDataHolder)
-            return 
std::static_pointer_cast<T>(pDataHolder->getSystemDependentData(aType));
-        return std::shared_ptr<T>();
+        return 
std::static_pointer_cast<T>(basegfx::SystemDependentDataHolder::getSystemDependentData(aType));
     }
 
     template<class T, class... Args>
     std::shared_ptr<T> addOrReplaceSystemDependentData(Args&&... args) const
     {
-        const basegfx::SystemDependentDataHolder* 
pDataHolder(accessSystemDependentDataHolder());
-        if(!pDataHolder)
-            return std::shared_ptr<T>();
+        const basegfx::SystemDependentDataHolder* pDataHolder = this;
 
         std::shared_ptr<T> r = 
std::make_shared<T>(std::forward<Args>(args)...);
 
diff --git a/vcl/inc/skia/salbmp.hxx b/vcl/inc/skia/salbmp.hxx
index ba1328fc0dbe..dd6225649c55 100644
--- a/vcl/inc/skia/salbmp.hxx
+++ b/vcl/inc/skia/salbmp.hxx
@@ -28,8 +28,7 @@
 
 #include <SkImage.h>
 
-class VCL_PLUGIN_PUBLIC SkiaSalBitmap final : public SalBitmap,
-                                              public 
basegfx::SystemDependentDataHolder
+class VCL_PLUGIN_PUBLIC SkiaSalBitmap final : public SalBitmap
 {
 public:
     SkiaSalBitmap();
@@ -65,8 +64,6 @@ public:
     virtual bool Erase(const Color& color) override;
     virtual bool AlphaBlendWith(const SalBitmap& rSalBmp) override;
     virtual bool Invert() override;
-    SAL_DLLPRIVATE virtual const basegfx::SystemDependentDataHolder*
-    accessSystemDependentDataHolder() const override;
 
 #if defined MACOSX || defined IOS
     virtual CGImageRef CreateWithMask(const SalBitmap& rMask, int nX, int nY, 
int nWidth,
diff --git a/vcl/inc/win/salbmp.h b/vcl/inc/win/salbmp.h
index 89135570d661..8ff069153d12 100644
--- a/vcl/inc/win/salbmp.h
+++ b/vcl/inc/win/salbmp.h
@@ -32,7 +32,7 @@ class   BitmapPalette;
 class   SalGraphics;
 namespace Gdiplus { class Bitmap; }
 
-class WinSalBitmap final: public SalBitmap, public 
basegfx::SystemDependentDataHolder
+class WinSalBitmap final: public SalBitmap
 {
 private:
     Size                maSize;
@@ -88,8 +88,6 @@ public:
     virtual bool                ScalingSupported() const override;
     virtual bool                Scale( const double& rScaleX, const double& 
rScaleY, BmpScaleFlag nScaleFlag ) override;
     virtual bool                Replace( const Color& rSearchColor, const 
Color& rReplaceColor, sal_uInt8 nTol ) override;
-
-    virtual const basegfx::SystemDependentDataHolder* 
accessSystemDependentDataHolder() const override;
 };
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/skia/salbmp.cxx b/vcl/skia/salbmp.cxx
index db74726bf68b..6dee8b0b5252 100644
--- a/vcl/skia/salbmp.cxx
+++ b/vcl/skia/salbmp.cxx
@@ -515,11 +515,6 @@ bool SkiaSalBitmap::Replace(const Color&, const Color&, 
sal_uInt8)
     return false;
 }
 
-const basegfx::SystemDependentDataHolder* 
SkiaSalBitmap::accessSystemDependentDataHolder() const
-{
-    return this;
-}
-
 bool SkiaSalBitmap::ConvertToGreyscale()
 {
 #ifdef DBG_UTIL
diff --git a/vcl/source/bitmap/bitmap.cxx b/vcl/source/bitmap/bitmap.cxx
index 187541328753..4e7fdf67bdad 100644
--- a/vcl/source/bitmap/bitmap.cxx
+++ b/vcl/source/bitmap/bitmap.cxx
@@ -1667,9 +1667,7 @@ void Bitmap::RemoveBlendedStartColor(
 
 const basegfx::SystemDependentDataHolder* 
Bitmap::accessSystemDependentDataHolder() const
 {
-    if(!mxSalBmp)
-        return nullptr;
-    return mxSalBmp->accessSystemDependentDataHolder();
+    return mxSalBmp.get();
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/source/bitmap/salbmp.cxx b/vcl/source/bitmap/salbmp.cxx
index 3e8f0b255d2d..6148e2ee3a48 100644
--- a/vcl/source/bitmap/salbmp.cxx
+++ b/vcl/source/bitmap/salbmp.cxx
@@ -326,10 +326,4 @@ std::unique_ptr< sal_uInt8[] > 
SalBitmap::convertDataBitCount( const sal_uInt8*
     return data;
 }
 
-const basegfx::SystemDependentDataHolder* 
SalBitmap::accessSystemDependentDataHolder() const
-{
-    // default has no support, returns nullptr
-    return nullptr;
-}
-
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/win/gdi/salbmp.cxx b/vcl/win/gdi/salbmp.cxx
index 3bdadfaefb96..e33ca5e03950 100644
--- a/vcl/win/gdi/salbmp.cxx
+++ b/vcl/win/gdi/salbmp.cxx
@@ -45,7 +45,6 @@
 
 WinSalBitmap::WinSalBitmap()
 :   SalBitmap(),
-    basegfx::SystemDependentDataHolder(),
     maSize(),
     mhDIB(nullptr),
     mhDDB(nullptr),
@@ -833,9 +832,4 @@ bool WinSalBitmap::Replace( const Color& /*rSearchColor*/, 
const Color& /*rRepla
     return false;
 }
 
-const basegfx::SystemDependentDataHolder* 
WinSalBitmap::accessSystemDependentDataHolder() const
-{
-    return this;
-}
-
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Reply via email to