app: clamp blended results for some compositing ops

Quite probably we shouldn't even clamp at the end, not doing that would speed
up compositing. See bug 744265.
This commit is contained in:
Øyvind Kolås 2015-10-15 00:22:53 +02:00
parent 940349c564
commit 23f118632c
6 changed files with 6 additions and 8 deletions

View file

@ -109,9 +109,9 @@ gimp_operation_burn_mode_process_pixels (gfloat *in,
for (b = RED; b < ALPHA; b++) for (b = RED; b < ALPHA; b++)
{ {
gfloat comp = (1.0 - in[b]) / layer[b]; gfloat comp = (1.0 - in[b]) / layer[b];
comp = CLAMP (1.0 - comp, 0.0, 1.0);
out[b] = comp * ratio + in[b] * (1.0 - ratio); out[b] = comp * ratio + in[b] * (1.0 - ratio);
out[b] = CLAMP (1.0 - out[b], 0.0, 1.0);
} }
} }
else else

View file

@ -109,9 +109,9 @@ gimp_operation_divide_mode_process_pixels (gfloat *in,
for (b = RED; b < ALPHA; b++) for (b = RED; b < ALPHA; b++)
{ {
gfloat comp = (4294967296.0 / 4294967295.0 * in[b]) / (1.0 / 4294967295.0 + layer[b]); gfloat comp = (4294967296.0 / 4294967295.0 * in[b]) / (1.0 / 4294967295.0 + layer[b]);
comp = CLAMP (comp, 0.0, 1.0);
out[b] = comp * ratio + in[b] * (1.0 - ratio); out[b] = comp * ratio + in[b] * (1.0 - ratio);
out[b] = CLAMP (out[b], 0.0, 1.0);
} }
} }
else else

View file

@ -109,9 +109,9 @@ gimp_operation_grain_extract_mode_process_pixels (gfloat *in,
for (b = RED; b < ALPHA; b++) for (b = RED; b < ALPHA; b++)
{ {
gfloat comp = in[b] - layer[b] + 0.5; gfloat comp = in[b] - layer[b] + 0.5;
comp = CLAMP (comp, 0.0, 1.0);
out[b] = comp * ratio + in[b] * (1.0 - ratio); out[b] = comp * ratio + in[b] * (1.0 - ratio);
out[b] = CLAMP (out[b], 0.0, 1.0);
} }
} }
else else

View file

@ -109,9 +109,9 @@ gimp_operation_grain_merge_mode_process_pixels (gfloat *in,
for (b = RED; b < ALPHA; b++) for (b = RED; b < ALPHA; b++)
{ {
gfloat comp = in[b] + layer[b] - 0.5; gfloat comp = in[b] + layer[b] - 0.5;
comp = CLAMP (comp, 0.0, 1.0);
out[b] = comp * ratio + in[b] * (1.0 - ratio); out[b] = comp * ratio + in[b] * (1.0 - ratio);
out[b] = CLAMP (out[b], 0.0, 1.0);
} }
} }
else else

View file

@ -109,9 +109,8 @@ gimp_operation_multiply_mode_process_pixels (gfloat *in,
for (b = RED; b < ALPHA; b++) for (b = RED; b < ALPHA; b++)
{ {
gfloat comp = layer[b] * in[b]; gfloat comp = layer[b] * in[b];
comp = CLAMP (comp, 0.0, 1.0);
out[b] = comp * ratio + in[b] * (1.0 - ratio); out[b] = comp * ratio + in[b] * (1.0 - ratio);
out[b] = CLAMP (out[b], 0.0, 1.0);
} }
} }
else else

View file

@ -109,9 +109,8 @@ gimp_operation_subtract_mode_process_pixels (gfloat *in,
for (b = RED; b < ALPHA; b++) for (b = RED; b < ALPHA; b++)
{ {
gfloat comp = in[b] - layer[b]; gfloat comp = in[b] - layer[b];
comp = (comp < 0) ? 0 : comp;
out[b] = comp * ratio + in[b] * (1.0 - ratio); out[b] = comp * ratio + in[b] * (1.0 - ratio);
out[b] = CLAMP(out[b], 0.0, 1.0);
} }
} }
else else