summaryrefslogtreecommitdiffstats
path: root/src/gui/text/qfontengine.cpp
diff options
context:
space:
mode:
authorLiang Qi <liang.qi@qt.io>2016-08-29 13:51:16 +0200
committerLiang Qi <liang.qi@qt.io>2016-08-29 15:30:17 +0200
commit1cc571593a67f3e688a5cbb896f0be71ca5a2b30 (patch)
treec652360c9276cbf475244fd02313d64e3df11a96 /src/gui/text/qfontengine.cpp
parent829c59aa4acf94bd979f6a3162808be36802d79a (diff)
parentcc74452d6d259d36ac47c536f11a5efb269e8e44 (diff)
Merge remote-tracking branch 'origin/5.7' into 5.8
cf53aa21bf0f8fbd13c0ce2d33ddf7bc63d0d76a and 3aaa5d6b32130d3eeac872a59a5a44bfb20dfd4a were reverted because of reconstruction in 5.7. defineTest(qtConfTest_checkCompiler) in configure.pri is smart enough to cover the case in a9474d1260a8c8cc9eae14f2984098919d9684e5. DirectWrite: Fix advances being scaled to 0 Since 131eee5cd, the stretch of a font can be 0, meaning "whatever the font provides". In combination with ec7fee96, this would cause advances in the DirectWrite engine to be scaled to 0, causing the QRawFont test to fail. Conflicts: configure mkspecs/features/uikit/device_destinations.sh mkspecs/features/uikit/xcodebuild.mk src/corelib/global/qglobal.cpp src/corelib/global/qnamespace.qdoc src/plugins/platforms/cocoa/qcocoamenuitem.h src/plugins/platforms/windows/qwindowsservices.cpp src/plugins/platformthemes/gtk3/qgtk3dialoghelpers.cpp src/plugins/platforms/windows/qwindowsfontenginedirectwrite.cpp src/widgets/kernel/qapplication.cpp tests/auto/widgets/dialogs/qfiledialog/tst_qfiledialog.cpp tests/auto/widgets/dialogs/qfiledialog2/tst_qfiledialog2.cpp Change-Id: I4656d8133da7ee9fcc84ad3f1c7950f924432d1e
Diffstat (limited to 'src/gui/text/qfontengine.cpp')
-rw-r--r--src/gui/text/qfontengine.cpp59
1 files changed, 28 insertions, 31 deletions
diff --git a/src/gui/text/qfontengine.cpp b/src/gui/text/qfontengine.cpp
index dbd47151bd..74ea8d15b7 100644
--- a/src/gui/text/qfontengine.cpp
+++ b/src/gui/text/qfontengine.cpp
@@ -1046,46 +1046,45 @@ QByteArray QFontEngine::getSfntTable(uint tag) const
return table;
}
-void QFontEngine::clearGlyphCache(const void *key)
+void QFontEngine::clearGlyphCache(const void *context)
{
- for (QLinkedList<GlyphCacheEntry>::iterator it = m_glyphCaches.begin(), end = m_glyphCaches.end(); it != end; ) {
- if (it->context == key)
- it = m_glyphCaches.erase(it);
- else
- ++it;
- }
+ m_glyphCaches.remove(context);
}
-void QFontEngine::setGlyphCache(const void *key, QFontEngineGlyphCache *data)
+void QFontEngine::setGlyphCache(const void *context, QFontEngineGlyphCache *cache)
{
- Q_ASSERT(data);
+ Q_ASSERT(cache);
- GlyphCacheEntry entry;
- entry.context = key;
- entry.cache = data;
- if (m_glyphCaches.contains(entry))
- return;
+ GlyphCaches &caches = m_glyphCaches[context];
+ for (GlyphCaches::const_iterator it = caches.constBegin(), end = caches.constEnd(); it != end; ++it) {
+ if (cache == it->cache.data())
+ return;
+ }
- // Limit the glyph caches to 4. This covers all 90 degree rotations and limits
- // memory use when there is continuous or random rotation
- if (m_glyphCaches.size() == 4)
- m_glyphCaches.removeLast();
+ // Limit the glyph caches to 4 per context. This covers all 90 degree rotations,
+ // and limits memory use when there is continuous or random rotation
+ if (caches.size() == 4)
+ caches.removeLast();
- m_glyphCaches.push_front(entry);
+ GlyphCacheEntry entry;
+ entry.cache = cache;
+ caches.push_front(entry);
}
-QFontEngineGlyphCache *QFontEngine::glyphCache(const void *key, GlyphFormat format, const QTransform &transform) const
+QFontEngineGlyphCache *QFontEngine::glyphCache(const void *context, GlyphFormat format, const QTransform &transform) const
{
- for (QLinkedList<GlyphCacheEntry>::const_iterator it = m_glyphCaches.constBegin(), end = m_glyphCaches.constEnd(); it != end; ++it) {
- QFontEngineGlyphCache *c = it->cache.data();
- if (key == it->context
- && format == c->glyphFormat()
- && qtransform_equals_no_translate(c->m_transform, transform)) {
- return c;
- }
+ const QHash<const void*, GlyphCaches>::const_iterator caches = m_glyphCaches.constFind(context);
+ if (caches == m_glyphCaches.cend())
+ return Q_NULLPTR;
+
+ for (GlyphCaches::const_iterator it = caches->begin(), end = caches->end(); it != end; ++it) {
+ QFontEngineGlyphCache *cache = it->cache.data();
+ if (format == cache->glyphFormat() && qtransform_equals_no_translate(cache->m_transform, transform))
+ return cache;
}
- return 0;
+
+ return Q_NULLPTR;
}
static inline QFixed kerning(int left, int right, const QFontEngine::KernPair *pairs, int numPairs)
@@ -1565,12 +1564,11 @@ QFixed QFontEngine::lastRightBearing(const QGlyphLayout &glyphs, bool round)
QFontEngine::GlyphCacheEntry::GlyphCacheEntry()
- : context(0)
{
}
QFontEngine::GlyphCacheEntry::GlyphCacheEntry(const GlyphCacheEntry &o)
- : context(o.context), cache(o.cache)
+ : cache(o.cache)
{
}
@@ -1580,7 +1578,6 @@ QFontEngine::GlyphCacheEntry::~GlyphCacheEntry()
QFontEngine::GlyphCacheEntry &QFontEngine::GlyphCacheEntry::operator=(const GlyphCacheEntry &o)
{
- context = o.context;
cache = o.cache;
return *this;
}