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.
This commit is contained in:
Thomas Goyne 2012-02-02 22:57:53 +00:00
parent ddc8dc9eca
commit 7ca0ad3233
3 changed files with 4 additions and 54 deletions

View File

@ -1235,60 +1235,13 @@ void AudioDisplay::OnStyleRangesChanged()
AudioStyleRangeMerger asrm;
controller->GetTimingController()->GetRenderingStyles(asrm);
std::map<int, int> old_style_ranges;
swap(old_style_ranges, style_ranges);
style_ranges.clear();
style_ranges.insert(asrm.begin(), asrm.end());
std::map<int, int>::iterator old_style_it = old_style_ranges.begin();
std::map<int, int>::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);
}

View File

@ -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

View File

@ -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