summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArmin Le Grand (allotropia) <armin.le.grand.extern@allotropia.de>2022-10-18 17:17:41 +0200
committerArmin Le Grand <Armin.Le.Grand@me.com>2022-10-18 19:38:53 +0200
commit02bd827f39c1e37baabeea1d83921a37450e8a97 (patch)
tree0d9c93bb25b7241525ae6ef631acd2e359bcdcf0
parentc74133420f6f9b4bc6b414b9c91d54cf8eb3f5af (diff)
Move access to SystemDependentDataHolder to Bitmap (2)
I was too positive thinking that SalBitmap would be fine, but it's locked to vcl. To be able to add system-dependent BitmapBuffering I move the access to Bitmap now. This is no functional change, but offers the same access as e.g. B2DPolygon/B2DPolyPolygon offer already. Also cleaned up usage/access to SystemDependentDataManager which removes quite some code in constructors and makes things easier in general. Change-Id: I2baa40a12479fab0fe66063a018f058c6b8f5597 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/141507 Tested-by: Jenkins Reviewed-by: Armin Le Grand <Armin.Le.Grand@me.com>
-rw-r--r--include/basegfx/polygon/b2dpolygon.hxx4
-rw-r--r--include/basegfx/polygon/b2dpolypolygon.hxx4
-rw-r--r--include/vcl/bitmap.hxx5
-rw-r--r--include/vcl/svapp.hxx7
-rw-r--r--vcl/headless/BitmapHelper.cxx20
-rw-r--r--vcl/headless/CairoCommon.cxx13
-rw-r--r--vcl/inc/headless/BitmapHelper.hxx7
-rw-r--r--vcl/inc/headless/CairoCommon.hxx3
-rw-r--r--vcl/inc/headless/svpbmp.hxx1
-rw-r--r--vcl/inc/salbmp.hxx8
-rw-r--r--vcl/inc/win/salbmp.h1
-rw-r--r--vcl/source/app/svapp.cxx5
-rw-r--r--vcl/source/bitmap/bitmap.cxx7
-rw-r--r--vcl/unx/generic/gdi/gdiimpl.cxx5
-rw-r--r--vcl/win/gdi/gdiimpl.cxx6
-rw-r--r--vcl/win/gdi/salbmp.cxx9
16 files changed, 52 insertions, 53 deletions
diff --git a/include/basegfx/polygon/b2dpolygon.hxx b/include/basegfx/polygon/b2dpolygon.hxx
index 0af041fe366a..435ebf419cba 100644
--- a/include/basegfx/polygon/b2dpolygon.hxx
+++ b/include/basegfx/polygon/b2dpolygon.hxx
@@ -237,9 +237,9 @@ namespace basegfx
}
template<class T, class... Args>
- std::shared_ptr<T> addOrReplaceSystemDependentData(SystemDependentDataManager& manager, Args&&... args) const
+ std::shared_ptr<T> addOrReplaceSystemDependentData(Args&&... args) const
{
- std::shared_ptr<T> r = std::make_shared<T>(manager, std::forward<Args>(args)...);
+ std::shared_ptr<T> r = std::make_shared<T>(std::forward<Args>(args)...);
// tdf#129845 only add to buffer if a relevant buffer time is estimated
if(r->calculateCombinedHoldCyclesInSeconds() > 0)
diff --git a/include/basegfx/polygon/b2dpolypolygon.hxx b/include/basegfx/polygon/b2dpolypolygon.hxx
index 68f1b0d6a619..d3177e3c4c91 100644
--- a/include/basegfx/polygon/b2dpolypolygon.hxx
+++ b/include/basegfx/polygon/b2dpolypolygon.hxx
@@ -128,9 +128,9 @@ namespace basegfx
}
template<class T, class... Args>
- std::shared_ptr<T> addOrReplaceSystemDependentData(SystemDependentDataManager& manager, Args&&... args) const
+ std::shared_ptr<T> addOrReplaceSystemDependentData(Args&&... args) const
{
- std::shared_ptr<T> r = std::make_shared<T>(manager, std::forward<Args>(args)...);
+ std::shared_ptr<T> r = std::make_shared<T>(std::forward<Args>(args)...);
// tdf#129845 only add to buffer if a relevant buffer time is estimated
if(r->calculateCombinedHoldCyclesInSeconds() > 0)
diff --git a/include/vcl/bitmap.hxx b/include/vcl/bitmap.hxx
index 165f0dc6ca05..ecbff7fbb8ef 100644
--- a/include/vcl/bitmap.hxx
+++ b/include/vcl/bitmap.hxx
@@ -87,6 +87,8 @@ class AlphaMask;
class OutputDevice;
class SalBitmap;
+namespace basegfx { class SystemDependentDataHolder; }
+
struct BitmapSystemData
{
#if defined(_WIN32)
@@ -497,6 +499,9 @@ public:
bool bInvert = false,
bool msoBrightness = false );
+ // access to SystemDependentDataHolder, to support overload in derived class(es)
+ const basegfx::SystemDependentDataHolder* accessSystemDependentDataHolder() const;
+
public:
/** ReassignWithSize and recalculate bitmap.
diff --git a/include/vcl/svapp.hxx b/include/vcl/svapp.hxx
index b7afb9589b3b..398358f1bfad 100644
--- a/include/vcl/svapp.hxx
+++ b/include/vcl/svapp.hxx
@@ -66,6 +66,7 @@ class MouseEvent;
class GestureEventPan;
struct ImplSVEvent;
struct ConvertData;
+namespace basegfx { class SystemDependentDataManager; }
namespace com::sun::star::uno {
class XComponentContext;
@@ -828,6 +829,12 @@ public:
*/
static OutputDevice* GetDefaultDevice();
+ /** access the DataManager for buffering system-dependent data
+
+ @returns the global instance of the SystemDependentDataManager
+ */
+ static basegfx::SystemDependentDataManager& GetSystemDependentDataManager();
+
/** Get the first top-level window of the application.
@returns Pointer to top-level window (a Window object)
diff --git a/vcl/headless/BitmapHelper.cxx b/vcl/headless/BitmapHelper.cxx
index 6657abec673e..35bcad3fe304 100644
--- a/vcl/headless/BitmapHelper.cxx
+++ b/vcl/headless/BitmapHelper.cxx
@@ -161,9 +161,8 @@ sal_Int64 estimateUsageInBytesForSurfaceHelper(const SurfaceHelper* pHelper)
} // end anonymous namespace
SystemDependentData_BitmapHelper::SystemDependentData_BitmapHelper(
- basegfx::SystemDependentDataManager& rSystemDependentDataManager,
std::shared_ptr<BitmapHelper> xBitmapHelper)
- : basegfx::SystemDependentData(rSystemDependentDataManager)
+ : basegfx::SystemDependentData(Application::GetSystemDependentDataManager())
, maBitmapHelper(std::move(xBitmapHelper))
{
}
@@ -174,9 +173,8 @@ sal_Int64 SystemDependentData_BitmapHelper::estimateUsageInBytes() const
}
SystemDependentData_MaskHelper::SystemDependentData_MaskHelper(
- basegfx::SystemDependentDataManager& rSystemDependentDataManager,
std::shared_ptr<MaskHelper> xMaskHelper)
- : basegfx::SystemDependentData(rSystemDependentDataManager)
+ : basegfx::SystemDependentData(Application::GetSystemDependentDataManager())
, maMaskHelper(std::move(xMaskHelper))
{
}
@@ -204,9 +202,8 @@ void tryToUseSourceBuffer(const SalBitmap& rSourceBitmap, std::shared_ptr<Bitmap
if (bBufferSource)
{
- const SvpSalBitmap& rSrcBmp(static_cast<const SvpSalBitmap&>(rSourceBitmap));
pSystemDependentData_BitmapHelper
- = rSrcBmp.getSystemDependentDataT<SystemDependentData_BitmapHelper>();
+ = rSourceBitmap.getSystemDependentData<SystemDependentData_BitmapHelper>();
if (pSystemDependentData_BitmapHelper)
{
@@ -224,9 +221,7 @@ void tryToUseSourceBuffer(const SalBitmap& rSourceBitmap, std::shared_ptr<Bitmap
if (bBufferSource)
{
// add to buffering mechanism to potentially reuse next time
- const SvpSalBitmap& rSrcBmp(static_cast<const SvpSalBitmap&>(rSourceBitmap));
- rSrcBmp.addOrReplaceSystemDependentDataT<SystemDependentData_BitmapHelper>(
- ImplGetSystemDependentDataManager(), rSurface);
+ rSourceBitmap.addOrReplaceSystemDependentData<SystemDependentData_BitmapHelper>(rSurface);
}
}
@@ -240,9 +235,8 @@ void tryToUseMaskBuffer(const SalBitmap& rMaskBitmap, std::shared_ptr<MaskHelper
if (bBufferMask)
{
- const SvpSalBitmap& rSrcBmp(static_cast<const SvpSalBitmap&>(rMaskBitmap));
pSystemDependentData_MaskHelper
- = rSrcBmp.getSystemDependentDataT<SystemDependentData_MaskHelper>();
+ = rMaskBitmap.getSystemDependentData<SystemDependentData_MaskHelper>();
if (pSystemDependentData_MaskHelper)
{
@@ -260,9 +254,7 @@ void tryToUseMaskBuffer(const SalBitmap& rMaskBitmap, std::shared_ptr<MaskHelper
if (bBufferMask)
{
// add to buffering mechanism to potentially reuse next time
- const SvpSalBitmap& rSrcBmp(static_cast<const SvpSalBitmap&>(rMaskBitmap));
- rSrcBmp.addOrReplaceSystemDependentDataT<SystemDependentData_MaskHelper>(
- ImplGetSystemDependentDataManager(), rMask);
+ rMaskBitmap.addOrReplaceSystemDependentData<SystemDependentData_MaskHelper>(rMask);
}
}
diff --git a/vcl/headless/CairoCommon.cxx b/vcl/headless/CairoCommon.cxx
index 11d4a9c0483a..ec73955f1c0b 100644
--- a/vcl/headless/CairoCommon.cxx
+++ b/vcl/headless/CairoCommon.cxx
@@ -306,10 +306,10 @@ basegfx::B2DPoint impPixelSnap(const basegfx::B2DPolygon& rPolygon,
return rPolygon.getB2DPoint(nIndex);
}
-SystemDependentData_CairoPath::SystemDependentData_CairoPath(
- basegfx::SystemDependentDataManager& rSystemDependentDataManager, size_t nSizeMeasure,
- cairo_t* cr, bool bNoJoin, bool bAntiAlias, const std::vector<double>* pStroke)
- : basegfx::SystemDependentData(rSystemDependentDataManager)
+SystemDependentData_CairoPath::SystemDependentData_CairoPath(size_t nSizeMeasure, cairo_t* cr,
+ bool bNoJoin, bool bAntiAlias,
+ const std::vector<double>* pStroke)
+ : basegfx::SystemDependentData(Application::GetSystemDependentDataManager())
, mpCairoPath(nullptr)
, mbNoJoin(bNoJoin)
, mbAntiAlias(bAntiAlias)
@@ -385,7 +385,7 @@ void add_polygon_path(cairo_t* cr, const basegfx::B2DPolyPolygon& rPolyPolygon,
// for decisions how/what to buffer, see Note in WinSalGraphicsImpl::drawPolyPolygon
pSystemDependentData_CairoPath
= rPolyPolygon.addOrReplaceSystemDependentData<SystemDependentData_CairoPath>(
- ImplGetSystemDependentDataManager(), nSizeMeasure, cr, false, false, nullptr);
+ nSizeMeasure, cr, false, false, nullptr);
}
}
@@ -856,8 +856,7 @@ bool CairoCommon::drawPolyLine(cairo_t* cr, basegfx::B2DRange* pExtents, const C
{
pSystemDependentData_CairoPath
= rPolyLine.addOrReplaceSystemDependentData<SystemDependentData_CairoPath>(
- ImplGetSystemDependentDataManager(), nSizeMeasure, cr, bNoJoin, bAntiAlias,
- pStroke);
+ nSizeMeasure, cr, bNoJoin, bAntiAlias, pStroke);
}
}
diff --git a/vcl/inc/headless/BitmapHelper.hxx b/vcl/inc/headless/BitmapHelper.hxx
index c86a79239d47..0aed5e3693fc 100644
--- a/vcl/inc/headless/BitmapHelper.hxx
+++ b/vcl/inc/headless/BitmapHelper.hxx
@@ -52,9 +52,7 @@ private:
std::shared_ptr<BitmapHelper> maBitmapHelper;
public:
- SystemDependentData_BitmapHelper(
- basegfx::SystemDependentDataManager& rSystemDependentDataManager,
- std::shared_ptr<BitmapHelper> xBitmapHelper);
+ SystemDependentData_BitmapHelper(std::shared_ptr<BitmapHelper> xBitmapHelper);
const std::shared_ptr<BitmapHelper>& getBitmapHelper() const { return maBitmapHelper; };
virtual sal_Int64 estimateUsageInBytes() const override;
@@ -66,8 +64,7 @@ private:
std::shared_ptr<MaskHelper> maMaskHelper;
public:
- SystemDependentData_MaskHelper(basegfx::SystemDependentDataManager& rSystemDependentDataManager,
- std::shared_ptr<MaskHelper> xMaskHelper);
+ SystemDependentData_MaskHelper(std::shared_ptr<MaskHelper> xMaskHelper);
const std::shared_ptr<MaskHelper>& getMaskHelper() const { return maMaskHelper; };
virtual sal_Int64 estimateUsageInBytes() const override;
diff --git a/vcl/inc/headless/CairoCommon.hxx b/vcl/inc/headless/CairoCommon.hxx
index e8b1a4927e21..476b031c451b 100644
--- a/vcl/inc/headless/CairoCommon.hxx
+++ b/vcl/inc/headless/CairoCommon.hxx
@@ -96,8 +96,7 @@ private:
std::vector<double> maStroke;
public:
- SystemDependentData_CairoPath(basegfx::SystemDependentDataManager& rSystemDependentDataManager,
- size_t nSizeMeasure, cairo_t* cr, bool bNoJoin, bool bAntiAlias,
+ SystemDependentData_CairoPath(size_t nSizeMeasure, cairo_t* cr, bool bNoJoin, bool bAntiAlias,
const std::vector<double>* pStroke); // MM01
virtual ~SystemDependentData_CairoPath() override;
diff --git a/vcl/inc/headless/svpbmp.hxx b/vcl/inc/headless/svpbmp.hxx
index 29e730ad4d6f..cd90d23e8e22 100644
--- a/vcl/inc/headless/svpbmp.hxx
+++ b/vcl/inc/headless/svpbmp.hxx
@@ -61,7 +61,6 @@ 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;
-protected:
virtual const basegfx::SystemDependentDataHolder* accessSystemDependentDataHolder() const override;
};
diff --git a/vcl/inc/salbmp.hxx b/vcl/inc/salbmp.hxx
index 32b1ffa14598..a48b48b2451c 100644
--- a/vcl/inc/salbmp.hxx
+++ b/vcl/inc/salbmp.hxx
@@ -129,13 +129,13 @@ protected:
int width, int height, int bitCount, int bytesPerRow, const BitmapPalette& palette,
BitConvert type );
+public:
// 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
+ std::shared_ptr<T> getSystemDependentData() const
{
const basegfx::SystemDependentDataHolder* pDataHolder(accessSystemDependentDataHolder());
if(pDataHolder)
@@ -144,13 +144,13 @@ public:
}
template<class T, class... Args>
- std::shared_ptr<T> addOrReplaceSystemDependentDataT(basegfx::SystemDependentDataManager& manager, Args&&... args) const
+ std::shared_ptr<T> addOrReplaceSystemDependentData(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)...);
+ std::shared_ptr<T> r = std::make_shared<T>(std::forward<Args>(args)...);
// tdf#129845 only add to buffer if a relevant buffer time is estimated
if(r->calculateCombinedHoldCyclesInSeconds() > 0)
diff --git a/vcl/inc/win/salbmp.h b/vcl/inc/win/salbmp.h
index 9db57b5cc9f7..d8d00e727f76 100644
--- a/vcl/inc/win/salbmp.h
+++ b/vcl/inc/win/salbmp.h
@@ -85,7 +85,6 @@ 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;
-protected:
virtual const basegfx::SystemDependentDataHolder* accessSystemDependentDataHolder() const override;
};
diff --git a/vcl/source/app/svapp.cxx b/vcl/source/app/svapp.cxx
index f18f580c83a2..6fb299f82a0f 100644
--- a/vcl/source/app/svapp.cxx
+++ b/vcl/source/app/svapp.cxx
@@ -1168,6 +1168,11 @@ OutputDevice* Application::GetDefaultDevice()
return ImplGetDefaultWindow()->GetOutDev();
}
+basegfx::SystemDependentDataManager& Application::GetSystemDependentDataManager()
+{
+ return ImplGetSystemDependentDataManager();
+}
+
vcl::Window* Application::GetFirstTopLevelWindow()
{
ImplSVData* pSVData = ImplGetSVData();
diff --git a/vcl/source/bitmap/bitmap.cxx b/vcl/source/bitmap/bitmap.cxx
index 5abd79c70fcc..d4edd8f711bc 100644
--- a/vcl/source/bitmap/bitmap.cxx
+++ b/vcl/source/bitmap/bitmap.cxx
@@ -1717,4 +1717,11 @@ bool Bitmap::Adjust( short nLuminancePercent, short nContrastPercent,
return bRet;
}
+const basegfx::SystemDependentDataHolder* Bitmap::accessSystemDependentDataHolder() const
+{
+ if(!mxSalBmp)
+ return nullptr;
+ return mxSalBmp->accessSystemDependentDataHolder();
+}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/unx/generic/gdi/gdiimpl.cxx b/vcl/unx/generic/gdi/gdiimpl.cxx
index 58068418deed..ad28e0fb39a9 100644
--- a/vcl/unx/generic/gdi/gdiimpl.cxx
+++ b/vcl/unx/generic/gdi/gdiimpl.cxx
@@ -1601,7 +1601,6 @@ private:
public:
SystemDependentData_Triangulation(
- basegfx::SystemDependentDataManager& rSystemDependentDataManager,
basegfx::triangulator::B2DTriangleVector&& rTriangles,
double fLineWidth,
basegfx::B2DLineJoin eJoin,
@@ -1623,14 +1622,13 @@ public:
}
SystemDependentData_Triangulation::SystemDependentData_Triangulation(
- basegfx::SystemDependentDataManager& rSystemDependentDataManager,
basegfx::triangulator::B2DTriangleVector&& rTriangles,
double fLineWidth,
basegfx::B2DLineJoin eJoin,
css::drawing::LineCap eCap,
double fMiterMinimumAngle,
const std::vector< double >* pStroke)
-: basegfx::SystemDependentData(rSystemDependentDataManager),
+: basegfx::SystemDependentData(Application::GetSystemDependentDataManager()),
maTriangles(std::move(rTriangles)),
mfLineWidth(fLineWidth),
meJoin(eJoin),
@@ -1823,7 +1821,6 @@ bool X11SalGraphicsImpl::drawPolyLine(
// Add all values the triangulation is based off, too, to check for
// validity (see above)
pSystemDependentData_Triangulation = rPolygon.addOrReplaceSystemDependentData<SystemDependentData_Triangulation>(
- ImplGetSystemDependentDataManager(),
std::move(aTriangles),
fLineWidth,
eLineJoin,
diff --git a/vcl/win/gdi/gdiimpl.cxx b/vcl/win/gdi/gdiimpl.cxx
index afe4492a83e7..85020f02cb1e 100644
--- a/vcl/win/gdi/gdiimpl.cxx
+++ b/vcl/win/gdi/gdiimpl.cxx
@@ -1993,7 +1993,6 @@ private:
public:
SystemDependentData_GraphicsPath(
- basegfx::SystemDependentDataManager& rSystemDependentDataManager,
std::shared_ptr<Gdiplus::GraphicsPath>& rpGraphicsPath,
bool bNoLineJoin,
const std::vector< double >* pStroke); // MM01
@@ -2009,11 +2008,10 @@ public:
}
SystemDependentData_GraphicsPath::SystemDependentData_GraphicsPath(
- basegfx::SystemDependentDataManager& rSystemDependentDataManager,
std::shared_ptr<Gdiplus::GraphicsPath>& rpGraphicsPath,
bool bNoLineJoin,
const std::vector< double >* pStroke)
-: basegfx::SystemDependentData(rSystemDependentDataManager),
+: basegfx::SystemDependentData(Application::GetSystemDependentDataManager()),
mpGraphicsPath(rpGraphicsPath),
mbNoLineJoin(bNoLineJoin),
maStroke()
@@ -2143,7 +2141,6 @@ bool WinSalGraphicsImpl::drawPolyPolygon(
// add to buffering mechanism
rPolyPolygon.addOrReplaceSystemDependentData<SystemDependentData_GraphicsPath>(
- ImplGetSystemDependentDataManager(),
pGraphicsPath,
false,
nullptr);
@@ -2462,7 +2459,6 @@ bool WinSalGraphicsImpl::drawPolyLine(
if (!bPixelSnapHairline /*tdf#124700*/)
{
rPolygon.addOrReplaceSystemDependentData<SystemDependentData_GraphicsPath>(
- ImplGetSystemDependentDataManager(),
pGraphicsPath,
bNoLineJoin,
pStroke);
diff --git a/vcl/win/gdi/salbmp.cxx b/vcl/win/gdi/salbmp.cxx
index 763a54c63059..e4b0f570f671 100644
--- a/vcl/win/gdi/salbmp.cxx
+++ b/vcl/win/gdi/salbmp.cxx
@@ -89,7 +89,6 @@ private:
public:
SystemDependentData_GdiPlusBitmap(
- basegfx::SystemDependentDataManager& rSystemDependentDataManager,
const std::shared_ptr<Gdiplus::Bitmap>& rGdiPlusBitmap,
const WinSalBitmap* pAssociatedAlpha);
@@ -102,10 +101,9 @@ public:
}
SystemDependentData_GdiPlusBitmap::SystemDependentData_GdiPlusBitmap(
- basegfx::SystemDependentDataManager& rSystemDependentDataManager,
const std::shared_ptr<Gdiplus::Bitmap>& rGdiPlusBitmap,
const WinSalBitmap* pAssociatedAlpha)
-: basegfx::SystemDependentData(rSystemDependentDataManager),
+: basegfx::SystemDependentData(Application::GetSystemDependentDataManager()),
mpGdiPlusBitmap(rGdiPlusBitmap),
mpAssociatedAlpha(pAssociatedAlpha)
{
@@ -170,7 +168,7 @@ std::shared_ptr< Gdiplus::Bitmap > WinSalBitmap::ImplGetGdiPlusBitmap(const WinS
// try to access buffered data
std::shared_ptr<SystemDependentData_GdiPlusBitmap> pSystemDependentData_GdiPlusBitmap(
- getSystemDependentDataT<SystemDependentData_GdiPlusBitmap>());
+ getSystemDependentData<SystemDependentData_GdiPlusBitmap>());
if(pSystemDependentData_GdiPlusBitmap)
{
@@ -208,8 +206,7 @@ std::shared_ptr< Gdiplus::Bitmap > WinSalBitmap::ImplGetGdiPlusBitmap(const WinS
}
// add to buffering mechanism
- addOrReplaceSystemDependentDataT<SystemDependentData_GdiPlusBitmap>(
- ImplGetSystemDependentDataManager(),
+ addOrReplaceSystemDependentData<SystemDependentData_GdiPlusBitmap>(
aRetval,
pAssociatedAlpha);
}