[gegl] noise-spread: for thread-safety use a samplers instead of gegl_buffer_sample



commit 2ee0f232516a97a29835914ac9ca1c5ebfa92c91
Author: Øyvind Kolås <pippin gimp org>
Date:   Thu Oct 12 01:03:58 2017 +0200

    noise-spread: for thread-safety use a samplers instead of gegl_buffer_sample

 operations/common/mblur.c        |    1 +
 operations/common/noise-spread.c |    8 ++++++--
 2 files changed, 7 insertions(+), 2 deletions(-)
---
diff --git a/operations/common/mblur.c b/operations/common/mblur.c
index 2b0f828..db7e0d8 100644
--- a/operations/common/mblur.c
+++ b/operations/common/mblur.c
@@ -138,6 +138,7 @@ gegl_op_class_init (GeglOpClass *klass)
 
   filter_class->process = process;
   operation_class->prepare = prepare;
+  operation_class->threaded = FALSE;
 
   gegl_operation_class_set_keys (operation_class,
     "name",        "gegl:mblur",
diff --git a/operations/common/noise-spread.c b/operations/common/noise-spread.c
index 6234058..69a6d57 100644
--- a/operations/common/noise-spread.c
+++ b/operations/common/noise-spread.c
@@ -104,6 +104,7 @@ process (GeglOperation       *operation,
   GeglBufferIterator *gi;
   gint                amount_x;
   gint                amount_y;
+  GeglSampler        *sampler;
 
   o = GEGL_PROPERTIES (operation);
 
@@ -116,6 +117,8 @@ process (GeglOperation       *operation,
   gi = gegl_buffer_iterator_new (output, result, 0, format,
                                  GEGL_ACCESS_WRITE, GEGL_ABYSS_CLAMP);
 
+  sampler = gegl_buffer_sampler_new_at_level (input, format, GEGL_SAMPLER_NEAREST, level);
+
   while (gegl_buffer_iterator_next (gi))
     {
       gchar        *data = gi->data[0];
@@ -129,12 +132,13 @@ process (GeglOperation       *operation,
 
             calc_sample_coords (i, j, amount_x, amount_y, o->rand, &x, &y);
 
-            gegl_buffer_sample_at_level (input, x, y, NULL, data, format, level,
-                                GEGL_SAMPLER_NEAREST, GEGL_ABYSS_CLAMP);
+            gegl_sampler_get (sampler, x, y, NULL, data, GEGL_ABYSS_CLAMP);
             data += bpp;
           }
     }
 
+  g_object_unref (sampler);
+
   return TRUE;
 }
 


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