From 5247001c8d1a012b5895223dd7f09a9a0fd9286e Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Wed, 19 Aug 2009 15:28:55 +0200 Subject: Speed up QStaticText initialization Instead of translating each position manually afterwards, just have the matrix do it when calculating the positions inside getGlyphPositions(). --- src/gui/text/qstatictext.cpp | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/src/gui/text/qstatictext.cpp b/src/gui/text/qstatictext.cpp index 5b0b471..30935f9 100644 --- a/src/gui/text/qstatictext.cpp +++ b/src/gui/text/qstatictext.cpp @@ -311,7 +311,7 @@ namespace { { } - virtual void drawTextItem(const QPointF &p, const QTextItem &textItem) + virtual void drawTextItem(const QPointF &position, const QTextItem &textItem) { const QTextItemInt &ti = static_cast(textItem); @@ -331,10 +331,12 @@ namespace { currentItem->glyphs = m_glyphPool; currentItem->glyphPositions = m_positionPool; + QTransform matrix = state->transform(); + matrix.translate(position.x(), position.y()); + QVarLengthArray glyphs; QVarLengthArray positions; - ti.fontEngine->getGlyphPositions(ti.glyphs, state->transform(), ti.flags, - glyphs, positions); + ti.fontEngine->getGlyphPositions(ti.glyphs, matrix, ti.flags, glyphs, positions); int size = glyphs.size(); Q_ASSERT(size == ti.glyphs.numGlyphs); @@ -343,13 +345,6 @@ namespace { memmove(currentItem->glyphs, glyphs.constData(), sizeof(glyph_t) * size); memmove(currentItem->glyphPositions, positions.constData(), sizeof(QFixedPoint) * size); - QFixed fx = QFixed::fromReal(p.x()); - QFixed fy = QFixed::fromReal(p.y()); - for (int i=0; iglyphPositions[i].x += fx; - currentItem->glyphPositions[i].y += fy; - } - m_glyphPool += size; m_positionPool += size; } -- cgit v0.12