Krita is a free and open source cross-platform application that offers an end-to-end solution for creating digital art files from scratch built on the KDE and Qt frameworks.
C++
Merge branch 'work/rempt/qt6-5' into 'master'
Ben Cooksley1679c69bdef3
diff --cc libs/pigment/KoColorSpaceMaths.hindex 35f177e632,316f817abc..4b9733cc9b--- a/libs/pigment/KoColorSpaceMaths.h+++ b/libs/pigment/KoColorSpaceMaths.h@@@ -270,54 -272,9 +272,54 @@@ public}inline static dst_compositetype clamp(dst_compositetype val) {- return qBound<dst_compositetype>(KoColorSpaceMathsTraits<_Tdst>::min, val, KoColorSpaceMathsTraits<_Tdst>::max);+ return kisBoundFast<dst_compositetype>(KoColorSpaceMathsTraits<_Tdst>::min, val, KoColorSpaceMathsTraits<_Tdst>::max);}+ inline static _T clampChannelToSDR(_T val) {+ if constexpr (std::numeric_limits<_T>::is_integer) {+ return val;+ } else {+ return qBound<_T>(KoColorSpaceMathsTraits<_T>::zeroValue, val, KoColorSpaceMathsTraits<_T>::unitValue);+ }+ }++ inline static _T clampChannelToSDRBottom(_T val)+ {+ if constexpr (std::numeric_limits<_T>::is_integer) {+ return val;+ } else {+ return qMax<_T>(KoColorSpaceMathsTraits<_T>::zeroValue, val);+ }+ }++ inline static dst_compositetype clampToSDR(dst_compositetype val) {+ return qBound<dst_compositetype>(KoColorSpaceMathsTraits<_Tdst>::zeroValue, val, KoColorSpaceMathsTraits<_Tdst>::unitValue);+ }++ inline static dst_compositetype clampToSDRTop(dst_compositetype val) {+ return qMin<dst_compositetype>(val, KoColorSpaceMathsTraits<_Tdst>::unitValue);+ }++ inline static dst_compositetype clampToSDRBottom(dst_compositetype val) {+ return qMax<dst_compositetype>(KoColorSpaceMathsTraits<_Tdst>::zeroValue, val);+ }++ inline static dst_compositetype divideInCompositeSpace(dst_compositetype a, dst_compositetype b) {+ if constexpr (std::numeric_limits<_Tdst>::is_integer) {+ return a * KoColorSpaceMathsTraits<_Tdst>::unitValue / b;+ } else {+ return a / b;+ }+ }++ inline static dst_compositetype multiplyInCompositeSpace(dst_compositetype a, dst_compositetype b) {+ if constexpr (std::numeric_limits<_Tdst>::is_integer) {+ return a * b / KoColorSpaceMathsTraits<_Tdst>::unitValue;+ } else {+ return a * b;+ }+ }+/*** Clamps the composite type on higher border only. That is a fast path* for scale-only transformationsdiff --cc libs/ui/tool/strokes/KisMaskingBrushCompositeOp.hindex de13d92e9c,d695fb36d4..ebe50eea9b--- a/libs/ui/tool/strokes/KisMaskingBrushCompositeOp.h+++ b/libs/ui/tool/strokes/KisMaskingBrushCompositeOp.h@@@ -193,12 -193,12 +193,12 @@@ inline T colorDodgeAlphaHelper(T src,// this case we also treat the denominator as an infinitely small number,// and the numerator can remain as 0, so dividing 0 over a number (no matter// how small it is) gives 0.- if (src == unitValue<T>()) {- return dst == zeroValue<T>() ? zeroValue<T>() : unitValue<T>();+ if (isUnitValueFuzzy<T>(src)) {+ return isZeroValueFuzzy<T>(dst) ? zeroValue<T>() : unitValue<T>();}- return qBound(composite_type(KoColorSpaceMathsTraits<T>::zeroValue),- div(dst, inv(src)),- composite_type(KoColorSpaceMathsTraits<T>::unitValue));+ return kisBoundFast(composite_type(KoColorSpaceMathsTraits<T>::zeroValue),+ div(dst, inv(src)),+ composite_type(KoColorSpaceMathsTraits<T>::unitValue));}// Integer version of color dodge alpha@@@ -260,20 -260,33 +260,20 @@@ inline T colorBurnAlphaHelper(T src, Tusing namespace Arithmetic;// Handle the case where the denominator is 0. See color dodge for a// detailed explanation- if(src == zeroValue<T>()) {- return dst == unitValue<T>() ? zeroValue<T>() : unitValue<T>();+ if(isZeroValueFuzzy<T>(src)) {+ return isUnitValueFuzzy<T>(dst) ? zeroValue<T>() : unitValue<T>();}- return qBound(composite_type(KoColorSpaceMathsTraits<T>::zeroValue),- div(inv(dst), src),- composite_type(KoColorSpaceMathsTraits<T>::unitValue));+ return kisBoundFast(composite_type(KoColorSpaceMathsTraits<T>::zeroValue),+ div(inv(dst), src),+ composite_type(KoColorSpaceMathsTraits<T>::unitValue));}-// Integer version of color burn alphatemplate<class T>-inline typename std::enable_if<std::numeric_limits<T>::is_integer, T>::type-colorBurnAlpha(T src, T dst)+inline T colorBurnAlpha(T src, T dst){using namespace Arithmetic;- return inv(colorBurnHelper(src, dst));-}--// Floating point version of color burn alpha-template<class T>-inline typename std::enable_if<!std::numeric_limits<T>::is_integer, T>::type-colorBurnAlpha(T src, T dst)-{- using namespace Arithmetic;- const T result = colorBurnAlphaHelper(src, dst);- // Constantly dividing by small numbers can quickly make the result- // become infinity or NaN, so we check that and correct (kind of clamping)- return inv(std::isfinite(result) ? result : KoColorSpaceMathsTraits<T>::unitValue);+ using namespace KoCompositeOpClampPolicy;+ return CFColorBurn<T>::composeChannel(src, dst);}template <typename channels_type>