diff options
author | Robin Gareus <robin@gareus.org> | 2013-07-12 17:56:42 +0200 |
---|---|---|
committer | Robin Gareus <robin@gareus.org> | 2013-07-12 17:56:42 +0200 |
commit | e0bbc0b435eb93ea2e1e2a61453a0639ac10071c (patch) | |
tree | 980efeab089b9c5479a0d75f887f9c9dae69903a /libs/gtkmm2ext | |
parent | 2a0440a37349b01d5b339dcd46e22d3f9cf85a2d (diff) |
minor peak-meter performance tweak
* redraw only missing parts of the outside rectangle,
* don't redraw RMS meter if value has not changed
Diffstat (limited to 'libs/gtkmm2ext')
-rw-r--r-- | libs/gtkmm2ext/fastmeter.cc | 17 | ||||
-rw-r--r-- | libs/gtkmm2ext/gtkmm2ext/fastmeter.h | 1 |
2 files changed, 5 insertions, 13 deletions
diff --git a/libs/gtkmm2ext/fastmeter.cc b/libs/gtkmm2ext/fastmeter.cc index 4819609878..c0bcb05af5 100644 --- a/libs/gtkmm2ext/fastmeter.cc +++ b/libs/gtkmm2ext/fastmeter.cc @@ -53,7 +53,6 @@ FastMeter::FastMeter (long hold, unsigned long dimen, Orientation o, int len, { orientation = o; hold_cnt = hold; - resized = true; hold_state = 0; bright_hold = false; current_peak = 0; @@ -353,7 +352,6 @@ FastMeter::on_size_allocate (Gtk::Allocation &alloc) } DrawingArea::on_size_allocate (alloc); - resized = true; } bool @@ -372,16 +370,13 @@ FastMeter::vertical_expose (GdkEventExpose* ev) cairo_t* cr = gdk_cairo_create (get_window ()->gobj()); - if (resized) { - cairo_set_source_rgb (cr, 0, 0, 0); // black - rounded_rectangle (cr, 0, 0, pixrect.width + 2, pixheight + 2, 2); - cairo_stroke (cr); - //cairo_fill (cr); - //resized = false; - } cairo_rectangle (cr, ev->area.x, ev->area.y, ev->area.width, ev->area.height); cairo_clip (cr); + cairo_set_source_rgb (cr, 0, 0, 0); // black + rounded_rectangle (cr, 0, 0, pixrect.width + 2, pixheight + 2, 2); + cairo_stroke (cr); + top_of_meter = (gint) floor (pixheight * current_level); /* reset the height & origin of the rect that needs to show the pixbuf @@ -464,11 +459,10 @@ FastMeter::set (float lvl, float peak) current_level = lvl; - if (current_level == old_level && current_peak == old_peak && hold_state == 0) { + if (current_level == old_level && current_peak == old_peak && (hold_state == 0 || peak != -1)) { return; } - Glib::RefPtr<Gdk::Window> win; if ((win = get_window()) == 0) { @@ -565,7 +559,6 @@ FastMeter::set_highlight (bool onoff) } highlight = onoff; bgpattern = request_vertical_background (request_width, pixheight, highlight ? _bgh : _bgc, highlight); - resized = true; queue_draw (); } diff --git a/libs/gtkmm2ext/gtkmm2ext/fastmeter.h b/libs/gtkmm2ext/gtkmm2ext/fastmeter.h index debe6c1cc7..f065020a57 100644 --- a/libs/gtkmm2ext/gtkmm2ext/fastmeter.h +++ b/libs/gtkmm2ext/gtkmm2ext/fastmeter.h @@ -91,7 +91,6 @@ private: float current_level; float current_peak; float current_user_level; - bool resized; bool highlight; bool vertical_expose (GdkEventExpose*); |