Performance: store NoteBase UIConfiguration colors between config changes.
Cumulative time in percent while wiggling the tempo lines rapidly. Before: MidiRegionview::update_sustained 12.02 NoteBase::base_color 6.43 MidiGhostRegion::update_note 3.12 Note::set 1.27 TempoMap::frame_at_quarter_note 0.59 _dynamic_cast 0.13 After: MidiRegionview::update_sustained 10.49 MidiGhostRegion::update_note 5.57 Note::set 2.52 TempoMap::frame_at_quarter_note 1.13 NoteBase::base_color 0.17 _dynamic_cast 0.17
This commit is contained in:
@@ -51,6 +51,7 @@
|
||||
#include "keyboard.h"
|
||||
#include "editor_cursors.h"
|
||||
#include "mouse_cursors.h"
|
||||
#include "note_base.h"
|
||||
#include "ui_config.h"
|
||||
#include "verbose_cursor.h"
|
||||
|
||||
@@ -943,6 +944,8 @@ Editor::color_handler()
|
||||
|
||||
refresh_location_display ();
|
||||
|
||||
NoteBase::set_colors ();
|
||||
|
||||
/* redraw the whole thing */
|
||||
_track_canvas->set_background_color (UIConfiguration::instance().color ("arrange base"));
|
||||
_track_canvas->queue_draw ();
|
||||
|
||||
@@ -44,6 +44,25 @@ const uint32_t NoteBase::midi_channel_colors[16] = {
|
||||
0x832dd3ff, 0xa92dd3ff, 0xd32dbfff, 0xd32d67ff
|
||||
};
|
||||
|
||||
bool NoteBase::_color_init = false;
|
||||
uint32_t NoteBase::_selected_mod_col = 0;
|
||||
uint32_t NoteBase::_selected_outline_col = 0;
|
||||
uint32_t NoteBase::_selected_col = 0;
|
||||
uint32_t NoteBase::_min_col = 0;
|
||||
uint32_t NoteBase::_mid_col = 0;
|
||||
uint32_t NoteBase::_max_col = 0;
|
||||
|
||||
void
|
||||
NoteBase::set_colors ()
|
||||
{
|
||||
_selected_mod_col = UIConfiguration::instance().color_mod ("midi note selected", "midi note");
|
||||
_selected_outline_col = UIConfiguration::instance().color ("midi note selected outline");
|
||||
_selected_col = UIConfiguration::instance().color ("midi note selected");
|
||||
_min_col = UIConfiguration::instance().color_mod ("midi note min", "midi note");
|
||||
_mid_col = UIConfiguration::instance().color_mod ("midi note mid", "midi note");
|
||||
_max_col = UIConfiguration::instance().color_mod ("midi note max", "midi note");
|
||||
}
|
||||
|
||||
NoteBase::NoteBase(MidiRegionView& region, bool with_events, const boost::shared_ptr<NoteType> note)
|
||||
: _region(region)
|
||||
, _item (0)
|
||||
@@ -56,6 +75,10 @@ NoteBase::NoteBase(MidiRegionView& region, bool with_events, const boost::shared
|
||||
, _mouse_x_fraction (-1.0)
|
||||
, _mouse_y_fraction (-1.0)
|
||||
{
|
||||
if (!_color_init) {
|
||||
NoteBase::set_colors();
|
||||
_color_init = true;
|
||||
}
|
||||
}
|
||||
|
||||
NoteBase::~NoteBase()
|
||||
@@ -169,14 +192,13 @@ NoteBase::base_color()
|
||||
case TrackColor:
|
||||
{
|
||||
const uint32_t region_color = _region.midi_stream_view()->get_region_color();
|
||||
return UINT_INTERPOLATE (UINT_RGBA_CHANGE_A (region_color, opacity),
|
||||
UIConfiguration::instance().color ("midi note selected"),
|
||||
return UINT_INTERPOLATE (UINT_RGBA_CHANGE_A (region_color, opacity), _selected_col,
|
||||
0.5);
|
||||
}
|
||||
|
||||
case ChannelColors:
|
||||
return UINT_INTERPOLATE (UINT_RGBA_CHANGE_A (NoteBase::midi_channel_colors[_note->channel()], opacity),
|
||||
UIConfiguration::instance().color ("midi note selected"), 0.5);
|
||||
_selected_col, 0.5);
|
||||
|
||||
default:
|
||||
return meter_style_fill_color(_note->velocity(), selected());
|
||||
|
||||
@@ -100,18 +100,16 @@ class NoteBase : public sigc::trackable
|
||||
const boost::shared_ptr<NoteType> note() const { return _note; }
|
||||
MidiRegionView& region_view() const { return _region; }
|
||||
|
||||
static void set_colors ();
|
||||
|
||||
inline static uint32_t meter_style_fill_color(uint8_t vel, bool selected) {
|
||||
if (selected) {
|
||||
return UIConfiguration::instance().color_mod ("midi note selected", "midi note");
|
||||
return _selected_mod_col;
|
||||
} else if (vel < 64) {
|
||||
return UINT_INTERPOLATE(
|
||||
UIConfiguration::instance().color_mod ("midi note min", "midi note"),
|
||||
UIConfiguration::instance().color_mod ("midi note mid", "midi note"),
|
||||
return UINT_INTERPOLATE(_min_col, _mid_col,
|
||||
(vel / (double)63.0));
|
||||
} else {
|
||||
return UINT_INTERPOLATE(
|
||||
UIConfiguration::instance().color_mod ("midi note mid", "midi note"),
|
||||
UIConfiguration::instance().color_mod ("midi note max", "midi note"),
|
||||
return UINT_INTERPOLATE(_mid_col, _max_col,
|
||||
((vel-64) / (double)63.0));
|
||||
}
|
||||
}
|
||||
@@ -119,7 +117,7 @@ class NoteBase : public sigc::trackable
|
||||
/// calculate outline colors from fill colors of notes
|
||||
inline static uint32_t calculate_outline(uint32_t color, bool selected=false) {
|
||||
if (selected) {
|
||||
return UIConfiguration::instance().color ("midi note selected outline");
|
||||
return _selected_outline_col;
|
||||
} else {
|
||||
return UINT_INTERPOLATE(color, 0x000000ff, 0.5);
|
||||
}
|
||||
@@ -150,6 +148,14 @@ protected:
|
||||
|
||||
private:
|
||||
bool event_handler (GdkEvent *);
|
||||
|
||||
static uint32_t _selected_mod_col;
|
||||
static uint32_t _selected_outline_col;
|
||||
static uint32_t _selected_col;
|
||||
static uint32_t _min_col;
|
||||
static uint32_t _mid_col;
|
||||
static uint32_t _max_col;
|
||||
static bool _color_init;
|
||||
};
|
||||
|
||||
#endif /* __gtk_ardour_note_h__ */
|
||||
|
||||
Reference in New Issue
Block a user