Merge branch 'master' into features/arcrenderer
This commit is contained in:
commit
4e83c4f2ef
|
@ -233,3 +233,17 @@ float qskConstrainedRadians( float radians )
|
||||||
|
|
||||||
return radians;
|
return radians;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// do not export;
|
||||||
|
bool qskHasEnvironment( const char* env )
|
||||||
|
{
|
||||||
|
bool ok;
|
||||||
|
|
||||||
|
const int value = qEnvironmentVariableIntValue( env, &ok );
|
||||||
|
if ( ok )
|
||||||
|
return value != 0;
|
||||||
|
|
||||||
|
// All other strings are true, apart from "false"
|
||||||
|
auto result = qgetenv( env );
|
||||||
|
return !result.isEmpty() && result != "false";
|
||||||
|
}
|
||||||
|
|
|
@ -209,6 +209,16 @@ namespace QskRgb
|
||||||
return toTransparent( rgb, qRound( opacity * 255 ) );
|
return toTransparent( rgb, qRound( opacity * 255 ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline bool isVisible( QRgb rgb )
|
||||||
|
{
|
||||||
|
return qAlpha( rgb ) > 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline bool isVisible( const QColor& color )
|
||||||
|
{
|
||||||
|
return color.isValid() && color.alpha() > 0;
|
||||||
|
}
|
||||||
|
|
||||||
QSK_EXPORT QRgb lighter( QRgb, int factor = 150 ) noexcept;
|
QSK_EXPORT QRgb lighter( QRgb, int factor = 150 ) noexcept;
|
||||||
QSK_EXPORT QRgb darker( QRgb, int factor = 200 ) noexcept;
|
QSK_EXPORT QRgb darker( QRgb, int factor = 200 ) noexcept;
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,31 +5,19 @@
|
||||||
|
|
||||||
#include "QskSetup.h"
|
#include "QskSetup.h"
|
||||||
|
|
||||||
|
extern bool qskHasEnvironment( const char* );
|
||||||
extern void qskUpdateItemFlags();
|
extern void qskUpdateItemFlags();
|
||||||
|
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
inline bool hasEnvironment( const char* env )
|
|
||||||
{
|
|
||||||
bool ok;
|
|
||||||
|
|
||||||
const int value = qEnvironmentVariableIntValue( env, &ok );
|
|
||||||
if ( ok )
|
|
||||||
return value != 0;
|
|
||||||
|
|
||||||
// All other strings are true, apart from "false"
|
|
||||||
auto result = qgetenv( env );
|
|
||||||
return !result.isEmpty() && result != "false";
|
|
||||||
}
|
|
||||||
|
|
||||||
inline const QskItem::UpdateFlags environmentUpdateFlags()
|
inline const QskItem::UpdateFlags environmentUpdateFlags()
|
||||||
{
|
{
|
||||||
QskItem::UpdateFlags flags;
|
QskItem::UpdateFlags flags;
|
||||||
|
|
||||||
if ( !hasEnvironment( "QSK_PREFER_FBO_PAINTING" ) )
|
if ( !qskHasEnvironment( "QSK_PREFER_FBO_PAINTING" ) )
|
||||||
flags |= QskItem::PreferRasterForTextures;
|
flags |= QskItem::PreferRasterForTextures;
|
||||||
|
|
||||||
if ( hasEnvironment( "QSK_FORCE_BACKGROUND" ) )
|
if ( qskHasEnvironment( "QSK_FORCE_BACKGROUND" ) )
|
||||||
flags |= QskItem::DebugForceBackground;
|
flags |= QskItem::DebugForceBackground;
|
||||||
|
|
||||||
return flags;
|
return flags;
|
||||||
|
|
|
@ -173,10 +173,8 @@ void QskSimpleListBox::removeAt( int index )
|
||||||
if ( w >= m_data->maxTextWidth )
|
if ( w >= m_data->maxTextWidth )
|
||||||
m_data->maxTextWidth = qskMaxWidth( effectiveFont( Text ), entries );
|
m_data->maxTextWidth = qskMaxWidth( effectiveFont( Text ), entries );
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
entries.removeAt( index );
|
entries.removeAt( index );
|
||||||
}
|
|
||||||
|
|
||||||
propagateEntries();
|
propagateEntries();
|
||||||
|
|
||||||
|
|
|
@ -12,6 +12,7 @@
|
||||||
#include "QskGradient.h"
|
#include "QskGradient.h"
|
||||||
#include "QskSGNode.h"
|
#include "QskSGNode.h"
|
||||||
#include "QskShadowMetrics.h"
|
#include "QskShadowMetrics.h"
|
||||||
|
#include "QskRgbValue.h"
|
||||||
|
|
||||||
#include <qpainterpath.h>
|
#include <qpainterpath.h>
|
||||||
|
|
||||||
|
@ -91,12 +92,10 @@ void QskArcNode::setArcData( const QRectF& rect, const QskArcMetrics& arcMetrics
|
||||||
const auto metricsArc = arcMetrics.toAbsolute( rect.size() );
|
const auto metricsArc = arcMetrics.toAbsolute( rect.size() );
|
||||||
|
|
||||||
const auto hasFilling = gradient.isVisible();
|
const auto hasFilling = gradient.isVisible();
|
||||||
const auto hasBorder = ( borderWidth > 0.0 )
|
const auto hasBorder = ( borderWidth > 0.0 ) && QskRgb::isVisible( borderColor );
|
||||||
&& borderColor.isValid() && ( borderColor.alpha() > 0 );
|
const auto hasShadow = hasFilling && QskRgb::isVisible( shadowColor );
|
||||||
|
|
||||||
const auto hasShadow = shadowColor.isValid() && ( shadowColor.alpha() > 0 );
|
if ( hasShadow )
|
||||||
|
|
||||||
if ( hasShadow && hasFilling )
|
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
The shader of the shadow node is for circular arcs and we have some
|
The shader of the shadow node is for circular arcs and we have some
|
||||||
|
@ -121,7 +120,10 @@ void QskArcNode::setArcData( const QRectF& rect, const QskArcMetrics& arcMetrics
|
||||||
|
|
||||||
if ( hasBorder && hasFilling )
|
if ( hasBorder && hasFilling )
|
||||||
{
|
{
|
||||||
if ( !QskArcRenderer::isGradientSupported( rect, metricsArc, gradient ) )
|
const bool doCombine = arcNode->hasHint( QskFillNode::PreferColoredGeometry )
|
||||||
|
&& QskArcRenderer::isGradientSupported( rect, metricsArc, gradient );
|
||||||
|
|
||||||
|
if ( !doCombine )
|
||||||
fillNode = qskNode< QskArcRenderNode >( this, FillRole );
|
fillNode = qskNode< QskArcRenderNode >( this, FillRole );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -9,11 +9,12 @@
|
||||||
#include "QskArcMetrics.h"
|
#include "QskArcMetrics.h"
|
||||||
#include "QskGradient.h"
|
#include "QskGradient.h"
|
||||||
#include "QskSGNode.h"
|
#include "QskSGNode.h"
|
||||||
|
#include "QskRgbValue.h"
|
||||||
#include "QskFillNodePrivate.h"
|
#include "QskFillNodePrivate.h"
|
||||||
|
|
||||||
static inline bool qskHasBorder( qreal width, const QColor& color )
|
static inline bool qskHasBorder( qreal width, const QColor& color )
|
||||||
{
|
{
|
||||||
return ( width > 0.0 ) && color.isValid() && ( color.alpha() > 0 );
|
return ( width > 0.0 ) && QskRgb::isVisible( color );
|
||||||
}
|
}
|
||||||
|
|
||||||
class QskArcRenderNodePrivate final : public QskFillNodePrivate
|
class QskArcRenderNodePrivate final : public QskFillNodePrivate
|
||||||
|
@ -42,7 +43,7 @@ class QskArcRenderNodePrivate final : public QskFillNodePrivate
|
||||||
{
|
{
|
||||||
QskHashValue hash = 13000;
|
QskHashValue hash = 13000;
|
||||||
|
|
||||||
if ( borderColor.isValid() && ( borderColor.alpha() > 0 ) )
|
if ( QskRgb::isVisible( borderColor ) )
|
||||||
hash = qHashBits( &borderColor, sizeof( borderColor ), hash );
|
hash = qHashBits( &borderColor, sizeof( borderColor ), hash );
|
||||||
|
|
||||||
if ( gradient.isVisible() )
|
if ( gradient.isVisible() )
|
||||||
|
|
|
@ -489,7 +489,7 @@ void QskArcRenderer::setColoredBorderLines( const QRectF& rect,
|
||||||
geometry.setDrawingMode( QSGGeometry::DrawTriangleStrip );
|
geometry.setDrawingMode( QSGGeometry::DrawTriangleStrip );
|
||||||
geometry.markVertexDataDirty();
|
geometry.markVertexDataDirty();
|
||||||
|
|
||||||
if ( borderWidth <= 0.0 || !( borderColor.isValid() && borderColor.alpha() > 0 ) )
|
if ( borderWidth <= 0.0 || !QskRgb::isVisible( borderColor ) )
|
||||||
{
|
{
|
||||||
qskAllocateColoredLines( geometry, 0 );
|
qskAllocateColoredLines( geometry, 0 );
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -13,6 +13,7 @@
|
||||||
#include "QskShadowMetrics.h"
|
#include "QskShadowMetrics.h"
|
||||||
#include "QskBoxBorderMetrics.h"
|
#include "QskBoxBorderMetrics.h"
|
||||||
#include "QskBoxBorderColors.h"
|
#include "QskBoxBorderColors.h"
|
||||||
|
#include "QskRgbValue.h"
|
||||||
|
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
|
@ -69,31 +70,40 @@ void QskBoxNode::updateNode( const QRectF& rect,
|
||||||
|
|
||||||
if ( !rect.isEmpty() )
|
if ( !rect.isEmpty() )
|
||||||
{
|
{
|
||||||
if ( !shadowMetrics.isNull()
|
const auto hasFilling = gradient.isVisible();
|
||||||
&& shadowColor.isValid() && shadowColor.alpha() != 0 )
|
const auto hasBorder = !borderMetrics.isNull() && borderColors.isVisible();
|
||||||
|
|
||||||
|
const auto hasShadow = hasFilling && !shadowMetrics.isNull()
|
||||||
|
&& QskRgb::isVisible( shadowColor );
|
||||||
|
|
||||||
|
if ( hasShadow )
|
||||||
{
|
{
|
||||||
shadowNode = qskNode< QskBoxShadowNode >( this, ShadowRole );
|
shadowNode = qskNode< QskBoxShadowNode >( this, ShadowRole );
|
||||||
shadowNode->setShadowData( shadowMetrics.shadowRect( rect ),
|
shadowNode->setShadowData( shadowMetrics.shadowRect( rect ),
|
||||||
shape, shadowMetrics.blurRadius(), shadowColor );
|
shape, shadowMetrics.blurRadius(), shadowColor );
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( QskBoxRectangleNode::isCombinedGeometrySupported( gradient ) )
|
if ( hasBorder || hasFilling )
|
||||||
{
|
{
|
||||||
rectNode = qskNode< QskBoxRectangleNode >( this, BoxRole );
|
rectNode = qskNode< QskBoxRectangleNode >( this, BoxRole );
|
||||||
rectNode->updateBox( rect, shape, borderMetrics, borderColors, gradient );
|
|
||||||
|
if ( hasBorder && hasFilling )
|
||||||
|
{
|
||||||
|
const bool doCombine = rectNode->hasHint( QskFillNode::PreferColoredGeometry )
|
||||||
|
&& QskBoxRectangleNode::isCombinedGeometrySupported( gradient );
|
||||||
|
|
||||||
|
if ( !doCombine )
|
||||||
|
fillNode = qskNode< QskBoxRectangleNode >( this, FillRole );
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( fillNode )
|
||||||
|
{
|
||||||
|
rectNode->updateBorder( rect, shape, borderMetrics, borderColors );
|
||||||
|
fillNode->updateFilling( rect, shape, borderMetrics, gradient );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if ( !borderMetrics.isNull() && borderColors.isVisible() )
|
rectNode->updateBox( rect, shape, borderMetrics, borderColors, gradient );
|
||||||
{
|
|
||||||
rectNode = qskNode< QskBoxRectangleNode >( this, BoxRole );
|
|
||||||
rectNode->updateBorder( rect, shape, borderMetrics, borderColors );
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( gradient.isVisible() )
|
|
||||||
{
|
|
||||||
fillNode = qskNode< QskBoxRectangleNode >( this, FillRole );
|
|
||||||
fillNode->updateFilling( rect, shape, borderMetrics, gradient );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -127,16 +127,8 @@ void QskBoxRectangleNode::updateFilling( const QRectF& rect,
|
||||||
markDirty( QSGNode::DirtyGeometry );
|
markDirty( QSGNode::DirtyGeometry );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
|
||||||
if ( fillGradient.isMonochrome() )
|
|
||||||
{
|
|
||||||
if ( dirtyMaterial )
|
|
||||||
setColoring( fillGradient.rgbStart() );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
setColoring( rect, fillGradient );
|
setColoring( rect, fillGradient );
|
||||||
}
|
|
||||||
|
|
||||||
if ( dirtyGeometry )
|
if ( dirtyGeometry )
|
||||||
{
|
{
|
||||||
|
|
|
@ -26,6 +26,17 @@ static inline QskFillNode::Coloring qskColoring( QskGradient::Type type )
|
||||||
return static_cast< QskFillNode::Coloring >( coloring );
|
return static_cast< QskFillNode::Coloring >( coloring );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline QskFillNode::Hints qskDefaultFillNodeHints()
|
||||||
|
{
|
||||||
|
extern bool qskHasEnvironment( const char* );
|
||||||
|
|
||||||
|
QskFillNode::Hints hints;
|
||||||
|
if ( !qskHasEnvironment( "QSK_PREFER_SHADER_COLORS" ) )
|
||||||
|
hints |= QskFillNode::PreferColoredGeometry;
|
||||||
|
|
||||||
|
return hints;
|
||||||
|
}
|
||||||
|
|
||||||
QskFillNode::QskFillNode()
|
QskFillNode::QskFillNode()
|
||||||
: QskFillNode( *new QskFillNodePrivate )
|
: QskFillNode( *new QskFillNodePrivate )
|
||||||
{
|
{
|
||||||
|
@ -34,6 +45,9 @@ QskFillNode::QskFillNode()
|
||||||
QskFillNode::QskFillNode( QskFillNodePrivate& dd )
|
QskFillNode::QskFillNode( QskFillNodePrivate& dd )
|
||||||
: QSGGeometryNode( dd )
|
: QSGGeometryNode( dd )
|
||||||
{
|
{
|
||||||
|
static const auto hints = qskDefaultFillNodeHints();
|
||||||
|
|
||||||
|
dd.hints = hints;
|
||||||
setGeometry( &dd.geometry );
|
setGeometry( &dd.geometry );
|
||||||
|
|
||||||
setMaterial( qskMaterialColorVertex );
|
setMaterial( qskMaterialColorVertex );
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
#include "QskStippleMetrics.h"
|
#include "QskStippleMetrics.h"
|
||||||
#include "QskStippledLineRenderer.h"
|
#include "QskStippledLineRenderer.h"
|
||||||
#include "QskSGNode.h"
|
#include "QskSGNode.h"
|
||||||
|
#include "QskRgbValue.h"
|
||||||
|
|
||||||
#include <qtransform.h>
|
#include <qtransform.h>
|
||||||
#include <qline.h>
|
#include <qline.h>
|
||||||
|
@ -163,8 +164,7 @@ void QskLinesNode::updateLines( const QColor& color,
|
||||||
qreal lineWidth, const QskStippleMetrics& stippleMetrics,
|
qreal lineWidth, const QskStippleMetrics& stippleMetrics,
|
||||||
const QTransform& transform, int count, const QLineF* lines )
|
const QTransform& transform, int count, const QLineF* lines )
|
||||||
{
|
{
|
||||||
if ( !stippleMetrics.isValid() || !color.isValid()
|
if ( !stippleMetrics.isValid() || !QskRgb::isVisible( color ) || count == 0 )
|
||||||
|| color.alpha() == 0 || count == 0 )
|
|
||||||
{
|
{
|
||||||
QskSGNode::resetGeometry( this );
|
QskSGNode::resetGeometry( this );
|
||||||
return;
|
return;
|
||||||
|
@ -195,7 +195,7 @@ void QskLinesNode::updateGrid( const QColor& color,
|
||||||
const QTransform& transform, const QRectF& rect,
|
const QTransform& transform, const QRectF& rect,
|
||||||
const QVector< qreal >& xValues, const QVector< qreal >& yValues )
|
const QVector< qreal >& xValues, const QVector< qreal >& yValues )
|
||||||
{
|
{
|
||||||
if ( !stippleMetrics.isValid() || !color.isValid() || color.alpha() == 0 )
|
if ( !stippleMetrics.isValid() || !QskRgb::isVisible( color ) )
|
||||||
{
|
{
|
||||||
QskSGNode::resetGeometry( this );
|
QskSGNode::resetGeometry( this );
|
||||||
return;
|
return;
|
||||||
|
@ -409,7 +409,7 @@ QSGGeometry::Point2D* QskLinesNode::setSolidLines(
|
||||||
void QskLinesNode::updatePolygon( const QColor& color, qreal lineWidth,
|
void QskLinesNode::updatePolygon( const QColor& color, qreal lineWidth,
|
||||||
const QTransform& transform, const QPolygonF& polygon )
|
const QTransform& transform, const QPolygonF& polygon )
|
||||||
{
|
{
|
||||||
if ( polygon.isEmpty() || !color.isValid() || ( color.alpha() == 0 ) )
|
if ( polygon.isEmpty() || !QskRgb::isVisible( color ) )
|
||||||
{
|
{
|
||||||
QskSGNode::resetGeometry( this );
|
QskSGNode::resetGeometry( this );
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
#include "QskStrokeNode.h"
|
#include "QskStrokeNode.h"
|
||||||
#include "QskVertex.h"
|
#include "QskVertex.h"
|
||||||
#include "QskGradient.h"
|
#include "QskGradient.h"
|
||||||
|
#include "QskRgbValue.h"
|
||||||
|
|
||||||
#include <qpainterpath.h>
|
#include <qpainterpath.h>
|
||||||
|
|
||||||
|
@ -24,7 +25,7 @@ static inline bool qskIsPenVisible( const QPen& pen )
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if ( !pen.color().isValid() || ( pen.color().alpha() == 0 ) )
|
if ( !QskRgb::isVisible( pen.color() ) )
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue