Skip to content

Commit

Permalink
QCoreTextFontEngine: Cache face_id.
Browse files Browse the repository at this point in the history
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 <[email protected]>
Reviewed-by: Morten Johan Sørvig <[email protected]>
  • Loading branch information
rburchell authored and KonstantinRitt committed Feb 22, 2015
1 parent 878cbbc commit 571908f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
12 changes: 5 additions & 7 deletions src/platformsupport/fontdatabases/mac/qfontengine_coretext.mm
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,10 @@ CGAffineTransform qt_transform_from_fontdef(const QFontDef &fontDef)
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;

Expand Down Expand Up @@ -696,13 +700,7 @@ static void qcoretextfontengine_scaleMetrics(glyph_metrics_t &br, const QTransfo

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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ class QCoreTextFontEngine : public QFontEngine
int synthesisFlags;
CGAffineTransform transform;
QFixed avgCharWidth;
QFontEngine::FaceId face_id;
};

CGAffineTransform qt_transform_from_fontdef(const QFontDef &fontDef);
Expand Down

0 comments on commit 571908f

Please sign in to comment.