[Follow up] Improve performance when rendering sample waveforms (#7695)
A follow up to 786088baec to fix rendering issues and crashes.
---------
Co-authored-by: Sotonye Atemie <sakertooth@gmail.com>
This commit is contained in:
@@ -67,6 +67,7 @@ private:
|
||||
SampleClip * m_clip;
|
||||
SampleThumbnail m_sampleThumbnail;
|
||||
QPixmap m_paintPixmap;
|
||||
long m_paintPixmapXPosition;
|
||||
bool splitClip( const TimePos pos ) override;
|
||||
} ;
|
||||
|
||||
|
||||
@@ -54,10 +54,8 @@ public:
|
||||
{
|
||||
QRect sampleRect; //!< A rectangle that covers the entire range of samples.
|
||||
|
||||
QRect drawRect; //!< Specifies the location in `sampleRect` where the waveform will be drawn. Equals
|
||||
//!< `sampleRect` when null.
|
||||
|
||||
QRect viewportRect; //!< Clips `drawRect`. Equals `drawRect` when null.
|
||||
QRect viewportRect; //!< Specifies the location in `sampleRect` where the waveform will be drawn. Equals
|
||||
//!< `sampleRect` when null.
|
||||
|
||||
float amplification = 1.0f; //!< The amount of amplification to apply to the waveform.
|
||||
|
||||
@@ -95,8 +93,8 @@ private:
|
||||
Peak operator+(const Peak& other) const { return Peak(std::min(min, other.min), std::max(max, other.max)); }
|
||||
Peak operator+(const SampleFrame& frame) const { return *this + Peak{frame}; }
|
||||
|
||||
float min = std::numeric_limits<float>::max();
|
||||
float max = std::numeric_limits<float>::min();
|
||||
float min = std::numeric_limits<float>::infinity();
|
||||
float max = -std::numeric_limits<float>::infinity();
|
||||
};
|
||||
|
||||
Thumbnail() = default;
|
||||
@@ -105,6 +103,7 @@ private:
|
||||
|
||||
Thumbnail zoomOut(float factor) const;
|
||||
|
||||
Peak* data() { return m_peaks.data(); }
|
||||
Peak& operator[](size_t index) { return m_peaks[index]; }
|
||||
const Peak& operator[](size_t index) const { return m_peaks[index]; }
|
||||
|
||||
@@ -134,7 +133,7 @@ private:
|
||||
|
||||
using ThumbnailCache = std::vector<Thumbnail>;
|
||||
std::shared_ptr<ThumbnailCache> m_thumbnailCache = std::make_shared<ThumbnailCache>();
|
||||
|
||||
std::shared_ptr<const SampleBuffer> m_buffer = SampleBuffer::emptyBuffer();
|
||||
inline static std::unordered_map<SampleThumbnailEntry, std::shared_ptr<ThumbnailCache>, Hash> s_sampleThumbnailCacheMap;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user