From 7ca0ad3233728faa2d2f199291ad0dda7f7b45a7 Mon Sep 17 00:00:00 2001 From: Thomas Goyne Date: Thu, 2 Feb 2012 22:57:53 +0000 Subject: [PATCH] Repaint the entire audio display when style ranges change In practice, painting audio from the cache isn't all that expensive, so the limited refreshing was just introducing places for bugs without improving performance all that much. Closes #1432. Originally committed to SVN as r6439. --- aegisub/src/audio_display.cpp | 51 ++------------------------- aegisub/src/audio_display.h | 5 --- aegisub/src/audio_timing_dialogue.cpp | 2 ++ 3 files changed, 4 insertions(+), 54 deletions(-) diff --git a/aegisub/src/audio_display.cpp b/aegisub/src/audio_display.cpp index 126277a5e..190fc55f6 100644 --- a/aegisub/src/audio_display.cpp +++ b/aegisub/src/audio_display.cpp @@ -1235,60 +1235,13 @@ void AudioDisplay::OnStyleRangesChanged() AudioStyleRangeMerger asrm; controller->GetTimingController()->GetRenderingStyles(asrm); - std::map old_style_ranges; - swap(old_style_ranges, style_ranges); + style_ranges.clear(); style_ranges.insert(asrm.begin(), asrm.end()); - std::map::iterator old_style_it = old_style_ranges.begin(); - std::map::iterator new_style_it = style_ranges.begin(); - - int old_style = old_style_it->second; - int new_style = new_style_it->second; - int range_start = 0; - - // Repaint each range which has changed - while (old_style_it != old_style_ranges.end() || new_style_it != style_ranges.end()) - { - if (new_style_it == style_ranges.end() || (old_style_it != old_style_ranges.end() && old_style_it->first <= new_style_it->first)) - { - if (old_style != new_style) - Redraw(range_start, old_style_it->first); - old_style = old_style_it->second; - range_start = old_style_it->first; - ++old_style_it; - } - else - { - if (old_style != new_style) - Redraw(range_start, new_style_it->first); - new_style = new_style_it->second; - range_start = new_style_it->first; - ++new_style_it; - } - } - - // Fill in the last style range - if (old_style != new_style) - { - Redraw(range_start, TimeFromRelativeX(GetClientSize().GetWidth())); - } -} - -void AudioDisplay::Redraw(int time_start, int time_end) -{ - if (time_start == time_end) return; - - time_start = RelativeXFromTime(time_start) - foot_size; - time_end = RelativeXFromTime(time_end) + foot_size; - - if (time_end >= 0 && time_start <= GetClientSize().GetWidth()) - { - RefreshRect(wxRect(time_start, audio_top, time_end - time_start, audio_height), false); - } + RefreshRect(wxRect(0, audio_top, GetClientSize().GetWidth(), audio_height), false); } void AudioDisplay::OnMarkerMoved() { - /// @todo investigate if it's worth refreshing only the changed spots RefreshRect(wxRect(0, audio_top, GetClientSize().GetWidth(), audio_height), false); } diff --git a/aegisub/src/audio_display.h b/aegisub/src/audio_display.h index d9ec7c069..886bc3bab 100644 --- a/aegisub/src/audio_display.h +++ b/aegisub/src/audio_display.h @@ -177,11 +177,6 @@ class AudioDisplay: public wxWindow { /// in Options and need to be reloaded to take effect. void ReloadRenderingSettings(); - /// @brief Repaint a time range - /// @param ms_start Beginning of range to repaint - /// @param ms_end End of range to repaint - void Redraw(int ms_start, int ms_end); - /// Paint the audio data for a time range /// @param dc DC to paint to /// @param updtime Time range to repaint diff --git a/aegisub/src/audio_timing_dialogue.cpp b/aegisub/src/audio_timing_dialogue.cpp index 3e4d3d955..2019cb8ff 100644 --- a/aegisub/src/audio_timing_dialogue.cpp +++ b/aegisub/src/audio_timing_dialogue.cpp @@ -554,6 +554,7 @@ void AudioTimingControllerDialogue::SetMarker(AudioMarkerDialogueTiming *marker, timing_modified = true; if (auto_commit->GetBool()) Commit(); UpdateSelection(); + AnnounceMarkerMoved(); } static bool noncomment_dialogue(AssEntry *e) @@ -616,6 +617,7 @@ void AudioTimingControllerDialogue::RegenerateInactiveLines() sort(inactive_markers.begin(), inactive_markers.end()); AnnounceUpdatedStyleRanges(); + AnnounceMarkerMoved(); } int AudioTimingControllerDialogue::SnapPosition(int position, int snap_range) const