diff options
author | Konstantin Ritt <ritt.ks@gmail.com> | 2012-07-09 17:06:33 +0300 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-07-10 03:23:43 +0200 |
commit | 98c1eb1750498cdff9d3b26658e5e5be9c026c92 (patch) | |
tree | ca8b225bcd476d526cfa5c7afd3c6e759bf3e79a /src/gui | |
parent | 1db99a6250f96892362f57180b3cccfd09bf7ff4 (diff) |
Optimize Q*FontEngine*::stringToCMap()
by avoiding the glyph metrics calculation when those metrics weren't requested
(QFontEngine::GlyphIndicesOnly flag has been passed).
As a side effect, this fixes a crash in case QGlyphLayout
was initialized only partially (with the glyphs array and the size).
Change-Id: I7d67abc2a74683131361fa21f8be203f61f247bc
Reviewed-by: Konstantin Ritt <ritt.ks@gmail.com>
Diffstat (limited to 'src/gui')
-rw-r--r-- | src/gui/text/qfontengine.cpp | 10 | ||||
-rw-r--r-- | src/gui/text/qfontengine_qpa.cpp | 5 | ||||
-rw-r--r-- | src/gui/text/qfontengine_qpf.cpp | 5 |
3 files changed, 14 insertions, 6 deletions
diff --git a/src/gui/text/qfontengine.cpp b/src/gui/text/qfontengine.cpp index 0f7efcca15..e757102db0 100644 --- a/src/gui/text/qfontengine.cpp +++ b/src/gui/text/qfontengine.cpp @@ -1190,8 +1190,7 @@ bool QFontEngineBox::stringToCMap(const QChar *, int len, QGlyphLayout *glyphs, return false; } - for (int i = 0; i < len; ++i) - glyphs->glyphs[i] = 0; + memset(glyphs->glyphs, 0, len * sizeof(HB_Glyph)); *nglyphs = len; glyphs->numGlyphs = len; @@ -1385,8 +1384,10 @@ bool QFontEngineMulti::stringToCMap(const QChar *str, int len, if (engine->type() == Box) continue; - glyphs->advances_x[glyph_pos] = glyphs->advances_y[glyph_pos] = 0; - glyphs->offsets[glyph_pos] = QFixedPoint(); + if (!(flags & GlyphIndicesOnly)) { + glyphs->advances_x[glyph_pos] = glyphs->advances_y[glyph_pos] = 0; + glyphs->offsets[glyph_pos] = QFixedPoint(); + } int num = 2; QGlyphLayout offs = glyphs->mid(glyph_pos, num); engine->stringToCMap(str + i, surrogate ? 2 : 1, &offs, &num, flags); @@ -1411,6 +1412,7 @@ bool QFontEngineMulti::stringToCMap(const QChar *str, int len, *nglyphs = ng; glyphs->numGlyphs = ng; + return true; } diff --git a/src/gui/text/qfontengine_qpa.cpp b/src/gui/text/qfontengine_qpa.cpp index af6620ecfa..e56b30ab44 100644 --- a/src/gui/text/qfontengine_qpa.cpp +++ b/src/gui/text/qfontengine_qpa.cpp @@ -383,7 +383,10 @@ bool QFontEngineQPA::stringToCMap(const QChar *str, int len, QGlyphLayout *glyph *nglyphs = glyph_pos; glyphs->numGlyphs = glyph_pos; - recalcAdvances(glyphs, flags); + + if (!(flags & GlyphIndicesOnly)) + recalcAdvances(glyphs, flags); + return true; } diff --git a/src/gui/text/qfontengine_qpf.cpp b/src/gui/text/qfontengine_qpf.cpp index 951be06b43..daa2c66bb4 100644 --- a/src/gui/text/qfontengine_qpf.cpp +++ b/src/gui/text/qfontengine_qpf.cpp @@ -592,7 +592,10 @@ bool QFontEngineQPF::stringToCMap(const QChar *str, int len, QGlyphLayout *glyph *nglyphs = glyph_pos; glyphs->numGlyphs = glyph_pos; - recalcAdvances(glyphs, flags); + + if (!(flags & GlyphIndicesOnly)) + recalcAdvances(glyphs, flags); + return true; } |