summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorKonstantin Ritt <ritt.ks@gmail.com>2012-07-09 04:30:28 +0300
committerQt by Nokia <qt-info@nokia.com>2012-07-10 03:23:48 +0200
commit917b0df6333a16d5348b535cb6720699965fb7eb (patch)
tree153141075f5511051ec0d7c5f9812e66670a2e53 /src
parent5cf93c435228af9527f42aea32585cb156d78826 (diff)
Optimize QFontMetrics:: boundingRect() and left/rightBearing()
by avoiding unneeded metrics calculation. Same optimization for QFontMetricsF. Change-Id: I7fd0caa2ddb45862ee9e9c0519a71b03bcd0cb6f Reviewed-by: Konstantin Ritt <ritt.ks@gmail.com>
Diffstat (limited to 'src')
-rw-r--r--src/gui/text/qfontmetrics.cpp12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/gui/text/qfontmetrics.cpp b/src/gui/text/qfontmetrics.cpp
index 41e561bf7a..d135b2a44b 100644
--- a/src/gui/text/qfontmetrics.cpp
+++ b/src/gui/text/qfontmetrics.cpp
@@ -453,7 +453,7 @@ int QFontMetrics::leftBearing(QChar ch) const
QGlyphLayoutArray<10> glyphs;
int nglyphs = 9;
- engine->stringToCMap(&ch, 1, &glyphs, &nglyphs, 0);
+ engine->stringToCMap(&ch, 1, &glyphs, &nglyphs, QFontEngine::GlyphIndicesOnly);
// ### can nglyphs != 1 happen at all? Not currently I think
qreal lb;
engine->getGlyphBearings(glyphs.glyphs[0], &lb);
@@ -488,7 +488,7 @@ int QFontMetrics::rightBearing(QChar ch) const
QGlyphLayoutArray<10> glyphs;
int nglyphs = 9;
- engine->stringToCMap(&ch, 1, &glyphs, &nglyphs, 0);
+ engine->stringToCMap(&ch, 1, &glyphs, &nglyphs, QFontEngine::GlyphIndicesOnly);
// ### can nglyphs != 1 happen at all? Not currently I think
qreal rb;
engine->getGlyphBearings(glyphs.glyphs[0], 0, &rb);
@@ -706,7 +706,7 @@ QRect QFontMetrics::boundingRect(QChar ch) const
QGlyphLayoutArray<10> glyphs;
int nglyphs = 9;
- engine->stringToCMap(&ch, 1, &glyphs, &nglyphs, 0);
+ engine->stringToCMap(&ch, 1, &glyphs, &nglyphs, QFontEngine::GlyphIndicesOnly);
glyph_metrics_t gm = engine->boundingBox(glyphs.glyphs[0]);
return QRect(qRound(gm.x), qRound(gm.y), qRound(gm.width), qRound(gm.height));
}
@@ -1324,7 +1324,7 @@ qreal QFontMetricsF::leftBearing(QChar ch) const
QGlyphLayoutArray<10> glyphs;
int nglyphs = 9;
- engine->stringToCMap(&ch, 1, &glyphs, &nglyphs, 0);
+ engine->stringToCMap(&ch, 1, &glyphs, &nglyphs, QFontEngine::GlyphIndicesOnly);
// ### can nglyphs != 1 happen at all? Not currently I think
qreal lb;
engine->getGlyphBearings(glyphs.glyphs[0], &lb);
@@ -1359,7 +1359,7 @@ qreal QFontMetricsF::rightBearing(QChar ch) const
QGlyphLayoutArray<10> glyphs;
int nglyphs = 9;
- engine->stringToCMap(&ch, 1, &glyphs, &nglyphs, 0);
+ engine->stringToCMap(&ch, 1, &glyphs, &nglyphs, QFontEngine::GlyphIndicesOnly);
// ### can nglyphs != 1 happen at all? Not currently I think
qreal rb;
engine->getGlyphBearings(glyphs.glyphs[0], 0, &rb);
@@ -1494,7 +1494,7 @@ QRectF QFontMetricsF::boundingRect(QChar ch) const
QGlyphLayoutArray<10> glyphs;
int nglyphs = 9;
- engine->stringToCMap(&ch, 1, &glyphs, &nglyphs, 0);
+ engine->stringToCMap(&ch, 1, &glyphs, &nglyphs, QFontEngine::GlyphIndicesOnly);
glyph_metrics_t gm = engine->boundingBox(glyphs.glyphs[0]);
return QRectF(gm.x.toReal(), gm.y.toReal(), gm.width.toReal(), gm.height.toReal());
}