[gimp] app: avoid an alloca in gimp_composite_blend()



commit 2ee8a2ed573b73b239a2448228c89947203618da
Author: Ell <ell_se yahoo com>
Date:   Mon Feb 27 13:49:51 2017 -0500

    app: avoid an alloca in gimp_composite_blend()
    
    Reuse one of the blend-func input buffers for output, when doing
    in-place processing and requiring a blend-space conversion.

 .../layer-modes/gimpoperationlayermode.c           |   13 +++++++++----
 1 files changed, 9 insertions(+), 4 deletions(-)
---
diff --git a/app/operations/layer-modes/gimpoperationlayermode.c 
b/app/operations/layer-modes/gimpoperationlayermode.c
index 3f50394..c44e96d 100644
--- a/app/operations/layer-modes/gimpoperationlayermode.c
+++ b/app/operations/layer-modes/gimpoperationlayermode.c
@@ -782,10 +782,6 @@ gimp_composite_blend (GimpOperationLayerMode *layer_mode,
                                                             [composite_space - 1];
     }
 
-  if (in == out) /* in-place detected, avoid clobbering since we need to
-                    read it for the compositing stage  */
-    blend_out = g_alloca (sizeof (gfloat) * 4 * samples);
-
   if (composite_to_blend_fish)
     {
       if (in != out || composite_needs_in_color)
@@ -801,6 +797,15 @@ gimp_composite_blend (GimpOperationLayerMode *layer_mode,
       babl_process (composite_to_blend_fish, layer, blend_layer, samples);
     }
 
+  if (in == out) /* in-place detected, avoid clobbering since we need to
+                    read 'in' for the compositing stage  */
+    {
+      if (blend_layer != layer)
+        blend_out = blend_layer;
+      else
+        blend_out = g_alloca (sizeof (gfloat) * 4 * samples);
+    }
+
   blend_func (blend_in, blend_layer, blend_out, samples);
 
   if (blend_to_composite_fish)


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