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



commit d0a6b2263f48a00422ba0c85c23eedb62a6ff1c2
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]