QRawFont: Add a qHash overload

This will be used in QtQuick to avoid costly string manipulation (which in turn
involves memory allocations).

Change-Id: I51a67a4cd97cc576f399483c9c0c13da1e1c6e72
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
This commit is contained in:
Robin Burchell 2016-11-15 18:16:50 +01:00
parent e8a41ed866
commit 094b64fb60
2 changed files with 15 additions and 0 deletions

View File

@ -315,6 +315,19 @@ bool QRawFont::operator==(const QRawFont &other) const
return d->fontEngine == other.d->fontEngine;
}
/*!
Returns the hash value for \a font. If specified, \a seed is used
to initialize the hash.
\relates QRawFont
\since 5.8
*/
uint qHash(const QRawFont &font, uint seed) Q_DECL_NOTHROW
{
return qHash(QRawFontPrivate::get(font)->fontEngine, seed);
}
/*!
\fn bool QRawFont::operator!=(const QRawFont &other) const

View File

@ -158,6 +158,8 @@ Q_DECLARE_SHARED(QRawFont)
Q_DECLARE_OPERATORS_FOR_FLAGS(QRawFont::LayoutFlags)
Q_GUI_EXPORT uint qHash(const QRawFont &font, uint seed = 0) Q_DECL_NOTHROW;
inline QVector<QPointF> QRawFont::advancesForGlyphIndexes(const QVector<quint32> &glyphIndexes, QRawFont::LayoutFlags layoutFlags) const
{
QVector<QPointF> advances(glyphIndexes.size());