+ProcessorEntry::RoutingIcon::RoutingIcon (bool input)
+ : _fed_by (false)
+ , _input (input)
+{
+ set_terminal (false);
+}
+
+void
+ProcessorEntry::RoutingIcon::set_terminal (bool b) {
+ _terminal = b;
+ int h = std::max (8.f, rintf(8.f * sqrt (UIConfiguration::instance().get_ui_scale())));
+ if (_terminal) {
+ h += std::max (4.f, rintf(4.f * sqrt (UIConfiguration::instance().get_ui_scale())));
+ }
+ set_size_request (-1, h);
+}
+
+void
+ProcessorEntry::RoutingIcon::set (
+ const ARDOUR::ChanCount& in,
+ const ARDOUR::ChanCount& out,
+ const ARDOUR::ChanCount& sinks,
+ const ARDOUR::ChanCount& sources,
+ const ARDOUR::ChanMapping& in_map,
+ const ARDOUR::ChanMapping& out_map,
+ const ARDOUR::ChanMapping& thru_map)
+{
+ _in = in;
+ _out = out;
+ _sources = sources;
+ _sinks = sinks;
+ _in_map = in_map;
+ _out_map = out_map;
+ _thru_map = thru_map;
+}
+
+bool
+ProcessorEntry::RoutingIcon::in_identity () const {
+ if (_thru_map.n_total () > 0) {
+ return false;
+ }
+ if (!_in_map.is_monotonic () || !_in_map.is_identity ()) {
+ return false;
+ }
+ if (_in_map.n_total () != _sinks.n_total () || _in.n_total () != _sinks.n_total ()) {
+ return false;
+ }
+ return true;
+}
+
+bool
+ProcessorEntry::RoutingIcon::out_identity () const {
+ if (_thru_map.n_total () > 0) {
+ // TODO skip if trhu is not connected to any of next's inputs
+ return false;
+ }
+ if (!_out_map.is_monotonic () || !_out_map.is_identity ()) {
+ return false;
+ }
+ if (_out_map.n_total () != _sources.n_total () || _out.n_total () != _sources.n_total ()) {
+ return false;
+ }
+ return true;
+}
+
+bool
+ProcessorEntry::RoutingIcon::can_coalesce () const {
+ if (_thru_map.n_total () > 0) {
+ return false;
+ }
+ if (_fed_by && _f_out != _f_sources) {
+ return false;
+ }
+ if (_fed_by && !_f_out_map.is_identity () && !_in_map.is_identity ()) {
+ return false;
+ }
+ if (_input && _sinks == _in && (!_fed_by || _f_out == _in)) {
+ return true;
+ }
+ return false;
+}
+
+void
+ProcessorEntry::RoutingIcon::set_fed_by (
+ const ARDOUR::ChanCount& out,
+ const ARDOUR::ChanCount& sources,
+ const ARDOUR::ChanMapping& out_map,
+ const ARDOUR::ChanMapping& thru_map)
+{
+ _f_out = out;
+ _f_sources = sources;
+ _f_out_map = out_map;
+ _f_thru_map = thru_map;
+ _fed_by = true;
+}
+
+void
+ProcessorEntry::RoutingIcon::set_feeding (
+ const ARDOUR::ChanCount& in,
+ const ARDOUR::ChanCount& sinks,
+ const ARDOUR::ChanMapping& in_map,
+ const ARDOUR::ChanMapping& thru_map)
+{
+ _i_in = in;
+ _i_sinks = sinks;
+ _i_in_map = in_map;
+ _i_thru_map = thru_map;
+ _feeding = true;
+}
+
+double
+ProcessorEntry::RoutingIcon::pin_x_pos (uint32_t i, double width, uint32_t n_total, uint32_t n_midi, bool midi)
+{
+ if (!midi) { i += n_midi; }
+ if (n_total == 1) {
+ assert (i == 0);
+ return rint (width * .5) +.5;
+ }
+ return rint (width * (.15 + .7 * i / (n_total - 1))) + .5;
+}
+
+void
+ProcessorEntry::RoutingIcon::draw_gnd (cairo_t* cr, double x0, double y0, double height, bool midi)
+{
+ const double dx = 1 + rint (max(2., 2. * UIConfiguration::instance().get_ui_scale()));
+ const double y1 = rint (height * .66) + .5;
+
+ cairo_save (cr);
+ cairo_translate (cr, x0, y0);
+ cairo_move_to (cr, 0, height);
+ cairo_line_to (cr, 0, y1);
+ cairo_move_to (cr, 0 - dx, y1);
+ cairo_line_to (cr, 0 + dx, y1);
+
+ set_routing_color (cr, midi);
+ cairo_set_line_width (cr, 1.0);
+ cairo_stroke (cr);
+ cairo_restore (cr);
+}
+
+void
+ProcessorEntry::RoutingIcon::draw_sidechain (cairo_t* cr, double x0, double y0, double height, bool midi)
+{
+ const double dx = 1 + rint (max(2., 2. * UIConfiguration::instance().get_ui_scale()));
+ const double y1 = rint (height * .5) - .5;
+
+ cairo_save (cr);
+ cairo_translate (cr, x0, y0);
+ cairo_move_to (cr, 0 - dx, height);
+ cairo_line_to (cr, 0, y1);
+ cairo_line_to (cr, 0 + dx, height);
+ cairo_close_path (cr);
+
+ set_routing_color (cr, midi);
+ cairo_fill (cr);
+ cairo_restore (cr);
+}
+
+void
+ProcessorEntry::RoutingIcon::draw_thru_src (cairo_t* cr, double x0, double y0, double height, bool midi)
+{
+ const double rad = 1;
+ const double y1 = height - rad - 1.5;
+
+ cairo_arc (cr, x0, y0 + y1, rad, 0, 2. * M_PI);
+ cairo_move_to (cr, x0, y0 + height - 1.5);
+ cairo_line_to (cr, x0, y0 + height);
+ set_routing_color (cr, midi);
+ cairo_set_line_width (cr, 1.0);
+ cairo_stroke (cr);
+}
+
+void
+ProcessorEntry::RoutingIcon::draw_thru_sink (cairo_t* cr, double x0, double y0, double height, bool midi)
+{
+ const double rad = 1;
+ const double y1 = rad + 1;
+
+ cairo_arc (cr, x0, y0 + y1, rad, 0, 2. * M_PI);
+ cairo_move_to (cr, x0, y0);
+ cairo_line_to (cr, x0, y0 + 1);
+ set_routing_color (cr, midi);
+ cairo_set_line_width (cr, 1.0);
+ cairo_stroke (cr);
+}
+
+void
+ProcessorEntry::RoutingIcon::draw_connection (cairo_t* cr, double x0, double x1, double y0, double y1, bool midi, bool dashed)
+{
+ double bz = abs (y1 - y0);
+
+ cairo_move_to (cr, x0, y0);
+ cairo_curve_to (cr, x0, y0 + bz, x1, y1 - bz, x1, y1);
+ cairo_set_line_width (cr, 1.0);
+ cairo_set_line_cap (cr, CAIRO_LINE_CAP_ROUND);
+ cairo_set_source_rgb (cr, 1, 0, 0);
+ if (dashed) {
+ const double dashes[] = { 2, 3 };
+ cairo_set_dash (cr, dashes, 2, 0);
+ }
+ set_routing_color (cr, midi);
+ cairo_stroke (cr);
+ if (dashed) {
+ cairo_set_dash (cr, 0, 0, 0);
+ }
+}
+