Mercurial > hg > svgui
diff layer/SpectrogramLayer.h @ 329:bbc9666cb961 spectrogram-cache-rejig
* First hack towards more efficient paint mechanism from cache filled
in a background thread. This doesn't work properly.
author | Chris Cannam |
---|---|
date | Wed, 14 Nov 2007 16:23:17 +0000 |
parents | c0b9eec70639 |
children | 846746e4e865 |
line wrap: on
line diff
--- a/layer/SpectrogramLayer.h Sun Nov 11 21:47:19 2007 +0000 +++ b/layer/SpectrogramLayer.h Wed Nov 14 16:23:17 2007 +0000 @@ -32,8 +32,8 @@ class View; class QPainter; -class QImage; -class QPixmap; +//class QImage; +//class QPixmap; class QTimer; class FFTModel; @@ -282,16 +282,17 @@ struct PixmapCache { - QPixmap pixmap; + QMutex mutex; + QImage pixmap; QRect validArea; long startFrame; size_t zoomLevel; }; - typedef std::map<const View *, PixmapCache> ViewPixmapCache; + typedef std::map<const View *, PixmapCache *> ViewPixmapCache; void invalidatePixmapCaches(); void invalidatePixmapCaches(size_t startFrame, size_t endFrame); mutable ViewPixmapCache m_pixmapCaches; - mutable QImage m_drawBuffer; + mutable QMutex m_pixmapCacheMutex; mutable QTimer *m_updateTimer; @@ -339,6 +340,22 @@ FFTModel *getFFTModel(const View *v) const; void invalidateFFTModels(); + class PaintThread : public Thread + { + public: + PaintThread(SpectrogramLayer *layer) : + m_layer(layer), m_exiting(false) { } + virtual void run(); + virtual void exiting() { m_exiting = true; } + + protected: + SpectrogramLayer *m_layer; + bool m_exiting; + }; + + PaintThread *m_paintThread; + bool paintCache(View *v) const; + typedef std::pair<FFTModel *, int> FFTFillPair; // model, last fill typedef std::map<const View *, FFTFillPair> ViewFFTMap; typedef std::vector<float> FloatVector;