[gimp/pippin/linear-is-the-new-black: 2/19] app: replace softlight code with blendfun



commit decdacea9e3fa661eb45ef3d0b93a8b1a9615f17
Author: Øyvind Kolås <pippin gimp org>
Date:   Mon Jan 16 18:34:15 2017 +0100

    app: replace softlight code with blendfun

 .../layer-modes/gimpoperationpointlayermode.h      |    3 +-
 .../layer-modes/gimpoperationsoftlight.c           |   61 ++------------------
 2 files changed, 7 insertions(+), 57 deletions(-)
---
diff --git a/app/operations/layer-modes/gimpoperationpointlayermode.h 
b/app/operations/layer-modes/gimpoperationpointlayermode.h
index 2895ee2..503bb69 100644
--- a/app/operations/layer-modes/gimpoperationpointlayermode.h
+++ b/app/operations/layer-modes/gimpoperationpointlayermode.h
@@ -644,7 +644,6 @@ blendfun_hardlight (const float *dest,
   }
 }
 
-
 static inline void
 blendfun_softlight (const float *dest,
                     const float *src,
@@ -658,7 +657,7 @@ blendfun_softlight (const float *dest,
       int c;
       for (c = 0; c < 3; c++)
       {
-        gfloat multiply = dest[c] - src[c];
+        gfloat multiply = dest[c] * src[c];
         gfloat screen = 1.0f - (1.0f - dest[c]) * (1.0f - src[c]);
         gfloat comp = (1.0f - src[c]) * multiply + dest[c] * screen;
         out[c] = comp;
diff --git a/app/operations/layer-modes/gimpoperationsoftlight.c 
b/app/operations/layer-modes/gimpoperationsoftlight.c
index 74b3ea1..ec4ad81 100644
--- a/app/operations/layer-modes/gimpoperationsoftlight.c
+++ b/app/operations/layer-modes/gimpoperationsoftlight.c
@@ -107,60 +107,11 @@ gimp_operation_softlight_process_pixels (gfloat              *in,
                                          const GeglRectangle *roi,
                                          gint                 level)
 {
-  const gboolean has_mask = mask != NULL;
-
-  while (samples--)
-    {
-      gfloat comp_alpha;
-
-      comp_alpha = layer[ALPHA] * opacity;
-      if (has_mask)
-        comp_alpha *= *mask;
-
-      if (comp_alpha != 0.0f)
-        {
-          gint   b;
-
-          for (b = RED; b < ALPHA; b++)
-            {
-#if 0
-              /* softlight is now used for what GIMP formerly called
-               * OVERLAY.  We fixed OVERLAY to use the right math
-               * (under the name NEW_OVERLAY), and redirect uses of
-               * the old OVERLAY blend mode here. This math was
-               * formerly used for OVERLAY and is exactly the same as
-               * the multiply, screen, comp math used below.
-               * See bug #673501.
-               */
-              gfloat comp = in[b] * (in[b] + (2.0 * layer[b]) * (1.0 - in[b]));
-#endif
-
-              gfloat multiply = in[b] * layer[b];
-              gfloat screen   = 1.0 - (1.0 - in[b]) * (1.0 - layer[b]);
-              gfloat comp     = (1.0 - in[b]) * multiply + in[b] * screen;
-
-              out[b] = comp * comp_alpha + in[b] * (1.0 - comp_alpha);
-            }
-        }
-      else
-        {
-          gint b;
-
-          for (b = RED; b < ALPHA; b++)
-            {
-              out[b] = in[b];
-            }
-        }
-
-      out[ALPHA] = in[ALPHA];
-
-      in    += 4;
-      layer += 4;
-      out   += 4;
-
-      if (has_mask)
-        mask ++;
-    }
-
+  gimp_composite_blend (
+     in, layer, mask, out, opacity, samples,
+     GIMP_LAYER_BLEND_RGB_PERCEPTUAL,
+     GIMP_LAYER_COMPOSITE_SRC_ATOP,
+     blendfun_softlight
+     );
   return TRUE;
 }


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