diff options
author | Thomas Hartmann <Thomas.Hartmann@nokia.com> | 2010-08-13 17:16:58 +0200 |
---|---|---|
committer | Thomas Hartmann <Thomas.Hartmann@nokia.com> | 2010-08-13 17:22:21 +0200 |
commit | 36c40b985b63b5cb0a8296e07643554d5aeb5f55 (patch) | |
tree | 3b07f542a73c9fb37e6b121a607fc5d37a21c15b /src/libs/qmleditorwidgets/colorbox.cpp | |
parent | 502ac08edbe0fca3eb52b8e4f050fe81c0672bc6 (diff) |
QuickToolBar: optimizing the painting of ColorBox
The painting was visible slow before.
Avoiding QPainter and setting pixels
directly leads to serious speedup.
Diffstat (limited to 'src/libs/qmleditorwidgets/colorbox.cpp')
-rw-r--r-- | src/libs/qmleditorwidgets/colorbox.cpp | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/src/libs/qmleditorwidgets/colorbox.cpp b/src/libs/qmleditorwidgets/colorbox.cpp index e09cc033405..4b0827bce88 100644 --- a/src/libs/qmleditorwidgets/colorbox.cpp +++ b/src/libs/qmleditorwidgets/colorbox.cpp @@ -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; |