[Development] QSGNode::markDirty no longer works?

achartier at fastmail.fm achartier at fastmail.fm
Thu Dec 5 02:04:37 CET 2013


It looks like using QSGNode::DirtyGeometry did the trick. I would have
expected QSGNode::DirtyForceUpdate to work though. Is this a bug?

On Wed, Dec 4, 2013, at 02:14 PM, achartier at fastmail.fm wrote:
> Hi,
> 
> I had a QQuickItem-based 2D linegraph working fine in prior versions of
> Qt 5. This code does not seem to work with Qt 5.2 RC 1. Below is the
> relevant code of my QQuickItem-based linegraph:
> 
> QSGNode* Linegraph::updatePaintNode(QSGNode* oldNode,
> UpdatePaintNodeData* updatePaintNodeData)
> {
>     Q_UNUSED(updatePaintNodeData);
> 
>     QSGGeometryNode* node = nullptr;
>     QSGGeometry* geometry = nullptr;
>     QSGFlatColorMaterial* material = nullptr;
> 
>     if (!oldNode)
>     {
>         node = new QSGGeometryNode();
>         geometry = new
>         QSGGeometry(QSGGeometry::defaultAttributes_Point2D(), 1000);
>         geometry->setLineWidth(1);
>         geometry->setDrawingMode(GL_LINE_STRIP);
>         geometry->allocate(1000);
>         node->setGeometry(geometry);
>         node->setFlag(QSGNode::OwnsGeometry);
>         material = new QSGFlatColorMaterial();
>         node->setMaterial(material);
>         node->setFlag(QSGNode::OwnsMaterial);
>     }
>     else
>     {
>         node = static_cast<QSGGeometryNode*>(oldNode);
>         geometry = node->geometry();
>         material = static_cast<QSGFlatColorMaterial*>(node->material());
>     }
> 
>     const QRectF bounds = boundingRect();
>     const float horizontalPointSpacing = (float)bounds.width() / (1000 -
>     1.0f);
>     QSGGeometry::Point2D* vertices = geometry->vertexDataAsPoint2D();
> 
>     float currentX = 0.0f;
>     float currentY = 0.0f;
> 
>     for (quint32 pointIndex = 0; pointIndex < m_numOfTracePoints;
>     ++pointIndex)
>     {
>         currentX = 1.0f + pointIndex * horizontalPointSpacing;
>         currentY = qBound(0.0f, (m_data[pointIndex] * (-1)) / 100000.0f,
>         1.0f) * (float)bounds.height();
> 
>         vertices[pointIndex].set(currentX, currentY);
>     }
> 
>     node->markDirty(QSGNode::DirtyForceUpdate);
> 
>     return node;
> }
> 
> In prior versions of Qt, the second to last line
> (node->markDirty(QSGNode::DirtyForceUpdate)) was needed, otherwise
> updates to the "vertices" point array would not be reflected in what
> gets drawn. Now, with Qt 5.2 RC 1, changes made to the points stored in
> the "vertices" point array are never reflected in what is drawn:
> whatever the array is initialized with is what is drawn in all
> subsequent updates.
> 
> Is this a user error on my part? Should I be using something other than
> QSGNode::markDirty to force the "vertices" point array changes to take
> effect? Or is this perhaps a bug in Qt 5.2 RC 1?
> 
> Any help is greatly appreciated.
> 
> Thanks.



More information about the Development mailing list