Audacity 3.2.0
Classes | Functions
anonymous_namespace{GraphicsDataCacheTests.cpp} Namespace Reference

Classes

struct  CacheElement
 

Functions

void CheckCacheElementLookup (GraphicsDataCache< CacheElement > &cache, const ZoomInfo &zoomInfo, double t0, double t1, size_t count)
 

Detailed Description


Audacity: A Digital Audio Editor

GraphicsDataCacheTests.cpp

Dmitry Vedenko

Function Documentation

◆ CheckCacheElementLookup()

void anonymous_namespace{GraphicsDataCacheTests.cpp}::CheckCacheElementLookup ( GraphicsDataCache< CacheElement > &  cache,
const ZoomInfo zoomInfo,
double  t0,
double  t1,
size_t  count 
)

Definition at line 38 of file GraphicsDataCacheTests.cpp.

39{
40 auto range = cache.PerformLookup(zoomInfo, t0, t1);
41
42 REQUIRE(count == range.size());
43
44 if (count == 0)
45 return;
46
47 const size_t t0Pixel = zoomInfo.TimeToPosition(t0);
48 const size_t t0Bin = t0Pixel / GraphicsDataCacheBase::CacheElementWidth;
49
50 const size_t leftOffset =
52
53 const size_t rightOffset =
55 zoomInfo.TimeToPosition(t1) - 1;
56
57 const auto age = range.first->LastCacheAccess;
58
59 if (count == 1)
60 {
61 REQUIRE(range.first.GetLeftOffset() == leftOffset);
62 REQUIRE(range.first.GetRightOffset() == rightOffset);
63 }
64 else
65 {
66 REQUIRE(range.first.GetLeftOffset() == leftOffset);
67 REQUIRE(range.first.GetRightOffset() == 0);
68
69 auto it = range.first;
70 ++it;
71
72 while (--count > 1)
73 {
74 REQUIRE(it.GetLeftOffset() == 0);
75 REQUIRE(it.GetRightOffset() == 0);
76 REQUIRE(it->LastCacheAccess == age);
77
78 ++it;
79 }
80
81 REQUIRE(it.GetLeftOffset() == 0);
82 REQUIRE(it.GetRightOffset() == rightOffset);
83 REQUIRE(it->LastCacheAccess == age);
84 }
85}
static constexpr uint32_t CacheElementWidth
IteratorRange< GraphicsDataCacheIterator< CacheElementType > > PerformLookup(const ZoomInfo &zoomInfo, double t0, double t1)
int64 TimeToPosition(double time, int64 origin=0, bool ignoreFisheye=false) const
STM: Converts a project time to screen x position.
Definition: ZoomInfo.cpp:44

References GraphicsDataCacheBase::CacheElementWidth, GraphicsDataCache< CacheElementType >::PerformLookup(), and ZoomInfo::TimeToPosition().

Referenced by TEST_CASE().

Here is the call graph for this function:
Here is the caller graph for this function: