From 2c5c611077278edd86247c58a078398ecf17a701 Mon Sep 17 00:00:00 2001 From: "Armin Le Grand (allotropia)" Date: Mon, 17 Oct 2022 14:22:08 +0200 Subject: 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 --- vcl/headless/BitmapHelper.cxx | 8 ++++---- vcl/headless/svpbmp.cxx | 5 +++++ vcl/inc/headless/svpbmp.hxx | 23 ++--------------------- vcl/inc/salbmp.hxx | 34 ++++++++++++++++++++++++++++++++++ vcl/inc/win/salbmp.h | 23 ++--------------------- vcl/source/bitmap/salbmp.cxx | 6 ++++++ vcl/win/gdi/salbmp.cxx | 9 +++++++-- 7 files changed, 60 insertions(+), 48 deletions(-) (limited to 'vcl') 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(rSourceBitmap)); pSystemDependentData_BitmapHelper - = rSrcBmp.getSystemDependentData(); + = rSrcBmp.getSystemDependentDataT(); if (pSystemDependentData_BitmapHelper) { @@ -225,7 +225,7 @@ void tryToUseSourceBuffer(const SalBitmap& rSourceBitmap, std::shared_ptr(rSourceBitmap)); - rSrcBmp.addOrReplaceSystemDependentData( + rSrcBmp.addOrReplaceSystemDependentDataT( ImplGetSystemDependentDataManager(), rSurface); } } @@ -242,7 +242,7 @@ void tryToUseMaskBuffer(const SalBitmap& rMaskBitmap, std::shared_ptr(rMaskBitmap)); pSystemDependentData_MaskHelper - = rSrcBmp.getSystemDependentData(); + = rSrcBmp.getSystemDependentDataT(); if (pSystemDependentData_MaskHelper) { @@ -261,7 +261,7 @@ void tryToUseMaskBuffer(const SalBitmap& rMaskBitmap, std::shared_ptr(rMaskBitmap)); - rSrcBmp.addOrReplaceSystemDependentData( + rSrcBmp.addOrReplaceSystemDependentDataT( 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 - std::shared_ptr getSystemDependentData() const - { - return std::static_pointer_cast(basegfx::SystemDependentDataHolder::getSystemDependentData(typeid(T).hash_code())); - } - - template - std::shared_ptr addOrReplaceSystemDependentData(basegfx::SystemDependentDataManager& manager, Args&&... args) const - { - std::shared_ptr r = std::make_shared(manager, std::forward(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 #include #include +#include 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 + std::shared_ptr getSystemDependentDataT() const + { + const basegfx::SystemDependentDataHolder* pDataHolder(accessSystemDependentDataHolder()); + if(pDataHolder) + return std::static_pointer_cast(pDataHolder->getSystemDependentData(typeid(T).hash_code())); + return std::shared_ptr(); + } + + template + std::shared_ptr addOrReplaceSystemDependentDataT(basegfx::SystemDependentDataManager& manager, Args&&... args) const + { + const basegfx::SystemDependentDataHolder* pDataHolder(accessSystemDependentDataHolder()); + if(!pDataHolder) + return std::shared_ptr(); + + std::shared_ptr r = std::make_shared(manager, std::forward(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 - std::shared_ptr getSystemDependentData() const - { - return std::static_pointer_cast(basegfx::SystemDependentDataHolder::getSystemDependentData(typeid(T).hash_code())); - } - - template - std::shared_ptr addOrReplaceSystemDependentData(basegfx::SystemDependentDataManager& manager, Args&&... args) const - { - std::shared_ptr r = std::make_shared(manager, std::forward(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 pSystemDependentData_GdiPlusBitmap( - getSystemDependentData()); + getSystemDependentDataT()); if(pSystemDependentData_GdiPlusBitmap) { @@ -208,7 +208,7 @@ std::shared_ptr< Gdiplus::Bitmap > WinSalBitmap::ImplGetGdiPlusBitmap(const WinS } // add to buffering mechanism - addOrReplaceSystemDependentData( + addOrReplaceSystemDependentDataT( 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: */ -- cgit