QskArcRenderNode is a QskFillNode now
This commit is contained in:
parent
cf33edb560
commit
5c80504c57
|
@ -9,44 +9,23 @@
|
||||||
#include "QskArcMetrics.h"
|
#include "QskArcMetrics.h"
|
||||||
#include "QskGradient.h"
|
#include "QskGradient.h"
|
||||||
#include "QskSGNode.h"
|
#include "QskSGNode.h"
|
||||||
|
#include "QskFillNodePrivate.h"
|
||||||
|
|
||||||
QSK_QT_PRIVATE_BEGIN
|
class QskArcRenderNodePrivate final : public QskFillNodePrivate
|
||||||
#include <private/qsgnode_p.h>
|
|
||||||
QSK_QT_PRIVATE_END
|
|
||||||
|
|
||||||
#if 1
|
|
||||||
#include <qsgvertexcolormaterial.h>
|
|
||||||
#include <qglobalstatic.h>
|
|
||||||
// deriving from QskFillNode:TODO ...
|
|
||||||
Q_GLOBAL_STATIC( QSGVertexColorMaterial, qskMaterialColorVertex )
|
|
||||||
#endif
|
|
||||||
|
|
||||||
class QskArcRenderNodePrivate final : public QSGGeometryNodePrivate
|
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
QskArcRenderNodePrivate()
|
inline void resetValues() { hash = 0; }
|
||||||
: geometry( QSGGeometry::defaultAttributes_ColoredPoint2D(), 0 )
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
inline void resetValues()
|
|
||||||
{
|
|
||||||
hash = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
QSGGeometry geometry;
|
|
||||||
QskHashValue hash = 0;
|
QskHashValue hash = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
QskArcRenderNode::QskArcRenderNode()
|
QskArcRenderNode::QskArcRenderNode()
|
||||||
: QSGGeometryNode( *new QskArcRenderNodePrivate )
|
: QskFillNode( *new QskArcRenderNodePrivate )
|
||||||
{
|
{
|
||||||
Q_D( QskArcRenderNode );
|
}
|
||||||
|
|
||||||
setGeometry( &d->geometry );
|
QskArcRenderNode::~QskArcRenderNode()
|
||||||
|
{
|
||||||
setMaterial( qskMaterialColorVertex );
|
|
||||||
setFlag( QSGNode::OwnsMaterial, false );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void QskArcRenderNode::updateNode( const QRectF& rect,
|
void QskArcRenderNode::updateNode( const QRectF& rect,
|
||||||
|
@ -70,18 +49,11 @@ void QskArcRenderNode::updateNode(
|
||||||
const auto metrics = arcMetrics.toAbsolute( rect.size() );
|
const auto metrics = arcMetrics.toAbsolute( rect.size() );
|
||||||
const auto borderMax = 0.5 * metrics.thickness();
|
const auto borderMax = 0.5 * metrics.thickness();
|
||||||
|
|
||||||
bool visible = !( rect.isEmpty() || metrics.isNull() );
|
const bool hasFill = gradient.isVisible() && ( borderWidth < borderMax );
|
||||||
if ( visible )
|
const bool hasBorder = ( borderWidth > 0.0 )
|
||||||
{
|
|
||||||
visible = gradient.isVisible() && ( borderWidth < borderMax );
|
|
||||||
if ( !visible )
|
|
||||||
{
|
|
||||||
visible = ( borderWidth > 0.0 )
|
|
||||||
&& borderColor.isValid() && ( borderColor.alpha() > 0 );
|
&& borderColor.isValid() && ( borderColor.alpha() > 0 );
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( !visible )
|
if ( rect.isEmpty() || metrics.isNull() || !( hasFill || hasBorder ) )
|
||||||
{
|
{
|
||||||
d->resetValues();
|
d->resetValues();
|
||||||
QskSGNode::resetGeometry( this );
|
QskSGNode::resetGeometry( this );
|
||||||
|
@ -100,14 +72,50 @@ void QskArcRenderNode::updateNode(
|
||||||
hash = gradient.hash( hash );
|
hash = gradient.hash( hash );
|
||||||
hash = qHash( radial, hash );
|
hash = qHash( radial, hash );
|
||||||
|
|
||||||
if ( hash != d->hash )
|
if ( hash == d->hash )
|
||||||
{
|
return;
|
||||||
|
|
||||||
d->hash = hash;
|
d->hash = hash;
|
||||||
|
|
||||||
|
auto coloring = QskFillNode::Polychrome;
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
if ( !( hasFill && hasBorder ) )
|
||||||
|
{
|
||||||
|
if ( hasBorder || ( hasFill && gradient.isMonochrome() ) )
|
||||||
|
coloring = QskFillNode::Monochrome;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
auto& geometry = *this->geometry();
|
||||||
|
|
||||||
|
if ( coloring == QskFillNode::Polychrome )
|
||||||
|
{
|
||||||
|
setColoring( coloring );
|
||||||
|
|
||||||
QskArcRenderer::renderArc( rect, metrics, radial,
|
QskArcRenderer::renderArc( rect, metrics, radial,
|
||||||
borderWidth, gradient, borderColor, *geometry() );
|
borderWidth, gradient, borderColor, geometry );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if ( hasFill )
|
||||||
|
{
|
||||||
|
setColoring( gradient.rgbStart() );
|
||||||
|
|
||||||
|
QskArcRenderer::renderArc( rect, metrics, radial,
|
||||||
|
borderWidth, gradient, borderColor, geometry );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
setColoring( borderColor );
|
||||||
|
|
||||||
|
QskArcRenderer::renderArc( rect, metrics, radial,
|
||||||
|
borderWidth, gradient, borderColor, geometry );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
markDirty( QSGNode::DirtyGeometry );
|
markDirty( QSGNode::DirtyGeometry );
|
||||||
markDirty( QSGNode::DirtyMaterial );
|
markDirty( QSGNode::DirtyMaterial );
|
||||||
}
|
|
||||||
|
geometry.markVertexDataDirty();
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,23 +7,25 @@
|
||||||
#define QSK_ARC_RENDER_NODE_H
|
#define QSK_ARC_RENDER_NODE_H
|
||||||
|
|
||||||
#include "QskGlobal.h"
|
#include "QskGlobal.h"
|
||||||
#include <qsgnode.h>
|
#include "QskFillNode.h"
|
||||||
|
|
||||||
class QskGradient;
|
class QskGradient;
|
||||||
class QskArcMetrics;
|
class QskArcMetrics;
|
||||||
|
|
||||||
class QskArcRenderNodePrivate;
|
class QskArcRenderNodePrivate;
|
||||||
|
|
||||||
class QSK_EXPORT QskArcRenderNode : public QSGGeometryNode
|
class QSK_EXPORT QskArcRenderNode : public QskFillNode
|
||||||
{
|
{
|
||||||
using Inherited = QSGGeometryNode;
|
using Inherited = QskFillNode;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
QskArcRenderNode();
|
QskArcRenderNode();
|
||||||
|
~QskArcRenderNode() override;
|
||||||
|
|
||||||
void updateNode( const QRectF&, const QskArcMetrics&, const QskGradient& );
|
void updateNode( const QRectF&, const QskArcMetrics&, const QskGradient& );
|
||||||
void updateNode( const QRectF&, const QskArcMetrics&, qreal borderWidth,
|
|
||||||
const QColor& borderColor );
|
void updateNode( const QRectF&, const QskArcMetrics&,
|
||||||
|
qreal borderWidth, const QColor& borderColor );
|
||||||
|
|
||||||
void updateNode( const QRectF&, const QskArcMetrics&, bool radial,
|
void updateNode( const QRectF&, const QskArcMetrics&, bool radial,
|
||||||
qreal borderWidth, const QColor& borderColor, const QskGradient& );
|
qreal borderWidth, const QColor& borderColor, const QskGradient& );
|
||||||
|
|
Loading…
Reference in New Issue