Skip to content
This repository has been archived by the owner on May 12, 2024. It is now read-only.

Commit

Permalink
Use native color depth for audio rendering
Browse files Browse the repository at this point in the history
  • Loading branch information
wangqr committed May 6, 2020
1 parent c967fe7 commit c2c772a
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
9 changes: 6 additions & 3 deletions src/audio_renderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,19 +50,22 @@ namespace {
}

AudioRendererBitmapCacheBitmapFactory::AudioRendererBitmapCacheBitmapFactory(AudioRenderer *renderer)
: renderer(renderer)
: renderer(renderer), block_size(0)
{
assert(renderer);
}

std::unique_ptr<wxBitmap> AudioRendererBitmapCacheBitmapFactory::ProduceBlock(int /* i */)
{
return agi::make_unique<wxBitmap>(renderer->cache_bitmap_width, renderer->pixel_height, 24);
std::unique_ptr<wxBitmap> ret = agi::make_unique<wxBitmap>(renderer->cache_bitmap_width, renderer->pixel_height);
block_size = sizeof(wxBitmap) + static_cast<size_t>(ret->GetWidth()) * ret->GetHeight() * ((ret->GetDepth() + 7) / 8);
return ret;
}

size_t AudioRendererBitmapCacheBitmapFactory::GetBlockSize() const
{
return sizeof(wxBitmap) + renderer->cache_bitmap_width * renderer->pixel_height * 3;
assert(block_size);
return block_size;
}

AudioRenderer::AudioRenderer()
Expand Down
1 change: 1 addition & 0 deletions src/audio_renderer.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ struct AudioRendererBitmapCacheBitmapFactory {
/// Produces a wxBitmap with dimensions pulled from our master AudioRenderer.
std::unique_ptr<wxBitmap> ProduceBlock(int i);

size_t block_size;
/// @brief Calculate the size of bitmaps
/// @return The size of bitmaps created
size_t GetBlockSize() const;
Expand Down
1 change: 0 additions & 1 deletion src/audio_renderer_spectrum.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,6 @@ void AudioSpectrumRenderer::Render(wxBitmap &bmp, int start, AudioRenderingStyle
return;

assert(bmp.IsOk());
assert(bmp.GetDepth() == 24);

int end = start + bmp.GetWidth();

Expand Down

0 comments on commit c2c772a

Please sign in to comment.