X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=libs%2Fcanvas%2Fcanvas%2Fwave_view.h;h=f26c3a5c104dfeb8c1ee6d31d973406b303943ad;hb=c4c7598adbc9e5eca5fe04a23bb7e88fc0989f34;hp=fc39d7e555484f413de73f0bf165b553f7e6f2af;hpb=5e0e41e068a04603198a4e50464d794156f42c47;p=ardour.git diff --git a/libs/canvas/canvas/wave_view.h b/libs/canvas/canvas/wave_view.h index fc39d7e555..f26c3a5c10 100644 --- a/libs/canvas/canvas/wave_view.h +++ b/libs/canvas/canvas/wave_view.h @@ -28,6 +28,7 @@ #include +#include "canvas/visibility.h" #include "canvas/item.h" #include "canvas/fill.h" #include "canvas/outline.h" @@ -44,14 +45,33 @@ class WaveViewTest; namespace ArdourCanvas { -class WaveView : virtual public Item, public Outline, public Fill +class LIBCANVAS_API WaveView : public Item { public: + enum Shape { Normal, - Rectified, + Rectified }; + struct CacheEntry { + int channel; + Coord height; + float amplitude; + Color fill_color; + framepos_t start; + framepos_t end; + Cairo::RefPtr image; + + CacheEntry(int chan, Coord hght, float amp, Color fcl, framepos_t strt, framepos_t ed, Cairo::RefPtr img) : + + channel (chan), height (hght), amplitude (amp), fill_color (fcl), + start (strt), end (ed), image (img) {} + }; + + /* final ImageSurface rendered with colours */ + Cairo::RefPtr _image; + /* Displays a single channel of waveform data for the given Region. x = 0 in the waveview corresponds to the first waveform datum taken @@ -71,7 +91,8 @@ public: */ - WaveView (Group *, boost::shared_ptr); + WaveView (Canvas *, boost::shared_ptr); + WaveView (Item*, boost::shared_ptr); ~WaveView (); void render (Rect const & area, Cairo::RefPtr) const; @@ -97,7 +118,6 @@ public: double gradient_depth() const { return _gradient_depth; } void set_shape (Shape); - /* currently missing because we don't need them (yet): set_shape_independent(); set_logscaled_independent() @@ -115,6 +135,9 @@ public: void set_amplitude_above_axis (double v); double amplitude_above_axis () const { return _amplitude_above_axis; } + static void set_clip_level (double dB); + static PBD::Signal0 ClipLevelChanged; + #ifdef CANVAS_COMPATIBILITY void*& property_gain_src () { return _foo_void; @@ -129,13 +152,14 @@ private: friend class ::WaveViewTest; - void invalidate_image (); + static std::map , std::vector > _image_cache; + void consolidate_image_cache () const; + void invalidate_image_cache (); boost::shared_ptr _region; int _channel; double _samples_per_pixel; Coord _height; - Color _wave_color; bool _show_zero; Color _zero_color; Color _clip_color; @@ -146,31 +170,30 @@ private: bool _logscaled_independent; bool _gradient_depth_independent; double _amplitude_above_axis; + float _region_amplitude; /** The `start' value to use for the region; we can't use the region's * value as the crossfade editor needs to alter it. */ ARDOUR::frameoffset_t _region_start; - - - mutable ARDOUR::framepos_t _sample_start; - mutable ARDOUR::framepos_t _sample_end; - mutable Cairo::RefPtr _image; - PBD::ScopedConnection invalidation_connection; + PBD::ScopedConnectionList invalidation_connection; static double _global_gradient_depth; static bool _global_logscaled; static Shape _global_shape; static bool _global_show_waveform_clipping; + static double _clip_level; static PBD::Signal0 VisualPropertiesChanged; void handle_visual_property_change (); + void handle_clip_level_change (); + + void get_image (Cairo::RefPtr& image, framepos_t start, framepos_t end, double& image_offset) const; - void ensure_cache (ARDOUR::framepos_t sample_start, ARDOUR::framepos_t sample_end) const; - ArdourCanvas::Coord position (double) const; - void draw_image (ARDOUR::PeakData*, int npeaks) const; + ArdourCanvas::Coord y_extent (double, bool) const; + void draw_image (Cairo::RefPtr&, ARDOUR::PeakData*, int) const; }; }