Mercurial > hg > svgui
diff widgets/Thumbwheel.cpp @ 382:06b5f110c5d2
* Speed up spectrogram painting by releasing mutex in FFTDataServer
while calculating data prior to writing it, and by adding whole-column
value query methods to FFT objects
* Add paint cache to Thumbwheel -- repaints of this widget were slowing
down the whole spectrogram repaint
* More uses of MutexLocker (named and with debug) and more profile
points
* Make startup much quicker some of the time, with OSC server in place
author | Chris Cannam |
---|---|
date | Thu, 08 May 2008 14:46:22 +0000 |
parents | c492902dba40 |
children | e233627a923e |
line wrap: on
line diff
--- a/widgets/Thumbwheel.cpp Tue Apr 29 11:07:14 2008 +0000 +++ b/widgets/Thumbwheel.cpp Thu May 08 14:46:22 2008 +0000 @@ -129,6 +129,7 @@ if (m_atDefault) { setValue(m_default); m_atDefault = true; // setValue unsets this + m_cache = QImage(); emit valueChanged(getValue()); } } @@ -145,6 +146,7 @@ if (newValue != getValue()) { setValue(newValue); changed = true; + m_cache = QImage(); } if (changed) emit valueChanged(newValue); m_noMappedUpdate = false; @@ -152,6 +154,7 @@ int v = int(mappedValue); if (v != getValue()) { setValue(v); + m_cache = QImage(); emit valueChanged(v); } } @@ -179,6 +182,7 @@ } m_rotation = float(m_value - m_min) / float(m_max - m_min); + m_cache = QImage(); if (isVisible()) update(); } @@ -188,6 +192,7 @@ if (m_default == m_value) return; setValue(m_default); m_atDefault = true; + m_cache = QImage(); emit valueChanged(getValue()); } @@ -436,7 +441,18 @@ void Thumbwheel::paintEvent(QPaintEvent *) { - Profiler profiler("Thumbwheel::paintEvent", true); + Profiler profiler("Thumbwheel::paintEvent"); + + if (!m_cache.isNull()) { + QPainter paint(this); + paint.drawImage(0, 0, m_cache); + return; + } + + Profiler profiler2("Thumbwheel::paintEvent (no cache)"); + + m_cache = QImage(size(), QImage::Format_ARGB32); + m_cache.fill(Qt::transparent); int bw = 3; @@ -447,7 +463,8 @@ subclip = QRect(bw+1, bw, width() - bw*2 - 2, height() - bw*2); } - QPainter paint(this); + QPainter paint(&m_cache); + paint.setClipRect(rect()); paint.fillRect(subclip, palette().background().color()); paint.setRenderHint(QPainter::Antialiasing, true); @@ -563,6 +580,9 @@ paint.drawRect(QRectF(bw, x0, width() - bw*2, x1 - x0)); } } + + QPainter paint2(this); + paint2.drawImage(0, 0, m_cache); } QSize