[gimp] app: coding styls cleanup in core/gimpbrush-transform.[ch]



commit 6e65d1a3920a1ab6f6500102736d4ffba9b4a7c0
Author: Michael Natterer <mitch gimp org>
Date:   Fri Apr 8 21:18:39 2011 +0200

    app: coding styls cleanup in core/gimpbrush-transform.[ch]

 app/core/gimpbrush-transform.c |   94 +++++++++++++++++++++------------------
 app/core/gimpbrush-transform.h |   46 ++++++++++----------
 2 files changed, 74 insertions(+), 66 deletions(-)
---
diff --git a/app/core/gimpbrush-transform.c b/app/core/gimpbrush-transform.c
index ab5f388..ff35d37 100644
--- a/app/core/gimpbrush-transform.c
+++ b/app/core/gimpbrush-transform.c
@@ -21,35 +21,40 @@
 
 #include <glib-object.h>
 
-#include "core-types.h"
-
 #include "libgimpmath/gimpmath.h"
 
-#include "gimpbrush.h"
-#include "gimpbrush-transform.h"
+#include "core-types.h"
 
 #include "base/temp-buf.h"
 #include "base/pixel-region.h"
 
 #include "paint-funcs/paint-funcs.h"
 
+#include "gimpbrush.h"
+#include "gimpbrush-transform.h"
+
+
+#define MAX_BLUR_KERNEL 15
+
+
 /*  local function prototypes  */
 
-static void    gimp_brush_transform_bounding_box (TempBuf           *brush,
-                                                  const GimpMatrix3 *matrix,
-                                                  gint              *x,
-                                                  gint              *y,
-                                                  gint              *width,
-                                                  gint              *height);
+static void    gimp_brush_transform_bounding_box     (TempBuf           *brush,
+                                                      const GimpMatrix3 *matrix,
+                                                      gint              *x,
+                                                      gint              *y,
+                                                      gint              *width,
+                                                      gint              *height);
 
-static gdouble gimp_brush_transform_array_sum    (gfloat            *arr,
-                                                  gint               len);
+static gdouble gimp_brush_transform_array_sum        (gfloat            *arr,
+                                                      gint               len);
 static void    gimp_brush_transform_fill_blur_kernel (gfloat            *arr,
                                                       gint               len);
-static gint    gimp_brush_transform_blur_kernel_size (gint height,
-                                                      gint width,
-                                                      gdouble hardness);
-#define MAX_BLUR_KERNEL   15
+static gint    gimp_brush_transform_blur_kernel_size (gint               height,
+                                                      gint               width,
+                                                      gdouble            hardness);
+
+
 /*  public functions  */
 
 void
