include OutputDevice MapMode in SalLayoutGlyphsCache key (tdf#148400)

The mapmode also affects the layout of the glyphs.

Change-Id: I9492bc4d3d9e991ef8ab5dc30ce424e44cbc79f7
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/132822
Tested-by: Jenkins
Reviewed-by: Luboš Luňák <l.lunak@collabora.com>
This commit is contained in:
Luboš Luňák
2022-04-12 13:31:09 +02:00
parent cbaf1fbaa6
commit 3361db2179
8 changed files with 46 additions and 1 deletions
+3
View File
@@ -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 );
+5
View File
@@ -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 );
+1
View File
@@ -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;
+3
View File
@@ -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;
+10
View File
@@ -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: */
+9
View File
@@ -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 )
+3 -1
View File
@@ -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).
+12
View File
@@ -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; }