summaryrefslogtreecommitdiff
path: root/vcl
diff options
context:
space:
mode:
authorArmin Le Grand (allotropia) <armin.le.grand.extern@allotropia.de>2022-10-17 14:22:08 +0200
committerArmin Le Grand <Armin.Le.Grand@me.com>2022-10-17 19:13:53 +0200
commit2c5c611077278edd86247c58a078398ecf17a701 (patch)
tree2dd6974861b2543b47ea2618a6eff7270fd102f6 /vcl
parentdba6eb60bcd9f55b49699e767993707ec26a8565 (diff)
Move access to SystemDependentDataHolder to SalBitmap
To be able to buffer BitmapData which is created based on Bitmap class data, move the access to basegfx::SystemDependentDataHolder from classes where it was used until now (WinSalBitmap and SvpSalBitmap) up to SalBitmap which is accessible outside vcl. This is a reorder plus a virtual access method to detect/access that helper layer, no functional change. It will be needed for system-dependent renderers when they want to use that standard buffering e.g. already used in the headless & windows backends. Change-Id: Ib30e7b98e722b977bb0c87ad253e3ffc1841e87e Reviewed-on: https://gerrit.libreoffice.org/c/core/+/141456 Tested-by: Jenkins Reviewed-by: Armin Le Grand <Armin.Le.Grand@me.com>
Diffstat (limited to 'vcl')
-rw-r--r--vcl/headless/BitmapHelper.cxx8
-rw-r--r--vcl/headless/svpbmp.cxx5
-rw-r--r--vcl/inc/headless/svpbmp.hxx23
-rw-r--r--vcl/inc/salbmp.hxx34
-rw-r--r--vcl/inc/win/salbmp.h23
-rw-r--r--vcl/source/bitmap/salbmp.cxx6
-rw-r--r--vcl/win/gdi/salbmp.cxx9
7 files changed, 60 insertions, 48 deletions
diff --git a/vcl/headless/BitmapHelper.cxx b/vcl/headless/BitmapHelper.cxx
index ddd7e10db689..6657abec673e 100644
--- a/vcl/headless/BitmapHelper.cxx
+++ b/vcl/headless/BitmapHelper.cxx
@@ -206,7 +206,7 @@ void tryToUseSourceBuffer(const SalBitmap& rSourceBitmap, std::shared_ptr<Bitmap
{
const SvpSalBitmap& rSrcBmp(static_cast<const SvpSalBitmap&>(rSourceBitmap));
pSystemDependentData_BitmapHelper
- = rSrcBmp.getSystemDependentData<SystemDependentData_BitmapHelper>();
+ = rSrcBmp.getSystemDependentDataT<SystemDependentData_BitmapHelper>();
if (pSystemDependentData_BitmapHelper)
{
@@ -225,7 +225,7 @@ void tryToUseSourceBuffer(const SalBitmap& rSourceBitmap, std::shared_ptr<Bitmap
{
// add to buffering mechanism to potentially reuse next time
const SvpSalBitmap& rSrcBmp(static_cast<const SvpSalBitmap&>(rSourceBitmap));
- rSrcBmp.addOrReplaceSystemDependentData<SystemDependentData_BitmapHelper>(
+ rSrcBmp.addOrReplaceSystemDependentDataT<SystemDependentData_BitmapHelper>(
ImplGetSystemDependentDataManager(), rSurface);
}
}
@@ -242,7 +242,7 @@ void tryToUseMaskBuffer(const SalBitmap& rMaskBitmap, std::shared_ptr<MaskHelper
{
const SvpSalBitmap& rSrcBmp(static_cast<const SvpSalBitmap&>(rMaskBitmap));
pSystemDependentData_MaskHelper
- = rSrcBmp.getSystemDependentData<SystemDependentData_MaskHelper>();
+ = rSrcBmp.getSystemDependentDataT<SystemDependentData_MaskHelper>();
if (pSystemDependentData_MaskHelper)
{
@@ -261,7 +261,7 @@ void tryToUseMaskBuffer(const SalBitmap& rMaskBitmap, std::shared_ptr<MaskHelper
{
// add to buffering mechanism to potentially reuse next time
const SvpSalBitmap& rSrcBmp(static_cast<const SvpSalBitmap&>(rMaskBitmap));
- rSrcBmp.addOrReplaceSystemDependentData<SystemDependentData_MaskHelper>(
+ rSrcBmp.addOrReplaceSystemDependentDataT<SystemDependentData_MaskHelper>(
ImplGetSystemDependentDataManager(), rMask);
}
}
diff --git a/vcl/headless/svpbmp.cxx b/vcl/headless/svpbmp.cxx
index 167a5165a893..a72774068d30 100644
--- a/vcl/headless/svpbmp.cxx
+++ b/vcl/headless/svpbmp.cxx
@@ -268,4 +268,9 @@ 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 2c347372a4d4..29e730ad4d6f 100644
--- a/vcl/inc/headless/svpbmp.hxx
+++ b/vcl/inc/headless/svpbmp.hxx
@@ -61,27 +61,8 @@ public:
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;
- // MM02 exclusive management op's for SystemDependentData at WinSalBitmap
- template<class T>
- std::shared_ptr<T> getSystemDependentData() const
- {
- return std::static_pointer_cast<T>(basegfx::SystemDependentDataHolder::getSystemDependentData(typeid(T).hash_code()));
- }
-
- template<class T, class... Args>
- std::shared_ptr<T> addOrReplaceSystemDependentData(basegfx::SystemDependentDataManager& manager, Args&&... args) const
- {
- std::shared_ptr<T> r = std::make_shared<T>(manager, std::forward<Args>(args)...);
-
- // tdf#129845 only add to buffer if a relevant buffer time is estimated
- if(r->calculateCombinedHoldCyclesInSeconds() > 0)
- {
- basegfx::SystemDependentData_SharedPtr r2(r);
- const_cast< SvpSalBitmap* >(this)->basegfx::SystemDependentDataHolder::addOrReplaceSystemDependentData(r2);
- }
-
- return r;
- }
+protected:
+ virtual const basegfx::SystemDependentDataHolder* accessSystemDependentDataHolder() const override;
};
#endif // INCLUDED_VCL_INC_HEADLESS_SVPBMP_HXX
diff --git a/vcl/inc/salbmp.hxx b/vcl/inc/salbmp.hxx
index f04ea291aa84..32b1ffa14598 100644
--- a/vcl/inc/salbmp.hxx
+++ b/vcl/inc/salbmp.hxx
@@ -27,6 +27,7 @@
#include <vcl/BitmapBuffer.hxx>
#include <vcl/bitmap/BitmapTypes.hxx>
#include <com/sun/star/rendering/XBitmapCanvas.hpp>
+#include <basegfx/utils/systemdependentdata.hxx>
struct BitmapBuffer;
class Color;
@@ -127,6 +128,39 @@ protected:
static std::unique_ptr< sal_uInt8[] > convertDataBitCount( const sal_uInt8* src,
int width, int height, int bitCount, int bytesPerRow, const BitmapPalette& palette,
BitConvert type );
+
+ // access to SystemDependentDataHolder, to support overload in derived class(es)
+ virtual const basegfx::SystemDependentDataHolder* accessSystemDependentDataHolder() const;
+
+public:
+ // exclusive management op's for SystemDependentData at SalBitmap
+ template<class T>
+ std::shared_ptr<T> getSystemDependentDataT() const
+ {
+ const basegfx::SystemDependentDataHolder* pDataHolder(accessSystemDependentDataHolder());
+ if(pDataHolder)
+ return std::static_pointer_cast<T>(pDataHolder->getSystemDependentData(typeid(T).hash_code()));
+ return std::shared_ptr<T>();
+ }
+
+ template<class T, class... Args>
+ std::shared_ptr<T> addOrReplaceSystemDependentDataT(basegfx::SystemDependentDataManager& manager, Args&&... args) const
+ {
+ const basegfx::SystemDependentDataHolder* pDataHolder(accessSystemDependentDataHolder());
+ if(!pDataHolder)
+ return std::shared_ptr<T>();
+
+ std::shared_ptr<T> r = std::make_shared<T>(manager, std::forward<Args>(args)...);
+
+ // tdf#129845 only add to buffer if a relevant buffer time is estimated
+ if(r->calculateCombinedHoldCyclesInSeconds() > 0)
+ {
+ basegfx::SystemDependentData_SharedPtr r2(r);
+ const_cast< basegfx::SystemDependentDataHolder* >(pDataHolder)->addOrReplaceSystemDependentData(r2);
+ }
+
+ return r;
+ }
};
#endif
diff --git a/vcl/inc/win/salbmp.h b/vcl/inc/win/salbmp.h
index c8fe3d851011..9db57b5cc9f7 100644
--- a/vcl/inc/win/salbmp.h
+++ b/vcl/inc/win/salbmp.h
@@ -85,27 +85,8 @@ public:
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;
- // exclusive management op's for SystemDependentData at WinSalBitmap
- template<class T>
- std::shared_ptr<T> getSystemDependentData() const
- {
- return std::static_pointer_cast<T>(basegfx::SystemDependentDataHolder::getSystemDependentData(typeid(T).hash_code()));
- }
-
- template<class T, class... Args>
- std::shared_ptr<T> addOrReplaceSystemDependentData(basegfx::SystemDependentDataManager& manager, Args&&... args) const
- {
- std::shared_ptr<T> r = std::make_shared<T>(manager, std::forward<Args>(args)...);
-
- // tdf#129845 only add to buffer if a relevant buffer time is estimated
- if(r->calculateCombinedHoldCyclesInSeconds() > 0)
- {
- basegfx::SystemDependentData_SharedPtr r2(r);
- const_cast< WinSalBitmap* >(this)->basegfx::SystemDependentDataHolder::addOrReplaceSystemDependentData(r2);
- }
-
- return r;
- }
+protected:
+ virtual const basegfx::SystemDependentDataHolder* accessSystemDependentDataHolder() const override;
};
#endif // INCLUDED_VCL_INC_WIN_SALBMP_H
diff --git a/vcl/source/bitmap/salbmp.cxx b/vcl/source/bitmap/salbmp.cxx
index a1fc7de7a60a..88cabc0968bc 100644
--- a/vcl/source/bitmap/salbmp.cxx
+++ b/vcl/source/bitmap/salbmp.cxx
@@ -331,4 +331,10 @@ 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 3538b503f08d..763a54c63059 100644
--- a/vcl/win/gdi/salbmp.cxx
+++ b/vcl/win/gdi/salbmp.cxx
@@ -170,7 +170,7 @@ std::shared_ptr< Gdiplus::Bitmap > WinSalBitmap::ImplGetGdiPlusBitmap(const WinS
// try to access buffered data
std::shared_ptr<SystemDependentData_GdiPlusBitmap> pSystemDependentData_GdiPlusBitmap(
- getSystemDependentData<SystemDependentData_GdiPlusBitmap>());
+ getSystemDependentDataT<SystemDependentData_GdiPlusBitmap>());
if(pSystemDependentData_GdiPlusBitmap)
{
@@ -208,7 +208,7 @@ std::shared_ptr< Gdiplus::Bitmap > WinSalBitmap::ImplGetGdiPlusBitmap(const WinS
}
// add to buffering mechanism
- addOrReplaceSystemDependentData<SystemDependentData_GdiPlusBitmap>(
+ addOrReplaceSystemDependentDataT<SystemDependentData_GdiPlusBitmap>(
ImplGetSystemDependentDataManager(),
aRetval,
pAssociatedAlpha);
@@ -914,4 +914,9 @@ 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: */