Explicitly declare DataBlockCache as moveable to make vs17 happy

This commit is contained in:
Thomas Goyne 2018-05-25 08:26:26 +02:00
parent e44f0b92b0
commit 4fdc5efb69
4 changed files with 13 additions and 11 deletions

View file

@ -67,6 +67,7 @@ size_t AudioRendererBitmapCacheBitmapFactory::GetBlockSize() const
AudioRenderer::AudioRenderer()
{
bitmaps.reserve(AudioStyle_MAX);
for (int i = 0; i < AudioStyle_MAX; ++i)
bitmaps.emplace_back(256, AudioRendererBitmapCacheBitmapFactory(this));
@ -157,21 +158,20 @@ size_t AudioRenderer::NumBlocks(const int64_t samples) const
return static_cast<size_t>(duration / pixel_ms / cache_bitmap_width);
}
const wxBitmap *AudioRenderer::GetCachedBitmap(const int i, const AudioRenderingStyle style)
wxBitmap const& AudioRenderer::GetCachedBitmap(const int i, const AudioRenderingStyle style)
{
assert(provider);
assert(renderer);
bool created = false;
wxBitmap *bmp = bitmaps[style].Get(i, &created);
assert(bmp);
auto& bmp = bitmaps[style].Get(i, &created);
if (created)
{
renderer->Render(*bmp, i*cache_bitmap_width, style);
renderer->Render(bmp, i*cache_bitmap_width, style);
needs_age = true;
}
assert(bmp->IsOk());
assert(bmp.IsOk());
return bmp;
}
@ -201,7 +201,7 @@ void AudioRenderer::Render(wxDC &dc, wxPoint origin, const int start, const int
for (int i = firstbitmap; i <= lastbitmap; ++i)
{
dc.DrawBitmap(*GetCachedBitmap(i, style), origin);
dc.DrawBitmap(GetCachedBitmap(i, style), origin);
origin.x += cache_bitmap_width;
}

View file

@ -111,7 +111,7 @@ class AudioRenderer {
///
/// Will attempt retrieving the requested bitmap from the cache, creating it
/// if the cache doesn't have it.
const wxBitmap *GetCachedBitmap(int i, AudioRenderingStyle style);
wxBitmap const& GetCachedBitmap(int i, AudioRenderingStyle style);
/// @brief Update the block count in the bitmap caches
///

View file

@ -240,7 +240,7 @@ void AudioSpectrumRenderer::Render(wxBitmap &bmp, int start, AudioRenderingStyle
{
// Derived audio data
size_t block_index = (size_t)(ax * pixel_ms * provider->GetSampleRate() / 1000) >> derivation_dist;
float *power = cache->Get(block_index);
float *power = &cache->Get(block_index);
// Prepare bitmap writing
unsigned char *px = imgdata + (imgheight-1) * stride + (ax - start) * 3;

View file

@ -109,6 +109,8 @@ public:
SetBlockCount(block_count);
}
DataBlockCache(DataBlockCache&&) = default;
DataBlockCache& operator=(DataBlockCache&&) = default;
/// @brief Change the number of blocks in cache
/// @param block_count New number of blocks to hold
@ -158,12 +160,12 @@ public:
/// @return A pointer to the block in cache
///
/// It is legal to pass 0 (null) for created, in this case nothing is returned in it.
BlockT *Get(size_t i, bool *created = nullptr)
BlockT& Get(size_t i, bool *created = nullptr)
{
size_t mbi = i >> MacroblockExponent;
assert(mbi < data.size());
MacroBlock &mb = data[mbi];
auto &mb = data[mbi];
// Move this macroblock to the front of the age list
if (mb.blocks.empty())
@ -193,6 +195,6 @@ public:
else
if (created) *created = false;
return b;
return *b;
}
};