[gimp/goat-invasion] app: added initial gegl replace mode



commit d2a7150cbf3acc362661c90f559d4ea0446e4353
Author: Ville Sokk <ville sokk gmail com>
Date:   Tue Apr 24 12:25:19 2012 +0300

    app: added initial gegl replace mode

 app/core/gimpdrawable-combine.c     |    2 +-
 app/gegl/gimp-gegl-nodes.c          |    1 -
 app/gegl/gimpoperationreplacemode.c |   24 ++++++++++++++++++++----
 3 files changed, 21 insertions(+), 6 deletions(-)
---
diff --git a/app/core/gimpdrawable-combine.c b/app/core/gimpdrawable-combine.c
index 48e7961..4abc088 100644
--- a/app/core/gimpdrawable-combine.c
+++ b/app/core/gimpdrawable-combine.c
@@ -122,7 +122,7 @@ gimp_drawable_real_apply_buffer (GimpDrawable         *drawable,
         }
     }
 
-  if (FALSE /* XXX gimp_use_gegl (image->gimp) && ! dest_buffer */)
+  if (gimp_use_gegl (image->gimp) && ! dest_buffer)
     {
       GeglBuffer *mask_buffer = NULL;
       GeglNode   *apply;
diff --git a/app/gegl/gimp-gegl-nodes.c b/app/gegl/gimp-gegl-nodes.c
index dde78ce..a750634 100644
--- a/app/gegl/gimp-gegl-nodes.c
+++ b/app/gegl/gimp-gegl-nodes.c
@@ -256,7 +256,6 @@ gimp_gegl_node_set_layer_mode (GeglNode             *node,
     case GIMP_VALUE_MODE:
     case GIMP_COLOR_ERASE_MODE:
     case GIMP_ERASE_MODE:
-    case GIMP_REPLACE_MODE:
     case GIMP_ANTI_ERASE_MODE:
       gegl_node_set (node,
                      "operation",     "gimp:point-layer-mode",
diff --git a/app/gegl/gimpoperationreplacemode.c b/app/gegl/gimpoperationreplacemode.c
index e8cd21c..2143772 100644
--- a/app/gegl/gimpoperationreplacemode.c
+++ b/app/gegl/gimpoperationreplacemode.c
@@ -78,10 +78,26 @@ gimp_operation_replace_mode_process (GeglOperation       *operation,
 
   while (samples--)
     {
-      out[RED]   = in[RED];
-      out[GREEN] = in[GREEN];
-      out[BLUE]  = in[BLUE];
-      out[ALPHA] = in[ALPHA];
+      gint b;
+      gfloat ratio = 1 / layer[ALPHA] / layer[ALPHA];
+
+      for (b = RED; b < ALPHA; b++)
+        {
+          gfloat t;
+
+          if (layer[b] > in[b])
+            {
+              t = (layer[b] - in[b]) * ratio;
+              out[b] = in[b] + t;
+            }
+          else
+            {
+              t= (in[b] - layer[b]) * ratio;
+              out[b] = in[b] - t;
+            }
+        }
+
+      out[ALPHA] = layer[ALPHA];
 
       in    += 4;
       layer += 4;



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