[gegl] convert-format: perform copy in GeglOperationFilter::process()
- From: N/A <ell src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gegl] convert-format: perform copy in GeglOperationFilter::process()
- Date: Thu, 17 May 2018 17:07:46 +0000 (UTC)
commit 923b4390bc3d43f07ef31d4db16c0551d78963d0
Author: Ell <ell_se yahoo com>
Date: Thu May 17 13:04:28 2018 -0400
convert-format: perform copy in GeglOperationFilter::process()
When the input and output formats are different, perform the copy
(and hence the conversion) from the input buffer to the output
buffer in GeglOperationFilter::process(), rather than
GeglOperation::process(), so that it's parallelized.
operations/core/convert-format.c | 48 +++++++++++++++++++++++--------------
1 files changed, 30 insertions(+), 18 deletions(-)
---
diff --git a/operations/core/convert-format.c b/operations/core/convert-format.c
index b36fa34..7a6d443 100644
--- a/operations/core/convert-format.c
+++ b/operations/core/convert-format.c
@@ -47,42 +47,54 @@ prepare (GeglOperation *self)
}
static gboolean
-process (GeglOperation *operation,
- GeglOperationContext *context,
- const gchar *output_prop,
- const GeglRectangle *roi,
- gint level)
+operation_process (GeglOperation *operation,
+ GeglOperationContext *context,
+ const gchar *output_prop,
+ const GeglRectangle *roi,
+ gint level)
{
GeglProperties *o = GEGL_PROPERTIES (operation);
GeglBuffer *input;
- GeglBuffer *output;
- input = (GeglBuffer*) gegl_operation_context_dup_object (context, "input");
+ input = (GeglBuffer*) gegl_operation_context_get_object (context, "input");
- if (gegl_buffer_get_format (input) != o->format)
+ if (gegl_buffer_get_format (input) == o->format)
{
- output = gegl_operation_context_get_target (context, "output");
- gegl_buffer_copy (input, roi, GEGL_ABYSS_NONE,
- output, roi);
- g_object_unref (input);
- }
- else
- {
- gegl_operation_context_take_object (context, "output", G_OBJECT (input));
+ gegl_operation_context_set_object (context, "output", G_OBJECT (input));
+
+ return TRUE;
}
+ return GEGL_OPERATION_CLASS (gegl_op_parent_class)->process (operation,
+ context,
+ output_prop,
+ roi, level);
+}
+
+static gboolean
+process (GeglOperation *operation,
+ GeglBuffer *input,
+ GeglBuffer *output,
+ const GeglRectangle *roi,
+ gint level)
+{
+ gegl_buffer_copy (input, roi, GEGL_ABYSS_NONE, output, roi);
+
return TRUE;
}
static void
gegl_op_class_init (GeglOpClass *klass)
{
- GeglOperationClass *operation_class = GEGL_OPERATION_CLASS (klass);
+ GeglOperationClass *operation_class = GEGL_OPERATION_CLASS (klass);
+ GeglOperationFilterClass *filter_class = GEGL_OPERATION_FILTER_CLASS (klass);
operation_class->prepare = prepare;
- operation_class->process = process;
+ operation_class->process = operation_process;
operation_class->no_cache = FALSE;
+ filter_class->process = process;
+
gegl_operation_class_set_keys (operation_class,
"name", "gegl:convert-format",
"title", _("Convert Format"),
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]