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/qtextengine_p.h | |
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/qtextengine_p.h')
-rw-r--r-- | src/gui/text/qtextengine_p.h | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/src/gui/text/qtextengine_p.h b/src/gui/text/qtextengine_p.h index 5588cbc..7270efb 100644 --- a/src/gui/text/qtextengine_p.h +++ b/src/gui/text/qtextengine_p.h @@ -550,6 +550,23 @@ public: mutable QScriptLineArray lines; + struct FontEngineCache { + FontEngineCache(); + mutable QFontEngine *prevFontEngine; + mutable QFontEngine *prevScaledFontEngine; + mutable int prevScript; + mutable int prevPosition; + mutable int prevLength; + inline void reset() { + prevFontEngine = 0; + prevScaledFontEngine = 0; + prevScript = -1; + prevPosition = -1; + prevLength = -1; + } + }; + mutable FontEngineCache feCache; + QString text; QFont fnt; QTextBlock block; |