From 45e59d6c109e9c586633750e5dec4a9ebc3ce3f9 Mon Sep 17 00:00:00 2001 From: Uwe Rathmann Date: Thu, 29 Sep 2022 17:26:15 +0200 Subject: [PATCH] wip --- playground/shapes/ShapeItem.cpp | 4 +--- src/nodes/QskStrokeNode.cpp | 27 ++++++++++++++++++++++----- src/nodes/QskStrokeNode.h | 2 +- 3 files changed, 24 insertions(+), 9 deletions(-) diff --git a/playground/shapes/ShapeItem.cpp b/playground/shapes/ShapeItem.cpp index a316cb6f..45680947 100644 --- a/playground/shapes/ShapeItem.cpp +++ b/playground/shapes/ShapeItem.cpp @@ -192,9 +192,7 @@ void ShapeItem::updateNode( QSGNode* parentNode ) } const auto transform = ::transformForRects( pathRect, rect ); - - const auto scaledPath = transform.map( m_path ); - borderNode->updateNode( scaledPath, pen ); + borderNode->updateNode( m_path, transform, pen ); } else { diff --git a/src/nodes/QskStrokeNode.cpp b/src/nodes/QskStrokeNode.cpp index 50726f73..2432803d 100644 --- a/src/nodes/QskStrokeNode.cpp +++ b/src/nodes/QskStrokeNode.cpp @@ -33,11 +33,13 @@ QskStrokeNode::QskStrokeNode() setMaterial( &d->material ); } -void QskStrokeNode::updateNode( const QPainterPath& path, const QPen& pen ) +void QskStrokeNode::updateNode( + const QPainterPath& path, const QTransform& transform, const QPen& pen ) { Q_D( QskStrokeNode ); - if ( path.isEmpty() || ( pen.style() == Qt::NoPen ) || ( pen.color().alpha() == 0 ) ) + if ( path.isEmpty() || ( pen.style() == Qt::NoPen ) || + !pen.color().isValid() || ( pen.color().alpha() == 0 ) ) { if ( d->geometry.vertexCount() > 0 ) { @@ -50,18 +52,33 @@ void QskStrokeNode::updateNode( const QPainterPath& path, const QPen& pen ) if ( true ) // For the moment we always update the geometry. TODO ... { + /* + Unfortunately QTriangulatingStroker does not offer on the fly + transformations - like with qTriangulate. TODO ... + */ + const auto scaledPath = transform.map( path ); + QTriangulatingStroker stroker; +#if 0 + // can we do something useful with this factor ??? + stroker.setInvScale( 1.0 ); +#endif if ( pen.style() == Qt::SolidLine ) { // clipRect, renderHint are ignored in QTriangulatingStroker::process - stroker.process( qtVectorPathForPath( path ), pen, {}, {} ); + stroker.process( qtVectorPathForPath( scaledPath ), pen, {}, {} ); } else { + constexpr QRectF clipRect; // empty rect: no clipping + QDashedStrokeProcessor dashStroker; - dashStroker.process( qtVectorPathForPath( path ), - pen, QRectF(), {} ); // empty rect: no clipping +#if 0 + // can we do something useful with this factor ??? + dashStroker.setInvScale( 1.0 ); +#endif + dashStroker.process( qtVectorPathForPath( scaledPath ), pen, clipRect, {} ); const QVectorPath dashedVectorPath( dashStroker.points(), dashStroker.elementCount(), dashStroker.elementTypes(), 0 ); diff --git a/src/nodes/QskStrokeNode.h b/src/nodes/QskStrokeNode.h index 86984473..4e922aed 100644 --- a/src/nodes/QskStrokeNode.h +++ b/src/nodes/QskStrokeNode.h @@ -19,7 +19,7 @@ class QSK_EXPORT QskStrokeNode : public QSGGeometryNode public: QskStrokeNode(); - void updateNode( const QPainterPath&, const QPen& ); + void updateNode( const QPainterPath&, const QTransform&, const QPen& ); private: Q_DECLARE_PRIVATE( QskStrokeNode )