mirror of
https://github.com/Ardour/ardour.git
synced 2025-12-06 14:54:56 +01:00
optimize button pattern cache
We really should statically cache patterns as done in PixFader and Meters (Cairo's cache is not nearly large enough)
This commit is contained in:
parent
fb473475c3
commit
6f30c1fddb
2 changed files with 23 additions and 16 deletions
|
|
@ -87,7 +87,8 @@ ArdourButton::ArdourButton (Element e)
|
||||||
, _fallthrough_to_parent (false)
|
, _fallthrough_to_parent (false)
|
||||||
, _layout_ellipsize_width (-1)
|
, _layout_ellipsize_width (-1)
|
||||||
, _ellipsis (Pango::ELLIPSIZE_NONE)
|
, _ellipsis (Pango::ELLIPSIZE_NONE)
|
||||||
, _update_colors_and_patterns (true)
|
, _update_colors (true)
|
||||||
|
, _pattern_height (0)
|
||||||
{
|
{
|
||||||
ARDOUR_UI_UTILS::ColorsChanged.connect (sigc::mem_fun (*this, &ArdourButton::color_handler));
|
ARDOUR_UI_UTILS::ColorsChanged.connect (sigc::mem_fun (*this, &ArdourButton::color_handler));
|
||||||
}
|
}
|
||||||
|
|
@ -173,10 +174,11 @@ ArdourButton::render (cairo_t* cr, cairo_rectangle_t *)
|
||||||
uint32_t text_color;
|
uint32_t text_color;
|
||||||
uint32_t led_color;
|
uint32_t led_color;
|
||||||
|
|
||||||
if (_update_colors_and_patterns) {
|
if (_update_colors) {
|
||||||
set_colors ();
|
set_colors ();
|
||||||
|
}
|
||||||
|
if (get_height() != _pattern_height) {
|
||||||
build_patterns ();
|
build_patterns ();
|
||||||
_update_colors_and_patterns = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( active_state() == Gtkmm2ext::ExplicitActive ) {
|
if ( active_state() == Gtkmm2ext::ExplicitActive ) {
|
||||||
|
|
@ -567,7 +569,11 @@ ArdourButton::on_size_request (Gtk::Requisition* req)
|
||||||
CairoWidget::on_size_request (req);
|
CairoWidget::on_size_request (req);
|
||||||
|
|
||||||
if (_diameter == 0) {
|
if (_diameter == 0) {
|
||||||
_diameter = rint (ARDOUR::Config->get_font_scale () / 1024. / 7.5); // 11px with 80% font-scaling
|
const float newdia = rint (ARDOUR::Config->get_font_scale () / 1024. / 7.5); // 11px with 80% font-scaling
|
||||||
|
if (_diameter != newdia) {
|
||||||
|
_pattern_height = 0;
|
||||||
|
_diameter = newdia;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((_elements & Text) && !_text.empty()) {
|
if ((_elements & Text) && !_text.empty()) {
|
||||||
|
|
@ -625,6 +631,7 @@ ArdourButton::on_size_request (Gtk::Requisition* req)
|
||||||
void
|
void
|
||||||
ArdourButton::set_colors ()
|
ArdourButton::set_colors ()
|
||||||
{
|
{
|
||||||
|
_update_colors = false;
|
||||||
if (_fixed_colors_set) {
|
if (_fixed_colors_set) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -703,6 +710,7 @@ ArdourButton::build_patterns ()
|
||||||
|
|
||||||
if (led_inset_pattern) {
|
if (led_inset_pattern) {
|
||||||
cairo_pattern_destroy (led_inset_pattern);
|
cairo_pattern_destroy (led_inset_pattern);
|
||||||
|
led_inset_pattern = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
//convex gradient
|
//convex gradient
|
||||||
|
|
@ -715,13 +723,11 @@ ArdourButton::build_patterns ()
|
||||||
cairo_pattern_add_color_stop_rgba (concave_pattern, 0.0, 0,0,0, 0.5);
|
cairo_pattern_add_color_stop_rgba (concave_pattern, 0.0, 0,0,0, 0.5);
|
||||||
cairo_pattern_add_color_stop_rgba (concave_pattern, 0.7, 0,0,0, 0.0);
|
cairo_pattern_add_color_stop_rgba (concave_pattern, 0.7, 0,0,0, 0.0);
|
||||||
|
|
||||||
if (_elements & Indicator) {
|
|
||||||
led_inset_pattern = cairo_pattern_create_linear (0.0, 0.0, 0.0, _diameter);
|
led_inset_pattern = cairo_pattern_create_linear (0.0, 0.0, 0.0, _diameter);
|
||||||
cairo_pattern_add_color_stop_rgba (led_inset_pattern, 0, 0,0,0, 0.4);
|
cairo_pattern_add_color_stop_rgba (led_inset_pattern, 0, 0,0,0, 0.4);
|
||||||
cairo_pattern_add_color_stop_rgba (led_inset_pattern, 1, 1,1,1, 0.7);
|
cairo_pattern_add_color_stop_rgba (led_inset_pattern, 1, 1,1,1, 0.7);
|
||||||
}
|
|
||||||
|
|
||||||
CairoWidget::set_dirty ();
|
_pattern_height = get_height() ;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
@ -800,7 +806,7 @@ ArdourButton::set_distinct_led_click (bool yn)
|
||||||
void
|
void
|
||||||
ArdourButton::color_handler ()
|
ArdourButton::color_handler ()
|
||||||
{
|
{
|
||||||
_update_colors_and_patterns = true;
|
_update_colors = true;
|
||||||
CairoWidget::set_dirty ();
|
CairoWidget::set_dirty ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -809,7 +815,7 @@ ArdourButton::on_size_allocate (Allocation& alloc)
|
||||||
{
|
{
|
||||||
CairoWidget::on_size_allocate (alloc);
|
CairoWidget::on_size_allocate (alloc);
|
||||||
setup_led_rect ();
|
setup_led_rect ();
|
||||||
_update_colors_and_patterns = true;
|
_update_colors = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
@ -891,7 +897,7 @@ ArdourButton::on_name_changed ()
|
||||||
_char_pixel_width = 0;
|
_char_pixel_width = 0;
|
||||||
_char_pixel_height = 0;
|
_char_pixel_height = 0;
|
||||||
_diameter = 0;
|
_diameter = 0;
|
||||||
_update_colors_and_patterns = true;
|
_update_colors = true;
|
||||||
if (is_realized()) {
|
if (is_realized()) {
|
||||||
queue_resize ();
|
queue_resize ();
|
||||||
}
|
}
|
||||||
|
|
@ -940,7 +946,7 @@ ArdourButton::set_active_state (Gtkmm2ext::ActiveState s)
|
||||||
bool changed = (_active_state != s);
|
bool changed = (_active_state != s);
|
||||||
CairoWidget::set_active_state (s);
|
CairoWidget::set_active_state (s);
|
||||||
if (changed) {
|
if (changed) {
|
||||||
_update_colors_and_patterns = true;
|
_update_colors = true;
|
||||||
CairoWidget::set_dirty ();
|
CairoWidget::set_dirty ();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -951,7 +957,7 @@ ArdourButton::set_visual_state (Gtkmm2ext::VisualState s)
|
||||||
bool changed = (_visual_state != s);
|
bool changed = (_visual_state != s);
|
||||||
CairoWidget::set_visual_state (s);
|
CairoWidget::set_visual_state (s);
|
||||||
if (changed) {
|
if (changed) {
|
||||||
_update_colors_and_patterns = true;
|
_update_colors = true;
|
||||||
CairoWidget::set_dirty ();
|
CairoWidget::set_dirty ();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -167,7 +167,8 @@ class ArdourButton : public CairoWidget , public Gtkmm2ext::Activatable
|
||||||
bool _fallthrough_to_parent;
|
bool _fallthrough_to_parent;
|
||||||
int _layout_ellipsize_width;
|
int _layout_ellipsize_width;
|
||||||
Pango::EllipsizeMode _ellipsis;
|
Pango::EllipsizeMode _ellipsis;
|
||||||
bool _update_colors_and_patterns;
|
bool _update_colors;
|
||||||
|
int _pattern_height;
|
||||||
|
|
||||||
void setup_led_rect ();
|
void setup_led_rect ();
|
||||||
void set_colors ();
|
void set_colors ();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue