Hi AND low pass filter -- fresh from the oven werks.
[ardour.git] / libs / gtkmm2ext / fastmeter.cc
index df3f09735e8be6c002e7dc953a398debe4f95396..c144a963bbd673df7e6734a1b998140f3a8278c6 100644 (file)
@@ -133,6 +133,14 @@ FastMeter::~FastMeter ()
 {
 }
 
+void
+FastMeter::flush_pattern_cache () {
+       hb_pattern_cache.clear();
+       hm_pattern_cache.clear();
+       vb_pattern_cache.clear();
+       vm_pattern_cache.clear();
+}
+
 Cairo::RefPtr<Cairo::Pattern>
 FastMeter::generate_meter_pattern (
                int width, int height, int *clr, float *stp, int styleflags, bool horiz)
@@ -222,7 +230,10 @@ FastMeter::generate_meter_pattern (
                        cairo_set_line_width(tc, 1.0);
                        cairo_set_source_rgba(tc, .0, .0, .0, 0.4);
                        //cairo_set_operator (tc, CAIRO_OPERATOR_SOURCE);
-                       for (float y=0.5; y < height; y+= 2.0) {
+                       for (int i = 0; float y = 0.5 + i * 2.0; ++i) {
+                               if (y >= height) {
+                                       break;
+                               }
                                cairo_move_to(tc, 0, y);
                                cairo_line_to(tc, width, y);
                                cairo_stroke (tc);
@@ -712,7 +723,9 @@ FastMeter::set (float lvl, float peak)
 
        current_level = lvl;
 
-       if (current_level == old_level && current_peak == old_peak && (hold_state == 0 || peak != -1)) {
+       const float pixscale = (orientation == Vertical) ? pixheight : pixwidth;
+#define PIX(X) floor(pixscale * (X))
+       if (PIX(current_level) == PIX(old_level) && PIX(current_peak) == PIX(old_peak) && (hold_state == 0 || peak != -1)) {
                return;
        }