comparison 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
comparison
equal deleted inserted replaced
328:b6df8b44b98d 329:bbc9666cb961
30 #include <QImage> 30 #include <QImage>
31 #include <QPixmap> 31 #include <QPixmap>
32 32
33 class View; 33 class View;
34 class QPainter; 34 class QPainter;
35 class QImage; 35 //class QImage;
36 class QPixmap; 36 //class QPixmap;
37 class QTimer; 37 class QTimer;
38 class FFTModel; 38 class FFTModel;
39 39
40 40
41 /** 41 /**
280 280
281 Palette m_palette; 281 Palette m_palette;
282 282
283 struct PixmapCache 283 struct PixmapCache
284 { 284 {
285 QPixmap pixmap; 285 QMutex mutex;
286 QImage pixmap;
286 QRect validArea; 287 QRect validArea;
287 long startFrame; 288 long startFrame;
288 size_t zoomLevel; 289 size_t zoomLevel;
289 }; 290 };
290 typedef std::map<const View *, PixmapCache> ViewPixmapCache; 291 typedef std::map<const View *, PixmapCache *> ViewPixmapCache;
291 void invalidatePixmapCaches(); 292 void invalidatePixmapCaches();
292 void invalidatePixmapCaches(size_t startFrame, size_t endFrame); 293 void invalidatePixmapCaches(size_t startFrame, size_t endFrame);
293 mutable ViewPixmapCache m_pixmapCaches; 294 mutable ViewPixmapCache m_pixmapCaches;
294 mutable QImage m_drawBuffer; 295 mutable QMutex m_pixmapCacheMutex;
295 296
296 mutable QTimer *m_updateTimer; 297 mutable QTimer *m_updateTimer;
297 298
298 mutable size_t m_candidateFillStartFrame; 299 mutable size_t m_candidateFillStartFrame;
299 bool m_exiting; 300 bool m_exiting;
336 337
337 size_t getZeroPadLevel(const View *v) const; 338 size_t getZeroPadLevel(const View *v) const;
338 size_t getFFTSize(const View *v) const; 339 size_t getFFTSize(const View *v) const;
339 FFTModel *getFFTModel(const View *v) const; 340 FFTModel *getFFTModel(const View *v) const;
340 void invalidateFFTModels(); 341 void invalidateFFTModels();
342
343 class PaintThread : public Thread
344 {
345 public:
346 PaintThread(SpectrogramLayer *layer) :
347 m_layer(layer), m_exiting(false) { }
348 virtual void run();
349 virtual void exiting() { m_exiting = true; }
350
351 protected:
352 SpectrogramLayer *m_layer;
353 bool m_exiting;
354 };
355
356 PaintThread *m_paintThread;
357 bool paintCache(View *v) const;
341 358
342 typedef std::pair<FFTModel *, int> FFTFillPair; // model, last fill 359 typedef std::pair<FFTModel *, int> FFTFillPair; // model, last fill
343 typedef std::map<const View *, FFTFillPair> ViewFFTMap; 360 typedef std::map<const View *, FFTFillPair> ViewFFTMap;
344 typedef std::vector<float> FloatVector; 361 typedef std::vector<float> FloatVector;
345 mutable ViewFFTMap m_fftModels; 362 mutable ViewFFTMap m_fftModels;