[gegl] s/double/float/ in api of GeglRandom



commit 5fa2e09479fc88936baebd7c171cc8c6d79b2c80
Author: Øyvind Kolås <pippin gimp org>
Date:   Sat Jul 20 16:35:42 2013 +0100

    s/double/float/ in api of GeglRandom
    
    This to make GeglRandom fit for implementation on GPUs with the same
    reproducable results as the cpu implementation.

 gegl/gegl-random.c               |   31 -------------------------------
 gegl/gegl.h                      |   33 ---------------------------------
 operations/common/noise-hurl.c   |    8 ++++----
 operations/common/noise-pick.c   |    2 +-
 operations/common/noise-rgb.c    |    4 ++--
 operations/common/noise-slur.c   |    2 +-
 operations/common/noise-spread.c |    2 +-
 7 files changed, 9 insertions(+), 73 deletions(-)
---
diff --git a/gegl/gegl-random.c b/gegl/gegl-random.c
index 408547c..347ff5f 100644
--- a/gegl/gegl-random.c
+++ b/gegl/gegl-random.c
@@ -163,16 +163,6 @@ gegl_random_int_range (int seed,
 
 #define G_RAND_FLOAT_TRANSFORM  0.00001525902189669642175
 
-double
-gegl_random_double (int seed,
-                    int x,
-                    int y,
-                    int z,
-                    int n)
-{
-  return gegl_random_float (seed, x, y, z, n);
-}
-
 float
 gegl_random_float (int seed,
                    int x,
@@ -183,27 +173,6 @@ gegl_random_float (int seed,
   return (_gegl_random_int (seed, x, y, z, n) & 0xffff) * G_RAND_FLOAT_TRANSFORM;
 }
 
-double
-gegl_random_double_range (int seed,
-                          int x,
-                          int y,
-                          int z,
-                          int n,
-                          double min,
-                          double max)
-{
-  return gegl_random_double (seed, x, y, z, n) * (max - min) + min;
-}
-
-float
-gegl_random_float_range (int seed,
-                         int x,
-                         int y,
-                         int z,
-                         int n,
-                         float min,
-                         float max);
-
 float
 gegl_random_float_range (int seed,
                          int x,
diff --git a/gegl/gegl.h b/gegl/gegl.h
index ab2a7c6..4d8314d 100644
--- a/gegl/gegl.h
+++ b/gegl/gegl.h
@@ -983,24 +983,6 @@ GeglNode *gegl_node (const gchar *op_type,
 GeglNode *gegl_graph (GeglNode *node);
 
 /**
- * gegl_random_double_range:
- * @seed: an integer seed, change for different permutation
- * @x: x coordinate
- * @y: y coordinate
- * @z: z coordinate (mipmap level)
- * @n: number no (each x,y coordinate provides its own sequence of
- * numbers
- * @min: minimum value
- * @max: maxmimum value
- *
- * Return a random floating point number in the range specified,
- * for the given x,y coordinates and seed provided, if multiple different
- * numbers are needed pass in incrementing n's.
- */
-double gegl_random_double_range (int seed, int x, int y, int z, int n, double min, double max);
-
-
-/**
  * gegl_random_float_range:
  * @seed: an integer seed, change for different permutation
  * @x: x coordinate
@@ -1049,21 +1031,6 @@ gint32 gegl_random_int_range    (int seed, int x, int y, int z, int n, int min,
 guint32 gegl_random_int         (int seed, int x, int y, int z, int n);
 
 /**
- * gegl_random_double:
- * @seed: an integer seed, change for different permutation
- * @x: x coordinate
- * @y: y coordinate
- * @z: z coordinate (mipmap level)
- * @n: number no (each x,y coordinate provides its own sequence of
- * numbers
- *
- * Return a random floating point number in range 0.0 .. 1.0.
- */
-double gegl_random_double       (int seed, int x, int y, int z, int n);
-
-
-
-/**
  * gegl_random_float:
  * @seed: an integer seed, change for different permutation
  * @x: x coordinate
diff --git a/operations/common/noise-hurl.c b/operations/common/noise-hurl.c
index a14f64e..4f16702 100644
--- a/operations/common/noise-hurl.c
+++ b/operations/common/noise-hurl.c
@@ -97,12 +97,12 @@ process (GeglOperation       *operation,
           blue  = out_pix[2];
           alpha = out_pix[3];
 
-          if (gegl_random_double_range (o->seed, x, y, 0, n++, 0.0, 100.0) <=
+          if (gegl_random_float_range (o->seed, x, y, 0, n++, 0.0, 100.0) <=
               o->pct_random)
             {
-              red   = gegl_random_double_range (o->seed, x, y, 0, n++, 0.0, 1.0);
-              green = gegl_random_double_range (o->seed, x, y, 0, n++, 0.0, 1.0);
-              blue  = gegl_random_double_range (o->seed, x, y, 0, n++, 0.0, 1.0);
+              red   = gegl_random_float_range (o->seed, x, y, 0, n++, 0.0, 1.0);
+              green = gegl_random_float_range (o->seed, x, y, 0, n++, 0.0, 1.0);
+              blue  = gegl_random_float_range (o->seed, x, y, 0, n++, 0.0, 1.0);
             }
 
           out_pix[0] = red;
diff --git a/operations/common/noise-pick.c b/operations/common/noise-pick.c
index 47ed2e4..4231bd3 100644
--- a/operations/common/noise-pick.c
+++ b/operations/common/noise-pick.c
@@ -115,7 +115,7 @@ process (GeglOperation       *operation,
         {
           gint b;
 
-          if (gegl_random_double_range (o->seed, x, y, 0, n++, 0.0, 100.0) <=
+          if (gegl_random_float_range (o->seed, x, y, 0, n++, 0.0, 100.0) <=
               o->pct_random)
             {
               gint k = gegl_random_int_range (o->seed, x, y, 0, n++, 0, 9);
diff --git a/operations/common/noise-rgb.c b/operations/common/noise-rgb.c
index d3ad580..1bd8c61 100644
--- a/operations/common/noise-rgb.c
+++ b/operations/common/noise-rgb.c
@@ -77,10 +77,10 @@ gauss (int seed, int *i, int xx, int yy)
 
   do
   {
-    v = gegl_random_double (seed, xx, yy, 0, (*i)++);
+    v = gegl_random_float (seed, xx, yy, 0, (*i)++);
 
     do
-      u = gegl_random_double (seed, xx, yy, 0, (*i)++);
+      u = gegl_random_float (seed, xx, yy, 0, (*i)++);
     while (u == 0);
 
     /* Const 1.715... = sqrt(8/e) */
diff --git a/operations/common/noise-slur.c b/operations/common/noise-slur.c
index 576265a..9d59d12 100644
--- a/operations/common/noise-slur.c
+++ b/operations/common/noise-slur.c
@@ -118,7 +118,7 @@ process (GeglOperation       *operation,
         {
           gint b;
 
-          if (gegl_random_double_range (o->seed, x, y, 0, n++, 0.0, 100.0) <=
+          if (gegl_random_float_range (o->seed, x, y, 0, n++, 0.0, 100.0) <=
               o->pct_random)
             {
               gint k = gegl_random_int_range (o->seed, x, y, 0, n++, 0, 10);
diff --git a/operations/common/noise-spread.c b/operations/common/noise-spread.c
index 0c8338e..5ffbd6f 100644
--- a/operations/common/noise-spread.c
+++ b/operations/common/noise-spread.c
@@ -62,7 +62,7 @@ calc_sample_coords (gint  src_x,
                                                 -amount_x, amount_x) : 0;
   ydist = amount_y > 0 ? gegl_random_int_range (seed, src_x, src_y, 0, 1,
                                                 -amount_y, amount_y) : 0;
-  angle = gegl_random_double_range (seed, src_x, src_y, 0, 2, -G_PI, G_PI);
+  angle = gegl_random_float_range (seed, src_x, src_y, 0, 2, -G_PI, G_PI);
 
   *x = src_x + floor (sin (angle) * xdist);
   *y = src_y + floor (cos (angle) * ydist);


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