diff options
author | Pierre Rossi <pierre.rossi@nokia.com> | 2012-01-16 17:40:21 +0100 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-03-01 15:47:24 +0100 |
commit | cc78f47778de0feda95d7a85440d03ad7dcf40bd (patch) | |
tree | 9dd229f840ae887d2199bdf937a9371a8bfbfab7 /src/gui/text/qfont.cpp | |
parent | 10ac80708555cd0cca181e637d3a95c80826ec69 (diff) |
Allow using multi fontengine in QTextLayout with QRawFont.
This change enables us to instantiate a QFontEngineMulti that takes
the raw font's font engine as its primary engine but can use fallback
engines based on the platform. Since this can be quite expensive, we
defer the query for fallback families' names until it's needed and
we cache the resulting multi font engine.
Change-Id: I390dbc1cb2fe61d56867f29a03f313eb3eb49dc3
Reviewed-by: Simon Hausmann <simon.hausmann@nokia.com>
Diffstat (limited to 'src/gui/text/qfont.cpp')
-rw-r--r-- | src/gui/text/qfont.cpp | 27 |
1 files changed, 17 insertions, 10 deletions
diff --git a/src/gui/text/qfont.cpp b/src/gui/text/qfont.cpp index ee833a06cf..3515c7dc3c 100644 --- a/src/gui/text/qfont.cpp +++ b/src/gui/text/qfont.cpp @@ -2715,18 +2715,22 @@ QFontEngine *QFontCache::findEngine(const Key &key) EngineCache::Iterator it = engineCache.find(key), end = engineCache.end(); if (it == end) return 0; - // found... update the hitcount and timestamp - it.value().hits++; - it.value().timestamp = ++current_timestamp; + updateHitCountAndTimeStamp(it.value()); + + return it.value().data; +} + +void QFontCache::updateHitCountAndTimeStamp(Engine &value) +{ + value.hits++; + value.timestamp = ++current_timestamp; FC_DEBUG("QFontCache: found font engine\n" " %p: timestamp %4u hits %3u ref %2d/%2d, type '%s'", - it.value().data, it.value().timestamp, it.value().hits, - it.value().data->ref.load(), it.value().data->cache_count, - it.value().data->name()); - - return it.value().data; + value.data, value.timestamp, value.hits, + value.data->ref.load(), value.data->cache_count, + value.data->name()); } void QFontCache::removeEngine(QFontEngine *engine) @@ -2743,14 +2747,17 @@ void QFontCache::removeEngine(QFontEngine *engine) } } -void QFontCache::insertEngine(const Key &key, QFontEngine *engine) +void QFontCache::insertEngine(const Key &key, QFontEngine *engine, bool insertMulti) { FC_DEBUG("QFontCache: inserting new engine %p", engine); Engine data(engine); data.timestamp = ++current_timestamp; - engineCache.insert(key, data); + if (insertMulti) + engineCache.insertMulti(key, data); + else + engineCache.insert(key, data); // only increase the cost if this is the first time we insert the engine if (engine->cache_count == 0) |