Skip to content

armgit / krita

Public Imported from GitHub
0

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++

Replace exact comparisons in KisMaskingBrushCompositeOps

Dmitry Kazakov818d99fe08c2
diff --git a/libs/ui/tool/strokes/KisMaskingBrushCompositeOp.h b/libs/ui/tool/strokes/KisMaskingBrushCompositeOp.h
index 729900ca32..66f788e119 100644
--- a/libs/ui/tool/strokes/KisMaskingBrushCompositeOp.h
+++ b/libs/ui/tool/strokes/KisMaskingBrushCompositeOp.h
@@ -193,8 +193,8 @@ inline T colorDodgeAlphaHelper(T src, T dst)
// 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 (isUnitValue<T>(src)) {
+ return isZeroValue<T>(dst) ? zeroValue<T>() : unitValue<T>();
}
return qBound(composite_type(KoColorSpaceMathsTraits<T>::zeroValue),
div(dst, inv(src)),
@@ -260,8 +260,8 @@ inline T colorBurnAlphaHelper(T src, T dst)
using 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(isZeroValue<T>(src)) {
+ return isUnitValue<T>(dst) ? zeroValue<T>() : unitValue<T>();
}
return qBound(composite_type(KoColorSpaceMathsTraits<T>::zeroValue),
div(inv(dst), src),
@@ -328,7 +328,7 @@ struct CompositeFunction<channels_type, KIS_MASKING_BRUSH_COMPOSITE_LINEAR_DODGE
{
using composite_type = typename KoColorSpaceMathsTraits<channels_type>::compositetype;
using namespace Arithmetic;
- if (dst == zeroValue<channels_type>()) {
+ if (isZeroValue<channels_type>(dst)) {
return zeroValue<channels_type>();
}
return qMin(composite_type(src) + dst, composite_type(unitValue<channels_type>()));
@@ -345,7 +345,7 @@ struct CompositeFunction<channels_type, KIS_MASKING_BRUSH_COMPOSITE_LINEAR_DODGE
{
using composite_type = typename KoColorSpaceMathsTraits<channels_type>::compositetype;
using namespace Arithmetic;
- if (dst == zeroValue<channels_type>()) {
+ if (isZeroValue<channels_type>(dst)) {
return zeroValue<channels_type>();
}
if constexpr (use_soft_texturing) {