From e3375c309abbfc42baaedcc9ba7367e89314ab69 Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Thu, 30 Apr 2015 18:01:30 +0200 Subject: [PATCH] suspend editor redisplay during batch changes (major speed-up when changing all meters) --- gtk2_ardour/editor_routes.cc | 17 +++++++++++++++-- gtk2_ardour/editor_routes.h | 7 ++++++- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/gtk2_ardour/editor_routes.cc b/gtk2_ardour/editor_routes.cc index 327841f4ad..8ab17897d7 100644 --- a/gtk2_ardour/editor_routes.cc +++ b/gtk2_ardour/editor_routes.cc @@ -77,7 +77,8 @@ EditorRoutes::EditorRoutes (Editor* e) , _menu (0) , old_focus (0) , selection_countdown (0) - , name_editable (0) + , name_editable (0) + , _redisplay_on_resume (false) { static const int column_width = 22; @@ -360,6 +361,13 @@ EditorRoutes::set_session (Session* s) if (_session) { _session->SoloChanged.connect (*this, MISSING_INVALIDATOR, boost::bind (&EditorRoutes::solo_changed_so_update_mute, this), gui_context()); _session->RecordStateChanged.connect (*this, MISSING_INVALIDATOR, boost::bind (&EditorRoutes::update_rec_display, this), gui_context()); + + /* TODO: check if these needs to be tied in with DisplaySuspender + * Given that the UI is single-threaded and DisplaySuspender is only used + * in loops in the UI thread all should be fine. + */ + _session->BatchUpdateStart.connect (*this, MISSING_INVALIDATOR, boost::bind (&EditorRoutes::suspend_redisplay, this), gui_context()); + _session->BatchUpdateEnd.connect (*this, MISSING_INVALIDATOR, boost::bind (&EditorRoutes::resume_redisplay, this), gui_context()); } } @@ -549,7 +557,12 @@ EditorRoutes::redisplay_real () void EditorRoutes::redisplay () { - if (_no_redisplay || !_session || _session->deletion_in_progress()) { + if (!_session || _session->deletion_in_progress()) { + return; + } + + if (_no_redisplay) { + _redisplay_on_resume = true; return; } diff --git a/gtk2_ardour/editor_routes.h b/gtk2_ardour/editor_routes.h index 8213e653ec..d0c32a8e8b 100644 --- a/gtk2_ardour/editor_routes.h +++ b/gtk2_ardour/editor_routes.h @@ -38,13 +38,18 @@ public: void move_selected_tracks (bool); void show_track_in_display (TimeAxisView &); + bool _redisplay_on_resume; + void suspend_redisplay () { + _redisplay_on_resume = false; _no_redisplay = true; } void resume_redisplay () { _no_redisplay = false; - redisplay (); + if (_redisplay_on_resume) { + redisplay (); + } } void redisplay ();