From 176625d9e0dbe53c9f5628d172ee6f5488be8202 Mon Sep 17 00:00:00 2001 From: nick_m Date: Wed, 14 Dec 2016 04:05:08 +1100 Subject: [PATCH] test diff for patch change performance when caching colours. --- gtk2_ardour/midi_region_view.cc | 17 +++++++++++++++-- gtk2_ardour/midi_region_view.h | 3 +++ gtk2_ardour/patch_change.cc | 8 +++++--- gtk2_ardour/patch_change.h | 4 +++- 4 files changed, 26 insertions(+), 6 deletions(-) diff --git a/gtk2_ardour/midi_region_view.cc b/gtk2_ardour/midi_region_view.cc index ec855adb25..c8de016216 100644 --- a/gtk2_ardour/midi_region_view.cc +++ b/gtk2_ardour/midi_region_view.cc @@ -126,6 +126,10 @@ MidiRegionView::MidiRegionView (ArdourCanvas::Container* parent, , _mouse_changed_selection (false) { CANVAS_DEBUG_NAME (_note_group, string_compose ("note group for %1", get_item_name())); + + _patch_change_outline = UIConfiguration::instance().color ("midi patch change outline"); + _patch_change_fill = UIConfiguration::instance().color_mod ("midi patch change fill", "midi patch change fill"); + _note_group->raise_to_top(); PublicEditor::DropDownKeys.connect (sigc::mem_fun (*this, &MidiRegionView::drop_down_keys)); @@ -169,6 +173,10 @@ MidiRegionView::MidiRegionView (ArdourCanvas::Container* parent, , _mouse_changed_selection (false) { CANVAS_DEBUG_NAME (_note_group, string_compose ("note group for %1", get_item_name())); + + _patch_change_outline = UIConfiguration::instance().color ("midi patch change outline"); + _patch_change_fill = UIConfiguration::instance().color_mod ("midi patch change fill", "midi patch change fill"); + _note_group->raise_to_top(); PublicEditor::DropDownKeys.connect (sigc::mem_fun (*this, &MidiRegionView::drop_down_keys)); @@ -1880,14 +1888,16 @@ MidiRegionView::add_canvas_patch_change (MidiModel::PatchChangePtr patch, const // so we need to do something more sophisticated to keep its color // appearance (MidiPatchChangeFill/MidiPatchChangeInactiveChannelFill) // up to date. - boost::shared_ptr patch_change = boost::shared_ptr( new PatchChange(*this, group, displaytext, height, x, 1.0, instrument_info(), - patch)); + patch, + _patch_change_outline, + _patch_change_fill) + ); if (patch_change->item().width() < _pixel_width) { // Show unless patch change is beyond the region bounds @@ -3830,6 +3840,9 @@ MidiRegionView::color_handler () { RegionView::color_handler (); + _patch_change_outline = UIConfiguration::instance().color ("midi patch change outline"); + _patch_change_fill = UIConfiguration::instance().color_mod ("midi patch change fill", "midi patch change fill"); + for (Events::iterator i = _events.begin(); i != _events.end(); ++i) { (*i)->set_selected ((*i)->selected()); // will change color } diff --git a/gtk2_ardour/midi_region_view.h b/gtk2_ardour/midi_region_view.h index 93ce1e5011..a99881bc21 100644 --- a/gtk2_ardour/midi_region_view.h +++ b/gtk2_ardour/midi_region_view.h @@ -512,6 +512,9 @@ private: bool _mouse_changed_selection; + ArdourCanvas::Color _patch_change_outline; + ArdourCanvas::Color _patch_change_fill; + Evoral::Beats snap_frame_to_grid_underneath (framepos_t p, int32_t divisions, bool shift_snap) const; PBD::ScopedConnection _mouse_mode_connection; diff --git a/gtk2_ardour/patch_change.cc b/gtk2_ardour/patch_change.cc index ee4165df4a..fb3507ae64 100644 --- a/gtk2_ardour/patch_change.cc +++ b/gtk2_ardour/patch_change.cc @@ -49,7 +49,9 @@ PatchChange::PatchChange(MidiRegionView& region, double x, double y, ARDOUR::InstrumentInfo& info, - ARDOUR::MidiModel::PatchChangePtr patch) + ARDOUR::MidiModel::PatchChangePtr patch, + ArdourCanvas::Color outline_color, + ArdourCanvas::Color fill_color) : _region (region) , _info (info) , _patch (patch) @@ -58,8 +60,8 @@ PatchChange::PatchChange(MidiRegionView& region, _flag = new ArdourCanvas::Flag ( parent, height, - UIConfiguration::instance().color ("midi patch change outline"), - UIConfiguration::instance().color_mod ("midi patch change fill", "midi patch change fill"), + outline_color, + fill_color, ArdourCanvas::Duple (x, y), true); diff --git a/gtk2_ardour/patch_change.h b/gtk2_ardour/patch_change.h index a734daf797..ae2305cf83 100644 --- a/gtk2_ardour/patch_change.h +++ b/gtk2_ardour/patch_change.h @@ -40,7 +40,9 @@ public: double x, double y, ARDOUR::InstrumentInfo& info, - ARDOUR::MidiModel::PatchChangePtr patch); + ARDOUR::MidiModel::PatchChangePtr patch, + ArdourCanvas::Color outline_color, + ArdourCanvas::Color fill_color); ~PatchChange();