[gegl] operations: use gegl_random in shift, fixes the leaked GRand*
- From: Michael Natterer <mitch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gegl] operations: use gegl_random in shift, fixes the leaked GRand*
- Date: Sun, 26 May 2013 23:58:00 +0000 (UTC)
commit 91fc7513cbed33567fc65f7963ad67f741152a54
Author: Michael Natterer <mitch gimp org>
Date: Mon May 27 01:56:42 2013 +0200
operations: use gegl_random in shift, fixes the leaked GRand*
operations/common/shift.c | 17 +++++------------
1 files changed, 5 insertions(+), 12 deletions(-)
---
diff --git a/operations/common/shift.c b/operations/common/shift.c
index cf3cfa4..41d7524 100644
--- a/operations/common/shift.c
+++ b/operations/common/shift.c
@@ -74,10 +74,8 @@ prepare (GeglOperation *operation)
op_area->right = 0;
}
- gegl_operation_set_format (operation, "input",
- babl_format ("RGBA float"));
- gegl_operation_set_format (operation, "output",
- babl_format ("RGBA float"));
+ gegl_operation_set_format (operation, "input", babl_format ("RGBA float"));
+ gegl_operation_set_format (operation, "output", babl_format ("RGBA float"));
}
static GMutex mutex;
@@ -111,22 +109,17 @@ process (GeglOperation *operation,
GeglRectangle *boundary;
- GRand *gr;
-
gint array_size = 0;
gint r;
/* calculate offsets once */
g_mutex_lock (&mutex);
if (!o->chant_data)
- {
+ {
boundary = gegl_operation_source_get_bounding_box (operation, "input");
if (boundary)
{
- gr = g_rand_new ();
- g_rand_set_seed (gr, o->seed);
-
offsets = g_array_new (FALSE, FALSE, sizeof (gint));
if (o->direction == GEGL_SHIFT_DIRECTION_HORIZONTAL)
@@ -140,7 +133,7 @@ process (GeglOperation *operation,
for (i = 0; i < array_size; i++)
{
- r = g_rand_int_range (gr, -s, s);
+ r = gegl_random_int_range (o->seed, x, 0, 0, 0, s, s + 1);
g_array_append_val (offsets, r);
}
o->chant_data = offsets;
@@ -148,7 +141,7 @@ process (GeglOperation *operation,
}
g_mutex_unlock (&mutex);
- offsets = (GArray*) o->chant_data;
+ offsets = o->chant_data;
src_rect.x = result->x - op_area->left;
src_rect.width = result->width + op_area->left + op_area->right;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]