mirror of
https://github.com/cookiengineer/audacity
synced 2025-07-08 08:27:43 +02:00
All backing bitmaps (not just the one in track panel) now are set to 24 bits. Big thanks to David Bailes for tracking down the root cause of slow BitBlts, and the comments at https://trac.wxwidgets.org/ticket/14403 which led to the fix. In testing the bitmaps, I also fixed the sizer errors reported for Export.cpp that wxWidgets now reports as ASSERTS when running in debug builds.
84 lines
1.8 KiB
C++
84 lines
1.8 KiB
C++
//
|
|
// BackedPanel.cpp
|
|
// Audacity
|
|
//
|
|
// Created by Paul Licameli on 5/7/16.
|
|
//
|
|
//
|
|
|
|
#include "../Audacity.h"
|
|
#include "BackedPanel.h"
|
|
|
|
BackedPanel::BackedPanel(wxWindow * parent, wxWindowID id,
|
|
const wxPoint & pos,
|
|
const wxSize & size,
|
|
long style)
|
|
: wxPanelWrapper(parent, id, pos, size, style)
|
|
, mBacking{ std::make_unique<wxBitmap>(1, 1, 24) }
|
|
{
|
|
// Preinit the backing DC and bitmap so routines that require it will
|
|
// not cause a crash if they run before the panel is fully initialized.
|
|
mBackingDC.SelectObject(*mBacking);
|
|
}
|
|
|
|
BackedPanel::~BackedPanel()
|
|
{
|
|
if (mBacking)
|
|
mBackingDC.SelectObject( wxNullBitmap );
|
|
}
|
|
|
|
wxDC &BackedPanel::GetBackingDC()
|
|
{
|
|
return mBackingDC;
|
|
}
|
|
|
|
wxDC &BackedPanel::GetBackingDCForRepaint()
|
|
{
|
|
if (mResizeBacking)
|
|
{
|
|
// Reset
|
|
mResizeBacking = false;
|
|
|
|
ResizeBacking();
|
|
}
|
|
|
|
return mBackingDC;
|
|
}
|
|
|
|
void BackedPanel::ResizeBacking()
|
|
{
|
|
// Delete the backing bitmap
|
|
if (mBacking)
|
|
mBackingDC.SelectObject(wxNullBitmap);
|
|
|
|
wxSize sz = GetClientSize();
|
|
mBacking = std::make_unique<wxBitmap>();
|
|
mBacking->Create(sz.x, sz.y,24); //, *dc);
|
|
mBackingDC.SelectObject(*mBacking);
|
|
}
|
|
|
|
void BackedPanel::RepairBitmap(wxDC &dc, wxCoord x, wxCoord y, wxCoord width, wxCoord height)
|
|
{
|
|
dc.Blit(x, y, width, height, &mBackingDC, x, y);
|
|
}
|
|
|
|
void BackedPanel::DisplayBitmap(wxDC &dc)
|
|
{
|
|
RepairBitmap(dc, 0, 0, mBacking->GetWidth(), mBacking->GetHeight());
|
|
}
|
|
|
|
void BackedPanel::OnSize(wxSizeEvent & /* event */)
|
|
{
|
|
// Tell OnPaint() to recreate the backing bitmap
|
|
mResizeBacking = true;
|
|
|
|
// Refresh the entire area. Really only need to refresh when
|
|
// expanding...is it worth the trouble?
|
|
Refresh();
|
|
}
|
|
|
|
BEGIN_EVENT_TABLE(BackedPanel, wxPanelWrapper)
|
|
EVT_SIZE(BackedPanel::OnSize)
|
|
END_EVENT_TABLE()
|
|
|