[gimp] Bug 780907 - GIMP 2.9.5 layer-blending-mode Tear



commit 2d22d0b0ff991fd21823f0f1da7e6b087520f931
Author: Ell <ell_se yahoo com>
Date:   Tue Apr 4 16:24:48 2017 -0400

    Bug 780907 - GIMP 2.9.5 layer-blending-mode Tear
    
    Commit 9d4084c82f8a7fa942b201ec651577d22b25f9c6 skips conversion and
    blending of (some) transparent source and destination pixels.  When
    `blend_out == blend_layer`, it banks on the fact that the alpha values
    of `blend_out` would be the same as those of `blend_layer`, and hence
    the same as those of `layer`; thing is, we only copy those values from
    `layer` to `blend_layer` for the pixels that we *don't* skip, so this
    assumption is just wrong :P  This leaves us with bogus alpha values in
    `blend_out` for the skipped pixels, when the above equality holds.
    For composite modes that use the alpha values of `blend_op` (aka `comp`)
    even for transparent input pixels (i.e., src-atop and src-in), this may
    result in artifacts.
    
    Fix this by simply initializing the alpha values of `blend_out` for
    skipped pixels unconditionally.

 .../layer-modes/gimpoperationlayermode.c           |   27 ++++---------------
 1 files changed, 6 insertions(+), 21 deletions(-)
---
diff --git a/app/operations/layer-modes/gimpoperationlayermode.c 
b/app/operations/layer-modes/gimpoperationlayermode.c
index e71103c..c9d18b5 100644
--- a/app/operations/layer-modes/gimpoperationlayermode.c
+++ b/app/operations/layer-modes/gimpoperationlayermode.c
@@ -1118,24 +1118,12 @@ gimp_composite_blend (GimpOperationLayerMode *layer_mode,
           /* skip any unblended samples.  the color values of `blend_out` for
            * these samples are unconstrained, in particular, they may be NaN,
            * but the alpha values should generally be finite, and specifically
-           * 0 when the source alpha is 0.  when `blend_out == blend_layer`,
-           * this is the case anyway, but otherwise, we need to manually set
-           * the unblended samples' alpha to zero.
+           * 0 when the source alpha is 0.
            */
-          if (blend_out == blend_layer)
+          while (i < end && (in[i] == 0.0f || layer[i] == 0.0f))
             {
-              while (i < end && (in[i] == 0.0f || layer[i] == 0.0f))
-                {
-                  i += 4;
-                }
-            }
-          else
-            {
-              while (i < end && (in[i] == 0.0f || layer[i] == 0.0f))
-                {
-                  blend_out[i] = 0.0f;
-                  i += 4;
-                }
+              blend_out[i] = 0.0f;
+              i += 4;
             }
 
           /* stop if there are no more samples */
@@ -1181,11 +1169,8 @@ gimp_composite_blend (GimpOperationLayerMode *layer_mode,
           /* make sure the alpha values of `blend_out` are valid for the
            * trailing unblended samples.
            */
-          if (blend_out != blend_layer)
-            {
-              for (; last < i; last += 4)
-                blend_out[last] = 0.0f;
-            }
+          for (; last < i; last += 4)
+            blend_out[last] = 0.0f;
         }
     }
   else


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