QskStrokeNode introduced ( untested so far )
This commit is contained in:
parent
ab34af0b03
commit
b2d7d77640
88
src/nodes/QskStrokeNode.cpp
Normal file
88
src/nodes/QskStrokeNode.cpp
Normal file
@ -0,0 +1,88 @@
|
|||||||
|
/******************************************************************************
|
||||||
|
* QSkinny - Copyright (C) 2016 Uwe Rathmann
|
||||||
|
* This file may be used under the terms of the QSkinny License, Version 1.0
|
||||||
|
*****************************************************************************/
|
||||||
|
|
||||||
|
#include "QskStrokeNode.h"
|
||||||
|
#include <qsgflatcolormaterial.h>
|
||||||
|
|
||||||
|
QSK_QT_PRIVATE_BEGIN
|
||||||
|
#include <private/qsgnode_p.h>
|
||||||
|
#include <private/qtriangulatingstroker_p.h>
|
||||||
|
QSK_QT_PRIVATE_END
|
||||||
|
|
||||||
|
class QskStrokeNodePrivate final : public QSGGeometryNodePrivate
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
QskStrokeNodePrivate()
|
||||||
|
: geometry( QSGGeometry::defaultAttributes_Point2D(), 0 )
|
||||||
|
{
|
||||||
|
geometry.setDrawingMode( QSGGeometry::DrawTriangleStrip );
|
||||||
|
}
|
||||||
|
|
||||||
|
QSGGeometry geometry;
|
||||||
|
QSGFlatColorMaterial material;
|
||||||
|
};
|
||||||
|
|
||||||
|
QskStrokeNode::QskStrokeNode()
|
||||||
|
: QSGGeometryNode( *new QskStrokeNodePrivate )
|
||||||
|
{
|
||||||
|
Q_D( QskStrokeNode );
|
||||||
|
|
||||||
|
setGeometry( &d->geometry );
|
||||||
|
setMaterial( &d->material );
|
||||||
|
}
|
||||||
|
|
||||||
|
void QskStrokeNode::updateNode( const QPainterPath& path, const QPen& pen )
|
||||||
|
{
|
||||||
|
Q_D( QskStrokeNode );
|
||||||
|
|
||||||
|
if ( path.isEmpty() || ( pen.style() == Qt::NoPen ) || ( pen.color().alpha() == 0 ) )
|
||||||
|
{
|
||||||
|
if ( d->geometry.vertexCount() > 0 )
|
||||||
|
{
|
||||||
|
d->geometry.allocate( 0 );
|
||||||
|
markDirty( QSGNode::DirtyGeometry );
|
||||||
|
}
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( true ) // For the moment we always update the geometry. TODO ...
|
||||||
|
{
|
||||||
|
const QVectorPath& vectorPath = qtVectorPathForPath(path);
|
||||||
|
|
||||||
|
QTriangulatingStroker stroker;
|
||||||
|
|
||||||
|
if ( pen.style() == Qt::SolidLine )
|
||||||
|
{
|
||||||
|
// clipRect, renderHint are ignored in QTriangulatingStroker::process
|
||||||
|
stroker.process( vectorPath, pen, {}, {} );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
QDashedStrokeProcessor dashStroker;
|
||||||
|
dashStroker.process( vectorPath, pen, QRectF(), {} ); // empty rect: no clipping
|
||||||
|
|
||||||
|
const QVectorPath dashedVectorPath( dashStroker.points(),
|
||||||
|
dashStroker.elementCount(), dashStroker.elementTypes(), 0 );
|
||||||
|
|
||||||
|
stroker.process( dashedVectorPath, pen, {}, {} );
|
||||||
|
}
|
||||||
|
|
||||||
|
d->geometry.allocate( stroker.vertexCount() );
|
||||||
|
|
||||||
|
memcpy( d->geometry.vertexData(), stroker.vertices(),
|
||||||
|
stroker.vertexCount() * sizeof( float ) );
|
||||||
|
|
||||||
|
markDirty( QSGNode::DirtyGeometry );
|
||||||
|
}
|
||||||
|
|
||||||
|
const auto color = pen.color().toRgb();
|
||||||
|
|
||||||
|
if ( d->material.color() != color )
|
||||||
|
{
|
||||||
|
d->material.setColor( color );
|
||||||
|
markDirty( QSGNode::DirtyMaterial );
|
||||||
|
}
|
||||||
|
}
|
28
src/nodes/QskStrokeNode.h
Normal file
28
src/nodes/QskStrokeNode.h
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
/******************************************************************************
|
||||||
|
* QSkinny - Copyright (C) 2016 Uwe Rathmann
|
||||||
|
* This file may be used under the terms of the QSkinny License, Version 1.0
|
||||||
|
*****************************************************************************/
|
||||||
|
|
||||||
|
#ifndef QSK_STROKE_NODE_H
|
||||||
|
#define QSK_STROKE_NODE_H
|
||||||
|
|
||||||
|
#include "QskGlobal.h"
|
||||||
|
#include <qsgnode.h>
|
||||||
|
|
||||||
|
class QPen;
|
||||||
|
class QPainterPath;
|
||||||
|
|
||||||
|
class QskStrokeNodePrivate;
|
||||||
|
|
||||||
|
class QSK_EXPORT QskStrokeNode : public QSGGeometryNode
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
QskStrokeNode();
|
||||||
|
|
||||||
|
void updateNode( const QPainterPath&, const QPen& );
|
||||||
|
|
||||||
|
private:
|
||||||
|
Q_DECLARE_PRIVATE( QskStrokeNode )
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
@ -111,6 +111,7 @@ HEADERS += \
|
|||||||
nodes/QskScaleRenderer.h \
|
nodes/QskScaleRenderer.h \
|
||||||
nodes/QskSGNode.h \
|
nodes/QskSGNode.h \
|
||||||
nodes/QskShadedBoxNode.h \
|
nodes/QskShadedBoxNode.h \
|
||||||
|
nodes/QskStrokeNode.h \
|
||||||
nodes/QskTextNode.h \
|
nodes/QskTextNode.h \
|
||||||
nodes/QskTextRenderer.h \
|
nodes/QskTextRenderer.h \
|
||||||
nodes/QskTextureRenderer.h \
|
nodes/QskTextureRenderer.h \
|
||||||
@ -133,6 +134,7 @@ SOURCES += \
|
|||||||
nodes/QskScaleRenderer.cpp \
|
nodes/QskScaleRenderer.cpp \
|
||||||
nodes/QskSGNode.cpp \
|
nodes/QskSGNode.cpp \
|
||||||
nodes/QskShadedBoxNode.cpp \
|
nodes/QskShadedBoxNode.cpp \
|
||||||
|
nodes/QskStrokeNode.cpp \
|
||||||
nodes/QskTextNode.cpp \
|
nodes/QskTextNode.cpp \
|
||||||
nodes/QskTextRenderer.cpp \
|
nodes/QskTextRenderer.cpp \
|
||||||
nodes/QskTextureRenderer.cpp \
|
nodes/QskTextureRenderer.cpp \
|
||||||
|
Loading…
x
Reference in New Issue
Block a user