@@ -218,10 +223,10 @@ gimp_brush_real_transform_mask (GimpBrush *brush,
   src_tl_to_bl_delta_y = bly - tly;
 
   /* speed optimized, note conversion to int precision */
-  src_walk_ux_i = (gint) ((src_tl_to_tr_delta_x / dest_width)* int_multiple);
-  src_walk_uy_i = (gint) ((src_tl_to_tr_delta_y / dest_width)* int_multiple);
-  src_walk_vx_i = (gint) ((src_tl_to_bl_delta_x / dest_height)* int_multiple);
-  src_walk_vy_i = (gint) ((src_tl_to_bl_delta_y / dest_height)* int_multiple);
+  src_walk_ux_i = (gint) ((src_tl_to_tr_delta_x / dest_width)  * int_multiple);
+  src_walk_uy_i = (gint) ((src_tl_to_tr_delta_y / dest_width)  * int_multiple);
+  src_walk_vx_i = (gint) ((src_tl_to_bl_delta_x / dest_height) * int_multiple);
+  src_walk_vy_i = (gint) ((src_tl_to_bl_delta_y / dest_height) * int_multiple);
 
   /* initialize current position in source space to the start position (tl)
    * speed optimized, note conversion to int precision
@@ -326,9 +331,9 @@ gimp_brush_real_transform_mask (GimpBrush *brush,
       TempBuf      *blur_src;
       PixelRegion  srcPR;
       PixelRegion  destPR;
-      gint kernel_size = gimp_brush_transform_blur_kernel_size ( result->height,
-                                                                 result->width,
-                                                                 hardness);
+      gint kernel_size = gimp_brush_transform_blur_kernel_size (result->height,
+                                                                result->width,
+                                                                hardness);
       gint kernel_len  = kernel_size * kernel_size;
       gfloat blur_kernel [kernel_len];
 
@@ -351,7 +356,6 @@ gimp_brush_real_transform_mask (GimpBrush *brush,
   return result;
 }
 
-
 /*
  * Transforms the brush pixmap with bilinear interpolation.
  *
@@ -640,8 +644,6 @@ gimp_brush_real_transform_pixmap (GimpBrush *brush,
   return result;
 }
 
-
-
 void
 gimp_brush_transform_matrix (gdouble      width,
                              gdouble      height,
@@ -671,9 +673,9 @@ gimp_brush_transform_matrix (gdouble      width,
   gimp_matrix3_translate (matrix, - center_x * scale_x, - center_y * scale_y);
   gimp_matrix3_rotate (matrix, -2 * G_PI * angle);
   gimp_matrix3_translate (matrix, center_x * scale_x, center_y * scale_y);
-
 }
 
+
 /*  private functions  */
 
 static void
@@ -706,48 +708,54 @@ gimp_brush_transform_bounding_box (TempBuf           *brush,
   *y = floor (temp_y);
 
   /* Transform size can not be less than 1 px */
-  *width  = MAX(1, *width);
-  *height = MAX(1, *height);
-
+  *width  = MAX (1, *width);
+  *height = MAX (1, *height);
 }
 
 static gdouble
-gimp_brush_transform_array_sum (gfloat *arr, gint len)
+gimp_brush_transform_array_sum (gfloat *arr,
+                                gint    len)
 {
-  int i;
   gfloat total = 0;
+  gint   i;
+
   for (i = 0; i < len; i++)
     {
       total += arr [i];
     }
+
   return total;
 }
 
 static void
-gimp_brush_transform_fill_blur_kernel (gfloat *arr, gint len)
+gimp_brush_transform_fill_blur_kernel (gfloat *arr,
+                                       gint    len)
 {
-  int i;
   gint half_point = ((gint) len / 2) + 1;
+  gint i;
 
   for (i = 0; i < len; i++)
     {
       if (i < half_point)
         arr [i] = half_point - i;
-      else arr [i] = i - half_point;
+      else
+        arr [i] = i - half_point;
     }
 }
 
 static gint
-gimp_brush_transform_blur_kernel_size (gint height,
-                                       gint width,
+gimp_brush_transform_blur_kernel_size (gint    height,
+                                       gint    width,
                                        gdouble hardness)
 {
-
-  gint kernel_size = MIN (MAX_BLUR_KERNEL, MIN(width, height)) *
-                        ((MIN (width, height) * (1.0 - hardness)) / MIN (width, height));
-
-  /*Kernel size must be odd*/
-  if ( kernel_size % 2 == 0) kernel_size++;
+  gint kernel_size = (MIN (MAX_BLUR_KERNEL,
+                           MIN (width, height)) *
+                      ((MIN (width, height) * (1.0 - hardness)) /
+                       MIN (width, height)));
+
+  /* Kernel size must be odd */
+  if (kernel_size % 2 == 0)
+    kernel_size++;
 
   return kernel_size;
 }
diff --git a/app/core/gimpbrush-transform.h b/app/core/gimpbrush-transform.h
index 5a587c2..5034e8a 100644
--- a/app/core/gimpbrush-transform.h
+++ b/app/core/gimpbrush-transform.h
@@ -1,7 +1,7 @@
 /* GIMP - The GNU Image Manipulation Program
  * Copyright (C) 1995 Spencer Kimball and Peter Mattis
  *
- * gimpbrush-scale.h
+ * gimpbrush-transform.h
  *
  * This program is free software: you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -23,29 +23,29 @@
 
 /*  virtual functions of GimpBrush, don't call directly  */
 
-void      gimp_brush_real_transform_size   (GimpBrush *brush,
-                                            gdouble    scale,
-                                            gdouble    aspect_ratio,
-                                            gdouble    angle,
-                                            gint      *scaled_width,
-                                            gint      *scaled_height);
-TempBuf * gimp_brush_real_transform_mask   (GimpBrush *brush,
-                                            gdouble    scale,
-                                            gdouble    aspect_ratio,
-                                            gdouble    angle,
-                                            gdouble    hardness);
-TempBuf * gimp_brush_real_transform_pixmap (GimpBrush *brush,
-                                            gdouble    scale,
-                                            gdouble    aspect_ratio,
-                                            gdouble    angle,
-                                            gdouble    hardness);
+void      gimp_brush_real_transform_size   (GimpBrush   *brush,
+                                            gdouble      scale,
+                                            gdouble      aspect_ratio,
+                                            gdouble      angle,
+                                            gint        *scaled_width,
+                                            gint        *scaled_height);
+TempBuf * gimp_brush_real_transform_mask   (GimpBrush   *brush,
+                                            gdouble      scale,
+                                            gdouble      aspect_ratio,
+                                            gdouble      angle,
+                                            gdouble      hardness);
+TempBuf * gimp_brush_real_transform_pixmap (GimpBrush   *brush,
+                                            gdouble      scale,
+                                            gdouble      aspect_ratio,
+                                            gdouble      angle,
+                                            gdouble      hardness);
 
-void        gimp_brush_transform_matrix    (gdouble            width,
-                                            gdouble            height,
-                                            gdouble            scale,
-                                            gdouble            aspect_ratio,
-                                            gdouble            angle,
-                                            GimpMatrix3       *matrix);
+void      gimp_brush_transform_matrix      (gdouble      width,
+                                            gdouble      height,
+                                            gdouble      scale,
+                                            gdouble      aspect_ratio,
+                                            gdouble      angle,
+                                            GimpMatrix3 *matrix);
 
 
 #endif  /*  __GIMP_BRUSH_SCALE_H__  */



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