comparison layer/SpectrogramLayer.h @ 1030:0be17aafa935 spectrogram-minor-refactor

Start refactoring out the spectrogram image cache
author Chris Cannam
date Fri, 29 Jan 2016 15:08:01 +0000
parents 53110ace211f
children bfce7940c017
comparison
equal deleted inserted replaced
1029:fdfd84b022df 1030:0be17aafa935
11 published by the Free Software Foundation; either version 2 of the 11 published by the Free Software Foundation; either version 2 of the
12 License, or (at your option) any later version. See the file 12 License, or (at your option) any later version. See the file
13 COPYING included with this distribution for more information. 13 COPYING included with this distribution for more information.
14 */ 14 */
15 15
16 #ifndef _SPECTROGRAM_LAYER_H_ 16 #ifndef SPECTROGRAM_LAYER_H
17 #define _SPECTROGRAM_LAYER_H_ 17 #define SPECTROGRAM_LAYER_H
18 18
19 #include "SliceableLayer.h" 19 #include "SliceableLayer.h"
20 #include "base/Window.h" 20 #include "base/Window.h"
21 #include "base/RealTime.h" 21 #include "base/RealTime.h"
22 #include "base/Thread.h" 22 #include "base/Thread.h"
23 #include "base/PropertyContainer.h" 23 #include "base/PropertyContainer.h"
24 #include "data/model/PowerOfSqrtTwoZoomConstraint.h" 24 #include "data/model/PowerOfSqrtTwoZoomConstraint.h"
25 #include "data/model/DenseTimeValueModel.h" 25 #include "data/model/DenseTimeValueModel.h"
26 #include "data/model/FFTModel.h" 26 #include "data/model/FFTModel.h"
27
28 #include "ScrollableImageCache.h"
27 29
28 #include <QMutex> 30 #include <QMutex>
29 #include <QWaitCondition> 31 #include <QWaitCondition>
30 #include <QImage> 32 #include <QImage>
31 #include <QPixmap> 33 #include <QPixmap>
292 QColor m_colours[256]; 294 QColor m_colours[256];
293 }; 295 };
294 296
295 Palette m_palette; 297 Palette m_palette;
296 298
297 /** 299 typedef std::map<int, ScrollableImageCache> ViewImageCache; // key is view id
298 * ImageCache covers the area of the view, at view resolution.
299 * Not all of it is necessarily valid at once (it is refreshed
300 * in parts when scrolling, for example).
301 */
302 struct ImageCache
303 {
304 QImage image;
305 QRect validArea;
306 sv_frame_t startFrame;
307 int zoomLevel;
308 };
309 typedef std::map<const View *, ImageCache> ViewImageCache;
310 void invalidateImageCaches(); 300 void invalidateImageCaches();
311 void invalidateImageCaches(sv_frame_t startFrame, sv_frame_t endFrame);
312 mutable ViewImageCache m_imageCaches; 301 mutable ViewImageCache m_imageCaches;
302 ScrollableImageCache &getImageCacheReference(const LayerGeometryProvider *) const;
313 303
314 /** 304 /**
315 * When painting, we draw directly onto the draw buffer and then 305 * When painting, we draw directly onto the draw buffer and then
316 * copy this to the part of the image cache that needed refreshing 306 * copy this to the part of the image cache that needed refreshing
317 * before copying the image cache onto the window. (Remind me why 307 * before copying the image cache onto the window. (Remind me why
361 int getFFTSize(const LayerGeometryProvider *v) const; 351 int getFFTSize(const LayerGeometryProvider *v) const;
362 FFTModel *getFFTModel(const LayerGeometryProvider *v) const; 352 FFTModel *getFFTModel(const LayerGeometryProvider *v) const;
363 Dense3DModelPeakCache *getPeakCache(const LayerGeometryProvider *v) const; 353 Dense3DModelPeakCache *getPeakCache(const LayerGeometryProvider *v) const;
364 void invalidateFFTModels(); 354 void invalidateFFTModels();
365 355
366 typedef std::map<const View *, FFTModel *> ViewFFTMap; 356 typedef std::map<int, FFTModel *> ViewFFTMap; // key is view id
367 typedef std::map<const View *, Dense3DModelPeakCache *> PeakCacheMap; 357 typedef std::map<int, Dense3DModelPeakCache *> PeakCacheMap; // key is view id
368 mutable ViewFFTMap m_fftModels; 358 mutable ViewFFTMap m_fftModels;
369 mutable PeakCacheMap m_peakCaches; 359 mutable PeakCacheMap m_peakCaches;
370 mutable Model *m_sliceableModel; 360 mutable Model *m_sliceableModel;
371 361
372 class MagnitudeRange { 362 class MagnitudeRange {
409 private: 399 private:
410 float m_min; 400 float m_min;
411 float m_max; 401 float m_max;
412 }; 402 };
413 403
414 typedef std::map<const LayerGeometryProvider *, MagnitudeRange> ViewMagMap; 404 typedef std::map<int, MagnitudeRange> ViewMagMap; // key is view id
415 mutable ViewMagMap m_viewMags; 405 mutable ViewMagMap m_viewMags;
416 mutable std::vector<MagnitudeRange> m_columnMags; 406 mutable std::vector<MagnitudeRange> m_columnMags;
417 void invalidateMagnitudes(); 407 void invalidateMagnitudes();
418 bool updateViewMagnitudes(LayerGeometryProvider *v) const; 408 bool updateViewMagnitudes(LayerGeometryProvider *v) const;
419 int paintDrawBuffer(LayerGeometryProvider *v, int w, int h, 409 int paintDrawBuffer(LayerGeometryProvider *v, int w, int h,