Commit 3a226430 authored by Michael Natterer's avatar Michael Natterer 😴 Committed by Michael Natterer

always take the "value" property into account even if there is an aux mask

2008-11-02  Michael Natterer  <mitch@gimp.org>

	* operations/common/opacity.c: always take the "value" property
	into account even if there is an aux mask input. This way we can
	optimize one node away when a graph has both opacity and mask
	nodes (as in the gimp layer stack).


svn path=/trunk/; revision=2683
parent f28b32a4
2008-11-02 Michael Natterer <mitch@gimp.org>
* operations/common/opacity.c: always take the "value" property
into account even if there is an aux mask input. This way we can
optimize one node away when a graph has both opacity and mask
nodes (as in the gimp layer stack).
2008-11-02 Øyvind Kolås <pippin@gimp.org>
* gegl/property-types/gegl-path.[ch]: cleaned up header and made
......
......@@ -22,8 +22,8 @@
#ifdef GEGL_CHANT_PROPERTIES
gegl_chant_double (value, _("Opacity"), -10.0, 10.0, 0.5,
_("Global opacity value, used if no auxiliary input buffer is provided."))
gegl_chant_double (value, _("Opacity"), -10.0, 10.0, 1.0,
_("Global opacity value that is always used on top of the optional auxiliary input buffer."))
#else
......@@ -51,18 +51,46 @@ process (GeglOperation *op,
gfloat *in = in_buf;
gfloat *out = out_buf;
gfloat *aux = aux_buf;
gfloat value = GEGL_CHANT_PROPERTIES (op)->value;
if (aux == NULL)
{
if (value == 1.0)
{
gint i;
for (i=0; i<n_pixels; i++)
{
gint j;
for (j=0; j<4; j++)
out[j] = in[j];
in += 4;
out += 4;
}
}
else
{
gint i;
for (i=0; i<n_pixels; i++)
{
gint j;
for (j=0; j<4; j++)
out[j] = in[j] * value;
in += 4;
out += 4;
}
}
}
else if (value == 1.0)
{
gint i;
gfloat value = GEGL_CHANT_PROPERTIES (op)->value;
for (i=0; i<n_pixels; i++)
{
gint j;
for (j=0; j<4; j++)
out[j] = in[j] * value;
out[j] = in[j] * (*aux);
in += 4;
out += 4;
aux += 1;
}
}
else
......@@ -70,9 +98,10 @@ process (GeglOperation *op,
gint i;
for (i=0; i<n_pixels; i++)
{
gint v = (*aux) * value;
gint j;
for (j=0; j<4; j++)
out[j] = in[j] * (*aux);
out[j] = in[j] * v;
in += 4;
out += 4;
aux += 1;
......@@ -97,8 +126,8 @@ gegl_chant_class_init (GeglChantClass *klass)
operation_class->name = "gegl:opacity";
operation_class->categories = "transparency";
operation_class->description =
_("Weights the opacity of the input with either the value of the aux"
" input or the global value property.");
_("Weights the opacity of the input both the value of the aux"
" input and the global value property.");
}
#endif
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