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

Extract blendmode's clamping policies into a separate file

Dmitry Kazakovd469ae796828
diff --git a/libs/pigment/compositeops/KoCompositeOpClampPolicy.h b/libs/pigment/compositeops/KoCompositeOpClampPolicy.h
new file mode 100644
index 0000000000..43e36f95d5
--- /dev/null
+++ b/libs/pigment/compositeops/KoCompositeOpClampPolicy.h
@@ -0,0 +1,92 @@
+/*
+ * SPDX-FileCopyrightText: 2024 Dmitry Kazakov <[email protected]>
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
+#ifndef KOCOMPOSITEOPCLAMPPOLICY_H
+#define KOCOMPOSITEOPCLAMPPOLICY_H
+
+#include <KoColorSpaceMaths.h>
+
+namespace KoCompositeOpClampPolicy
+{
+template <typename T>
+struct ClampAsInteger {
+ using channels_type = T;
+ using compositetype = typename KoColorSpaceMathsTraits<T>::compositetype;
+
+ static inline channels_type clampResultAllowNegative(compositetype value) {
+ using namespace Arithmetic;
+ return clampToSDR<channels_type>(value);
+ }
+
+ static inline channels_type clampResult(compositetype value) {
+ using namespace Arithmetic;
+ return clampToSDR<channels_type>(value);
+ }
+
+ static inline channels_type clampInvertedResult(compositetype value) {
+ using namespace Arithmetic;
+ return clampToSDR<channels_type>(value);
+ }
+
+ static inline compositetype fixInfiniteAfterDivision(compositetype value) {
+ return value;
+ }
+};
+
+template <typename T>
+struct ClampAsFloatSDR {
+ using channels_type = T;
+ using compositetype = typename KoColorSpaceMathsTraits<T>::compositetype;
+
+ static channels_type clampResultAllowNegative(compositetype value) {
+ using namespace Arithmetic;
+ return clampToSDR<channels_type>(value);
+ }
+
+ static inline channels_type clampResult(compositetype value) {
+ using namespace Arithmetic;
+ return clampToSDR<channels_type>(value);
+ }
+
+ static channels_type clampInvertedResult(compositetype value) {
+ using namespace Arithmetic;
+ return clampToSDR<channels_type>(value);
+ }
+
+ static compositetype fixInfiniteAfterDivision(compositetype value) {
+ // Constantly dividing by small numbers can quickly make the result
+ // become infinity or NaN, so we check that and correct (kind of clamping)
+ return std::isfinite(value) ? value : KoColorSpaceMathsTraits<T>::unitValue;
+ }
+};
+
+template <typename T>
+struct ClampAsFloatHDR {
+ using channels_type = T;
+ using compositetype = typename KoColorSpaceMathsTraits<T>::compositetype;
+
+ static channels_type clampResultAllowNegative(compositetype value) {
+ return value;
+ }
+
+ static inline channels_type clampResult(compositetype value) {
+ using namespace Arithmetic;
+ return clampToSDRBottom<channels_type>(value);
+ }
+
+ static channels_type clampInvertedResult(compositetype value) {
+ using namespace Arithmetic;
+ return clampToSDRTop<channels_type>(value);
+ }
+
+ static compositetype fixInfiniteAfterDivision(compositetype value) {
+ // Constantly dividing by small numbers can quickly make the result
+ // become infinity or NaN, so we check that and correct (kind of clamping)
+ return std::isfinite(value) ? value : KoColorSpaceMathsTraits<T>::max;
+ }
+};
+}
+
+#endif // KOCOMPOSITEOPCLAMPPOLICY_H
diff --git a/libs/pigment/compositeops/KoCompositeOpGreater.h b/libs/pigment/compositeops/KoCompositeOpGreater.h
index 553cc5e22c..dc89fd7286 100644
--- a/libs/pigment/compositeops/KoCompositeOpGreater.h
+++ b/libs/pigment/compositeops/KoCompositeOpGreater.h
@@ -22,10 +22,6 @@
#include "KoCompositeOpBase.h"
-namespace tmp3 {
-using namespace Arithmetic;
-}
-
/**
* Greater-than compositor - uses the greater of two alpha values to determine the color
*/
@@ -51,10 +47,10 @@ public:
const QBitArray& channelFlags ) {
using namespace Arithmetic;
- if (tmp3::isUnitValue(dstAlpha)) return dstAlpha;
+ if (isUnitValue(dstAlpha)) return dstAlpha;
channels_type appliedAlpha = mul(maskAlpha, srcAlpha, opacity);
- if (tmp3::isZeroValue(appliedAlpha)) return dstAlpha;
+ if (isZeroValue(appliedAlpha)) return dstAlpha;
channels_type newDstAlpha;
float dA = scale<float>(dstAlpha);
@@ -75,9 +71,9 @@ public:
float fakeOpacity = 1.0f - (1.0f - a)/(1.0f - dA + 1e-16f);
newDstAlpha=scale<channels_type>(a);
- if (tmp3::isZeroValue(newDstAlpha)) {
+ if (isZeroValue(newDstAlpha)) {
// just do nothing with color channels and return null opacity
- } else if (!tmp3::isZeroValue(dstAlpha)) {
+ } else if (!isZeroValue(dstAlpha)) {
for (qint8 channel = 0; channel < channels_nb; ++channel)
if(channel != alpha_pos && (allChannelFlags || channelFlags.testBit(channel)))
{
diff --git a/libs/pigment/tests/KoCompositeOpFunctions2.h b/libs/pigment/tests/KoCompositeOpFunctions2.h
index 8346c4a29a..bc9d68bfb3 100644
--- a/libs/pigment/tests/KoCompositeOpFunctions2.h
+++ b/libs/pigment/tests/KoCompositeOpFunctions2.h
@@ -20,88 +20,6 @@
#include "half.h"
#endif
-template <typename T>
-struct ClampPolicyInteger {
- using channels_type = T;
- using compositetype = typename KoColorSpaceMathsTraits<T>::compositetype;
-
- static inline channels_type clampResultAllowNegative(compositetype value) {
- using namespace Arithmetic;
- return clampToSDR<channels_type>(value);
- }
-
- static inline channels_type clampResult(compositetype value) {
- using namespace Arithmetic;
- return clampToSDR<channels_type>(value);
- }
-
- static inline channels_type clampInvertedResult(compositetype value) {
- using namespace Arithmetic;
- return clampToSDR<channels_type>(value);
- }
-
- static inline compositetype fixInfiniteAfterDivision(compositetype value) {
- return value;
- }
-};
-
-template <typename T>
-struct ClampPolicyFloatSDR {
- using channels_type = T;
- using compositetype = typename KoColorSpaceMathsTraits<T>::compositetype;
-
- static channels_type clampResultAllowNegative(compositetype value) {
- using namespace Arithmetic;
- return clampToSDR<channels_type>(value);
- }
-
- static inline channels_type clampResult(compositetype value) {
- using namespace Arithmetic;
- return clampToSDR<channels_type>(value);
- }
-
- static channels_type clampInvertedResult(compositetype value) {
- using namespace Arithmetic;
- return clampToSDR<channels_type>(value);
- }
-
- static compositetype fixInfiniteAfterDivision(compositetype value) {
- // Constantly dividing by small numbers can quickly make the result
- // become infinity or NaN, so we check that and correct (kind of clamping)
- return std::isfinite(value) ? value : KoColorSpaceMathsTraits<T>::unitValue;
- }
-};
-
-template <typename T>
-struct ClampPolicyFloatHDR {
- using channels_type = T;
- using compositetype = typename KoColorSpaceMathsTraits<T>::compositetype;
-
- static channels_type clampResultAllowNegative(compositetype value) {
- return value;
- }
-
- static inline channels_type clampResult(compositetype value) {
- using namespace Arithmetic;
- return clampToSDRBottom<channels_type>(value);
- }
-
- static channels_type clampInvertedResult(compositetype value) {
- using namespace Arithmetic;
- return clampToSDRTop<channels_type>(value);
- }
-
- static compositetype fixInfiniteAfterDivision(compositetype value) {
- // Constantly dividing by small numbers can quickly make the result
- // become infinity or NaN, so we check that and correct (kind of clamping)
- return std::isfinite(value) ? value : KoColorSpaceMathsTraits<T>::max;
- }
-};
-
-namespace tmp {
-using namespace Arithmetic;
-}
-
template<class HSXType, class TReal>
inline void cfReorientedNormalMapCombine(TReal srcR, TReal srcG, TReal srcB, TReal& dstR, TReal& dstG, TReal& dstB)
{
@@ -304,8 +222,8 @@ struct CFColorBurn : ClampedSourceCompositeFunctorBase<T>
// Handle the case where the denominator is 0. See color dodge for a
// detailed explanation
- if (tmp::isZeroValue(src)) {
- return !tmp::isUnitValueClamped(dst) ? zeroValue<T>() : clamp_policy::clampResultAllowNegative(dst);
+ if (isZeroValue(src)) {
+ return !isUnitValueClamped(dst) ? zeroValue<T>() : clamp_policy::clampResultAllowNegative(dst);
}
return inv<T>(
clamp_policy::clampInvertedResult(
@@ -348,7 +266,7 @@ struct CFColorDodge : ClampedSourceCompositeFunctorBase<T> {
// and the numerator can remain as 0, so dividing 0 over a number (no matter
// how small it is) gives 0.
if (KoColorSpaceMaths<T>::isUnitValue(src)) {
- return tmp::isZeroValueClamped(dst) ? zeroValue<T>() : KoColorSpaceMathsTraits<T>::unitValue;
+ return isZeroValueClamped(dst) ? zeroValue<T>() : KoColorSpaceMathsTraits<T>::unitValue;
}
return clamp_policy::clampResultAllowNegative(
@@ -397,8 +315,8 @@ inline T cfDivide(T src, T dst) {
using namespace Arithmetic;
//typedef typename KoColorSpaceMathsTraits<T>::compositetype composite_type;
- if (tmp::isZeroValue(src))
- return tmp::isZeroValue(dst) ? zeroValue<T>() : unitValue<T>();
+ if (isZeroValue(src))
+ return isZeroValue(dst) ? zeroValue<T>() : unitValue<T>();
return clamp<T>(div(dst, src));
}
@@ -409,7 +327,7 @@ struct CFHardLight : ClampedSourceCompositeFunctorBase<T> {
using namespace Arithmetic;
using composite_type = typename KoColorSpaceMathsTraits<T>::compositetype;
- if (tmp::isHalfValue(src)) {
+ if (isHalfValue(src)) {
return dst;
}
@@ -489,8 +407,8 @@ struct CFVividLight : ClampedSourceCompositeFunctorBase<T> {
using composite_type = typename KoColorSpaceMathsTraits<T>::compositetype;
if (src < halfValue<T>()) {
- if (tmp::isZeroValue(src)) {
- return tmp::isUnitValueClamped(dst) ? clamp_policy::clampResultAllowNegative(dst) : zeroValue<T>();
+ if (isZeroValue(src)) {
+ return isUnitValueClamped(dst) ? clamp_policy::clampResultAllowNegative(dst) : zeroValue<T>();
}
// min(1,max(0,1-(1-dst) / (2*src)))
@@ -499,13 +417,13 @@ struct CFVividLight : ClampedSourceCompositeFunctorBase<T> {
return clamp_policy::clampResult(
unitValue<T>() -
clamp_policy::fixInfiniteAfterDivision(
- tmp::divideInCompositeSpace<T>(dsti, src2)
+ divideInCompositeSpace<T>(dsti, src2)
)
);
}
- if (tmp::isUnitValue(src)) {
- return tmp::isZeroValueClamped(dst) ? zeroValue<T>() : unitValue<T>();
+ if (isUnitValue(src)) {
+ return isZeroValueClamped(dst) ? zeroValue<T>() : unitValue<T>();
}
// min(1,max(0, dst / (2*(1-src)))
@@ -513,7 +431,7 @@ struct CFVividLight : ClampedSourceCompositeFunctorBase<T> {
srci2 += srci2;
return clamp_policy::clampResultAllowNegative(
clamp_policy::fixInfiniteAfterDivision(
- tmp::divideInCompositeSpace<T>(composite_type(dst), srci2)
+ divideInCompositeSpace<T>(composite_type(dst), srci2)
)
);
}
@@ -540,8 +458,8 @@ template<class T>
inline T cfArcTangent(T src, T dst) {
using namespace Arithmetic;
- if (tmp::isZeroValue(dst))
- return tmp::isZeroValue(src) ? zeroValue<T>() : unitValue<T>();
+ if (isZeroValue(dst))
+ return isZeroValue(src) ? zeroValue<T>() : unitValue<T>();
return scale<T>(2.0 * atan(scale<qreal>(src) / scale<qreal>(dst)) / Arithmetic::pi);
}
@@ -677,11 +595,11 @@ struct CFGammaDark : ClampedSourceAndDestinationBottomCompositeFunctorBase<T> {
static inline T composeChannel(T src, T dst) {
using namespace Arithmetic;
- if (tmp::isZeroValue(src)) {
+ if (isZeroValue(src)) {
return zeroValue<T>();
}
- if (tmp::isUnitValue(dst)) {
+ if (isUnitValue(dst)) {
return unitValue<T>();
}
@@ -695,11 +613,11 @@ struct CFGammaLight : ClampedSourceAndDestinationBottomCompositeFunctorBase<T> {
static inline T composeChannel(T src, T dst) {
using namespace Arithmetic;
- if (tmp::isZeroValue(dst)) {
- return tmp::isZeroValue(src) ? unitValue<T>() : zeroValue<T>();
+ if (isZeroValue(dst)) {
+ return isZeroValue(src) ? unitValue<T>() : zeroValue<T>();
}
- if (tmp::isUnitValue(dst)) {
+ if (isUnitValue(dst)) {
return unitValue<T>();
}
@@ -720,7 +638,7 @@ struct CFGeometricMean : ClampedSourceAndDestinationBottomCompositeFunctorBase<T
static inline T composeChannel(T src, T dst) {
using namespace Arithmetic;
- if (tmp::isUnitValue(src) && tmp::isUnitValue(dst)) {
+ if (isUnitValue(src) && isUnitValue(dst)) {
return unitValue<T>();
}
@@ -745,21 +663,21 @@ struct CFHardOverlay : ClampedSourceCompositeFunctorBase<T> {
using clamp_policy = ClampPolicy<T>;
using composite_type = typename KoColorSpaceMathsTraits<T>::compositetype;
- if (tmp::isUnitValue(src)) {
+ if (isUnitValue(src)) {
return unitValue<T>();
}
if(src >= halfValue<T>()) {
return clamp_policy::clampResultAllowNegative(
clamp_policy::fixInfiniteAfterDivision(
- tmp::divideInCompositeSpace<T>(composite_type(dst),
+ divideInCompositeSpace<T>(composite_type(dst),
2 * composite_type(inv(src)))
)
);
}
return clamp_policy::clampResultAllowNegative(
- tmp::multiplyInCompositeSpace<T>(composite_type(dst),
+ multiplyInCompositeSpace<T>(composite_type(dst),
2 * composite_type(src))
);
}
diff --git a/libs/pigment/tests/KoCompositeOpGeneric2.h b/libs/pigment/tests/KoCompositeOpGeneric2.h
index 38cee663ef..5ff0fae6b2 100644
--- a/libs/pigment/tests/KoCompositeOpGeneric2.h
+++ b/libs/pigment/tests/KoCompositeOpGeneric2.h
@@ -14,10 +14,6 @@
#include "KoCompositeOpBase.h"
-namespace tmp2 {
-using namespace Arithmetic;
-}
-
template <class Traits,
typename Traits::channels_type compositeFunc(typename Traits::channels_type, typename Traits::channels_type)>
struct CompositeFunctionWrapper
@@ -55,12 +51,12 @@ struct ClampedSourceAndDestinationBottomCompositeFunctorBase
{
static inline T clampSourceChannelValue(T value) {
using namespace Arithmetic;
- return tmp2::clampChannelToSDRBottom(value);
+ return clampChannelToSDRBottom(value);
}
static inline T clampDestinationChannelValue(T value) {
using namespace Arithmetic;
- return tmp2::clampChannelToSDRBottom(value);
+ return clampChannelToSDRBottom(value);
}
};
@@ -111,12 +107,12 @@ public:
srcAlpha = mul(srcAlpha, maskAlpha, opacity);
- if (tmp2::isZeroValue(srcAlpha)) {
+ if (isZeroValue(srcAlpha)) {
return dstAlpha;
}
if(alphaLocked) {
- if(!tmp2::isZeroValue(dstAlpha)) {
+ if(!isZeroValue(dstAlpha)) {
for(qint32 i=0; i <channels_nb; i++) {
if(i != alpha_pos && (allChannelFlags || channelFlags.testBit(i))) {
const channels_type srcInBlendSpace =
@@ -137,7 +133,7 @@ public:
}
return dstAlpha;
- } else if (tmp2::isZeroValue(dstAlpha)) {
+ } else if (isZeroValue(dstAlpha)) {
for(qint32 i=0; i <channels_nb; i++) {
if(i != alpha_pos && (allChannelFlags || channelFlags.testBit(i))) {
dst[i] = BlendingPolicy::fromAdditiveSpace(
@@ -146,7 +142,7 @@ public:
}
}
return srcAlpha;
- } else if (tmp2::isUnitValue(dstAlpha)) {
+ } else if (isUnitValue(dstAlpha)) {
for(qint32 i=0; i <channels_nb; i++) {
if(i != alpha_pos && (allChannelFlags || channelFlags.testBit(i))) {
const channels_type srcInBlendSpace =
@@ -165,7 +161,7 @@ public:
}
}
return unitValue<channels_type>();
- } else if (tmp2::isUnitValue(srcAlpha)) {
+ } else if (isUnitValue(srcAlpha)) {
for(qint32 i=0; i <channels_nb; i++) {
if(i != alpha_pos && (allChannelFlags || channelFlags.testBit(i))) {
const channels_type srcInBlendSpace =
@@ -187,7 +183,7 @@ public:
} else {
channels_type newDstAlpha = unionShapeOpacity(srcAlpha, dstAlpha);
- if (!tmp2::isZeroValue(newDstAlpha)) {
+ if (!isZeroValue(newDstAlpha)) {
for(qint32 i=0; i <channels_nb; i++) {
if(i != alpha_pos && (allChannelFlags || channelFlags.testBit(i))) {
@@ -218,8 +214,8 @@ public:
// << ppVar(newDstAlpha)
// << ppVar(srcAlpha)
// << ppVar(dstAlpha)
-// << ppVar(tmp2::isUnitValue(result))
-// << ppVar(tmp2::isUnitValue(newDstAlpha));
+// << ppVar(isUnitValue(result))
+// << ppVar(isUnitValue(newDstAlpha));
}
}
}
diff --git a/libs/pigment/tests/TestCompositeOpInversion_p.cpp b/libs/pigment/tests/TestCompositeOpInversion_p.cpp
index 9c62234c6b..c0a373cc72 100644
--- a/libs/pigment/tests/TestCompositeOpInversion_p.cpp
+++ b/libs/pigment/tests/TestCompositeOpInversion_p.cpp
@@ -14,59 +14,62 @@
#include <KoCompositeOpGeneric2.h>
#include <KoCompositeOpFunctions2.h>
#include "compositeops/KoColorSpaceBlendingPolicy.h"
+#include "compositeops/KoCompositeOpClampPolicy.h"
const KoCompositeOp* createOp(const KoColorSpace *cs, const QString &id, bool isHDR)
{
+ using namespace KoCompositeOpClampPolicy;
+
const KoCompositeOp *op = nullptr;
if (id == COMPOSITE_DODGE) {
if (cs->colorDepthId() == Float32BitsColorDepthID) {
using Traits = KoRgbF32Traits;
if (isHDR) {
- using func = CFColorDodge<float, ClampPolicyFloatHDR>;
+ using func = CFColorDodge<float, ClampAsFloatHDR>;
op = new KoCompositeOpGenericSCFunctor<Traits, func, KoAdditiveBlendingPolicy<Traits>>(cs, id, KoCompositeOp::categoryLight());
} else {
- using func = CFColorDodge<float, ClampPolicyFloatSDR>;
+ using func = CFColorDodge<float, ClampAsFloatSDR>;
op = new KoCompositeOpGenericSCFunctor<Traits, func, KoAdditiveBlendingPolicy<Traits>>(cs, id, KoCompositeOp::categoryLight());
}
} else if (cs->colorDepthId() == Integer16BitsColorDepthID) {
using Traits = KoRgbU16Traits;
- using func = CFColorDodge<quint16, ClampPolicyInteger>;
+ using func = CFColorDodge<quint16, ClampAsInteger>;
op = new KoCompositeOpGenericSCFunctor<Traits, func, KoAdditiveBlendingPolicy<Traits>>(cs, id, KoCompositeOp::categoryLight());
}
} else if (id == COMPOSITE_BURN) {
if (cs->colorDepthId() == Float32BitsColorDepthID) {
using Traits = KoRgbF32Traits;
if (isHDR) {
- using func = CFColorBurn<float, ClampPolicyFloatHDR>;
+ using func = CFColorBurn<float, ClampAsFloatHDR>;
op = new KoCompositeOpGenericSCFunctor<Traits, func,
KoAdditiveBlendingPolicy<Traits>>
(cs, id, KoCompositeOp::categoryDark());
} else {
- using func = CFColorBurn<float, ClampPolicyFloatSDR>;
+ using func = CFColorBurn<float, ClampAsFloatSDR>;
op = new KoCompositeOpGenericSCFunctor<Traits, func,
KoAdditiveBlendingPolicy<Traits>>
(cs, id, KoCompositeOp::categoryDark());
}
} else if (cs->colorDepthId() == Integer16BitsColorDepthID) {
using Traits = KoRgbU16Traits;
- using func = CFColorBurn<quint16, ClampPolicyInteger>;
+ using func = CFColorBurn<quint16, ClampAsInteger>;
op = new KoCompositeOpGenericSCFunctor<Traits, func, KoAdditiveBlendingPolicy<Traits>>(cs, id, KoCompositeOp::categoryDark());
}
} else if (id == COMPOSITE_LINEAR_BURN) {
if (cs->colorDepthId() == Float32BitsColorDepthID) {
using Traits = KoRgbF32Traits;
if (isHDR) {
- using func = CFLinearBurn<float, ClampPolicyFloatHDR>;
+ using func = CFLinearBurn<float, ClampAsFloatHDR>;
op = new KoCompositeOpGenericSCFunctor<Traits, func, KoAdditiveBlendingPolicy<Traits>>(cs, id, KoCompositeOp::categoryDark());
} else {
- using func = CFLinearBurn<float, ClampPolicyFloatSDR>;
+ using func = CFLinearBurn<float, ClampAsFloatSDR>;
op = new KoCompositeOpGenericSCFunctor<Traits, func, KoAdditiveBlendingPolicy<Traits>>(cs, id, KoCompositeOp::categoryDark());
}
} else if (cs->colorDepthId() == Integer16BitsColorDepthID) {
using Traits = KoRgbU16Traits;
- using func = CFLinearBurn<quint16, ClampPolicyInteger>;
+ using func = CFLinearBurn<quint16, ClampAsInteger>;
op = new KoCompositeOpGenericSCFunctor<Traits, func, KoAdditiveBlendingPolicy<Traits>>(cs, id, KoCompositeOp::categoryDark());
}
@@ -104,45 +107,45 @@ const KoCompositeOp* createOp(const KoColorSpace *cs, const QString &id, bool is
if (cs->colorDepthId() == Float32BitsColorDepthID) {
using Traits = KoRgbF32Traits;
if (isHDR) {
- using func = CFVividLight<float, ClampPolicyFloatHDR>;
+ using func = CFVividLight<float, ClampAsFloatHDR>;
op = new KoCompositeOpGenericSCFunctor<Traits, func, KoAdditiveBlendingPolicy<Traits>>(cs, id, KoCompositeOp::categoryDark());
} else {
- using func = CFVividLight<float, ClampPolicyFloatSDR>;
+ using func = CFVividLight<float, ClampAsFloatSDR>;
op = new KoCompositeOpGenericSCFunctor<Traits, func, KoAdditiveBlendingPolicy<Traits>>(cs, id, KoCompositeOp::categoryDark());
}
} else if (cs->colorDepthId() == Integer16BitsColorDepthID) {
using Traits = KoRgbU16Traits;
- using func = CFVividLight<quint16, ClampPolicyInteger>;
+ using func = CFVividLight<quint16, ClampAsInteger>;
op = new KoCompositeOpGenericSCFunctor<Traits, func, KoAdditiveBlendingPolicy<Traits>>(cs, id, KoCompositeOp::categoryArithmetic());
}
} else if (id == COMPOSITE_HARD_OVERLAY) {
if (cs->colorDepthId() == Float32BitsColorDepthID) {
using Traits = KoRgbF32Traits;
if (isHDR) {
- using func = CFHardOverlay<float, ClampPolicyFloatHDR>;
+ using func = CFHardOverlay<float, ClampAsFloatHDR>;
op = new KoCompositeOpGenericSCFunctor<Traits, func, KoAdditiveBlendingPolicy<Traits>>(cs, id, KoCompositeOp::categoryDark());
} else {
- using func = CFHardOverlay<float, ClampPolicyFloatSDR>;
+ using func = CFHardOverlay<float, ClampAsFloatSDR>;
op = new KoCompositeOpGenericSCFunctor<Traits, func, KoAdditiveBlendingPolicy<Traits>>(cs, id, KoCompositeOp::categoryDark());
}
} else if (cs->colorDepthId() == Integer16BitsColorDepthID) {
using Traits = KoRgbU16Traits;
- using func = CFHardOverlay<quint16, ClampPolicyInteger>;
+ using func = CFHardOverlay<quint16, ClampAsInteger>;
op = new KoCompositeOpGenericSCFunctor<Traits, func, KoAdditiveBlendingPolicy<Traits>>(cs, id, KoCompositeOp::categoryArithmetic());
}
} else if (id == COMPOSITE_PIN_LIGHT) {
if (cs->colorDepthId() == Float32BitsColorDepthID) {
using Traits = KoRgbF32Traits;
if (isHDR) {
- using func = CFPinLight<float, ClampPolicyFloatHDR>;
+ using func = CFPinLight<float, ClampAsFloatHDR>;
op = new KoCompositeOpGenericSCFunctor<Traits, func, KoAdditiveBlendingPolicy<Traits>>(cs, id, KoCompositeOp::categoryDark());
} else {
- using func = CFPinLight<float, ClampPolicyFloatSDR>;
+ using func = CFPinLight<float, ClampAsFloatSDR>;
op = new KoCompositeOpGenericSCFunctor<Traits, func, KoAdditiveBlendingPolicy<Traits>>(cs, id, KoCompositeOp::categoryDark());
}
} else if (cs->colorDepthId() == Integer16BitsColorDepthID) {
using Traits = KoRgbU16Traits;
- using func = CFPinLight<quint16, ClampPolicyInteger>;
+ using func = CFPinLight<quint16, ClampAsInteger>;
op = new KoCompositeOpGenericSCFunctor<Traits, func, KoAdditiveBlendingPolicy<Traits>>(cs, id, KoCompositeOp::categoryArithmetic());
}
} else if (id == COMPOSITE_ADD) {
@@ -259,15 +262,15 @@ const KoCompositeOp* createOp(const KoColorSpace *cs, const QString &id, bool is
if (cs->colorDepthId() == Float32BitsColorDepthID) {
using Traits = KoRgbF32Traits;
if (isHDR) {
- using func = CFHardMix<float, ClampPolicyFloatHDR>;
+ using func = CFHardMix<float, ClampAsFloatHDR>;
op = new KoCompositeOpGenericSCFunctor<Traits, func, KoAdditiveBlendingPolicy<Traits>>(cs, id, KoCompositeOp::categoryDark());
} else {
- using func = CFHardMix<float, ClampPolicyFloatSDR>;
+ using func = CFHardMix<float, ClampAsFloatSDR>;
op = new KoCompositeOpGenericSCFunctor<Traits, func, KoAdditiveBlendingPolicy<Traits>>(cs, id, KoCompositeOp::categoryDark());
}
} else if (cs->colorDepthId() == Integer16BitsColorDepthID) {
using Traits = KoRgbU16Traits;
- using func = CFHardMix<quint16, ClampPolicyInteger>;
+ using func = CFHardMix<quint16, ClampAsInteger>;
op = new KoCompositeOpGenericSCFunctor<Traits, func, KoAdditiveBlendingPolicy<Traits>>(cs, id, KoCompositeOp::categoryArithmetic());
}
} else if (id == COMPOSITE_HARD_MIX_PHOTOSHOP) {