diff options
author | Paul Davis <paul@linuxaudiosystems.com> | 2008-02-21 20:43:46 +0000 |
---|---|---|
committer | Paul Davis <paul@linuxaudiosystems.com> | 2008-02-21 20:43:46 +0000 |
commit | 9961984c9b09c0b99a170ba5bb1eff93e090c011 (patch) | |
tree | 999496a2e4ee7eded5d271cc2ce03d6149f24de2 | |
parent | d5878ac268a70abe4f9a0b405538553ddce301cf (diff) |
final (?) tweak for totally optimized meter redraws (vertical only)
git-svn-id: svn://localhost/ardour2/branches/2.0-ongoing@3103 d708f5d6-7413-0410-9779-e7cbd77b26cf
-rw-r--r-- | libs/gtkmm2ext/fastmeter.cc | 38 | ||||
-rw-r--r-- | libs/gtkmm2ext/gtkmm2ext/fastmeter.h | 4 |
2 files changed, 30 insertions, 12 deletions
diff --git a/libs/gtkmm2ext/fastmeter.cc b/libs/gtkmm2ext/fastmeter.cc index 94e6bffd91..cad900d8ed 100644 --- a/libs/gtkmm2ext/fastmeter.cc +++ b/libs/gtkmm2ext/fastmeter.cc @@ -481,8 +481,16 @@ FastMeter::set (float lvl) return; } - /* now carefully compute the part we really want updated */ + if (orientation == Vertical) { + queue_vertical_redraw (win, old_level); + } else { + queue_horizontal_redraw (win, old_level); + } +} +void +FastMeter::queue_vertical_redraw (const Glib::RefPtr<Gdk::Window>& win, float old_level) +{ GdkRectangle rect; gint new_top = (gint) floor (pixheight * current_level); @@ -510,31 +518,39 @@ FastMeter::set (float lvl) } GdkRegion* region; + bool queue = false; if (rect.height != 0) { /* ok, first region to draw ... */ region = gdk_region_rectangle (&rect); - } else { - region = gdk_region_new (); + queue = true; } - /* redraw the last place where the peak hold bar was; - the expose will draw the new one whether its part of + /* redraw the last place where the last peak hold bar was; + the next expose will draw the new one whether its part of expose region or not. */ if (last_peak_rect.width * last_peak_rect.height != 0) { + if (!queue) { + region = gdk_region_new (); + queue = true; + } gdk_region_union_with_rect (region, &last_peak_rect); - } + } - if (rect.height == 0 && !hold_state) { - /* nothing to do */ - return; + if (queue) { + gdk_window_invalidate_region (win->gobj(), region, true); } - - gdk_window_invalidate_region (win->gobj(), region, true); +} + +void +FastMeter::queue_horizontal_redraw (const Glib::RefPtr<Gdk::Window>& win, float old_level) +{ + /* XXX OPTIMIZE (when we have some horizontal meters) */ + queue_draw (); } void diff --git a/libs/gtkmm2ext/gtkmm2ext/fastmeter.h b/libs/gtkmm2ext/gtkmm2ext/fastmeter.h index b8441aacae..7a5ba70a9d 100644 --- a/libs/gtkmm2ext/gtkmm2ext/fastmeter.h +++ b/libs/gtkmm2ext/gtkmm2ext/fastmeter.h @@ -70,7 +70,9 @@ class FastMeter : public Gtk::DrawingArea { bool vertical_expose (GdkEventExpose*); bool horizontal_expose (GdkEventExpose*); - + void queue_vertical_redraw (const Glib::RefPtr<Gdk::Window>&, float); + void queue_horizontal_redraw (const Glib::RefPtr<Gdk::Window>&, float); + static Glib::RefPtr<Gdk::Pixbuf> request_vertical_meter(int w, int h); static Glib::RefPtr<Gdk::Pixbuf> *v_pixbuf_cache; |