diff options
author | Armin Le Grand (allotropia) <armin.le.grand.extern@allotropia.de> | 2024-07-11 17:54:18 +0200 |
---|---|---|
committer | Armin Le Grand <Armin.Le.Grand@me.com> | 2024-07-12 17:59:50 +0200 |
commit | f74bb604ff043caa552d809bd8e9157ac7854f96 (patch) | |
tree | 3cf4ff858f22d4759d58d333331f24fff368b0f5 /include/basegfx/utils | |
parent | 943ee532597d24c50e650b8910241c0b7a3a6fef (diff) |
Make SystemDependentData mechanism type-based
Up to now that genereal buffering mechanism used
typeid.*hash_code to identify the class. As we
have learned this is not safe. Thus I changed it
to use enum'ed SystemDependentDataType definitions
Change-Id: I803912ec419290db1d40bae0bc41364fad64cbfd
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/170385
Tested-by: Jenkins
Reviewed-by: Armin Le Grand <Armin.Le.Grand@me.com>
Diffstat (limited to 'include/basegfx/utils')
-rw-r--r-- | include/basegfx/utils/systemdependentdata.hxx | 34 |
1 files changed, 25 insertions, 9 deletions
diff --git a/include/basegfx/utils/systemdependentdata.hxx b/include/basegfx/utils/systemdependentdata.hxx index 9304153c1327..b07ae267e662 100644 --- a/include/basegfx/utils/systemdependentdata.hxx +++ b/include/basegfx/utils/systemdependentdata.hxx @@ -12,7 +12,7 @@ #include <sal/types.h> #include <basegfx/basegfxdllapi.h> #include <memory> -#include <map> +#include <unordered_map> namespace basegfx { @@ -41,6 +41,20 @@ namespace basegfx virtual void flushAll() = 0; }; + // (S)ystem(D)ependent(D)ata_Type + enum class BASEGFX_DLLPUBLIC SDD_Type : sal_uInt16 { + SDDType_CairoPathGeometry, + SDDType_CairoSurface, + SDDType_ID2D1PathGeometry, + SDDType_ID2D1Bitmap, + SDDType_BitmapHelper, + SDDType_MaskHelper, + SDDType_CairoPath, + SDDType_ModifiedBitmapEx, + SDDType_GraphicsPath, + SDDType_GdiPlusBitmap + }; + class BASEGFX_DLLPUBLIC SystemDependentData { private: @@ -52,6 +66,9 @@ namespace basegfx // a single, globally used one, but not necessarily SystemDependentDataManager& mrSystemDependentDataManager; + // Type identifier + SDD_Type maSystemDependentDataType; + // Buffered CalculatedCycles, result of estimations using // getHoldCyclesInSeconds and estimateUsageInBytes, executed // using getHoldCyclesInSeconds. StartValue is 0 to detect @@ -60,18 +77,17 @@ namespace basegfx public: SystemDependentData( - SystemDependentDataManager& rSystemDependentDataManager); - - // CAUTION! It is VERY important to keep this base class - // virtual, else typeid(class).hash_code() from derived classes - // will NOT work what is ESSENTIAL for the SystemDependentData - // mechanism to work properly. So DO NOT REMOVE virtual here, please. + SystemDependentDataManager& rSystemDependentDataManager, + SDD_Type aSystemDependentDataType); virtual ~SystemDependentData(); // allow access to call startUsage/endUsage/touchUsage // using getSystemDependentDataManager() SystemDependentDataManager& getSystemDependentDataManager() { return mrSystemDependentDataManager; } + // read access to SDD_Type + SDD_Type getSystemDependentDataType() const { return maSystemDependentDataType; } + // Calculate HoldCyclesInSeconds based on using // getHoldCyclesInSeconds and estimateUsageInBytes, the // result is created once on-demand and buffered in @@ -93,7 +109,7 @@ namespace basegfx { private: // Possibility to hold System-Dependent B2DPolygon-Representations - std::map< size_t, SystemDependentData_WeakPtr > maSystemDependentReferences; + std::unordered_map< SDD_Type, SystemDependentData_WeakPtr > maSystemDependentReferences; // noncopyable SystemDependentDataHolder(const SystemDependentDataHolder&) = delete; @@ -104,7 +120,7 @@ namespace basegfx virtual ~SystemDependentDataHolder(); void addOrReplaceSystemDependentData(SystemDependentData_SharedPtr& rData); - SystemDependentData_SharedPtr getSystemDependentData(size_t hash_code) const; + SystemDependentData_SharedPtr getSystemDependentData(SDD_Type aType) const; }; } // end of namespace basegfx |