diff options
author | Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@nokia.com> | 2009-12-09 13:23:02 (GMT) |
---|---|---|
committer | Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@nokia.com> | 2010-01-14 13:07:11 (GMT) |
commit | eb674a7ff5fad2f4a76e3b20873c574eb8a6135f (patch) | |
tree | 958d115a90d12410aec322fcb5a55d2cebeb08ba /src/gui/text/qstatictext.cpp | |
parent | a9e08c091c822e65ae8453581c6fee4b94001682 (diff) | |
download | Qt-eb674a7ff5fad2f4a76e3b20873c574eb8a6135f.zip Qt-eb674a7ff5fad2f4a76e3b20873c574eb8a6135f.tar.gz Qt-eb674a7ff5fad2f4a76e3b20873c574eb8a6135f.tar.bz2 |
Optimize drawStaticText() with rectangle destination
In order to be feature consistent with drawText(), we have to clip the
text whenever the text expands beyond its borders. This is a
performance hit, but luckily we can detect the cases where it's
necessary before-hand.
Diffstat (limited to 'src/gui/text/qstatictext.cpp')
-rw-r--r-- | src/gui/text/qstatictext.cpp | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/src/gui/text/qstatictext.cpp b/src/gui/text/qstatictext.cpp index 9a0ddca..85d3c81 100644 --- a/src/gui/text/qstatictext.cpp +++ b/src/gui/text/qstatictext.cpp @@ -263,7 +263,7 @@ bool QStaticText::isEmpty() const } QStaticTextPrivate::QStaticTextPrivate() - : items(0), itemCount(0), glyphPool(0), positionPool(0) + : items(0), itemCount(0), glyphPool(0), positionPool(0), needsClipRect(false) { ref = 1; } @@ -482,10 +482,17 @@ void QStaticTextPrivate::init() painter.setFont(font); painter.setTransform(matrix); - if (size.isValid()) - painter.drawText(QRectF(QPointF(0, 0), size), text); - else + if (size.isValid()) { + QRectF boundingRect; + painter.drawText(QRectF(QPointF(0, 0), size), 0, text, &boundingRect); + + needsClipRect = boundingRect.width() > size.width() + || boundingRect.height() > size.height(); + + } else { painter.drawText(0, 0, text); + needsClipRect = false; + } } } |