using left/top/right/bottom

This commit is contained in:
Uwe Rathmann 2022-04-16 16:01:40 +02:00
parent 628e57a9ff
commit ab095afb13
3 changed files with 25 additions and 22 deletions

View File

@ -138,8 +138,7 @@ void QskBoxNode::setBoxData( const QRectF& rect,
{
if ( isFillMonochrome && isBorderMonochrome )
{
if ( borderColors.gradient( Qsk::Left ).startColor()
== fillGradient.startColor() )
if ( borderColors.left().startColor() == fillGradient.startColor() )
{
// we can draw border and background in one
hasBorder = false;
@ -193,7 +192,7 @@ void QskBoxNode::setBoxData( const QRectF& rect,
}
else
{
flatMaterial->setColor( borderColors.gradient( Qsk::Left ).startColor().rgba() );
flatMaterial->setColor( borderColors.left().startColor().rgba() );
renderer.renderBorder( d->rect, shape, borderMetrics, *geometry() );
}
}

View File

@ -115,7 +115,7 @@ namespace
static inline QRgb qskRgbBorder( const QskBoxBorderColors& borderColors )
{
return qskRgbGradientStart( borderColors.gradient( Qsk::Left ) );
return qskRgbGradientStart( borderColors.left() );
}
}
@ -1015,8 +1015,10 @@ static inline void qskRenderBorder( const QskBoxRenderer::Metrics& metrics,
{
const int stepCount = metrics.corner[ 0 ].stepCount;
auto left = c.gradient( Qsk::Left ), top = c.gradient( Qsk::Top ),
right = c.gradient( Qsk::Right ), bottom = c.gradient( Qsk::Bottom );
const auto& left = c.left();
const auto& top = c.top();
const auto& right = c.right();
const auto& bottom = c.bottom();
qskRenderBorderLines( metrics, orientation, line,
BorderMapGradient( stepCount, qskRgbGradientStart( top ), qskRgbGradientEnd( left ), left ),
@ -1052,7 +1054,7 @@ static inline void qskRenderBoxRandom(
if ( bc.isMonochrome() )
{
const BorderMapSolid borderMap( qskRgbBorder( bc.gradient( Qsk::Left ) ) );
const BorderMapSolid borderMap( qskRgbBorder( bc.left() ) );
if ( gradient.isMonochrome() )
{
@ -1071,8 +1073,10 @@ static inline void qskRenderBoxRandom(
{
const int n = metrics.corner[ 0 ].stepCount;
auto left = bc.gradient( Qsk::Left ), top = bc.gradient( Qsk::Top ),
right = bc.gradient( Qsk::Right ), bottom = bc.gradient( Qsk::Bottom );
const auto& left = bc.left();
const auto& top = bc.top();
const auto& right = bc.right();
const auto& bottom = bc.bottom();
const BorderMapGradient tl( n, qskRgbGradientStart( top.startColor() ), qskRgbGradientEnd( left.endColor() ), left );
const BorderMapGradient tr( n, qskRgbGradientStart( right ), qskRgbGradientEnd( top ), top );
@ -1369,10 +1373,10 @@ void QskBoxRenderer::renderRectellipse( const QRectF& rect,
borderLineCount = 4 * ( stepCount + 1 ) + 1;
const int additionalLines =
additionalGradientStops( borderColors.gradient( Qsk::Left ) )
+ additionalGradientStops( borderColors.gradient( Qsk::Top ) )
+ additionalGradientStops( borderColors.gradient( Qsk::Right ) )
+ additionalGradientStops( borderColors.gradient( Qsk::Bottom ) );
additionalGradientStops( borderColors.left() )
+ additionalGradientStops( borderColors.top() )
+ additionalGradientStops( borderColors.right() )
+ additionalGradientStops( borderColors.bottom() );
borderLineCount += additionalLines;
}

View File

@ -422,10 +422,10 @@ static inline void qskCreateBorder(
const QskBoxRenderer::Quad& out, const QskBoxRenderer::Quad& in,
const QskBoxBorderColors& colors, Line* line )
{
const auto& gradientLeft = colors.gradient( Qsk::Left );
const auto& gradientRight = colors.gradient( Qsk::Right );
const auto& gradientTop = colors.gradient( Qsk::Top );
const auto& gradientBottom = colors.gradient( Qsk::Bottom );
const auto& gradientLeft = colors.left();
const auto& gradientRight = colors.right();
const auto& gradientTop = colors.top();
const auto& gradientBottom = colors.bottom();
// qdebug
@ -571,10 +571,10 @@ void QskBoxRenderer::renderRect(
// ### As an optimization we could check orientation and colors
// to test whether colors are the same
const int additionalLines = -1
+ bc.gradient( Qsk::Left ).stops().count() - 1
+ bc.gradient( Qsk::Top ).stops().count() - 1
+ bc.gradient( Qsk::Right ).stops().count() - 1
+ bc.gradient( Qsk::Bottom ).stops().count() - 1;
+ bc.left().stops().count() - 1
+ bc.top().stops().count() - 1
+ bc.right().stops().count() - 1
+ bc.bottom().stops().count() - 1;
borderLineCount += qMax( additionalLines, 0 );
}
@ -624,7 +624,7 @@ void QskBoxRenderer::renderRect(
if ( bc.isMonochrome() )
{
const auto rgb = bc.gradient( Qsk::Left ).startColor().rgba();
const auto rgb = bc.left().startColor().rgba();
qskCreateBorderMonochrome( rect, in, rgb, fillLines );
}
else