[QFontEngineFT] Avoid caching a transformed glyph in defaultGlyphSet

and only cache non-scalable glyphs in defaultGlyphSet
if a requested transform is translation.

Change-Id: I49d936736871bd455e573335c014ddefe8bb915e
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
bb10
Konstantin Ritt 2015-03-07 07:59:06 +04:00
parent 08aa2c9297
commit 69504803a9
2 changed files with 5 additions and 17 deletions

View File

@ -1334,14 +1334,14 @@ static inline FT_Matrix QTransformToFTMatrix(const QTransform &matrix)
return m;
}
QFontEngineFT::QGlyphSet *QFontEngineFT::loadTransformedGlyphSet(const QTransform &matrix)
QFontEngineFT::QGlyphSet *QFontEngineFT::loadGlyphSet(const QTransform &matrix)
{
if (matrix.type() > QTransform::TxShear || !cacheEnabled)
return 0;
// FT_Set_Transform only supports scalable fonts
if (!FT_IS_SCALABLE(freetype->face))
return 0;
return matrix.type() <= QTransform::TxTranslate ? &defaultGlyphSet : Q_NULLPTR;
FT_Matrix m = QTransformToFTMatrix(matrix);
@ -1758,15 +1758,11 @@ QImage *QFontEngineFT::lockedAlphaMapForGlyph(glyph_t glyphIndex, QFixed subPixe
QFontEngineFT::Glyph *glyph;
QScopedPointer<QFontEngineFT::Glyph> glyphGuard;
if (cacheEnabled) {
QFontEngineFT::QGlyphSet *gset = &defaultGlyphSet;
QGlyphSet *gset = loadGlyphSet(t);
QFontEngine::HintStyle hintStyle = default_hint_style;
if (t.type() >= QTransform::TxScale) {
// disable hinting if the glyphs are transformed
default_hint_style = HintNone;
if (t.isAffine())
gset = loadTransformedGlyphSet(t);
else
gset = 0;
}
if (gset) {
@ -1843,15 +1839,7 @@ QFontEngineFT::Glyph *QFontEngineFT::loadGlyphFor(glyph_t g,
const QTransform &t,
bool fetchBoundingBox)
{
QGlyphSet *glyphSet = 0;
if (cacheEnabled) {
if (t.type() > QTransform::TxTranslate && FT_IS_SCALABLE(freetype->face))
glyphSet = loadTransformedGlyphSet(t);
else
glyphSet = &defaultGlyphSet;
Q_ASSERT(glyphSet != 0);
}
QGlyphSet *glyphSet = loadGlyphSet(t);
if (glyphSet != 0 && glyphSet->outline_drawing && !fetchBoundingBox)
return 0;

View File

@ -268,7 +268,7 @@ private:
Glyph *loadGlyph(QGlyphSet *set, uint glyph, QFixed subPixelPosition, GlyphFormat = Format_None, bool fetchMetricsOnly = false) const;
Glyph *loadGlyphFor(glyph_t g, QFixed subPixelPosition, GlyphFormat format, const QTransform &t, bool fetchBoundingBox = false);
QGlyphSet *loadTransformedGlyphSet(const QTransform &matrix);
QGlyphSet *loadGlyphSet(const QTransform &matrix);
QFontEngineFT(const QFontDef &fd);
virtual ~QFontEngineFT();