From 96048ad4c09aca166dcccce9abe91da209a09b93 Mon Sep 17 00:00:00 2001 From: nick_m Date: Fri, 23 Dec 2016 00:51:34 +1100 Subject: [PATCH] midi scrooming performance updates. - MGR visibility is handled by update_note/hit() MRV unconditionally updates MGR events - remove MidiGhostRegion::update_range() - rename set_contents_height -> update_contents_height --- gtk2_ardour/ghostregion.cc | 60 +++++++++++-------------------- gtk2_ardour/ghostregion.h | 3 +- gtk2_ardour/midi_region_view.cc | 63 ++++++++++++++++++--------------- gtk2_ardour/midi_time_axis.cc | 7 ---- 4 files changed, 57 insertions(+), 76 deletions(-) diff --git a/gtk2_ardour/ghostregion.cc b/gtk2_ardour/ghostregion.cc index 10893c0f1b..1da70631f7 100644 --- a/gtk2_ardour/ghostregion.cc +++ b/gtk2_ardour/ghostregion.cc @@ -184,9 +184,6 @@ MidiGhostRegion::MidiGhostRegion(RegionView& rv, _outline = UIConfiguration::instance().color ("ghost track midi outline"); base_rect->lower_to_bottom(); - update_range (); - - midi_view()->NoteRangeChanged.connect (sigc::mem_fun (*this, &MidiGhostRegion::update_range)); } /** @@ -208,9 +205,6 @@ MidiGhostRegion::MidiGhostRegion(RegionView& rv, _outline = UIConfiguration::instance().color ("ghost track midi outline"); base_rect->lower_to_bottom(); - update_range (); - - midi_view()->NoteRangeChanged.connect (sigc::mem_fun (*this, &MidiGhostRegion::update_range)); } MidiGhostRegion::~MidiGhostRegion() @@ -262,7 +256,7 @@ void MidiGhostRegion::set_height () { GhostRegion::set_height(); - set_contents_height (); + update_contents_height (); } void @@ -297,27 +291,7 @@ note_y(TimeAxisView& trackview, MidiStreamView* mv, uint8_t note_num) } void -MidiGhostRegion::update_range () -{ - MidiStreamView* mv = midi_view(); - - if (!mv) { - return; - } - - for (EventList::iterator it = events.begin(); it != events.end(); ++it) { - uint8_t const note_num = (*it).second->event->note()->note(); - - if (note_num < mv->lowest_note() || note_num > mv->highest_note()) { - (*it).second->item->hide(); - } else { - (*it).second->item->show(); - } - } -} - -void -MidiGhostRegion::set_contents_height () +MidiGhostRegion::update_contents_height () { MidiStreamView* mv = midi_view(); @@ -408,10 +382,14 @@ MidiGhostRegion::update_note (Note* note) double const y = note_y(trackview, mv, note_num); double const h = note_height(trackview, mv); - if ((_tmp_rect = dynamic_cast(ev->item))) { - _tmp_rect->set (ArdourCanvas::Rect (note->x0(), y, note->x1(), y + h)); + if (note_num < mv->lowest_note() || note_num > mv->highest_note()) { + ev->item->hide(); + } else { + if ((_tmp_rect = dynamic_cast(ev->item))) { + _tmp_rect->set (ArdourCanvas::Rect (note->x0(), y, note->x1(), y + h)); + } + ev->item->show(); } - } /** Update the x positions of our representation of a parent's hit. @@ -436,14 +414,18 @@ MidiGhostRegion::update_hit (Hit* hit) double const h = note_height(trackview, mv); double const y = note_y(trackview, mv, note_num); - - if ((_tmp_poly = dynamic_cast(ev->item))) { - ArdourCanvas::Duple ppos = hit->position(); - ArdourCanvas::Duple gpos = _tmp_poly->position(); - gpos.x = ppos.x; - gpos.y = y; - _tmp_poly->set_position(gpos); - _tmp_poly->set(Hit::points(h)); + if (note_num < mv->lowest_note() || note_num > mv->highest_note()) { + ev->item->hide(); + } else { + if ((_tmp_poly = dynamic_cast(ev->item))) { + ArdourCanvas::Duple ppos = hit->position(); + ArdourCanvas::Duple gpos = _tmp_poly->position(); + gpos.x = ppos.x; + gpos.y = y; + _tmp_poly->set_position(gpos); + _tmp_poly->set(Hit::points(h)); + } + ev->item->show(); } } diff --git a/gtk2_ardour/ghostregion.h b/gtk2_ardour/ghostregion.h index f4848fd3cc..000399007b 100644 --- a/gtk2_ardour/ghostregion.h +++ b/gtk2_ardour/ghostregion.h @@ -106,8 +106,7 @@ public: void set_samples_per_pixel (double spu); void set_colors(); - void update_range(); - void set_contents_height(); + void update_contents_height(); void add_note(NoteBase*); void update_note (Note*); diff --git a/gtk2_ardour/midi_region_view.cc b/gtk2_ardour/midi_region_view.cc index 4e0e2af1e4..90a1e36883 100644 --- a/gtk2_ardour/midi_region_view.cc +++ b/gtk2_ardour/midi_region_view.cc @@ -1189,6 +1189,8 @@ MidiRegionView::redisplay_model() bool empty_when_starting = _events.empty(); MidiModel::ReadLock lock(_model->read_lock()); MidiModel::Notes missing_notes = _model->notes(); // copy + Note* sus = NULL; + Hit* hit = NULL; if (!empty_when_starting) { MidiModel::Notes::iterator f; @@ -1225,10 +1227,11 @@ MidiRegionView::redisplay_model() } else { NoteBase* cne = (*i); bool visible; + bool update = false; if (note_in_region_range (note, visible)) { if (visible) { - update_note (cne); + update = true; cne->show (); } else { cne->hide (); @@ -1236,7 +1239,31 @@ MidiRegionView::redisplay_model() } else { cne->hide (); } + if ((sus = dynamic_cast(cne))) { + + if (update) { + update_sustained (sus); + } + + for (std::vector::iterator i = ghosts.begin(); i != ghosts.end(); ++i) { + MidiGhostRegion* gr = dynamic_cast (*i); + if (gr) { + gr->update_note (sus); + } + } + } else if ((hit = dynamic_cast(cne))) { + if (update) { + update_hit (hit); + } + + for (std::vector::iterator i = ghosts.begin(); i != ghosts.end(); ++i) { + MidiGhostRegion* gr = dynamic_cast (*i); + if (gr) { + gr->update_hit (hit); + } + } + } ++i; } } @@ -1248,18 +1275,14 @@ MidiRegionView::redisplay_model() NoteBase* cne = add_note (note, true); bool visible; - if (note_in_region_range (note, visible)) { - if (visible) { - set::iterator it; - - cne->show (); + for (set::iterator it = _pending_note_selection.begin(); it != _pending_note_selection.end(); ++it) { + if ((*it) == note->id()) { + add_to_selection (cne); + } + } - for (it = _pending_note_selection.begin(); it != _pending_note_selection.end(); ++it) { - if ((*it) == note->id()) { - add_to_selection (cne); - } - } - } else { + if (note_in_region_range (note, visible)) { + if (!visible) { cne->hide (); } } else { @@ -1747,14 +1770,6 @@ MidiRegionView::update_sustained (Note* ev, bool update_ghost_regions) ev->set_fill_color(base_col); ev->set_outline_color(ev->calculate_outline(base_col, ev->selected())); - if (update_ghost_regions) { - for (std::vector::iterator i = ghosts.begin(); i != ghosts.end(); ++i) { - MidiGhostRegion* gr = dynamic_cast (*i); - if (gr) { - gr->update_note (ev); - } - } - } } void @@ -1784,14 +1799,6 @@ MidiRegionView::update_hit (Hit* ev, bool update_ghost_regions) ev->set_fill_color(base_col); ev->set_outline_color(ev->calculate_outline(base_col, ev->selected())); - if (update_ghost_regions) { - for (std::vector::iterator i = ghosts.begin(); i != ghosts.end(); ++i) { - MidiGhostRegion* gr = dynamic_cast (*i); - if (gr) { - gr->update_hit (ev); - } - } - } } /** Add a MIDI note to the view (with length). diff --git a/gtk2_ardour/midi_time_axis.cc b/gtk2_ardour/midi_time_axis.cc index 1679039990..6bbc813eb2 100644 --- a/gtk2_ardour/midi_time_axis.cc +++ b/gtk2_ardour/midi_time_axis.cc @@ -1239,13 +1239,6 @@ MidiTimeAxisView::set_note_range (MidiStreamView::VisibleNoteRange range, bool a void MidiTimeAxisView::update_range() { - MidiGhostRegion* mgr; - - for (list::iterator i = ghosts.begin(); i != ghosts.end(); ++i) { - if ((mgr = dynamic_cast(*i)) != 0) { - mgr->update_range(); - } - } } void -- 2.30.2