This commit is contained in:
Uwe Rathmann 2024-09-20 11:58:32 +02:00
parent 28f818b62a
commit b17cabaa83
4 changed files with 73 additions and 19 deletions

View File

@ -20,6 +20,31 @@ class QskArcRenderNodePrivate final : public QskFillNodePrivate
node->resetGeometry(); node->resetGeometry();
} }
inline bool updateHash( const QRectF& rect, const QskArcMetrics& metrics,
bool radial, qreal borderWidth, const QColor& borderColor,
const QskGradient& gradient )
{
QskHashValue value = 3496;
value = qHashBits( &rect, sizeof( QRectF ), value );
value = metrics.hash( value );
value = qHash( radial, value );
value = qHash( borderWidth, value );
value = qHashBits( &borderColor, sizeof( borderColor ), value );
if ( gradient.isVisible() )
value = gradient.hash( value );
if ( hash != value )
{
hash = value;
return true;
}
return false;
}
private:
QskHashValue hash = 0; QskHashValue hash = 0;
}; };
@ -39,10 +64,45 @@ void QskArcRenderNode::updateFilling( const QRectF& rect,
} }
void QskArcRenderNode::updateFilling( const QRectF& rect, void QskArcRenderNode::updateFilling( const QRectF& rect,
const QskArcMetrics& metrics, bool radial, const QskArcMetrics& arcMetrics, bool radial,
qreal borderWidth, const QskGradient& gradient ) qreal borderWidth, const QskGradient& gradient )
{ {
updateArc( rect, metrics, radial, borderWidth, QColor(), gradient ); Q_D( QskArcRenderNode );
const auto metrics = arcMetrics.toAbsolute( rect.size() );
const auto borderMax = 0.5 * metrics.thickness();
const bool hasFill = gradient.isVisible() && ( borderWidth < borderMax );
const bool hasBorder = false;
if ( rect.isEmpty() || metrics.isNull() || !( hasFill || hasBorder ) )
{
d->resetNode( this );
return;
}
borderWidth = qMin( borderWidth, borderMax );
if ( !d->updateHash( rect, metrics, radial, borderWidth, QColor(), gradient ) )
{
d->resetNode( this );
return;
}
#if 1
const bool coloredGeometry = hasHint( PreferColoredGeometry )
&& QskArcRenderer::isGradientSupported( rect, metrics, gradient );
Q_ASSERT( coloredGeometry ); // TODO ...
#endif
auto& geometry = *this->geometry();
setColoring( QskFillNode::Polychrome );
QskArcRenderer::setColoredFillLines( rect, metrics, radial,
borderWidth, gradient, geometry );
markDirty( QSGNode::DirtyGeometry );
} }
void QskArcRenderNode::updateBorder( const QRectF& rect, void QskArcRenderNode::updateBorder( const QRectF& rect,
@ -73,19 +133,11 @@ void QskArcRenderNode::updateArc(
borderWidth = qMin( borderWidth, borderMax ); borderWidth = qMin( borderWidth, borderMax );
QskHashValue hash = 3496; if ( !d->updateHash( rect, metrics, radial, borderWidth, borderColor, gradient ) )
{
hash = qHashBits( &rect, sizeof( QRectF ), hash ); d->resetNode( this );
hash = qHash( borderWidth, hash );
hash = qHashBits( &borderColor, sizeof( borderColor ), hash );
hash = metrics.hash( hash );
hash = gradient.hash( hash );
hash = qHash( radial, hash );
if ( hash == d->hash )
return; return;
}
d->hash = hash;
#if 1 #if 1
const bool coloredGeometry = hasHint( PreferColoredGeometry ) const bool coloredGeometry = hasHint( PreferColoredGeometry )

View File

@ -505,7 +505,7 @@ void QskArcRenderer::setColoredBorderLines( const QRectF& rect,
} }
void QskArcRenderer::setColoredFillLines( const QRectF& rect, const QskArcMetrics& metrics, void QskArcRenderer::setColoredFillLines( const QRectF& rect, const QskArcMetrics& metrics,
bool radial, const QskGradient& gradient, QSGGeometry& geometry ) bool radial, qreal borderWidth, const QskGradient& gradient, QSGGeometry& geometry )
{ {
geometry.setDrawingMode( QSGGeometry::DrawTriangleStrip ); geometry.setDrawingMode( QSGGeometry::DrawTriangleStrip );
geometry.markVertexDataDirty(); geometry.markVertexDataDirty();
@ -520,7 +520,7 @@ void QskArcRenderer::setColoredFillLines( const QRectF& rect, const QskArcMetric
if ( const auto lines = qskAllocateColoredLines( geometry, renderer.fillCount() ) ) if ( const auto lines = qskAllocateColoredLines( geometry, renderer.fillCount() ) )
{ {
renderer.renderArc( metrics.thickness(), 0.0, lines, renderer.renderArc( metrics.thickness(), borderWidth, lines,
static_cast< QskVertex::ColoredLine* >( nullptr ) ); static_cast< QskVertex::ColoredLine* >( nullptr ) );
} }
} }

View File

@ -45,7 +45,8 @@ namespace QskArcRenderer
const QColor& borderColor, QSGGeometry& ); const QColor& borderColor, QSGGeometry& );
QSK_EXPORT void setColoredFillLines( const QRectF&, QSK_EXPORT void setColoredFillLines( const QRectF&,
const QskArcMetrics&, bool radial, const QskGradient&, QSGGeometry& ); const QskArcMetrics&, bool radial, qreal borderWidth,
const QskGradient&, QSGGeometry& );
QSK_EXPORT void setColoredBorderAndFillLines( const QRectF&, QSK_EXPORT void setColoredBorderAndFillLines( const QRectF&,
const QskArcMetrics&, bool radial, qreal borderWidth, const QskArcMetrics&, bool radial, qreal borderWidth,

View File

@ -21,7 +21,7 @@ class QskBoxRectangleNodePrivate final : public QskFillNodePrivate
node->resetGeometry(); node->resetGeometry();
} }
bool updateMetrics( const QRectF& rect, inline bool updateMetrics( const QRectF& rect,
const QskBoxShapeMetrics& shape, const QskBoxBorderMetrics& borderMetrics ) const QskBoxShapeMetrics& shape, const QskBoxBorderMetrics& borderMetrics )
{ {
QskHashValue hash = 13000; QskHashValue hash = 13000;
@ -33,7 +33,8 @@ class QskBoxRectangleNodePrivate final : public QskFillNodePrivate
return updateValue( m_metricsHash, hash ); return updateValue( m_metricsHash, hash );
} }
bool updateColors( const QskBoxBorderColors& borderColors, const QskGradient& gradient ) inline bool updateColors(
const QskBoxBorderColors& borderColors, const QskGradient& gradient )
{ {
QskHashValue hash = 13000; QskHashValue hash = 13000;