[gimp/soc-2009-dynamics] Bail out early if dynamic opacity results in 0.0



commit aae7c2ef3872d624ff6207897a697ff2faf354ad
Author: Michael Natterer <mitch gimp org>
Date:   Tue Oct 13 20:18:55 2009 +0200

    Bail out early if dynamic opacity results in 0.0
    
    Same change needed anywhere, more to come.

 app/paint/gimppaintbrush.c |   19 ++++++++++++++-----
 1 files changed, 14 insertions(+), 5 deletions(-)
---
diff --git a/app/paint/gimppaintbrush.c b/app/paint/gimppaintbrush.c
index 792e3b8..27d11c1 100644
--- a/app/paint/gimppaintbrush.c
+++ b/app/paint/gimppaintbrush.c
@@ -111,20 +111,27 @@ _gimp_paintbrush_motion (GimpPaintCore    *paint_core,
 {
   GimpBrushCore            *brush_core = GIMP_BRUSH_CORE (paint_core);
   GimpContext              *context    = GIMP_CONTEXT (paint_options);
+  GimpDynamics             *dynamics   = brush_core->dynamics;
   GimpImage                *image;
   GimpRGB                   gradient_color;
   TempBuf                  *area;
   guchar                    col[MAX_CHANNELS];
   GimpPaintApplicationMode  paint_appl_mode;
+  gdouble                   fade_point;
   gdouble                   grad_point;
   gdouble                   hardness;
-  gdouble                   fade_point;
 
   image = gimp_item_get_image (GIMP_ITEM (drawable));
 
   fade_point = gimp_paint_options_get_fade (paint_options, image,
                                           paint_core->pixel_dist);
 
+  opacity *= gimp_dynamics_output_get_linear_value (dynamics->opacity_output,
+                                                    *coords,
+                                                    fade_point);
+  if (opacity == 0.0)
+    return;
+
   area = gimp_paint_core_get_paint_area (paint_core, drawable, paint_options,
                                          coords);
   if (! area)
@@ -132,7 +139,9 @@ _gimp_paintbrush_motion (GimpPaintCore    *paint_core,
 
   paint_appl_mode = paint_options->application_mode;
 
-  grad_point = gimp_dynamics_output_get_linear_value (brush_core->dynamics->color_output, *coords, fade_point);
+  grad_point = gimp_dynamics_output_get_linear_value (dynamics->color_output,
+                                                      *coords,
+                                                      fade_point);
 
   /* optionally take the color from the current gradient */
   if (gimp_paint_options_get_gradient_color (paint_options, image,
@@ -177,9 +186,9 @@ _gimp_paintbrush_motion (GimpPaintCore    *paint_core,
                     area->bytes);
     }
 
-  opacity *= gimp_dynamics_output_get_linear_value (brush_core->dynamics->opacity_output, *coords, fade_point);
-
-  hardness = gimp_dynamics_output_get_linear_value (brush_core->dynamics->hardness_output, *coords, fade_point);
+  hardness = gimp_dynamics_output_get_linear_value (dynamics->hardness_output,
+                                                    *coords,
+                                                    fade_point);
 
   /* finally, let the brush core paste the colored area on the canvas */
   gimp_brush_core_paste_canvas (brush_core, drawable,



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