Audacity 3.2.0
|
A base class for the GraphicsDataCache. Implements LRU policy. More...
#include <GraphicsDataCache.h>
Classes | |
struct | BaseLookupResult |
A result of the cache lookup. More... | |
struct | LookupElement |
Element of the cache lookup. More... | |
Public Member Functions | |
virtual | ~GraphicsDataCacheBase ()=default |
void | Invalidate () |
Invalidate the cache content. More... | |
double | GetScaledSampleRate () const noexcept |
Returns the sample rate associated with cache. More... | |
void | UpdateViewportWidth (int64_t width) noexcept |
int64_t | GetMaxViewportWidth () const noexcept |
Static Public Attributes | |
static constexpr uint32_t | CacheElementWidth = 256 |
Protected Types | |
using | Lookup = std::vector< LookupElement > |
Cache lookup is a vector, with items sorted using Key. More... | |
Protected Member Functions | |
GraphicsDataCacheBase (double scaledSampleRate) | |
void | SetScaledSampleRate (double scaledSampleRate) |
virtual GraphicsDataCacheElementBase * | CreateElement (const GraphicsDataCacheKey &key)=0 |
Create a new Cache element. Implementation is responsible of the lifetime control. More... | |
virtual void | DisposeElement (GraphicsDataCacheElementBase *element)=0 |
This method is called, when the cache element should be evicted. Implementation may not deallocate the object. More... | |
virtual bool | UpdateElement (const GraphicsDataCacheKey &key, GraphicsDataCacheElementBase &element)=0 |
This method is called on all elements matching the request that are not complete (i. e. IsComplete if false). More... | |
BaseLookupResult | PerformBaseLookup (const ZoomInfo &zoomInfo, double t0, double t1) |
Perform a lookup inside the cache. This method modifies mLookup and invalidates any previous result. More... | |
const GraphicsDataCacheElementBase * | PerformBaseLookup (GraphicsDataCacheKey key) |
Perform a lookup for the given key. This method modifies mLookup and invalidates any previous result. More... | |
Private Member Functions | |
bool | CreateNewItems () |
void | DisposeNewItems () |
Lookup::iterator | FindKey (GraphicsDataCacheKey key) |
void | PerformCleanup () |
void | PerformFullCleanup (int64_t currentSize, int64_t itemsToEvict) |
Private Attributes | |
Lookup | mLookup |
Lookup | mLookupHelper |
Lookup | mNewLookupItems |
std::vector< size_t > | mLRUHelper |
double | mScaledSampleRate {} |
int64_t | mMaxWidth { 1600 } |
uint64_t | mCacheAccessIndex {} |
int32_t | mCacheSizeMultiplier { 4 } |
Friends | |
template<typename CacheElementType > | |
class | GraphicsDataCacheIterator |
A base class for the GraphicsDataCache. Implements LRU policy.
Definition at line 54 of file GraphicsDataCache.h.
|
protected |
Cache lookup is a vector, with items sorted using Key.
Definition at line 83 of file GraphicsDataCache.h.
|
virtualdefault |
|
explicitprotected |
Definition at line 97 of file GraphicsDataCache.cpp.
|
protectedpure virtual |
Create a new Cache element. Implementation is responsible of the lifetime control.
Implemented in GraphicsDataCache< CacheElementType >, GraphicsDataCache< WaveBitmapCacheElement >, and GraphicsDataCache< WaveCacheElement >.
Referenced by CreateNewItems(), and PerformBaseLookup().
|
private |
Definition at line 298 of file GraphicsDataCache.cpp.
References CreateElement(), mCacheAccessIndex, and mNewLookupItems.
Referenced by PerformBaseLookup().
|
protectedpure virtual |
This method is called, when the cache element should be evicted. Implementation may not deallocate the object.
Implemented in GraphicsDataCache< CacheElementType >, GraphicsDataCache< WaveBitmapCacheElement >, and GraphicsDataCache< WaveCacheElement >.
Referenced by Invalidate(), PerformCleanup(), and PerformFullCleanup().
|
private |
Definition at line 313 of file GraphicsDataCache.cpp.
References mNewLookupItems.
Referenced by PerformBaseLookup().
|
private |
Definition at line 325 of file GraphicsDataCache.cpp.
References key, mLookup, mScaledSampleRate, and anonymous_namespace{ClipSegmentTest.cpp}::sampleRate.
Referenced by PerformBaseLookup().
|
noexcept |
Definition at line 92 of file GraphicsDataCache.cpp.
References mMaxWidth.
Referenced by WaveBitmapCache::LookupHelper::PerformLookup().
|
noexcept |
Returns the sample rate associated with cache.
Definition at line 82 of file GraphicsDataCache.cpp.
References mScaledSampleRate.
Referenced by WaveDataCache::InitializeElement(), and WaveBitmapCache::LookupHelper::PerformLookup().
void GraphicsDataCacheBase::Invalidate | ( | ) |
Invalidate the cache content.
Definition at line 74 of file GraphicsDataCache.cpp.
References DisposeElement(), and mLookup.
Referenced by WaveBitmapCache::CheckCache(), WaveBitmapCache::SetPaintParameters(), SetScaledSampleRate(), WaveBitmapCache::SetSelection(), and GraphicsDataCache< CacheElementType >::~GraphicsDataCache().
|
protected |
Perform a lookup inside the cache. This method modifies mLookup and invalidates any previous result.
Definition at line 123 of file GraphicsDataCache.cpp.
References CacheElementWidth, CreateNewItems(), DisposeNewItems(), FindKey(), anonymous_namespace{GraphicsDataCache.cpp}::GetPPSMatchRange(), ZoomInfo::GetZoom(), anonymous_namespace{GraphicsDataCache.cpp}::IsSameSample(), GraphicsDataCacheElementBase::LastCacheAccess, mCacheAccessIndex, mLookup, mLookupHelper, mNewLookupItems, mScaledSampleRate, PerformCleanup(), anonymous_namespace{ClipSegmentTest.cpp}::sampleRate, anonymous_namespace{NoteTrack.cpp}::swap(), ZoomInfo::TimeToPosition(), UpdateElement(), and UpdateViewportWidth().
Referenced by GraphicsDataCache< CacheElementType >::PerformLookup().
|
protected |
Perform a lookup for the given key. This method modifies mLookup and invalidates any previous result.
Definition at line 241 of file GraphicsDataCache.cpp.
References CreateElement(), FindKey(), GraphicsDataCacheElementBase::IsComplete, key, GraphicsDataCacheElementBase::LastUpdate, mCacheAccessIndex, mLookup, mNewLookupItems, mScaledSampleRate, PerformCleanup(), anonymous_namespace{ClipSegmentTest.cpp}::sampleRate, GraphicsDataCacheElementBase::Smooth(), and UpdateElement().
|
private |
Definition at line 333 of file GraphicsDataCache.cpp.
References CacheElementWidth, DisposeElement(), mCacheAccessIndex, mCacheSizeMultiplier, mLookup, mMaxWidth, PerformFullCleanup(), and RoundUpUnsafe().
Referenced by PerformBaseLookup().
|
private |
Definition at line 364 of file GraphicsDataCache.cpp.
References DisposeElement(), mCacheAccessIndex, mLookup, and mLRUHelper.
Referenced by PerformCleanup().
|
protected |
Definition at line 102 of file GraphicsDataCache.cpp.
References Invalidate(), and mScaledSampleRate.
Referenced by WaveBitmapCache::WaveBitmapCache().
|
protectedpure virtual |
This method is called on all elements matching the request that are not complete (i. e. IsComplete if false).
Implemented in GraphicsDataCache< CacheElementType >, GraphicsDataCache< WaveBitmapCacheElement >, and GraphicsDataCache< WaveCacheElement >.
Referenced by PerformBaseLookup().
|
noexcept |
Definition at line 87 of file GraphicsDataCache.cpp.
Referenced by PerformBaseLookup().
|
friend |
Definition at line 143 of file GraphicsDataCache.h.
|
staticconstexpr |
Definition at line 58 of file GraphicsDataCache.h.
Referenced by anonymous_namespace{GraphicsDataCacheTests.cpp}::CheckCacheElementLookup(), anonymous_namespace{WaveformView.cpp}::WaveformPainter::Draw(), WaveDataCache::InitializeElement(), anonymous_namespace{GraphicsDataCache.cpp}::IsSamePPS(), PerformBaseLookup(), PerformCleanup(), and TEST_CASE().
|
private |
Definition at line 138 of file GraphicsDataCache.h.
Referenced by CreateNewItems(), PerformBaseLookup(), PerformCleanup(), and PerformFullCleanup().
|
private |
Definition at line 140 of file GraphicsDataCache.h.
Referenced by PerformCleanup().
|
private |
Definition at line 124 of file GraphicsDataCache.h.
Referenced by FindKey(), Invalidate(), PerformBaseLookup(), PerformCleanup(), and PerformFullCleanup().
|
private |
Definition at line 126 of file GraphicsDataCache.h.
Referenced by PerformBaseLookup().
|
private |
Definition at line 130 of file GraphicsDataCache.h.
Referenced by PerformFullCleanup().
|
private |
Definition at line 136 of file GraphicsDataCache.h.
Referenced by GetMaxViewportWidth(), and PerformCleanup().
|
private |
Definition at line 128 of file GraphicsDataCache.h.
Referenced by CreateNewItems(), DisposeNewItems(), and PerformBaseLookup().
|
private |
Definition at line 133 of file GraphicsDataCache.h.
Referenced by FindKey(), GetScaledSampleRate(), PerformBaseLookup(), and SetScaledSampleRate().