This commit is contained in:
Uwe Rathmann 2022-09-29 17:26:15 +02:00
parent f798f2228c
commit 45e59d6c10
3 changed files with 24 additions and 9 deletions

View File

@ -192,9 +192,7 @@ void ShapeItem::updateNode( QSGNode* parentNode )
} }
const auto transform = ::transformForRects( pathRect, rect ); const auto transform = ::transformForRects( pathRect, rect );
borderNode->updateNode( m_path, transform, pen );
const auto scaledPath = transform.map( m_path );
borderNode->updateNode( scaledPath, pen );
} }
else else
{ {

View File

@ -33,11 +33,13 @@ QskStrokeNode::QskStrokeNode()
setMaterial( &d->material ); 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 ); 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 ) 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 ... 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; QTriangulatingStroker stroker;
#if 0
// can we do something useful with this factor ???
stroker.setInvScale( 1.0 );
#endif
if ( pen.style() == Qt::SolidLine ) if ( pen.style() == Qt::SolidLine )
{ {
// clipRect, renderHint are ignored in QTriangulatingStroker::process // clipRect, renderHint are ignored in QTriangulatingStroker::process
stroker.process( qtVectorPathForPath( path ), pen, {}, {} ); stroker.process( qtVectorPathForPath( scaledPath ), pen, {}, {} );
} }
else else
{ {
constexpr QRectF clipRect; // empty rect: no clipping
QDashedStrokeProcessor dashStroker; QDashedStrokeProcessor dashStroker;
dashStroker.process( qtVectorPathForPath( path ), #if 0
pen, QRectF(), {} ); // empty rect: no clipping // can we do something useful with this factor ???
dashStroker.setInvScale( 1.0 );
#endif
dashStroker.process( qtVectorPathForPath( scaledPath ), pen, clipRect, {} );
const QVectorPath dashedVectorPath( dashStroker.points(), const QVectorPath dashedVectorPath( dashStroker.points(),
dashStroker.elementCount(), dashStroker.elementTypes(), 0 ); dashStroker.elementCount(), dashStroker.elementTypes(), 0 );

View File

@ -19,7 +19,7 @@ class QSK_EXPORT QskStrokeNode : public QSGGeometryNode
public: public:
QskStrokeNode(); QskStrokeNode();
void updateNode( const QPainterPath&, const QPen& ); void updateNode( const QPainterPath&, const QTransform&, const QPen& );
private: private:
Q_DECLARE_PRIVATE( QskStrokeNode ) Q_DECLARE_PRIVATE( QskStrokeNode )