From 8c3397413149b87d2755494fe73186f27edab369 Mon Sep 17 00:00:00 2001 From: Soeren Apel Date: Fri, 5 Jan 2018 20:48:20 +0100 Subject: [PATCH] Supply the segment ID when adding samples to optimize trace painting Use case is as follows: - Capture 20+ segments with ~500kS each - Afterwards, enable conversion for a channel Without this change, the converted logic will be repainted 20++ times because we are only told that new samples were added but not which segment. With this change, the logic trace is only painted when we see that samples were added to the segment we're showing. --- pv/data/analogsegment.hpp | 2 +- pv/data/logicsegment.hpp | 2 +- pv/data/segment.hpp | 6 +++++- pv/views/trace/view.hpp | 2 -- pv/views/viewbase.cpp | 23 ++++++++++++++++++++--- pv/views/viewbase.hpp | 6 ++++++ 6 files changed, 33 insertions(+), 8 deletions(-) diff --git a/pv/data/analogsegment.hpp b/pv/data/analogsegment.hpp index 5267e77e..7c74e776 100644 --- a/pv/data/analogsegment.hpp +++ b/pv/data/analogsegment.hpp @@ -44,7 +44,7 @@ typedef struct { float* value; } SegmentAnalogDataIterator; -class AnalogSegment : public QObject, public Segment +class AnalogSegment : public Segment { Q_OBJECT diff --git a/pv/data/logicsegment.hpp b/pv/data/logicsegment.hpp index 7becfc3e..2e03fd55 100644 --- a/pv/data/logicsegment.hpp +++ b/pv/data/logicsegment.hpp @@ -54,7 +54,7 @@ typedef struct { uint8_t* value; } SegmentLogicDataIterator; -class LogicSegment : public QObject, public Segment +class LogicSegment : public Segment { Q_OBJECT diff --git a/pv/data/segment.hpp b/pv/data/segment.hpp index 18f1aed7..9ea9629d 100644 --- a/pv/data/segment.hpp +++ b/pv/data/segment.hpp @@ -27,6 +27,8 @@ #include #include +#include + using std::recursive_mutex; using std::vector; @@ -52,8 +54,10 @@ typedef struct { uint8_t* value; } SegmentRawDataIterator; -class Segment +class Segment : public QObject { + Q_OBJECT + private: static const uint64_t MaxChunkSize; diff --git a/pv/views/trace/view.hpp b/pv/views/trace/view.hpp index 712151dc..679e587b 100644 --- a/pv/views/trace/view.hpp +++ b/pv/views/trace/view.hpp @@ -443,8 +443,6 @@ private: vector< shared_ptr > decode_traces_; #endif - /// The ID of the currently displayed segment - int current_segment_; Trace::SegmentDisplayMode segment_display_mode_; /// Signals whether the user can change the currently shown segment. diff --git a/pv/views/viewbase.cpp b/pv/views/viewbase.cpp index 7d986fe0..65cf6842 100644 --- a/pv/views/viewbase.cpp +++ b/pv/views/viewbase.cpp @@ -26,6 +26,7 @@ #include "pv/session.hpp" #include "pv/util.hpp" +#include "pv/data/segment.hpp" using std::shared_ptr; @@ -36,7 +37,8 @@ const int ViewBase::MaxViewAutoUpdateRate = 25; // No more than 25 Hz ViewBase::ViewBase(Session &session, bool is_main_view, QWidget *parent) : session_(session), - is_main_view_(is_main_view) + is_main_view_(is_main_view), + current_segment_(0) { (void)parent; @@ -78,7 +80,7 @@ void ViewBase::clear_signalbases() disconnect(signalbase.get(), SIGNAL(samples_cleared()), this, SLOT(on_data_updated())); disconnect(signalbase.get(), SIGNAL(samples_added(QObject*, uint64_t, uint64_t)), - this, SLOT(on_data_updated())); + this, SLOT(on_samples_added(QObject*, uint64_t, uint64_t))); } signalbases_.clear(); @@ -91,7 +93,7 @@ void ViewBase::add_signalbase(const shared_ptr signalbase) connect(signalbase.get(), SIGNAL(samples_cleared()), this, SLOT(on_data_updated())); connect(signalbase.get(), SIGNAL(samples_added(QObject*, uint64_t, uint64_t)), - this, SLOT(on_data_updated())); + this, SLOT(on_samples_added(QObject*, uint64_t, uint64_t))); } #ifdef ENABLE_DECODE @@ -148,6 +150,21 @@ void ViewBase::perform_delayed_view_update() { } +void ViewBase::on_samples_added(QObject* segment, uint64_t start_sample, + uint64_t end_sample) +{ + (void)start_sample; + (void)end_sample; + + data::Segment* s = qobject_cast(segment); + + if (s->segment_id() != current_segment_) + return; + + if (!delayed_view_updater_.isActive()) + delayed_view_updater_.start(); +} + void ViewBase::on_data_updated() { if (!delayed_view_updater_.isActive()) diff --git a/pv/views/viewbase.hpp b/pv/views/viewbase.hpp index 8e71f3bb..c8f72ab7 100644 --- a/pv/views/viewbase.hpp +++ b/pv/views/viewbase.hpp @@ -100,6 +100,9 @@ public Q_SLOTS: virtual void perform_delayed_view_update(); private Q_SLOTS: + void on_samples_added(QObject* segment, uint64_t start_sample, + uint64_t end_sample); + void on_data_updated(); protected: @@ -111,6 +114,9 @@ protected: unordered_set< shared_ptr > signalbases_; + /// The ID of the currently displayed segment + uint32_t current_segment_; + QTimer delayed_view_updater_; }; -- 2.30.2