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>
This commit is contained in:
committed by
Armin Le Grand
parent
c74133420f
commit
02bd827f39
@@ -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)
|
||||
|
@@ -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)
|
||||
|
@@ -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.
|
||||
|
||||
|
@@ -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)
|
||||
|
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -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;
|
||||
|
@@ -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;
|
||||
|
||||
|
@@ -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;
|
||||
};
|
||||
|
||||
|
@@ -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)
|
||||
|
@@ -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;
|
||||
};
|
||||
|
||||
|
@@ -1168,6 +1168,11 @@ OutputDevice* Application::GetDefaultDevice()
|
||||
return ImplGetDefaultWindow()->GetOutDev();
|
||||
}
|
||||
|
||||
basegfx::SystemDependentDataManager& Application::GetSystemDependentDataManager()
|
||||
{
|
||||
return ImplGetSystemDependentDataManager();
|
||||
}
|
||||
|
||||
vcl::Window* Application::GetFirstTopLevelWindow()
|
||||
{
|
||||
ImplSVData* pSVData = ImplGetSVData();
|
||||
|
@@ -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: */
|
||||
|
@@ -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,
|
||||
|
@@ -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);
|
||||
|
@@ -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);
|
||||
}
|
||||
|
Reference in New Issue
Block a user