QskBoxRenderer fixes

This commit is contained in:
Uwe Rathmann 2023-01-04 16:15:22 +01:00
parent 25558dd50d
commit 1b85d3053e
2 changed files with 34 additions and 59 deletions

View File

@ -74,14 +74,9 @@ bool QskBoxRenderer::isGradientSupported(
// rectangles are fully supported // rectangles are fully supported
return true; return true;
} }
else
{
/*
For rounded rectangles we currently support
only the most common use cases. TODO ...
*/
const auto dir = gradient.linearDirection(); const auto dir = gradient.linearDirection();
if ( dir.isTilted() ) if ( dir.isTilted() )
{ {
return ( dir.x1() == 0.0 && dir.x2() == 0.0 ) return ( dir.x1() == 0.0 && dir.x2() == 0.0 )
@ -89,10 +84,32 @@ bool QskBoxRenderer::isGradientSupported(
} }
else else
{ {
return ( dir.x1() == 0.0 && dir.x2() == 1.0 ) // different radii at oppsoite corners are not implemented TODO ...
|| ( dir.y1() == 0.0 && dir.y2() == 1.0 );
const auto r1 = shape.radius( Qt::TopLeftCorner );
const auto r2 = shape.radius( Qt::TopRightCorner );
const auto r3 = shape.radius( Qt::BottomLeftCorner );
const auto r4 = shape.radius( Qt::BottomRightCorner );
if ( dir.isHorizontal() )
{
if ( dir.x1() == 0.0 && dir.x2() == 1.0 )
{
return ( r1.width() == r3.width() )
&& ( r2.width() == r4.width() );
} }
} }
else
{
if ( dir.y1() == 0.0 && dir.y2() == 1.0 )
{
return ( r1.height() == r2.height() )
&& ( r3.height() == r4.height() );
}
}
}
return false;
} }
default: default:

View File

@ -6,7 +6,7 @@
#ifndef QSK_BOX_RENDERER_H #ifndef QSK_BOX_RENDERER_H
#define QSK_BOX_RENDERER_H #define QSK_BOX_RENDERER_H
#include "QskVertex.h" #include "QskGlobal.h"
class QskBoxBorderMetrics; class QskBoxBorderMetrics;
class QskBoxBorderColors; class QskBoxBorderColors;
@ -16,61 +16,19 @@ class QskGradient;
class QSGGeometry; class QSGGeometry;
class QRectF; class QRectF;
class QSK_EXPORT QskBoxRenderer namespace QskBoxRenderer
{ {
public: QSK_EXPORT void renderBorder( const QRectF&,
static void renderBorder( const QRectF&,
const QskBoxShapeMetrics&, const QskBoxBorderMetrics&, QSGGeometry& ); const QskBoxShapeMetrics&, const QskBoxBorderMetrics&, QSGGeometry& );
static void renderFill( const QRectF&, QSK_EXPORT void renderFill( const QRectF&,
const QskBoxShapeMetrics&, const QskBoxBorderMetrics&, QSGGeometry& ); const QskBoxShapeMetrics&, const QskBoxBorderMetrics&, QSGGeometry& );
static void renderBox( const QRectF&, QSK_EXPORT void renderBox( const QRectF&,
const QskBoxShapeMetrics&, const QskBoxBorderMetrics&, const QskBoxShapeMetrics&, const QskBoxBorderMetrics&,
const QskBoxBorderColors&, const QskGradient&, QSGGeometry& ); const QskBoxBorderColors&, const QskGradient&, QSGGeometry& );
static bool isGradientSupported( const QskBoxShapeMetrics&, const QskGradient& ); QSK_EXPORT bool isGradientSupported( const QskBoxShapeMetrics&, const QskGradient& );
}
class Metrics
{
public:
Metrics( const QRectF&, const QskBoxShapeMetrics&, const QskBoxBorderMetrics& );
QskVertex::Quad outerQuad;
QskVertex::Quad innerQuad;
#if 1
QskVertex::Quad centerQuad; // to be removed
#endif
struct Corner
{
bool isCropped;
qreal centerX, centerY;
qreal radiusX, radiusY;
qreal radiusInnerX, radiusInnerY;
int stepCount;
} corner[ 4 ];
bool isBorderRegular;
bool isRadiusRegular;
bool isTotallyCropped;
};
private:
static void renderRectellipseFill( const QRectF&,
const QskBoxShapeMetrics&, const QskBoxBorderMetrics&, QSGGeometry& );
static void renderRectellipseBorder( const QRectF&,
const QskBoxShapeMetrics&, const QskBoxBorderMetrics&, QSGGeometry& );
static void renderRectellipse( const QRectF&,
const QskBoxShapeMetrics&, const QskBoxBorderMetrics&,
const QskBoxBorderColors&, const QskGradient&, QSGGeometry& );
static void renderDiagonalFill( const Metrics&, const QskGradient&,
int lineCount, QskVertex::ColoredLine* );
};
#endif #endif