QskBoxRenderer::isGradientSupported introduced
This commit is contained in:
parent
9d409ab89b
commit
c31d554d6b
|
@ -7,6 +7,7 @@
|
||||||
#include "QskBoxFillNode.h"
|
#include "QskBoxFillNode.h"
|
||||||
#include "QskBoxShadowNode.h"
|
#include "QskBoxShadowNode.h"
|
||||||
#include "QskBoxRectangleNode.h"
|
#include "QskBoxRectangleNode.h"
|
||||||
|
#include "QskBoxRenderer.h"
|
||||||
#include "QskSGNode.h"
|
#include "QskSGNode.h"
|
||||||
|
|
||||||
#include "QskGradient.h"
|
#include "QskGradient.h"
|
||||||
|
@ -49,37 +50,6 @@ inline Node* qskNode( QSGNode* parentNode, quint8 role )
|
||||||
return node;
|
return node;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline bool qskIsBoxGradient( const QskGradient& gradient )
|
|
||||||
{
|
|
||||||
if ( !gradient.isVisible() || gradient.isMonochrome() )
|
|
||||||
return true;
|
|
||||||
|
|
||||||
switch( gradient.type() )
|
|
||||||
{
|
|
||||||
case QskGradient::Linear:
|
|
||||||
{
|
|
||||||
auto dir = gradient.linearDirection();
|
|
||||||
|
|
||||||
if ( dir.isTilted() )
|
|
||||||
{
|
|
||||||
// only diagonal from topLeft to bottomRight
|
|
||||||
return ( dir.x1() == dir.x2() ) && ( dir.y1() == dir.y2() );
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
case QskGradient::Radial:
|
|
||||||
case QskGradient::Conic:
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
default:
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
QskBoxNode::QskBoxNode()
|
QskBoxNode::QskBoxNode()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
@ -113,7 +83,7 @@ void QskBoxNode::updateNode( const QRectF& rect,
|
||||||
However the border is always done with a QskBoxRectangleNode
|
However the border is always done with a QskBoxRectangleNode
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if ( qskIsBoxGradient( gradient ) )
|
if ( QskBoxRenderer::isGradientSupported( gradient ) )
|
||||||
{
|
{
|
||||||
rectNode = qskNode< QskBoxRectangleNode >( this, BoxRole );
|
rectNode = qskNode< QskBoxRectangleNode >( this, BoxRole );
|
||||||
rectNode->updateNode( rect, shape, borderMetrics, borderColors, gradient );
|
rectNode->updateNode( rect, shape, borderMetrics, borderColors, gradient );
|
||||||
|
|
|
@ -36,6 +36,8 @@ class QSK_EXPORT QskBoxRenderer
|
||||||
static void renderRect( const QRectF&, const QskGradient&, QSGGeometry& );
|
static void renderRect( const QRectF&, const QskGradient&, QSGGeometry& );
|
||||||
static void renderRect( const QRectF&, QSGGeometry& );
|
static void renderRect( const QRectF&, QSGGeometry& );
|
||||||
|
|
||||||
|
static bool isGradientSupported( const QskGradient& );
|
||||||
|
|
||||||
class Quad
|
class Quad
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
|
@ -681,3 +681,35 @@ void QskBoxRenderer::renderRectFill( const QskBoxRenderer::Quad& rect,
|
||||||
{
|
{
|
||||||
qskCreateFillOrdered( rect, gradient, line );
|
qskCreateFillOrdered( rect, gradient, line );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool QskBoxRenderer::isGradientSupported( const QskGradient& gradient )
|
||||||
|
{
|
||||||
|
if ( !gradient.isVisible() || gradient.isMonochrome() )
|
||||||
|
return true;
|
||||||
|
|
||||||
|
switch( gradient.type() )
|
||||||
|
{
|
||||||
|
case QskGradient::Linear:
|
||||||
|
{
|
||||||
|
auto dir = gradient.linearDirection();
|
||||||
|
|
||||||
|
if ( dir.isTilted() )
|
||||||
|
{
|
||||||
|
// only diagonal from topLeft to bottomRight
|
||||||
|
return ( dir.x1() == dir.x2() ) && ( dir.y1() == dir.y2() );
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
case QskGradient::Radial:
|
||||||
|
case QskGradient::Conic:
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue