summaryrefslogtreecommitdiffstats
path: root/src/gui/text
diff options
context:
space:
mode:
authormae <qt-info@nokia.com>2009-05-05 12:22:21 (GMT)
committermae <qt-info@nokia.com>2009-05-05 12:22:21 (GMT)
commit6cbbc22cb8493120ccd01b62028866995e9f5cd7 (patch)
tree57ef710755da5e6050c144ddf7acfff59a90f9f2 /src/gui/text
parent5dec3808ed6724a096e5dfc579d37e8528de75e0 (diff)
downloadQt-6cbbc22cb8493120ccd01b62028866995e9f5cd7.zip
Qt-6cbbc22cb8493120ccd01b62028866995e9f5cd7.tar.gz
Qt-6cbbc22cb8493120ccd01b62028866995e9f5cd7.tar.bz2
Extend change 759338df758ad16cdfd9521b270f7e379bbfa57c to cover extra
selections with different foreground but no background The main concern is to avoid double painting. With anti-aliasing turned on by default, we can not draw a piece of text on top of the same piece of text without artefacts. Task-number: 252310
Diffstat (limited to 'src/gui/text')
-rw-r--r--src/gui/text/qtextlayout.cpp39
1 files changed, 25 insertions, 14 deletions
diff --git a/src/gui/text/qtextlayout.cpp b/src/gui/text/qtextlayout.cpp
index 3222237..fa624ef 100644
--- a/src/gui/text/qtextlayout.cpp
+++ b/src/gui/text/qtextlayout.cpp
@@ -1145,7 +1145,7 @@ void QTextLayout::draw(QPainter *p, const QPointF &pos, const QVector<FormatRang
}
QPainterPath excludedRegion;
- QPainterPath needsTextButNoBackground;
+ QPainterPath textDoneRegion;
for (int i = 0; i < selections.size(); ++i) {
FormatRange selection = selections.at(i);
const QBrush bg = selection.format.background();
@@ -1205,18 +1205,25 @@ void QTextLayout::draw(QPainter *p, const QPointF &pos, const QVector<FormatRang
}
- p->save();
- p->setClipPath(region, Qt::IntersectClip);
- selection.format.setProperty(ObjectSelectionBrush, selection.format.property(QTextFormat::BackgroundBrush));
- // don't just clear the property, set an empty brush that overrides a potential
- // background brush specified in the text
- selection.format.setProperty(QTextFormat::BackgroundBrush, QBrush());
- selection.format.clearProperty(QTextFormat::OutlinePen);
+ bool hasText = (selection.format.foreground().style() != Qt::NoBrush);
+ bool hasBackground= (selection.format.background().style() != Qt::NoBrush);
+
+ if (hasBackground) {
+ selection.format.setProperty(ObjectSelectionBrush, selection.format.property(QTextFormat::BackgroundBrush));
+ // don't just clear the property, set an empty brush that overrides a potential
+ // background brush specified in the text
+ selection.format.setProperty(QTextFormat::BackgroundBrush, QBrush());
+ selection.format.clearProperty(QTextFormat::OutlinePen);
+ }
- bool noText = (selection.format.foreground().style() == Qt::NoBrush);
+ selection.format.setProperty(SuppressText, !hasText);
+
+ if (hasText && !hasBackground && !(textDoneRegion & region).isEmpty())
+ continue;
- selection.format.setProperty(SuppressText, noText);
+ p->save();
+ p->setClipPath(region, Qt::IntersectClip);
for (int line = firstLine; line < lastLine; ++line) {
QTextLine l(line, d);
@@ -1224,13 +1231,17 @@ void QTextLayout::draw(QPainter *p, const QPointF &pos, const QVector<FormatRang
}
p->restore();
- if (noText)
- needsTextButNoBackground += region;
- else
- needsTextButNoBackground -= region;
+ if (hasText) {
+ textDoneRegion += region;
+ } else {
+ if (hasBackground)
+ textDoneRegion -= region;
+ }
+
excludedRegion += region;
}
+ QPainterPath needsTextButNoBackground = excludedRegion - textDoneRegion;
if (!needsTextButNoBackground.isEmpty()){
p->save();
p->setClipPath(needsTextButNoBackground, Qt::IntersectClip);