[gegl] write-buffer: parallelize when in_format != out_format
- From: Ell <ell src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gegl] write-buffer: parallelize when in_format != out_format
- Date: Mon, 7 Jan 2019 20:33:50 +0000 (UTC)
commit 9f63d3f095dd56da48a1bd534b85ef88c9ae236f
Author: Ell <ell_se yahoo com>
Date: Mon Jan 7 15:32:00 2019 -0500
write-buffer: parallelize when in_format != out_format
... so that conversion happens accross multiple threads.
operations/common/write-buffer.c | 40 +++++++++++++++++++++++++++++++++++-----
1 file changed, 35 insertions(+), 5 deletions(-)
---
diff --git a/operations/common/write-buffer.c b/operations/common/write-buffer.c
index 4f0977d7f..86a20f504 100644
--- a/operations/common/write-buffer.c
+++ b/operations/common/write-buffer.c
@@ -37,6 +37,20 @@ property_object (buffer, _("Buffer location"), GEGL_TYPE_BUFFER)
#include "opencl/gegl-cl.h"
#include "gegl-buffer-cl-iterator.h"
+typedef struct
+{
+ GeglBuffer *input;
+ GeglBuffer *output;
+} ThreadData;
+
+static void
+thread_process (const GeglRectangle *area,
+ ThreadData *data)
+{
+ gegl_buffer_copy (data->input, area, GEGL_ABYSS_NONE,
+ data->output, area);
+}
+
static gboolean
process (GeglOperation *operation,
GeglBuffer *input,
@@ -105,13 +119,29 @@ process (GeglOperation *operation,
}
}
- if (cl_err || err)
- gegl_buffer_copy (input, result, GEGL_ABYSS_NONE,
- output, result);
+ if (! (cl_err || err))
+ return TRUE;
+ }
+
+ if (in_format == out_format)
+ {
+ gegl_buffer_copy (input, result, GEGL_ABYSS_NONE,
+ output, result);
}
else
- gegl_buffer_copy (input, result, GEGL_ABYSS_NONE,
- output, result);
+ {
+ ThreadData data;
+
+ data.input = input;
+ data.output = output;
+
+ gegl_parallel_distribute_area (
+ result,
+ gegl_operation_get_pixels_per_thread (operation),
+ GEGL_SPLIT_STRATEGY_AUTO,
+ (GeglParallelDistributeAreaFunc) thread_process,
+ &data);
+ }
}
return TRUE;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]