mirror of https://github.com/odrling/Aegisub
Optimized the audio display redraw.
Originally committed to SVN as r2453.
This commit is contained in:
parent
b310869224
commit
e11bd3f659
|
@ -103,6 +103,7 @@ AudioDisplay::AudioDisplay(wxWindow *parent)
|
|||
hold = 0;
|
||||
samples = 0;
|
||||
hasFocus = (wxWindow::FindFocus() == this);
|
||||
needImageUpdate = false;
|
||||
|
||||
// Init
|
||||
UpdateTimer.SetOwner(this,Audio_Update_Timer);
|
||||
|
@ -159,9 +160,23 @@ void AudioDisplay::Reset() {
|
|||
////////////////
|
||||
// Update image
|
||||
void AudioDisplay::UpdateImage(bool weak) {
|
||||
// Update samples
|
||||
UpdateSamples();
|
||||
|
||||
// Set image as needing to be redrawn
|
||||
needImageUpdate = true;
|
||||
if (!needImageUpdateWeak) needImageUpdateWeak = weak;
|
||||
Refresh(false);
|
||||
}
|
||||
|
||||
void AudioDisplay::DoUpdateImage() {
|
||||
// Loaded?
|
||||
if (!loaded || !provider) return;
|
||||
|
||||
// Needs updating?
|
||||
if (!needImageUpdate) return;
|
||||
bool weak = needImageUpdateWeak;
|
||||
|
||||
// Prepare bitmap
|
||||
int timelineHeight = Options.AsBool(_T("Audio Draw Timeline")) ? 20 : 0;
|
||||
int displayH = h+timelineHeight;
|
||||
|
@ -189,9 +204,6 @@ void AudioDisplay::UpdateImage(bool weak) {
|
|||
spectrum = true;
|
||||
}
|
||||
|
||||
// Update samples
|
||||
UpdateSamples();
|
||||
|
||||
// Draw image to be displayed
|
||||
wxMemoryDC dc;
|
||||
dc.SelectObject(*origImage);
|
||||
|
@ -372,7 +384,8 @@ void AudioDisplay::UpdateImage(bool weak) {
|
|||
}
|
||||
|
||||
// Done
|
||||
Refresh(false);
|
||||
needImageUpdate = false;
|
||||
needImageUpdateWeak = false;
|
||||
}
|
||||
|
||||
|
||||
|
@ -1313,6 +1326,7 @@ END_EVENT_TABLE()
|
|||
// Paint
|
||||
void AudioDisplay::OnPaint(wxPaintEvent& event) {
|
||||
if (w == 0 || h == 0) return;
|
||||
DoUpdateImage();
|
||||
|
||||
wxPaintDC dc(this);
|
||||
dc.DrawBitmap(*origImage,0,0);
|
||||
|
@ -1397,7 +1411,7 @@ void AudioDisplay::OnMouseEvent(wxMouseEvent& event) {
|
|||
}
|
||||
|
||||
// Cursor drawing
|
||||
if (!player->IsPlaying()) {
|
||||
if (!player->IsPlaying() && origImage) {
|
||||
// Draw bg
|
||||
wxClientDC dc(this);
|
||||
dc.DrawBitmap(*origImage,0,0);
|
||||
|
|
|
@ -84,6 +84,9 @@ private:
|
|||
bool blockUpdate;
|
||||
bool dontReadTimes;
|
||||
|
||||
bool needImageUpdate;
|
||||
bool needImageUpdateWeak;
|
||||
|
||||
bool hasSel;
|
||||
bool hasKaraoke;
|
||||
bool diagUpdated;
|
||||
|
@ -130,6 +133,7 @@ private:
|
|||
void UpdatePosition(int pos,bool IsSample=false);
|
||||
|
||||
int GetBoundarySnap(int x,int range,bool shiftHeld,bool start=true);
|
||||
void DoUpdateImage();
|
||||
|
||||
public:
|
||||
AudioProvider *provider;
|
||||
|
|
Loading…
Reference in New Issue