[gimp/soc-2011-seamless-clone2] app: small optimization in gimp_operation_normal_mode_process()



commit cab20d3d4329f13de563f3a1a7df6ad210aa36d8
Author: Michael Natterer <mitch gimp org>
Date:   Sun Apr 28 23:32:49 2013 +0200

    app: small optimization in gimp_operation_normal_mode_process()
    
    Move some calculations out of the R,G,B loop, including a floating
    point division, now there is only one division left per pixel.

 app/operations/gimpoperationnormalmode.c |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)
---
diff --git a/app/operations/gimpoperationnormalmode.c b/app/operations/gimpoperationnormalmode.c
index 0e263be..9aed268 100644
--- a/app/operations/gimpoperationnormalmode.c
+++ b/app/operations/gimpoperationnormalmode.c
@@ -176,11 +176,13 @@ gimp_operation_normal_mode_process (GeglOperation       *operation,
 
       if (out[ALPHA])
         {
-          gint b;
+          gfloat in_weight       = in[ALPHA] * (1.0f - aux_alpha);
+          gfloat recip_out_alpha = 1.0f / out[ALPHA];
+          gint   b;
 
           for (b = RED; b < ALPHA; b++)
             {
-              out[b] = (aux[b] * aux_alpha + in[b] * in[ALPHA] * (1.0f - aux_alpha)) / out[ALPHA];
+              out[b] = (aux[b] * aux_alpha + in[b] * in_weight) * recip_out_alpha;
             }
         }
       else


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