QCoreTextFontEngine: Cache face_id.

This involves a significant amount of memory allocation, which made it rather
more expensive than one would expect. The FT engine also caches face id, so this
seems like a reasonable prospect.

Increases delegates_text by another few ops/frame.

Change-Id: If31e6b54478e4caf46a3a12a9ac45254a1f01525
Reviewed-by: Konstantin Ritt <ritt.ks@gmail.com>
Reviewed-by: Morten Johan Sørvig <morten.sorvig@theqtcompany.com>
This commit is contained in:
Robin Burchell 2015-02-13 22:20:12 +01:00 committed by Konstantin Ritt
parent 878cbbcb65
commit 571908f7fc
2 changed files with 6 additions and 7 deletions

View File

@ -162,6 +162,10 @@ void QCoreTextFontEngine::init()
Q_ASSERT(ctfont != NULL);
Q_ASSERT(cgFont != NULL);
face_id.index = 0;
QCFString name = CTFontCopyName(ctfont, kCTFontUniqueNameKey);
face_id.filename = QCFString::toQString(name).toUtf8();
QCFString family = CTFontCopyFamilyName(ctfont);
fontDef.family = family;
@ -696,13 +700,7 @@ void QCoreTextFontEngine::recalcAdvances(QGlyphLayout *glyphs, QFontEngine::Shap
QFontEngine::FaceId QCoreTextFontEngine::faceId() const
{
FaceId result;
result.index = 0;
QCFString name = CTFontCopyName(ctfont, kCTFontUniqueNameKey);
result.filename = QCFString::toQString(name).toUtf8();
return result;
return face_id;
}
bool QCoreTextFontEngine::canRender(const QChar *string, int len) const

View File

@ -135,6 +135,7 @@ private:
int synthesisFlags;
CGAffineTransform transform;
QFixed avgCharWidth;
QFontEngine::FaceId face_id;
};
CGAffineTransform qt_transform_from_fontdef(const QFontDef &fontDef);