mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
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 <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
parent
ada5e8a49d
commit
faf3e7079d
4 changed files with 49 additions and 36 deletions
|
@ -14,13 +14,15 @@ static int round_up(double f)
|
|||
}
|
||||
|
||||
ChartItem::ChartItem(StatsView &v, ChartZValue z) :
|
||||
dirty(false), zValue(z), view(v)
|
||||
dirty(false), dirtyPrev(nullptr), dirtyNext(nullptr),
|
||||
zValue(z), view(v)
|
||||
{
|
||||
}
|
||||
|
||||
ChartItem::~ChartItem()
|
||||
{
|
||||
view.unregisterChartItem(this);
|
||||
if (dirty)
|
||||
view.unregisterDirtyChartItem(*this);
|
||||
}
|
||||
|
||||
QSizeF ChartItem::sceneSize() const
|
||||
|
@ -41,19 +43,17 @@ ChartPixmapItem::~ChartPixmapItem()
|
|||
void ChartPixmapItem::setTextureDirty()
|
||||
{
|
||||
textureDirty = true;
|
||||
dirty = true;
|
||||
view.registerDirtyChartItem(*this);
|
||||
}
|
||||
|
||||
void ChartPixmapItem::setPositionDirty()
|
||||
{
|
||||
positionDirty = true;
|
||||
dirty = true;
|
||||
view.registerDirtyChartItem(*this);
|
||||
}
|
||||
|
||||
void ChartPixmapItem::render()
|
||||
{
|
||||
if (!dirty)
|
||||
return;
|
||||
if (!node) {
|
||||
node.reset(view.w()->createImageNode());
|
||||
view.addQSGNode(node.get(), zValue);
|
||||
|
@ -71,7 +71,6 @@ void ChartPixmapItem::render()
|
|||
node->setRect(rect);
|
||||
positionDirty = false;
|
||||
}
|
||||
dirty = false;
|
||||
}
|
||||
|
||||
void ChartPixmapItem::resize(QSizeF size)
|
||||
|
@ -161,5 +160,5 @@ void ChartLineItem::setLine(QPointF fromIn, QPointF toIn)
|
|||
from = fromIn;
|
||||
to = toIn;
|
||||
positionDirty = true;
|
||||
dirty = true;
|
||||
view.registerDirtyChartItem(*this);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue