summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon Hausmann <simon.hausmann@nokia.com>2010-03-16 15:03:24 (GMT)
committerSimon Hausmann <simon.hausmann@nokia.com>2010-03-16 15:03:53 (GMT)
commit6c6972cd99ea8a350b2ec495f4051c12c20153af (patch)
treeb84e62f97ab9d170f3f6bf0b2df7bf1635eca8b9
parentd202681aa857cce2468c95676a56c9133a8f226c (diff)
downloadQt-6c6972cd99ea8a350b2ec495f4051c12c20153af.zip
Qt-6c6972cd99ea8a350b2ec495f4051c12c20153af.tar.gz
Qt-6c6972cd99ea8a350b2ec495f4051c12c20153af.tar.bz2
Speed up various QFontMetrics functions
Use QStackTextEngine to avoid heap allocations. Reviewed-by: Lars
-rw-r--r--src/gui/text/qfontmetrics.cpp14
1 files changed, 7 insertions, 7 deletions
diff --git a/src/gui/text/qfontmetrics.cpp b/src/gui/text/qfontmetrics.cpp
index 41d0af1..13a5704 100644
--- a/src/gui/text/qfontmetrics.cpp
+++ b/src/gui/text/qfontmetrics.cpp
@@ -533,7 +533,7 @@ int QFontMetrics::width(const QString &text, int len) const
if (len == 0)
return 0;
- QTextEngine layout(text, d.data());
+ QStackTextEngine layout(text, d.data());
layout.ignoreBidi = true;
return qRound(layout.width(0, len));
}
@@ -609,7 +609,7 @@ int QFontMetrics::charWidth(const QString &text, int pos) const
int from = qMax(0, pos - 8);
int to = qMin(text.length(), pos + 8);
QString cstr = QString::fromRawData(text.unicode() + from, to - from);
- QTextEngine layout(cstr, d.data());
+ QStackTextEngine layout(cstr, d.data());
layout.ignoreBidi = true;
layout.itemize();
width = qRound(layout.width(pos-from, 1));
@@ -658,7 +658,7 @@ QRect QFontMetrics::boundingRect(const QString &text) const
if (text.length() == 0)
return QRect();
- QTextEngine layout(text, d.data());
+ QStackTextEngine layout(text, d.data());
layout.ignoreBidi = true;
layout.itemize();
glyph_metrics_t gm = layout.boundingBox(0, text.length());
@@ -828,7 +828,7 @@ QRect QFontMetrics::tightBoundingRect(const QString &text) const
if (text.length() == 0)
return QRect();
- QTextEngine layout(text, d.data());
+ QStackTextEngine layout(text, d.data());
layout.ignoreBidi = true;
layout.itemize();
glyph_metrics_t gm = layout.tightBoundingBox(0, text.length());
@@ -1370,7 +1370,7 @@ qreal QFontMetricsF::width(const QString &text) const
int pos = text.indexOf(QLatin1Char('\x9c'));
int len = (pos != -1) ? pos : text.length();
- QTextEngine layout(text, d.data());
+ QStackTextEngine layout(text, d.data());
layout.ignoreBidi = true;
layout.itemize();
return layout.width(0, len).toReal();
@@ -1447,7 +1447,7 @@ QRectF QFontMetricsF::boundingRect(const QString &text) const
if (len == 0)
return QRectF();
- QTextEngine layout(text, d.data());
+ QStackTextEngine layout(text, d.data());
layout.ignoreBidi = true;
layout.itemize();
glyph_metrics_t gm = layout.boundingBox(0, len);
@@ -1620,7 +1620,7 @@ QRectF QFontMetricsF::tightBoundingRect(const QString &text) const
if (text.length() == 0)
return QRect();
- QTextEngine layout(text, d.data());
+ QStackTextEngine layout(text, d.data());
layout.ignoreBidi = true;
layout.itemize();
glyph_metrics_t gm = layout.tightBoundingBox(0, text.length());