This commit is contained in:
Uwe Rathmann 2024-09-02 12:00:41 +02:00
parent 32890fe47f
commit b97507bf84
3 changed files with 41 additions and 7 deletions

View File

@ -120,8 +120,8 @@ void QskArcNode::setArcData( const QRectF& rect, const QskArcMetrics& arcMetrics
metricsArc.startAngle(), metricsArc.spanAngle(), shadowColor );
}
auto pathNode = qskInsertOrRemoveNode< QskShapeNode >(
this, PathRole, hasFilling && !QskArcRenderer::isGradientSupported( gradient ) );
auto pathNode = qskInsertOrRemoveNode< QskShapeNode >( this, PathRole,
hasFilling && !QskArcRenderer::isGradientSupported( rect, metricsArc, gradient ) );
if ( pathNode )
{

View File

@ -442,12 +442,45 @@ namespace
}
}
bool QskArcRenderer::isGradientSupported( const QskGradient& gradient )
bool QskArcRenderer::isGradientSupported( const QRectF& rect,
const QskArcMetrics& metrics, const QskGradient& gradient )
{
if ( gradient.isVisible() && !gradient.isMonochrome() )
return gradient.type() == QskGradient::Stops;
if ( rect.isEmpty() || metrics.isNull() )
return true;
if ( !gradient.isVisible() || gradient.isMonochrome() )
return true;
switch( gradient.type() )
{
case QskGradient::Stops:
{
return true;
}
case QskGradient::Conic:
{
const auto direction = gradient.conicDirection();
if ( direction.center() == rect.center() )
{
const auto aspectRatio = rect.width() / rect.height();
if ( qskFuzzyCompare( direction.aspectRatio(), aspectRatio ) )
{
/*
we should be able to create a list of stops from
this gradient that works for the renderer. TODO ...
*/
}
}
return false;
}
default:
{
return false;
}
}
return false;
}
void QskArcRenderer::renderArc( const QRectF& rect, const QskArcMetrics& metrics,

View File

@ -35,7 +35,8 @@ namespace QskArcRenderer
Filling the geometry with color information:
see QSGGeometry::defaultAttributes_ColoredPoint2D()
*/
QSK_EXPORT bool isGradientSupported( const QskGradient& );
QSK_EXPORT bool isGradientSupported(
const QRectF&, const QskArcMetrics&, const QskGradient& );
QSK_EXPORT void renderArc( const QRectF&, const QskArcMetrics&, bool radial,
qreal borderWidth, const QskGradient&, const QColor& borderColor, QSGGeometry& );