OpenVG: Use QRawFont qHash function in font cache

A qHash function was added for QRawFont, so use that instead of our own.

Change-Id: Iad8deb8a0e2a727039ec752e38e42cef2127735c
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
This commit is contained in:
Andy Nichols 2016-12-02 11:19:48 +01:00
parent 0119439c9d
commit 4cdeeea8e2
2 changed files with 3 additions and 28 deletions

View File

@ -56,37 +56,14 @@ QSGOpenVGFontGlyphCacheManager::~QSGOpenVGFontGlyphCacheManager()
QSGOpenVGFontGlyphCache *QSGOpenVGFontGlyphCacheManager::cache(const QRawFont &font) QSGOpenVGFontGlyphCache *QSGOpenVGFontGlyphCacheManager::cache(const QRawFont &font)
{ {
return m_caches.value(fontKey(font), nullptr); return m_caches.value(font, nullptr);
} }
void QSGOpenVGFontGlyphCacheManager::insertCache(const QRawFont &font, QSGOpenVGFontGlyphCache *cache) void QSGOpenVGFontGlyphCacheManager::insertCache(const QRawFont &font, QSGOpenVGFontGlyphCache *cache)
{ {
m_caches.insert(fontKey(font), cache); m_caches.insert(font, cache);
} }
QString QSGOpenVGFontGlyphCacheManager::fontKey(const QRawFont &font)
{
QFontEngine *fe = QRawFontPrivate::get(font)->fontEngine;
if (!fe->faceId().filename.isEmpty()) {
QByteArray keyName = fe->faceId().filename;
if (font.style() != QFont::StyleNormal)
keyName += QByteArray(" I");
if (font.weight() != QFont::Normal)
keyName += ' ' + QByteArray::number(font.weight());
keyName += " " + QString::number(font.pixelSize());
keyName += QByteArray(" DF");
return QString::fromUtf8(keyName);
} else {
return QString::fromLatin1("%1_%2_%3_%4_%5")
.arg(font.familyName())
.arg(font.styleName())
.arg(font.weight())
.arg(font.style())
.arg(font.pixelSize());
}
}
QSGOpenVGFontGlyphCache::QSGOpenVGFontGlyphCache(QSGOpenVGFontGlyphCacheManager *manager, const QRawFont &font) QSGOpenVGFontGlyphCache::QSGOpenVGFontGlyphCache(QSGOpenVGFontGlyphCacheManager *manager, const QRawFont &font)
: m_manager(manager) : m_manager(manager)
{ {

View File

@ -59,9 +59,7 @@ public:
void insertCache(const QRawFont &font, QSGOpenVGFontGlyphCache *cache); void insertCache(const QRawFont &font, QSGOpenVGFontGlyphCache *cache);
private: private:
static QString fontKey(const QRawFont &font); QHash<QRawFont, QSGOpenVGFontGlyphCache *> m_caches;
QHash<QString, QSGOpenVGFontGlyphCache *> m_caches;
}; };
class QSGOpenVGFontGlyphCache class QSGOpenVGFontGlyphCache