From aecd84e7fd5ca463dcef91e57cf7a260a9d11614 Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Tue, 5 Jan 2021 23:23:22 +0100 Subject: [PATCH] Update session extents calculation * Expose API via Public Editor * Skip hidden tracks in calculation * Use a single call to query playlist extents. This way the playlist read-lock is needed at most once per track which speeds up calculation. --- gtk2_ardour/editor_canvas.cc | 24 ++++++++++++------------ gtk2_ardour/public_editor.h | 2 ++ 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/gtk2_ardour/editor_canvas.cc b/gtk2_ardour/editor_canvas.cc index ddfc7a0973..e698110de4 100644 --- a/gtk2_ardour/editor_canvas.cc +++ b/gtk2_ardour/editor_canvas.cc @@ -623,19 +623,19 @@ Editor::session_gui_extents (bool use_extra) const boost::shared_ptr rl = _session->get_routes(); for (RouteList::iterator r = rl->begin(); r != rl->end(); ++r) { boost::shared_ptr tr = boost::dynamic_pointer_cast (*r); - if (tr) { - boost::shared_ptr pl = tr->playlist(); - if (pl && !pl->all_regions_empty()) { - pair e; - e = pl->get_extent(); - if (e.first < session_extent_start) { - session_extent_start = e.first; - } - if (e.second > session_extent_end) { - session_extent_end = e.second; - } - } + if (!tr) { + continue; } + if (tr->presentation_info ().hidden ()) { + continue; + } + pair e = tr->playlist()->get_extent (); + if (e.first == e.second) { + /* no regions present */ + continue; + } + session_extent_start = std::min (session_extent_start, e.first); + session_extent_end = std::max (session_extent_end, e.second); } } diff --git a/gtk2_ardour/public_editor.h b/gtk2_ardour/public_editor.h index af26f69d83..0a0c036d6b 100644 --- a/gtk2_ardour/public_editor.h +++ b/gtk2_ardour/public_editor.h @@ -480,6 +480,8 @@ public: virtual void get_pointer_position (double &, double &) const = 0; + virtual std::pair session_gui_extents (bool use_extra = true) const = 0; + virtual ARDOUR::Location* find_location_from_marker (ArdourMarker*, bool&) const = 0; virtual ArdourMarker* find_marker_from_location_id (PBD::ID const&, bool) const = 0;