diff options
author | Konstantin Ritt <ritt.ks@gmail.com> | 2014-01-30 05:46:35 +0200 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2014-01-30 12:43:33 +0100 |
commit | a5614264d5a5d6d1cc0f2773f4d7cd70195a0546 (patch) | |
tree | 23ce986e78fd6d84e57972be6502fa9ac7f2d7dc /src/gui/text/qtextlayout.cpp | |
parent | dca65cd2bc1a999b81df9d45c317a92651db3f82 (diff) |
Get rid of QGlyphLayout::advances_y
...and thus consume 4 bytes less per glyph and increase the performance a bit.
It seems, the only CTFontGetAdvancesForGlyphs() returns both x and y
advances, though y advances are always equal to 0 for horizontal
orientation and x advances are always equal to 0 for vertical orientation.
Also, rename `advances_x` to `advances` for consistency
and declare QGlyphLayout's data size in a single place.
Change-Id: I56b20f893f8a6feb7aa870e3edbca99dd93ba2e2
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@digia.com>
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Diffstat (limited to 'src/gui/text/qtextlayout.cpp')
-rw-r--r-- | src/gui/text/qtextlayout.cpp | 18 |
1 files changed, 7 insertions, 11 deletions
diff --git a/src/gui/text/qtextlayout.cpp b/src/gui/text/qtextlayout.cpp index 66341e186a..c6e5160edc 100644 --- a/src/gui/text/qtextlayout.cpp +++ b/src/gui/text/qtextlayout.cpp @@ -1693,7 +1693,7 @@ static inline void addNextCluster(int &pos, int end, QScriptLine &line, int &gly } while (pos < end && logClusters[pos] == glyphPosition); do { // calculate the textWidth for the rest of the current cluster. if (!glyphs.attributes[glyphPosition].dontPrint) - line.textWidth += glyphs.advances_x[glyphPosition]; + line.textWidth += glyphs.advances[glyphPosition]; ++glyphPosition; } while (glyphPosition < current.num_glyphs && !glyphs.attributes[glyphPosition].clusterStart); @@ -1871,9 +1871,9 @@ void QTextLine::layout_helper(int maxGlyphs) // and thus become invisible again. // if (line.length) - lbh.softHyphenWidth = lbh.glyphs.advances_x[lbh.logClusters[lbh.currentPosition - 1]]; + lbh.softHyphenWidth = lbh.glyphs.advances[lbh.logClusters[lbh.currentPosition - 1]]; else if (breakany) - lbh.tmpData.textWidth += lbh.glyphs.advances_x[lbh.logClusters[lbh.currentPosition - 1]]; + lbh.tmpData.textWidth += lbh.glyphs.advances[lbh.logClusters[lbh.currentPosition - 1]]; } // The actual width of the text needs to take the right bearing into account. The @@ -2249,14 +2249,12 @@ QList<QGlyphRun> QTextLine::glyphRuns(int from, int length) const if (relativeFrom != (iterator.itemStart - si.position) && !rtl) { for (int i=itemGlyphsStart; i<glyphsStart; ++i) { QFixed justification = QFixed::fromFixed(glyphLayout.justifications[i].space_18d6); - pos += QPointF((glyphLayout.advances_x[i] + justification).toReal(), - glyphLayout.advances_y[i].toReal()); + pos.rx() += (glyphLayout.advances[i] + justification).toReal(); } } else if (relativeTo != (iterator.itemEnd - si.position - 1) && rtl) { for (int i=itemGlyphsEnd; i>glyphsEnd; --i) { QFixed justification = QFixed::fromFixed(glyphLayout.justifications[i].space_18d6); - pos += QPointF((glyphLayout.advances_x[i] + justification).toReal(), - glyphLayout.advances_y[i].toReal()); + pos.rx() += (glyphLayout.advances[i] + justification).toReal(); } } @@ -2295,10 +2293,8 @@ QList<QGlyphRun> QTextLine::glyphRuns(int from, int length) const glyphRuns.append(glyphRunWithInfo(multiFontEngine->engine(which), subLayout, pos, subFlags, x, width)); - for (int i = 0; i < subLayout.numGlyphs; i++) { - pos += QPointF(subLayout.advances_x[i].toReal(), - subLayout.advances_y[i].toReal()); - } + for (int i = 0; i < subLayout.numGlyphs; ++i) + pos.rx() += subLayout.advances[i].toReal(); if (rtl) end = start; |