summaryrefslogtreecommitdiffstats
path: root/src/gui/painting/qpainter.cpp
diff options
context:
space:
mode:
authorEskil Abrahamsen Blomfeldt <eblomfel@trolltech.com>2009-08-21 14:29:44 (GMT)
committerEskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@nokia.com>2010-01-14 13:05:08 (GMT)
commitbf919e06127962836a6b566bf119cf248c6a999b (patch)
tree789ca79fa342cf741513cb21e6d4d3728345a511 /src/gui/painting/qpainter.cpp
parent7fbffd29e5904151a3a249004031d0502a16f4fc (diff)
downloadQt-bf919e06127962836a6b566bf119cf248c6a999b.zip
Qt-bf919e06127962836a6b566bf119cf248c6a999b.tar.gz
Qt-bf919e06127962836a6b566bf119cf248c6a999b.tar.bz2
Implement drawStaticTextItem() in OpenGL paint engines
The OpenGL and OpenGL2 engines now have support for static text, as well as the QEmulationPaintEngine. Also contains an optimization: Instead of passing both the position and glyph positions to drawStaticTextItem() we add the position into the glyph position and update it only when it changes. Otherwise we would have to do this work in all engines for every call. This means we have to cache the position in QStaticTextPrivate as well, but it seems like a small price to pay, since it's a per-text overhead and only 16 bytes.
Diffstat (limited to 'src/gui/painting/qpainter.cpp')
-rw-r--r--src/gui/painting/qpainter.cpp20
1 files changed, 18 insertions, 2 deletions
diff --git a/src/gui/painting/qpainter.cpp b/src/gui/painting/qpainter.cpp
index c75547f..524f243 100644
--- a/src/gui/painting/qpainter.cpp
+++ b/src/gui/painting/qpainter.cpp
@@ -5787,11 +5787,27 @@ void QPainter::drawStaticText(const QPointF &position, const QStaticText &static
// Recreate the layout of the static text because the matrix or font has changed
if (staticTextNeedsReinit)
- staticText_d->init();
+ staticText_d->init();
+
+ if (transformedPosition != staticText_d->position) { // Translate to actual position
+ QFixed fx = QFixed::fromReal(transformedPosition.x());
+ QFixed fy = QFixed::fromReal(transformedPosition.y());
+ QFixed oldX = QFixed::fromReal(staticText_d->position.x());
+ QFixed oldY = QFixed::fromReal(staticText_d->position.y());
+ for (int item=0; item<staticText_d->itemCount;++item) {
+ QStaticTextItem *textItem = staticText_d->items + item;
+ for (int i=0; i<textItem->numGlyphs; ++i) {
+ textItem->glyphPositions[i].x += fx - oldX;
+ textItem->glyphPositions[i].y += fy - oldY;
+ }
+ }
+
+ staticText_d->position = transformedPosition;
+ }
for (int i=0; i<staticText_d->itemCount; ++i) {
QStaticTextItem *item = staticText_d->items + i;
- d->extended->drawStaticTextItem(transformedPosition, item);
+ d->extended->drawStaticTextItem(item);
}
if (restoreWhenFinished)