summaryrefslogtreecommitdiffstats
path: root/src/gui/painting/qpaintengine_raster.cpp
diff options
context:
space:
mode:
authorEskil Abrahamsen Blomfeldt <eblomfel@trolltech.com>2009-08-17 13:29:02 (GMT)
committerEskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@nokia.com>2010-01-14 12:55:45 (GMT)
commit5290c50b240abbcd0477df1db1808d33b96ca856 (patch)
treef458300ef95d7c51f70d82dfec0b244faad5b14a /src/gui/painting/qpaintengine_raster.cpp
parent91e96d6c730aac4accef64e5eaab1b289939ef8e (diff)
downloadQt-5290c50b240abbcd0477df1db1808d33b96ca856.zip
Qt-5290c50b240abbcd0477df1db1808d33b96ca856.tar.gz
Qt-5290c50b240abbcd0477df1db1808d33b96ca856.tar.bz2
Support transformations in drawStaticText() and optimize for space
1. Support transformations on the painter in drawStaticText(). Transforming the painter will cause the text layout to be recalculated, except for translations, which are handled by shifting the position of the text items. 2. Make const length arrays of the internal data in QStaticTextItem in order to minimize the memory consumption.
Diffstat (limited to 'src/gui/painting/qpaintengine_raster.cpp')
-rw-r--r--src/gui/painting/qpaintengine_raster.cpp34
1 files changed, 16 insertions, 18 deletions
diff --git a/src/gui/painting/qpaintengine_raster.cpp b/src/gui/painting/qpaintengine_raster.cpp
index 387d646..87f374c 100644
--- a/src/gui/painting/qpaintengine_raster.cpp
+++ b/src/gui/painting/qpaintengine_raster.cpp
@@ -3007,23 +3007,22 @@ void QRasterPaintEngine::alphaPenBlt(const void* src, int bpl, int depth, int rx
blend(current, spans, &s->penData);
}
-void QRasterPaintEngine::drawCachedGlyphs(const QVarLengthArray<glyph_t> &glyphs,
- const QVarLengthArray<QFixedPoint> &positions,
- QFontEngine *fontEngine,
- const QTransform &matrix)
+void QRasterPaintEngine::drawCachedGlyphs(int numGlyphs, const glyph_t *glyphs,
+ const QFixedPoint *positions, QFontEngine *fontEngine)
{
Q_D(QRasterPaintEngine);
+ QRasterPaintEngineState *s = state();
QFontEngineGlyphCache::Type glyphType = fontEngine->glyphFormat >= 0 ? QFontEngineGlyphCache::Type(fontEngine->glyphFormat) : d->glyphCacheType;
QImageTextureGlyphCache *cache =
- static_cast<QImageTextureGlyphCache *>(fontEngine->glyphCache(0, glyphType, matrix));
+ static_cast<QImageTextureGlyphCache *>(fontEngine->glyphCache(0, glyphType, s->matrix));
if (!cache) {
- cache = new QImageTextureGlyphCache(glyphType, matrix);
+ cache = new QImageTextureGlyphCache(glyphType, s->matrix);
fontEngine->setGlyphCache(0, cache);
}
- cache->populate(fontEngine, glyphs, positions);
+ cache->populate(fontEngine, numGlyphs, glyphs, positions);
const QImage &image = cache->image();
int bpl = image.bytesPerLine();
@@ -3041,7 +3040,7 @@ void QRasterPaintEngine::drawCachedGlyphs(const QVarLengthArray<glyph_t> &glyphs
const QFixed offs = QFixed::fromReal(aliasedCoordinateDelta);
const uchar *bits = image.bits();
- for (int i=0; i<glyphs.size(); ++i) {
+ for (int i=0; i<numGlyphs; ++i) {
const QTextureGlyphCache::Coord &c = cache->coords.value(glyphs[i]);
int x = qFloor(positions[i].x + offs) + c.baseLineX - margin;
int y = qFloor(positions[i].y + offs) - c.baseLineY - margin;
@@ -3218,19 +3217,16 @@ void QRasterPaintEngine::drawStaticTextItem(const QPointF &p, QStaticTextItem *t
ensurePen();
ensureState();
- QTransform matrix;
- matrix.translate(p.x(), p.y());
-
// Translate to actual position
- QVarLengthArray<QFixedPoint> glyphPositions = textItem->glyphPositions;
-
QFixed fx = QFixed::fromReal(p.x());
QFixed fy = QFixed::fromReal(p.y());
- for (int i=0; i<glyphPositions.size(); ++i) {
- glyphPositions[i].x += fx;
- glyphPositions[i].y += fy;
+ for (int i=0; i<textItem->numGlyphs; ++i) {
+ textItem->glyphPositions[i].x += fx;
+ textItem->glyphPositions[i].y += fy;
}
- drawCachedGlyphs(textItem->glyphs, glyphPositions, textItem->fontEngine, matrix);
+
+ drawCachedGlyphs(textItem->numGlyphs, textItem->glyphs, textItem->glyphPositions,
+ textItem->fontEngine);
}
/*!
@@ -3285,11 +3281,13 @@ void QRasterPaintEngine::drawTextItem(const QPointF &p, const QTextItem &textIte
QVarLengthArray<QFixedPoint> positions;
QVarLengthArray<glyph_t> glyphs;
+
QTransform matrix = s->matrix;
matrix.translate(p.x(), p.y());
+
ti.fontEngine->getGlyphPositions(ti.glyphs, matrix, ti.flags, glyphs, positions);
- drawCachedGlyphs(glyphs, positions, ti.fontEngine, matrix);
+ drawCachedGlyphs(glyphs.size(), glyphs.constData(), positions.constData(), ti.fontEngine);
return;
}