final (?) tweak for totally optimized meter redraws (vertical only)
authorPaul Davis <paul@linuxaudiosystems.com>
Thu, 21 Feb 2008 20:43:46 +0000 (20:43 +0000)
committerPaul Davis <paul@linuxaudiosystems.com>
Thu, 21 Feb 2008 20:43:46 +0000 (20:43 +0000)
git-svn-id: svn://localhost/ardour2/branches/2.0-ongoing@3103 d708f5d6-7413-0410-9779-e7cbd77b26cf

libs/gtkmm2ext/fastmeter.cc
libs/gtkmm2ext/gtkmm2ext/fastmeter.h

index 94e6bffd9184dff3933bd57430b74a383cd9a5f8..cad900d8edf4c7759075b49a21b59c1d644cb3b1 100644 (file)
@@ -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
index b8441aacae01f4ca7e90186d61386f4ec35a3b9e..7a5ba70a9da227473ca69ac809878fb68a10e3ea 100644 (file)
@@ -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;