Commit 067e7f5d authored by Ivan Yossi's avatar Ivan Yossi 👌

Check for nan results on alphafactor

Vc do treats a nan as it is instead of silently converting to
a zero. This made the mask render wrongly on certain extreme
conditions like ratio = 0.

Also removed mask to clip non values (inf, -inf, nan) as it is not
possible to know if they were supposed to be 0,1 or something else
parent f3efbf17
......@@ -222,10 +222,6 @@ FastRowProcessor::process<Vc::CurrentImplementation::current()>(float* buffer, i
Vc::float_v fullFade = vAlphafactor * ( VcExtraMath::erf(valDist + vCenter) - VcExtraMath::erf(valDist - vCenter));
Vc::float_m mask;
// Mask undefined values, out of range are out of mask
mask = Vc::isfinite(fullFade);
fullFade.setZero(!mask);
// Mask in the inner circe of the mask
mask = fullFade < vZero;
fullFade.setZero(mask);
......@@ -411,9 +407,6 @@ FastRowProcessor::process<Vc::CurrentImplementation::current()>(float* buffer, i
d->fadeMaker.apply2DFader(fullFade,excludeMask,xr,yr);
Vc::float_m mask;
// Mask undefined values, out of range are out of mask
mask = Vc::isfinite(fullFade);
fullFade.setZero(!mask);
// Mask in the inner circe of the mask
mask = fullFade < vZero;
......@@ -426,7 +419,6 @@ FastRowProcessor::process<Vc::CurrentImplementation::current()>(float* buffer, i
// Mask (value - value), presicion errors.
Vc::float_v vFade = fullFade / vValMax;
// return original vValue values before vFade transform
vFade(excludeMask) = vValue;
vFade.store(bufferPointer, Vc::Aligned);
......
......@@ -100,6 +100,8 @@ void KisGaussRectangleMaskGenerator::setScale(qreal scaleX, qreal scaleY)
d->halfHeight = height * 0.5 - 2.5 * yfade;
d->alphafactor = 255.0 / (4.0 * erf(d->halfWidth * d->xfade) * erf(d->halfHeight * d->yfade));
if (isnan(d->alphafactor)) d->alphafactor = 0.0f; // erf can return nan if ratio is 0
d->fadeMaker.setLimits(0.5 * width, 0.5 * height);
}
......
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