QskSGNode::resetGeometry added

This commit is contained in:
Uwe Rathmann 2022-12-05 17:00:54 +01:00
parent 740101b9a2
commit 6ed417873e
4 changed files with 21 additions and 22 deletions

View File

@ -10,6 +10,7 @@
#include "QskBoxShapeMetrics.h" #include "QskBoxShapeMetrics.h"
#include "QskBoxBorderMetrics.h" #include "QskBoxBorderMetrics.h"
#include "QskBoxRenderer.h" #include "QskBoxRenderer.h"
#include "QskSGNode.h"
#include <qsgflatcolormaterial.h> #include <qsgflatcolormaterial.h>
@ -41,16 +42,6 @@ static inline QskGradient qskEffectiveGradient( const QskGradient& gradient )
return gradient; return gradient;
} }
static inline void qskResetGeometry( QskBoxFillNode* node )
{
auto g = node->geometry();
if ( g->vertexCount() > 0 )
{
g->allocate( 0 );
node->markDirty( QSGNode::DirtyGeometry );
}
}
class QskBoxFillNodePrivate final : public QSGGeometryNodePrivate class QskBoxFillNodePrivate final : public QSGGeometryNodePrivate
{ {
public: public:
@ -86,7 +77,7 @@ void QskBoxFillNode::updateNode(
{ {
d->rect = QRectF(); d->rect = QRectF();
d->metricsHash = 0; d->metricsHash = 0;
qskResetGeometry( this ); QskSGNode::resetGeometry( this );
return; return;
} }

View File

@ -166,3 +166,18 @@ void QskSGNode::replaceChildNode(
delete oldNode; delete oldNode;
} }
} }
void QskSGNode::resetGeometry( QSGGeometryNode* node )
{
if ( node )
{
if ( auto g = node->geometry() )
{
if ( g->vertexCount() > 0 || g->indexCount() > 0 )
{
g->allocate( 0, 0 );
node->markDirty( QSGNode::DirtyGeometry );
}
}
}
}

View File

@ -84,6 +84,8 @@ namespace QskSGNode
return static_cast< Node* >( node ); return static_cast< Node* >( node );
} }
void resetGeometry( QSGGeometryNode* );
} }
#endif #endif

View File

@ -7,6 +7,7 @@
#include "QskGradientMaterial.h" #include "QskGradientMaterial.h"
#include "QskGradient.h" #include "QskGradient.h"
#include "QskGradientDirection.h" #include "QskGradientDirection.h"
#include "QskSGNode.h"
#include <qsgflatcolormaterial.h> #include <qsgflatcolormaterial.h>
@ -73,16 +74,6 @@ static void qskUpdateGeometry( const QPainterPath& path,
#endif #endif
} }
static inline void qskResetGeometry( QskShapeNode* node )
{
auto g = node->geometry();
if ( g->vertexCount() > 0 )
{
g->allocate( 0 );
node->markDirty( QSGNode::DirtyGeometry );
}
}
class QskShapeNodePrivate final : public QSGGeometryNodePrivate class QskShapeNodePrivate final : public QSGGeometryNodePrivate
{ {
public: public:
@ -122,7 +113,7 @@ void QskShapeNode::updateNode( const QPainterPath& path,
{ {
d->path = QPainterPath(); d->path = QPainterPath();
d->transform = QTransform(); d->transform = QTransform();
qskResetGeometry( this ); QskSGNode::resetGeometry( this );
return; return;
} }