[gimp] app: GimpIscissorsTool: move one-time initializations to class_init()



commit e5fc441433a8bb987fe9aa0bfa8ef180084e8b34
Author: Michael Natterer <mitch gimp org>
Date:   Sun May 20 19:19:12 2012 +0200

    app: GimpIscissorsTool: move one-time initializations to class_init()

 app/tools/gimpiscissorstool.c |   26 ++++++++++----------------
 1 files changed, 10 insertions(+), 16 deletions(-)
---
diff --git a/app/tools/gimpiscissorstool.c b/app/tools/gimpiscissorstool.c
index 12bf086..5d1fae6 100644
--- a/app/tools/gimpiscissorstool.c
+++ b/app/tools/gimpiscissorstool.c
@@ -289,7 +289,8 @@ gimp_iscissors_tool_class_init (GimpIscissorsToolClass *klass)
   GObjectClass      *object_class    = G_OBJECT_CLASS (klass);
   GimpToolClass     *tool_class      = GIMP_TOOL_CLASS (klass);
   GimpDrawToolClass *draw_tool_class = GIMP_DRAW_TOOL_CLASS (klass);
-  gint               i;
+  gint               i, j;
+  gint               radius;
 
   object_class->finalize     = gimp_iscissors_tool_finalize;
 
@@ -320,6 +321,14 @@ gimp_iscissors_tool_class_init (GimpIscissorsToolClass *klass)
   direction_value[255][1] = 255;
   direction_value[255][2] = 255;
   direction_value[255][3] = 255;
+
+  /*  compute the distance weights  */
+  radius = GRADIENT_SEARCH >> 1;
+
+  for (i = 0; i < GRADIENT_SEARCH; i++)
+    for (j = 0; j < GRADIENT_SEARCH; j++)
+      distance_weights[i * GRADIENT_SEARCH + j] =
+        1.0 / (1 + sqrt (SQR (i - radius) + SQR (j - radius)));
 }
 
 static void
@@ -1649,8 +1658,6 @@ gradmap_tile_validate (TileManager *tm,
                        Tile        *tile,
                        GimpImage   *image)
 {
-  static gboolean first_gradient = TRUE;
-
   GimpPickable *pickable;
   const Babl   *pickable_format;
   GeglBuffer   *src_buffer;
@@ -1666,19 +1673,6 @@ gradmap_tile_validate (TileManager *tm,
   guint8       *tiledata;
   guint8       *gradmap;
 
-  if (first_gradient)
-    {
-      gint radius = GRADIENT_SEARCH >> 1;
-
-      /*  compute the distance weights  */
-      for (i = 0; i < GRADIENT_SEARCH; i++)
-        for (j = 0; j < GRADIENT_SEARCH; j++)
-          distance_weights[i * GRADIENT_SEARCH + j] =
-            1.0 / (1 + sqrt (SQR (i - radius) + SQR (j - radius)));
-
-      first_gradient = FALSE;
-    }
-
   tile_manager_get_tile_coordinates (tm, tile, &x, &y);
 
   dw = tile_ewidth (tile);



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