]> sigrok.org Git - pulseview.git/commitdiff
Supply the segment ID when adding samples to optimize trace painting
authorSoeren Apel <redacted>
Fri, 5 Jan 2018 19:48:20 +0000 (20:48 +0100)
committerUwe Hermann <redacted>
Tue, 9 Jan 2018 23:34:39 +0000 (00:34 +0100)
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
pv/data/logicsegment.hpp
pv/data/segment.hpp
pv/views/trace/view.hpp
pv/views/viewbase.cpp
pv/views/viewbase.hpp

index 5267e77e604ed27fa6f3d3ad09ea4779e9d1f3e3..7c74e77678c6e5693f9465dd0bfd221b46c71c3d 100644 (file)
@@ -44,7 +44,7 @@ typedef struct {
        float* value;
 } SegmentAnalogDataIterator;
 
-class AnalogSegment : public QObject, public Segment
+class AnalogSegment : public Segment
 {
        Q_OBJECT
 
index 7becfc3e70c1fc47abacc7dcd124e6c09f0f11a7..2e03fd55585a99f8adbe4e22e753a3aae0fcf9e5 100644 (file)
@@ -54,7 +54,7 @@ typedef struct {
        uint8_t* value;
 } SegmentLogicDataIterator;
 
-class LogicSegment : public QObject, public Segment
+class LogicSegment : public Segment
 {
        Q_OBJECT
 
index 18f1aed77192978ce1a87cbb86aaf7b929672f73..9ea9629dcbd0d8e294b07f46c81573a9fc2c4681 100644 (file)
@@ -27,6 +27,8 @@
 #include <thread>
 #include <vector>
 
+#include <QObject>
+
 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;
 
index 712151dcae30fc2d11a503a04cc90e4ea697f236..679e587bf3036e705820604eb2f23df99d89205f 100644 (file)
@@ -443,8 +443,6 @@ private:
        vector< shared_ptr<DecodeTrace> > 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.
index 7d986fe051e730b55034bb423a0afdc1ca058c87..65cf6842aeee0699686f59990379c48d9a2499c2 100644 (file)
@@ -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<data::SignalBase> 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<data::Segment*>(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())
index 8e71f3bbe221c9b05a0ee36cd84c7a713483e974..c8f72ab7a3caf9e6005379bd253e779974c5b73a 100644 (file)
@@ -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<data::SignalBase> > signalbases_;
 
+       /// The ID of the currently displayed segment
+       uint32_t current_segment_;
+
        QTimer delayed_view_updater_;
 };