From 1dcdca34891300c57b7265cc4b9f967b0f4d6968 Mon Sep 17 00:00:00 2001 From: Uwe Rathmann Date: Sat, 4 Feb 2023 11:55:06 +0100 Subject: [PATCH] faster isMonochrome calculations --- src/common/QskBoxBorderColors.cpp | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/src/common/QskBoxBorderColors.cpp b/src/common/QskBoxBorderColors.cpp index 15a7680f..87d31046 100644 --- a/src/common/QskBoxBorderColors.cpp +++ b/src/common/QskBoxBorderColors.cpp @@ -152,19 +152,24 @@ bool QskBoxBorderColors::isVisible() const bool QskBoxBorderColors::isMonochrome() const { - if ( m_gradients[ 1 ] != m_gradients[ 0 ] ) - return false; - - if ( m_gradients[ 2 ] != m_gradients[ 1 ] ) - return false; - - if ( m_gradients[ 3 ] != m_gradients[ 2 ] ) - return false; - - return m_gradients[ 0 ].isMonochrome() + if ( m_gradients[ 0 ].isMonochrome() && m_gradients[ 1 ].isMonochrome() && m_gradients[ 2 ].isMonochrome() - && m_gradients[ 3 ].isMonochrome(); + && m_gradients[ 3 ].isMonochrome() ) + { + if ( m_gradients[ 1 ].rgbStart() != m_gradients[ 0 ].rgbStart() ) + return false; + + if ( m_gradients[ 2 ].rgbStart() != m_gradients[ 1 ].rgbStart() ) + return false; + + if ( m_gradients[ 3 ].rgbStart() != m_gradients[ 2 ].rgbStart() ) + return false; + + return true; + } + + return false; } bool QskBoxBorderColors::isValid() const