Add Canvas::get_microseconds_since_render_start() method

Initial use is for the WaveView class to determine whether on not to draw the
waveform in the GUI thread.
This commit is contained in:
Tim Mayberry 2017-03-28 15:52:28 +10:00
parent 4d863b47e5
commit d276e12b21
2 changed files with 14 additions and 0 deletions

View file

@ -163,6 +163,18 @@ Canvas::prepare_for_render (Rect const & area) const
}
}
gint64
Canvas::get_microseconds_since_render_start () const
{
gint64 timestamp = g_get_monotonic_time();
if (_last_render_start_timestamp == 0 || timestamp <= _last_render_start_timestamp) {
return 0;
}
return timestamp - _last_render_start_timestamp;
}
ostream&
operator<< (ostream& o, Canvas& c)
{

View file

@ -91,6 +91,8 @@ public:
gint64 get_last_render_start_timestamp () const { return _last_render_start_timestamp; }
gint64 get_microseconds_since_render_start () const;
/** @return root group */
Item* root () {
return &_root;