diff options
author | Michael Brasser <michael.brasser@nokia.com> | 2010-07-09 01:33:56 (GMT) |
---|---|---|
committer | Michael Brasser <michael.brasser@nokia.com> | 2010-07-09 01:33:56 (GMT) |
commit | 0c56bef89b6e3fe4c9fb32eb8b51a6ea316a89fa (patch) | |
tree | 171fc686b4f6cb66b7b98cc23c5662784497efd9 /src/gui/text/qtextlayout.cpp | |
parent | fb89f24ec1c799ed23ed5ee566e6d5d78122fc46 (diff) | |
download | Qt-0c56bef89b6e3fe4c9fb32eb8b51a6ea316a89fa.zip Qt-0c56bef89b6e3fe4c9fb32eb8b51a6ea316a89fa.tar.gz Qt-0c56bef89b6e3fe4c9fb32eb8b51a6ea316a89fa.tar.bz2 |
Optimize text layout.
When laying out text, a significant amount of time was being spent
querying for the font engine. This patch:
* changes the layout to only query for the engine when a new script item
is encountered.
* adds an internal cache of the previous result to
QTextEngine::fontEngine(). This catches the important case of multiline
text with few font engine changes.
With these changes layout costs are now approximately 60% of what they
were previously, as measured by the text layout benchmarks.
Reviewed-by: Eskil Abrahamsen Blomfeldt
Diffstat (limited to 'src/gui/text/qtextlayout.cpp')
-rw-r--r-- | src/gui/text/qtextlayout.cpp | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/src/gui/text/qtextlayout.cpp b/src/gui/text/qtextlayout.cpp index 0df3c2e..3bad6a5 100644 --- a/src/gui/text/qtextlayout.cpp +++ b/src/gui/text/qtextlayout.cpp @@ -401,6 +401,7 @@ QTextLayout::~QTextLayout() void QTextLayout::setFont(const QFont &font) { d->fnt = font; + d->feCache.reset(); } /*! @@ -540,6 +541,7 @@ void QTextLayout::setAdditionalFormats(const QList<FormatRange> &formatList) } if (d->block.docHandle()) d->block.docHandle()->documentChange(d->block.position(), d->block.length()); + d->feCache.reset(); } /*! @@ -1860,14 +1862,14 @@ void QTextLine::layout_helper(int maxGlyphs) lbh.currentPosition = qMax(line.from, current.position); end = current.position + eng->length(item); lbh.glyphs = eng->shapedGlyphs(¤t); + QFontEngine *fontEngine = eng->fontEngine(current); + if (lbh.fontEngine != fontEngine) { + lbh.fontEngine = fontEngine; + lbh.minimumRightBearing = qMin(QFixed(), + QFixed::fromReal(fontEngine->minRightBearing())); + } } const QScriptItem ¤t = eng->layoutData->items[item]; - QFontEngine *fontEngine = eng->fontEngine(current); - if (lbh.fontEngine != fontEngine) { - lbh.fontEngine = fontEngine; - lbh.minimumRightBearing = qMin(QFixed(), - QFixed::fromReal(fontEngine->minRightBearing())); - } lbh.tmpData.leading = qMax(lbh.tmpData.leading + lbh.tmpData.ascent, current.leading + current.ascent) - qMax(lbh.tmpData.ascent, |