app: reintroduce clamping to vivid-light mode

... removed by commit 0f9da165e0, and
improved by this commit.

Our foo-light modes aren't really prepared to handle out-of-range
input.  Make sure that in-range input doesn't result in out-of-
range output.
This commit is contained in:
Ell 2018-01-06 12:51:08 -05:00
parent bc8c79e95a
commit d34800c5fc
1 changed files with 8 additions and 2 deletions

View File

@ -1083,9 +1083,15 @@ gimp_operation_layer_mode_blend_vivid_light (const gfloat *in,
gfloat val;
if (layer[c] <= 0.5f)
val = 1.0f - safe_div (1.0f - in[c], 2.0f * layer[c]);
{
val = 1.0f - safe_div (1.0f - in[c], 2.0f * layer[c]);
val = MAX (val, 0.0f);
}
else
val = safe_div (in[c], 2.0f * (1.0f - layer[c]));
{
val = safe_div (in[c], 2.0f * (1.0f - layer[c]));
val = MIN (val, 1.0f);
}
comp[c] = val;
}