gegl r2683 - in trunk: . operations/common



Author: mitch
Date: Sun Nov  2 18:09:06 2008
New Revision: 2683
URL: http://svn.gnome.org/viewvc/gegl?rev=2683&view=rev

Log:
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).



Modified:
   trunk/ChangeLog
   trunk/operations/common/opacity.c

Modified: trunk/operations/common/opacity.c
==============================================================================
--- trunk/operations/common/opacity.c	(original)
+++ trunk/operations/common/opacity.c	Sun Nov  2 18:09:06 2008
@@ -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 @@
   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 @@
       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 @@
   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



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]