71 {
73
74 srcAlpha =
mul(srcAlpha, maskAlpha, opacity);
75
76 if (isZeroValueFuzzy(srcAlpha)) {
77 return dstAlpha;
78 }
79
80 if(alphaLocked) {
81 if(!isZeroValueFuzzy(dstAlpha)) {
83 if(i !=
alpha_pos && (allChannelFlags || channelFlags.testBit(i))) {
85 CompositeOpFunctor::clampSourceChannelValue(
86 BlendingPolicy::toAdditiveSpace(
87 src[i]));
89 CompositeOpFunctor::clampDestinationChannelValue(
90 BlendingPolicy::toAdditiveSpace(
91 dst[i]));
92
93 dst[i] = BlendingPolicy::fromAdditiveSpace(
95 CompositeOpFunctor::composeChannel(srcInBlendSpace, dstInBlendSpace),
96 srcAlpha));
97 }
98 }
99 }
100
101 return dstAlpha;
102 } else if (isZeroValueFuzzy(dstAlpha)) {
104 if(i !=
alpha_pos && (allChannelFlags || channelFlags.testBit(i))) {
105 dst[i] = BlendingPolicy::fromAdditiveSpace(
106 CompositeOpFunctor::clampSourceChannelValue(
107 BlendingPolicy::toAdditiveSpace(src[i])));
108 }
109 }
110 return srcAlpha;
111 } else if (isUnitValueFuzzy(dstAlpha)) {
113 if(i !=
alpha_pos && (allChannelFlags || channelFlags.testBit(i))) {
115 CompositeOpFunctor::clampSourceChannelValue(
116 BlendingPolicy::toAdditiveSpace(
117 src[i]));
119 CompositeOpFunctor::clampDestinationChannelValue(
120 BlendingPolicy::toAdditiveSpace(
121 dst[i]));
122
123 dst[i] = BlendingPolicy::fromAdditiveSpace(
124 lerp(dstInBlendSpace,
125 CompositeOpFunctor::composeChannel(srcInBlendSpace, dstInBlendSpace),
126 srcAlpha));
127 }
128 }
129 return unitValue<channels_type>();
130 } else if (isUnitValueFuzzy(srcAlpha)) {
132 if(i !=
alpha_pos && (allChannelFlags || channelFlags.testBit(i))) {
134 CompositeOpFunctor::clampSourceChannelValue(
135 BlendingPolicy::toAdditiveSpace(
136 src[i]));
138 CompositeOpFunctor::clampDestinationChannelValue(
139 BlendingPolicy::toAdditiveSpace(
140 dst[i]));
141
142 dst[i] = BlendingPolicy::fromAdditiveSpace(
143 lerp(srcInBlendSpace,
144 CompositeOpFunctor::composeChannel(srcInBlendSpace, dstInBlendSpace),
145 dstAlpha));
146 }
147 }
148 return unitValue<channels_type>();
149 } else {
151
152 if (!isZeroValueFuzzy(newDstAlpha)) {
153
155 if(i !=
alpha_pos && (allChannelFlags || channelFlags.testBit(i))) {
157 CompositeOpFunctor::clampSourceChannelValue(
158 BlendingPolicy::toAdditiveSpace(
159 src[i]));
161 CompositeOpFunctor::clampDestinationChannelValue(
162 BlendingPolicy::toAdditiveSpace(
163 dst[i]));
164
166 blend(srcInBlendSpace, srcAlpha,
167 dstInBlendSpace, dstAlpha,
168 CompositeOpFunctor::composeChannel(srcInBlendSpace, dstInBlendSpace));
169
170 dst[i] = BlendingPolicy::fromAdditiveSpace(
div(result, newDstAlpha));
171 }
172 }
173 }
174
175 return newDstAlpha;
176 }
177 }
QPointF lerp(const QPointF &p1, const QPointF &p2, qreal t)
Traits::channels_type channels_type
static const qint32 alpha_pos
static const qint32 channels_nb
T blend(T src, T srcAlpha, T dst, T dstAlpha, T cfValue)
T unionShapeOpacity(T a, T b)
KoColorSpaceMathsTraits< T >::compositetype div(T a, T b)