summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThorbjørn Lindeijer <thorbjorn.lindeijer@nokia.com>2010-01-25 13:46:08 +0100
committerThorbjørn Lindeijer <thorbjorn.lindeijer@nokia.com>2010-01-25 13:59:01 +0100
commit0ddfcdff434f808b10d414e6a1c1df7d3642f40b (patch)
treefb3c1337eed3e8b1461b5c79f5466fcfbd79e46d
parentd82c10921dbb579a0139856c8700ed18b87fe8b5 (diff)
downloadqt-creator-0ddfcdff434f808b10d414e6a1c1df7d3642f40b.tar.gz
Fixed performance issue with scrolling when using X11 graphics system
Depending on the XRender driver (probably), drawing a short straight line can take quite a while when this line is transparent. On my laptop's onboard ATI card, this meant that scrolling was unusably slow when this transparent line was being drawn. Fixed by avoiding the issue, since there is no actual need to use transparency here. We can calculate the resulting color in advance instead.
-rw-r--r--src/plugins/texteditor/basetexteditor.cpp19
1 files changed, 11 insertions, 8 deletions
diff --git a/src/plugins/texteditor/basetexteditor.cpp b/src/plugins/texteditor/basetexteditor.cpp
index b9bcb9660d..7825941ea5 100644
--- a/src/plugins/texteditor/basetexteditor.cpp
+++ b/src/plugins/texteditor/basetexteditor.cpp
@@ -1926,6 +1926,13 @@ void BaseTextEditorPrivate::moveCursorVisible(bool ensureVisible)
q->ensureCursorVisible();
}
+static QColor blendColors(const QColor &a, const QColor &b, int alpha)
+{
+ return QColor((a.red() * (256 - alpha) + b.red() * alpha) / 256,
+ (a.green() * (256 - alpha) + b.green() * alpha) / 256,
+ (a.blue() * (256 - alpha) + b.blue() * alpha) / 256);
+}
+
static QColor calcBlendColor(const QColor &baseColor, int level, int count)
{
QColor color80;
@@ -1960,10 +1967,7 @@ static QColor calcBlendColor(const QColor &baseColor, int level, int count)
const int blendFactor = level * (256 / (count - 2));
- return QColor(
- (color90.red() * blendFactor + color80.red() * (256 - blendFactor)) / 256,
- (color90.green() * blendFactor + color80.green() * (256 - blendFactor)) / 256,
- (color90.blue() * blendFactor + color80.blue() * (256 - blendFactor)) / 256);
+ return blendColors(color80, color90, blendFactor);
}
void BaseTextEditor::paintEvent(QPaintEvent *e)
@@ -2379,10 +2383,9 @@ void BaseTextEditor::paintEvent(QPaintEvent *e)
if (lineX > 0) {
const QColor bg = palette().base().color();
- QColor col = (bg.value() > 128) ? Qt::black : Qt::white;
- col.setAlpha(32);
- painter.setPen(QPen(col, 0));
- painter.drawLine(QPointF(lineX, 0), QPointF(lineX, viewport()->height()));
+ const QColor col = (bg.value() > 128) ? Qt::black : Qt::white;
+ painter.setPen(blendColors(d->m_ifdefedOutFormat.background().color(), col, 32));
+ painter.drawLine(QPointF(lineX, er.top()), QPointF(lineX, er.bottom()));
}
}