summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/tools/fract.hxx3
-rw-r--r--include/tools/gen.hxx5
-rw-r--r--include/vcl/glyphitemcache.hxx1
-rw-r--r--include/vcl/mapmod.hxx3
-rw-r--r--tools/source/generic/fract.cxx10
-rw-r--r--tools/source/generic/gen.cxx9
-rw-r--r--vcl/source/gdi/impglyphitem.cxx4
-rw-r--r--vcl/source/gdi/mapmod.cxx12
8 files changed, 46 insertions, 1 deletions
diff --git a/include/tools/fract.hxx b/include/tools/fract.hxx
index 7f2bb3d320ac..c844f8eed619 100644
--- a/include/tools/fract.hxx
+++ b/include/tools/fract.hxx
@@ -72,6 +72,9 @@ public:
void ReduceInaccurate( unsigned nSignificantBits );
+ // Compute value usable as hash.
+ size_t GetHashValue() const;
+
TOOLS_DLLPUBLIC friend Fraction operator+( const Fraction& rVal1, const Fraction& rVal2 );
TOOLS_DLLPUBLIC friend Fraction operator-( const Fraction& rVal1, const Fraction& rVal2 );
TOOLS_DLLPUBLIC friend Fraction operator*( const Fraction& rVal1, const Fraction& rVal2 );
diff --git a/include/tools/gen.hxx b/include/tools/gen.hxx
index 01e3b45e456d..6d4548065495 100644
--- a/include/tools/gen.hxx
+++ b/include/tools/gen.hxx
@@ -53,6 +53,9 @@ public:
TOOLS_DLLPUBLIC rtl::OString toString() const;
+ // Compute value usable as hash.
+ TOOLS_DLLPUBLIC size_t GetHashValue() const;
+
protected:
tools::Long nA;
tools::Long nB;
@@ -111,6 +114,7 @@ public:
sal_Int64 nMulY, sal_Int64 nDivY) const;
using Pair::toString;
+ using Pair::GetHashValue;
};
inline void Point::Move( tools::Long nHorzMove, tools::Long nVertMove )
@@ -232,6 +236,7 @@ public:
Pair & toPair() { return *this; }
using Pair::toString;
+ using Pair::GetHashValue;
Size& operator += ( const Size& rSize );
Size& operator -= ( const Size& rSize );
diff --git a/include/vcl/glyphitemcache.hxx b/include/vcl/glyphitemcache.hxx
index 34a5b51d6c1b..e0ab8aaf1013 100644
--- a/include/vcl/glyphitemcache.hxx
+++ b/include/vcl/glyphitemcache.hxx
@@ -67,6 +67,7 @@ private:
tools::Long logicWidth;
VclPtr<const OutputDevice> outputDevice;
vcl::Font font;
+ MapMode mapMode;
bool rtl;
vcl::text::ComplexTextLayoutFlags layoutMode;
LanguageType digitLanguage;
diff --git a/include/vcl/mapmod.hxx b/include/vcl/mapmod.hxx
index 591db8d8c1c0..f3c937a5f915 100644
--- a/include/vcl/mapmod.hxx
+++ b/include/vcl/mapmod.hxx
@@ -64,6 +64,9 @@ public:
}
bool IsDefault() const;
+ // Compute value usable as hash.
+ size_t GetHashValue() const;
+
// tdf#117984 needs to be thread-safe due to being used e.g. in Bitmaps
// vcl::ScopedBitmapAccess in parallelized 3D renderer
typedef o3tl::cow_wrapper< ImplMapMode, o3tl::ThreadSafeRefCountingPolicy > ImplType;
diff --git a/tools/source/generic/fract.cxx b/tools/source/generic/fract.cxx
index 49c26c0f1be4..7f2ffba1003d 100644
--- a/tools/source/generic/fract.cxx
+++ b/tools/source/generic/fract.cxx
@@ -19,6 +19,7 @@
#include <tools/fract.hxx>
#include <tools/debug.hxx>
+#include <o3tl/hash_combine.hxx>
#include <o3tl/safeint.hxx>
#include <sal/log.hxx>
#include <osl/diagnose.h>
@@ -473,4 +474,13 @@ static void rational_ReduceInaccurate(boost::rational<sal_Int32>& rRational, uns
rRational.assign( bNeg ? -nMul : nMul, nDiv );
}
+size_t Fraction::GetHashValue() const
+{
+ size_t hash = 0;
+ o3tl::hash_combine( hash, mnNumerator );
+ o3tl::hash_combine( hash, mnDenominator );
+ o3tl::hash_combine( hash, mbValid );
+ return hash;
+}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/tools/source/generic/gen.cxx b/tools/source/generic/gen.cxx
index b3331b7b4e4d..27120d6abbd1 100644
--- a/tools/source/generic/gen.cxx
+++ b/tools/source/generic/gen.cxx
@@ -22,6 +22,7 @@
#include <algorithm>
#include <tuple>
+#include <o3tl/hash_combine.hxx>
#include <o3tl/safeint.hxx>
#include <tools/gen.hxx>
@@ -33,6 +34,14 @@ OString Pair::toString() const
return OString::number(A()) + ", " + OString::number(B());
}
+size_t Pair::GetHashValue() const
+{
+ size_t hash = 0;
+ o3tl::hash_combine( hash, nA );
+ o3tl::hash_combine( hash, nB );
+ return hash;
+}
+
void tools::Rectangle::SetSize( const Size& rSize )
{
if ( rSize.Width() < 0 )
diff --git a/vcl/source/gdi/impglyphitem.cxx b/vcl/source/gdi/impglyphitem.cxx
index 130039ed88ee..b97096cd199c 100644
--- a/vcl/source/gdi/impglyphitem.cxx
+++ b/vcl/source/gdi/impglyphitem.cxx
@@ -163,6 +163,7 @@ SalLayoutGlyphsCache::CachedGlyphsKey::CachedGlyphsKey(const VclPtr<const Output
// TODO there is still something missing, otherwise it wouldn't be necessary to compare
// also the OutputDevice pointers
, font(outputDevice->GetFont())
+ , mapMode(outputDevice->GetMapMode())
, rtl(outputDevice->IsRTLEnabled())
, layoutMode(outputDevice->GetLayoutMode())
, digitLanguage(outputDevice->GetDigitLanguage())
@@ -177,6 +178,7 @@ SalLayoutGlyphsCache::CachedGlyphsKey::CachedGlyphsKey(const VclPtr<const Output
SvMemoryStream stream;
WriteFont(stream, font);
o3tl::hash_combine(hashValue, static_cast<const char*>(stream.GetData()), stream.GetSize());
+ o3tl::hash_combine(hashValue, mapMode.GetHashValue());
o3tl::hash_combine(hashValue, rtl);
o3tl::hash_combine(hashValue, layoutMode);
o3tl::hash_combine(hashValue, digitLanguage.get());
@@ -186,7 +188,7 @@ inline bool SalLayoutGlyphsCache::CachedGlyphsKey::operator==(const CachedGlyphs
{
return hashValue == other.hashValue && index == other.index && len == other.len
&& logicWidth == other.logicWidth && outputDevice == other.outputDevice
- && rtl == other.rtl && layoutMode == other.layoutMode
+ && mapMode == other.mapMode && rtl == other.rtl && layoutMode == other.layoutMode
&& digitLanguage == other.digitLanguage
// Need to use EqualIgnoreColor, because sometimes the color changes, but it's irrelevant
// for text layout (and also obsolete in vcl::Font).
diff --git a/vcl/source/gdi/mapmod.cxx b/vcl/source/gdi/mapmod.cxx
index 0e74157dec86..3efb0529368a 100644
--- a/vcl/source/gdi/mapmod.cxx
+++ b/vcl/source/gdi/mapmod.cxx
@@ -19,6 +19,7 @@
#include <vcl/mapmod.hxx>
+#include <o3tl/hash_combine.hxx>
#include <tools/gen.hxx>
#include <tools/fract.hxx>
#include <tools/stream.hxx>
@@ -135,6 +136,17 @@ bool MapMode::IsDefault() const
return mpImplMapMode.same_object(GetGlobalDefault());
}
+size_t MapMode::GetHashValue() const
+{
+ size_t hash = 0;
+ o3tl::hash_combine( hash, mpImplMapMode->meUnit );
+ o3tl::hash_combine( hash, mpImplMapMode->maOrigin.GetHashValue());
+ o3tl::hash_combine( hash, mpImplMapMode->maScaleX.GetHashValue());
+ o3tl::hash_combine( hash, mpImplMapMode->maScaleY.GetHashValue());
+ o3tl::hash_combine( hash, mpImplMapMode->mbSimple );
+ return hash;
+}
+
MapUnit MapMode::GetMapUnit() const { return mpImplMapMode->meUnit; }
const Point& MapMode::GetOrigin() const { return mpImplMapMode->maOrigin; }