Commit 36c40b98 authored by Thomas Hartmann's avatar Thomas Hartmann
Browse files

QuickToolBar: optimizing the painting of ColorBox

The painting was visible slow before.
Avoiding QPainter and setting pixels
directly leads to serious speedup.
parent 502ac08e
......@@ -184,22 +184,21 @@ void ColorBox::paintEvent(QPaintEvent *event)
int fixedHue = clamp(m_lastHue, 0, 359);
m_cache = QPixmap(120, 120);
QImage cache = QImage(120, 120, QImage::Format_RGB32);
int height = 120;
int width = 120;
QPainter chacheP(&m_cache);
for (int y = 0; y < height; y++)
for (int x = 0; x < width; x++)
{
QColor c;
c.setHsv(fixedHue, (x*255) / width, 255 - (y*255) / height);
chacheP.setPen(c);
chacheP.drawPoint(x ,y);
for (int y = 0; y < height; y++) {
for (int x = 0; x < width; x++) {
QColor c;
c.setHsv(fixedHue, (x*255) / width, 255 - (y*255) / height);
cache.setPixel(x, y, c.rgb());
}
}
m_cache = QPixmap::fromImage(cache);
}
p.drawPixmap(5, 5, m_cache);
int x = clamp(m_color.hsvSaturationF() * 120, 0, 119) + 5;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment