Commit 9838f9c6 authored by Wolthera van Hövell's avatar Wolthera van Hövell 🛍

Revert "Temporarily push D18467"

This reverts commit e3c2f5be.

As noted in the original commit, reverting this till it was reviewed properly.

Artists are very happy with it in any case.
parent 60675b40
......@@ -57,7 +57,7 @@ public:
qint32 srcInc = (params.srcRowStride == 0) ? 0 : channels_nb;
channels_type flow = scale<channels_type>(params.flow);
channels_type opacity = scale<channels_type>(params.opacity);
channels_type opacity = mul(flow, scale<channels_type>(params.opacity));
quint8* dstRowStart = params.dstRowStart;
const quint8* srcRowStart = params.srcRowStart;
const quint8* maskRowStart = params.maskRowStart;
......@@ -89,7 +89,7 @@ public:
if(alpha_pos != -1) {
channels_type fullFlowAlpha;
channels_type averageOpacity = scale<channels_type>(*params.lastOpacity);
channels_type averageOpacity = mul(flow, scale<channels_type>(*params.lastOpacity));
if (averageOpacity > opacity) {
channels_type reverseBlend = KoColorSpaceMaths<channels_type>::divide(dstAlpha, averageOpacity);
......@@ -101,7 +101,7 @@ public:
if (params.flow == 1.0) {
dstAlpha = fullFlowAlpha;
} else {
channels_type zeroFlowAlpha = dstAlpha;
channels_type zeroFlowAlpha = unionShapeOpacity(srcAlpha, dstAlpha);
dstAlpha = lerp(zeroFlowAlpha, fullFlowAlpha, flow);
}
......
......@@ -29,11 +29,13 @@ struct AlphaDarkenCompositor128 {
struct OptionalParams {
OptionalParams(const KoCompositeOp::ParameterInfo& params)
: flow(params.flow)
, averageOpacity(*params.lastOpacity)
, averageOpacity(*params.lastOpacity * params.flow)
, premultipliedOpacity(params.opacity * params.flow)
{
}
float flow;
float averageOpacity;
float premultipliedOpacity;
};
struct Pixel {
......@@ -81,7 +83,12 @@ struct AlphaDarkenCompositor128 {
msk_norm_alpha = src_alpha;
}
Vc::float_v opacity_vec(opacity);
// we don't use directly passed value
Q_UNUSED(opacity);
// instead we should use opacity premultiplied by flow
opacity = oparams.premultipliedOpacity;
Vc::float_v opacity_vec(oparams.premultipliedOpacity);
src_alpha = msk_norm_alpha * opacity_vec;
......@@ -135,7 +142,7 @@ struct AlphaDarkenCompositor128 {
dst_alpha = fullFlowAlpha;
}
else {
Vc::float_v zeroFlowAlpha = dst_alpha;
Vc::float_v zeroFlowAlpha = src_alpha + dst_alpha - src_alpha * dst_alpha;
Vc::float_v flow_norm_vec(oparams.flow);
dst_alpha = (fullFlowAlpha - zeroFlowAlpha) * flow_norm_vec + zeroFlowAlpha;
}
......@@ -159,6 +166,9 @@ struct AlphaDarkenCompositor128 {
const float uint8Rec1 = 1.0 / 255.0;
float mskAlphaNorm = haveMask ? float(*mask) * uint8Rec1 * src[alpha_pos] : src[alpha_pos];
Q_UNUSED(opacity);
opacity = oparams.premultipliedOpacity;
float srcAlphaNorm = mskAlphaNorm * opacity;
if (dstAlphaNorm != 0) {
......@@ -185,7 +195,7 @@ struct AlphaDarkenCompositor128 {
if (flow == 1.0) {
dst[alpha_pos] = fullFlowAlpha;
} else {
float zeroFlowAlpha = dstAlphaNorm;
float zeroFlowAlpha = unionShapeOpacity(srcAlphaNorm, dstAlphaNorm);
dst[alpha_pos] = lerp(zeroFlowAlpha, fullFlowAlpha, flow);
}
}
......
......@@ -31,11 +31,13 @@ struct AlphaDarkenCompositor32 {
struct OptionalParams {
OptionalParams(const KoCompositeOp::ParameterInfo& params)
: flow(params.flow),
averageOpacity(*params.lastOpacity)
averageOpacity(*params.lastOpacity * params.flow),
premultipliedOpacity(params.opacity * params.flow)
{
}
float flow;
float averageOpacity;
float premultipliedOpacity;
};
/**
......@@ -57,7 +59,12 @@ struct AlphaDarkenCompositor32 {
Vc::float_v src_alpha;
Vc::float_v dst_alpha;
Vc::float_v opacity_vec(255.0 * opacity);
// we don't use directly passed value
Q_UNUSED(opacity);
// instead we should use opacity premultiplied by flow
opacity = oparams.premultipliedOpacity;
Vc::float_v opacity_vec(255.0 * oparams.premultipliedOpacity);
Vc::float_v average_opacity_vec(255.0 * oparams.averageOpacity);
Vc::float_v flow_norm_vec(oparams.flow);
......@@ -163,7 +170,8 @@ struct AlphaDarkenCompositor32 {
if (oparams.flow == 1.0) {
dst_alpha = fullFlowAlpha;
} else {
Vc::float_v zeroFlowAlpha = dst_alpha;
Vc::float_v zeroFlowAlpha = src_alpha + dst_alpha -
dst_blend * dst_alpha;
dst_alpha = (fullFlowAlpha - zeroFlowAlpha) * flow_norm_vec + zeroFlowAlpha;
}
......@@ -188,6 +196,9 @@ struct AlphaDarkenCompositor32 {
float srcAlphaNorm;
float mskAlphaNorm;
Q_UNUSED(opacity);
opacity = oparams.premultipliedOpacity;
if (haveMask) {
mskAlphaNorm = float(*mask) * uint8Rec2 * src[alpha_pos];
srcAlphaNorm = mskAlphaNorm * opacity;
......@@ -223,7 +234,7 @@ struct AlphaDarkenCompositor32 {
if (flow == 1.0) {
dstAlpha = fullFlowAlpha * uint8Max;
} else {
float zeroFlowAlpha = dstAlphaNorm;
float zeroFlowAlpha = unionShapeOpacity(srcAlphaNorm, dstAlphaNorm);
dstAlpha = lerp(zeroFlowAlpha, fullFlowAlpha, flow) * uint8Max;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment