From b8f198a97ab167acd597755b438969c084a03566 Mon Sep 17 00:00:00 2001 From: Uwe Rathmann Date: Tue, 14 Feb 2023 09:29:51 +0100 Subject: [PATCH] irrelevant micro optimzation removed, that was using the wrong corner iteration --- src/nodes/QskBoxBasicStroker.cpp | 44 ++++---------------------------- src/nodes/QskBoxMetrics.h | 7 +++++ 2 files changed, 12 insertions(+), 39 deletions(-) diff --git a/src/nodes/QskBoxBasicStroker.cpp b/src/nodes/QskBoxBasicStroker.cpp index 31bf15ec..e1a006cf 100644 --- a/src/nodes/QskBoxBasicStroker.cpp +++ b/src/nodes/QskBoxBasicStroker.cpp @@ -283,65 +283,31 @@ static inline void qskCreateFill( } } } - else if ( m_metrics.stepSymmetries ) - { - auto line = lines; - - if ( isHorizontal ) - { - int stepCount = qMax( cn[TopLeftCorner].stepCount, cn[BottomLeftCorner].stepCount ); - - for ( ArcIterator it( stepCount, true ); !it.isDone(); ++it ) - map.setVLine( TopLeftCorner, BottomLeftCorner, it.cos(), it.sin(), line++ ); - - stepCount = qMax( cn[TopRightCorner].stepCount, cn[BottomRightCorner].stepCount ); - - for ( ArcIterator it( stepCount, false ); !it.isDone(); ++it ) - map.setVLine( TopRightCorner, BottomRightCorner, it.cos(), it.sin(), line++ ); - } - else - { - int stepCount = qMax( cn[TopLeftCorner].stepCount, cn[TopRightCorner].stepCount ); - - for ( ArcIterator it( stepCount, false ); !it.isDone(); ++it ) - map.setHLine( TopLeftCorner, TopRightCorner, it.cos(), it.sin(), line++ ); - - stepCount = qMax( cn[BottomLeftCorner].stepCount, cn[BottomRightCorner].stepCount ); - - for ( ArcIterator it( stepCount, true ); !it.isDone(); ++it ) - map.setHLine( BottomLeftCorner, BottomRightCorner, it.cos(), it.sin(), line++ ); - } - } else { - /* - This fallback code creates the same points. The cases above are - simply micro oprimization reducing the loops or calculations - to get there. - */ - auto line = lines; + int stepCount; if ( isHorizontal ) { - int stepCount = qMax( cn[TopLeftCorner].stepCount, cn[BottomLeftCorner].stepCount ); + stepCount = m_metrics.innerStepCount( TopLeftCorner, BottomLeftCorner ); for ( ArcIterator it( stepCount, true ); !it.isDone(); ++it ) map.setLine( TopLeftCorner, BottomLeftCorner, it.cos(), it.sin(), line++ ); - stepCount = qMax( cn[TopRightCorner].stepCount, cn[BottomRightCorner].stepCount ); + stepCount = m_metrics.innerStepCount( TopRightCorner, BottomRightCorner ); for ( ArcIterator it( stepCount, false ); !it.isDone(); ++it ) map.setLine( TopRightCorner, BottomRightCorner, it.cos(), it.sin(), line++ ); } else { - int stepCount = qMax( cn[TopLeftCorner].stepCount, cn[TopRightCorner].stepCount ); + stepCount = m_metrics.innerStepCount( TopLeftCorner, TopRightCorner ); for ( ArcIterator it( stepCount, false ); !it.isDone(); ++it ) map.setLine( TopLeftCorner, TopRightCorner, it.cos(), it.sin(), line++ ); - stepCount = qMax( cn[BottomLeftCorner].stepCount, cn[BottomRightCorner].stepCount ); + stepCount = m_metrics.innerStepCount( BottomLeftCorner, BottomRightCorner ); for ( ArcIterator it( stepCount, true ); !it.isDone(); ++it ) map.setLine( BottomLeftCorner, BottomRightCorner, it.cos(), it.sin(), line++ ); diff --git a/src/nodes/QskBoxMetrics.h b/src/nodes/QskBoxMetrics.h index abf7c824..e2bf19e8 100644 --- a/src/nodes/QskBoxMetrics.h +++ b/src/nodes/QskBoxMetrics.h @@ -7,6 +7,7 @@ #define QSK_BOX_METRICS_H #include +#include #include class QskBoxShapeMetrics; @@ -24,6 +25,12 @@ class QskBoxMetrics int outerStepCount() const; int innerStepCount() const; + int innerStepCount( int corner1, int corner2 ) const + { + return qMax( corners[ corner1 ].innerStepCount(), + corners[ corner2 ].innerStepCount() ); + } + struct Corner { inline qreal xInner( qreal cos ) const