From 4f9b75c8a2ba182ae0a3131352284f2ccd04193e Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Sat, 23 Apr 2011 02:00:23 +0000 Subject: Remove unnecessary refresh_location_display_s method. Speed up marker loading somewhat by only setting up marker labels once after load. Fix check on visible status of the location UI so that it is built when opened rather than on load. The location UI is still extremely slow to build with a couple of thousand markers. This fixes #3958. git-svn-id: svn://localhost/ardour2/branches/3.0@9414 d708f5d6-7413-0410-9779-e7cbd77b26cf --- gtk2_ardour/editor.cc | 2 +- gtk2_ardour/editor.h | 2 +- gtk2_ardour/editor_markers.cc | 32 ++++++++++++++++++-------------- gtk2_ardour/location_ui.cc | 11 ++++++----- gtk2_ardour/location_ui.h | 2 +- 5 files changed, 27 insertions(+), 22 deletions(-) (limited to 'gtk2_ardour') diff --git a/gtk2_ardour/editor.cc b/gtk2_ardour/editor.cc index e131efeb2a..bfcaba145f 100644 --- a/gtk2_ardour/editor.cc +++ b/gtk2_ardour/editor.cc @@ -1138,7 +1138,7 @@ Editor::set_session (Session *t) _session->locations()->added.connect (_session_connections, invalidator (*this), ui_bind (&Editor::add_new_location, this, _1), gui_context()); _session->locations()->removed.connect (_session_connections, invalidator (*this), ui_bind (&Editor::location_gone, this, _1), gui_context()); _session->locations()->changed.connect (_session_connections, invalidator (*this), boost::bind (&Editor::refresh_location_display, this), gui_context()); - _session->locations()->StateChanged.connect (_session_connections, invalidator (*this), ui_bind (&Editor::refresh_location_display_s, this, _1), gui_context()); + _session->locations()->StateChanged.connect (_session_connections, invalidator (*this), ui_bind (&Editor::refresh_location_display, this), gui_context()); _session->history().Changed.connect (_session_connections, invalidator (*this), boost::bind (&Editor::history_changed, this), gui_context()); if (Profile->get_sae()) { diff --git a/gtk2_ardour/editor.h b/gtk2_ardour/editor.h index 1a08dd3aac..10fba5e8b6 100644 --- a/gtk2_ardour/editor.h +++ b/gtk2_ardour/editor.h @@ -541,9 +541,9 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD void location_changed (ARDOUR::Location *); void location_flags_changed (ARDOUR::Location *, void *); void refresh_location_display (); - void refresh_location_display_s (const PBD::PropertyChange&); void refresh_location_display_internal (ARDOUR::Locations::LocationList&); void add_new_location (ARDOUR::Location *); + ArdourCanvas::Group* add_new_location_internal (ARDOUR::Location *); void location_gone (ARDOUR::Location *); void remove_marker (ArdourCanvas::Item&, GdkEvent*); gint really_remove_marker (ARDOUR::Location* loc); diff --git a/gtk2_ardour/editor_markers.cc b/gtk2_ardour/editor_markers.cc index 8b4b2b39bb..34fdc094b1 100644 --- a/gtk2_ardour/editor_markers.cc +++ b/gtk2_ardour/editor_markers.cc @@ -61,8 +61,21 @@ Editor::clear_marker_display () void Editor::add_new_location (Location *location) { - ENSURE_GUI_THREAD (*this, &Editor::add_new_location, location) + ENSURE_GUI_THREAD (*this, &Editor::add_new_location, location); + ArdourCanvas::Group* group = add_new_location_internal (location); + + /* Do a full update of the markers in this group */ + update_marker_labels (group); +} + +/** Add a new location, without a time-consuming update of all marker labels; + * the caller must call update_marker_labels () after calling this. + * @return canvas group that the location's marker was added to. + */ +ArdourCanvas::Group* +Editor::add_new_location_internal (Location* location) +{ LocationMarkers *lam = new LocationMarkers; uint32_t color; @@ -163,15 +176,14 @@ Editor::add_new_location (Location *location) lam->set_show_lines (_show_marker_lines); /* Add these markers to the appropriate sorted marker lists, which will render - them unsorted until the update_marker_labels() below sorts them out. + them unsorted until a call to update_marker_labels() sorts them out. */ _sorted_marker_lists[group].push_back (lam->start); if (lam->end) { _sorted_marker_lists[group].push_back (lam->end); } - /* Do a full update of the markers in this group */ - update_marker_labels (group); + return group; } void @@ -483,7 +495,7 @@ Editor::refresh_location_display_internal (Locations::LocationList& locations) continue; } - add_new_location (*i); + add_new_location_internal (*i); } /* remove dead ones */ @@ -521,16 +533,8 @@ Editor::refresh_location_display () if (_session) { _session->locations()->apply (*this, &Editor::refresh_location_display_internal); } -} - -void -Editor::refresh_location_display_s (const PropertyChange&) -{ - ENSURE_GUI_THREAD (*this, &Editor::refresh_location_display_s, ignored) - if (_session) { - _session->locations()->apply (*this, &Editor::refresh_location_display_internal); - } + update_marker_labels (); } void diff --git a/gtk2_ardour/location_ui.cc b/gtk2_ardour/location_ui.cc index c24da57685..97f0d03a38 100644 --- a/gtk2_ardour/location_ui.cc +++ b/gtk2_ardour/location_ui.cc @@ -972,7 +972,7 @@ LocationUI::map_locations (Locations::LocationList& locations) if (location->is_mark()) { LocationEditRow* erow = manage (new LocationEditRow (_session, location, mark_n)); - erow->set_clock_group (*_clock_group); + erow->set_clock_group (*_clock_group); erow->remove_requested.connect (sigc::mem_fun(*this, &LocationUI::location_remove_requested)); erow->redraw_ranges.connect (sigc::mem_fun(*this, &LocationUI::location_redraw_ranges)); @@ -1052,7 +1052,9 @@ LocationUI::refresh_location_list () using namespace Box_Helpers; // this is just too expensive to do when window is not shown - if (!is_visible()) return; + if (!is_mapped()) { + return; + } BoxList & loc_children = location_rows.children(); BoxList & range_children = range_rows.children(); @@ -1063,7 +1065,6 @@ LocationUI::refresh_location_list () if (_session) { _session->locations()->apply (*this, &LocationUI::map_locations); } - } void @@ -1133,10 +1134,10 @@ LocationUIWindow::~LocationUIWindow() } void -LocationUIWindow::on_show() +LocationUIWindow::on_map () { + ArdourDialog::on_map (); _ui.refresh_location_list(); - ArdourDialog::on_show(); } bool diff --git a/gtk2_ardour/location_ui.h b/gtk2_ardour/location_ui.h index 84c6fa9fc5..325ab96bd7 100644 --- a/gtk2_ardour/location_ui.h +++ b/gtk2_ardour/location_ui.h @@ -206,7 +206,7 @@ class LocationUIWindow : public ArdourDialog LocationUIWindow (); ~LocationUIWindow (); - void on_show(); + void on_map (); void set_session (ARDOUR::Session *); LocationUI& ui() { return _ui; } -- cgit v1.2.3