Use custom class to index tiles by fftSize, zoomLevel and sample number

This commit is contained in:
Mike Walters
2015-09-13 01:30:52 +01:00
parent d679ab6b6c
commit ac9d703978
2 changed files with 30 additions and 4 deletions

View File

@@ -97,7 +97,7 @@ void Spectrogram::paintEvent(QPaintEvent *event)
float* Spectrogram::getTile(off_t tile)
{
float *obj = fftCache.object(qMakePair(fftSize, tile));
float *obj = fftCache.object(TileCacheKey(fftSize, zoomLevel, tile));
if (obj != 0)
return obj;
@@ -109,7 +109,7 @@ float* Spectrogram::getTile(off_t tile)
sample += getStride();
ptr += fftSize;
}
fftCache.insert(qMakePair(fftSize, tile), dest);
fftCache.insert(TileCacheKey(fftSize, zoomLevel, tile), dest);
return dest;
}
@@ -222,3 +222,7 @@ QString Spectrogram::sampleToTime(off_t sample)
int Spectrogram::linesPerTile() {
return tileSize / fftSize;
}
uint qHash(const TileCacheKey &key, uint seed) {
return key.fftSize ^ key.zoomLevel ^ key.sample ^ seed;
}