From faf3e7079ddd680ab0e53a27a7ddc0d863792117 Mon Sep 17 00:00:00 2001 From: Berthold Stoeger Date: Fri, 15 Jan 2021 12:22:32 +0100 Subject: statistics: keep track of dirty items in double-linked list So far the items to be recalculated in the drawing thread had a "dirty" flag and were kept in one array par z-level. Once the series are implemented in terms of QSGNodes, there may lots of these items. To make this more efficient when only one or two of these items change (e.g. highlighting due to mouseover), keep the dirty items in a linked list. Of course, this makes the draw first version of the chart less efficient. There are more fancy ways of implementing the double-linked list, but the few ns gained in the render thread are hardly worth it. Signed-off-by: Berthold Stoeger --- stats/statsview.h | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'stats/statsview.h') diff --git a/stats/statsview.h b/stats/statsview.h index c8e850d9b..f472e1e16 100644 --- a/stats/statsview.h +++ b/stats/statsview.h @@ -54,8 +54,8 @@ public: QQuickWindow *w() const; // Make window available to items QSizeF size() const; void addQSGNode(QSGNode *node, ChartZValue z); // Must only be called in render thread! - void registerChartItem(ChartItem *item); - void unregisterChartItem(const ChartItem *item); + void registerDirtyChartItem(ChartItem &item); + void unregisterDirtyChartItem(ChartItem &item); template std::unique_ptr createChartItem(Args&&... args); @@ -142,7 +142,6 @@ private: StatsState state; QFont titleFont; - std::unique_ptr[]> chartItems; std::vector> axes; std::unique_ptr grid; std::vector> series; @@ -162,6 +161,7 @@ private: void mouseReleaseEvent(QMouseEvent *event) override; void mouseMoveEvent(QMouseEvent *event) override; RootNode *rootNode; + ChartItem *firstDirtyChartItem, *lastDirtyChartItem; }; // This implementation detail must be known to users of the class. @@ -170,7 +170,6 @@ template std::unique_ptr StatsView::createChartItem(Args&&... args) { std::unique_ptr res(new T(*this, std::forward(args)...)); - registerChartItem(res.get()); return res; } -- cgit v1.2.3-70-g09d2