resolving QskGradient::Stops depends on the shape and can't be resolved

in QskFillNode.
This commit is contained in:
Uwe Rathmann 2024-09-24 12:20:03 +02:00
parent b6cd4a23d7
commit a989ff92c9
3 changed files with 33 additions and 11 deletions

View File

@ -104,8 +104,17 @@ void QskArcRenderNode::updateFilling( const QRectF& rect,
return; return;
} }
const bool coloredGeometry = hasHint( PreferColoredGeometry ) bool coloredGeometry = hasHint( PreferColoredGeometry );
&& QskArcRenderer::isGradientSupported( rect, metrics, gradient ); if ( coloredGeometry )
{
// not all gradients are supported by the renderer
coloredGeometry = QskArcRenderer::isGradientSupported( rect, metrics, gradient );
}
else
{
// QskGradient::Stops is specific for QskArcRenderer
coloredGeometry = ( gradient.type() == QskGradient::Stops );
}
bool dirtyGeometry = d->updateMetrics( rect, metrics, radial, borderWidth ); bool dirtyGeometry = d->updateMetrics( rect, metrics, radial, borderWidth );
bool dirtyMaterial = d->updateColors( QColor(), gradient ); bool dirtyMaterial = d->updateColors( QColor(), gradient );

View File

@ -458,6 +458,7 @@ bool QskArcRenderer::isGradientSupported( const QRectF& rect,
} }
case QskGradient::Conic: case QskGradient::Conic:
{ {
#if 0
const auto direction = gradient.conicDirection(); const auto direction = gradient.conicDirection();
if ( direction.center() == rect.center() ) if ( direction.center() == rect.center() )
{ {
@ -470,6 +471,7 @@ bool QskArcRenderer::isGradientSupported( const QRectF& rect,
*/ */
} }
} }
#endif
return false; return false;
} }
@ -572,7 +574,7 @@ void QskArcRenderer::setBorderLines( const QRectF& rect,
return; return;
} }
const Renderer renderer( rect, metrics, radial, QskGradient(), 0 ); const Renderer renderer( rect, metrics, radial, QskGradient(), QskRgb::Black );
const auto lines = qskAllocateLines( geometry, renderer.borderCount() ); const auto lines = qskAllocateLines( geometry, renderer.borderCount() );
if ( lines ) if ( lines )

View File

@ -136,10 +136,12 @@ void QskFillNode::setColoring( const QColor& color )
{ {
setColoring( Monochrome ); setColoring( Monochrome );
const auto colorRgb = color.toRgb();
auto mat = static_cast< QSGFlatColorMaterial* >( material() ); auto mat = static_cast< QSGFlatColorMaterial* >( material() );
if ( mat->color() != color ) if ( mat->color() != colorRgb )
{ {
mat->setColor( color ); mat->setColor( colorRgb );
markDirty( QSGNode::DirtyMaterial ); markDirty( QSGNode::DirtyMaterial );
} }
} }
@ -148,17 +150,26 @@ void QskFillNode::setColoring( const QRectF& rect, const QskGradient& gradient )
{ {
if ( gradient.isMonochrome() ) if ( gradient.isMonochrome() )
{ {
setColoring( gradient.startColor().toRgb() ); setColoring( gradient.startColor() );
} }
else else
{ {
const auto effectiveGradient = gradient.effectiveGradient(); if ( gradient.type() == QskGradient::Stops )
setColoring( qskColoring( effectiveGradient.type() ) ); {
qWarning() << "QskFillNode::setColoring:"
<< "QskGradient::Stops is not supported, using the first color instead.";
setColoring( gradient.startColor() );
}
else
{
setColoring( qskColoring( gradient.type() ) );
auto mat = static_cast< QskGradientMaterial* >( material() ); auto mat = static_cast< QskGradientMaterial* >( material() );
if ( mat->updateGradient( rect, effectiveGradient ) ) if ( mat->updateGradient( rect, gradient ) )
markDirty( QSGNode::DirtyMaterial ); markDirty( QSGNode::DirtyMaterial );
} }
}
} }
void QskFillNode::setHint( Hint hint, bool on ) void QskFillNode::setHint( Hint hint, bool on )