[gegl/wip/pippin/pipeline: 83/95] gegl: replace processing in point ops with pipeline
- From: Øyvind "pippin" Kolås <ok src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gegl/wip/pippin/pipeline: 83/95] gegl: replace processing in point ops with pipeline
- Date: Wed, 12 Sep 2018 11:54:42 +0000 (UTC)
commit 2c5c82804ecd47516736b33d7568f2ba31855ed9
Author: Øyvind Kolås <pippin gimp org>
Date: Mon Jul 23 18:15:55 2018 +0200
gegl: replace processing in point ops with pipeline
For now we lose multi-threading and opencl code paths - even single
ops gets processed with a pipeline.
gegl/operation/gegl-operation-point-composer.c | 31 +++++++++++++-
gegl/operation/gegl-operation-point-composer3.c | 37 +++++++++++++++--
gegl/operation/gegl-operation-point-filter.c | 55 ++++++++++++++++++++-----
3 files changed, 108 insertions(+), 15 deletions(-)
---
diff --git a/gegl/operation/gegl-operation-point-composer.c b/gegl/operation/gegl-operation-point-composer.c
index ddf64561c..6e2cd4881 100644
--- a/gegl/operation/gegl-operation-point-composer.c
+++ b/gegl/operation/gegl-operation-point-composer.c
@@ -25,6 +25,7 @@
#include "gegl-debug.h"
#include "gegl-operation-point-composer.h"
#include "gegl-operation-context.h"
+#include "gegl-operation-pipeline.h"
#include "gegl-config.h"
#include "gegl-types-internal.h"
#include "gegl-buffer-private.h"
@@ -105,10 +106,12 @@ gegl_operation_composer_process (GeglOperation *operation,
gint level)
{
GeglOperationComposerClass *klass = GEGL_OPERATION_COMPOSER_GET_CLASS (operation);
+ GeglOperationPointComposerClass *point_composer_class = GEGL_OPERATION_POINT_COMPOSER_GET_CLASS
(operation);
GeglBuffer *input;
GeglBuffer *aux;
GeglBuffer *output;
gboolean success = FALSE;
+ PipeLine *pipeline;
GeglRectangle scaled_result = *result;
if (level)
@@ -133,12 +136,38 @@ gegl_operation_composer_process (GeglOperation *operation,
}
input = (GeglBuffer*) gegl_operation_context_dup_object (context, "input");
+ aux = (GeglBuffer*) gegl_operation_context_dup_object (context, "aux");
+
+ if (!input && !aux)
+ return FALSE;
+
+ pipeline = gegl_operation_pipeline_ensure (operation, context, input);
+
+ gegl_operation_pipeline_add (pipeline, operation, 2,
+ gegl_operation_get_format (operation, "input"),
+ gegl_operation_get_format (operation, "output"),
+ gegl_operation_get_format (operation, "aux"),
+ NULL,
+ aux, NULL,
+ point_composer_class->process);
+
+ if (gegl_operation_pipeline_is_intermediate_node (operation, pipeline))
+ {
+ gegl_operation_context_take_object (context, "output", G_OBJECT (input));
+
+ return TRUE;
+ }
+
+
output = gegl_operation_context_get_output_maybe_in_place (operation,
context,
input,
result);
+ gegl_operation_pipeline_process (pipeline, output, result, level);
+ g_free (pipeline);
+ gegl_operation_context_set_pipeline (context, NULL);
+ return TRUE;
- aux = (GeglBuffer*) gegl_operation_context_dup_object (context, "aux");
/* A composer with a NULL aux, can still be valid, the
* subclass has to handle it.
diff --git a/gegl/operation/gegl-operation-point-composer3.c b/gegl/operation/gegl-operation-point-composer3.c
index f54d2ace4..a5f8caa27 100644
--- a/gegl/operation/gegl-operation-point-composer3.c
+++ b/gegl/operation/gegl-operation-point-composer3.c
@@ -24,6 +24,7 @@
#include "gegl.h"
#include "gegl-operation-point-composer3.h"
#include "gegl-operation-context.h"
+#include "gegl-operation-pipeline.h"
#include "gegl-types-internal.h"
#include "gegl-config.h"
#include "gegl-buffer-private.h"
@@ -102,6 +103,7 @@ static GThreadPool *thread_pool (void)
return pool;
}
+
static gboolean
gegl_operation_composer3_process (GeglOperation *operation,
GeglOperationContext *context,
@@ -110,11 +112,13 @@ gegl_operation_composer3_process (GeglOperation *operation,
gint level)
{
GeglOperationComposer3Class *klass = GEGL_OPERATION_COMPOSER3_GET_CLASS (operation);
+ GeglOperationPointComposer3Class *point_composer3_class = GEGL_OPERATION_POINT_COMPOSER3_GET_CLASS
(operation);
GeglBuffer *input;
GeglBuffer *aux;
GeglBuffer *aux2;
GeglBuffer *output;
gboolean success = FALSE;
+ PipeLine *pipeline;
if (strcmp (output_prop, "output"))
{
@@ -129,10 +133,37 @@ gegl_operation_composer3_process (GeglOperation *operation,
}
input = (GeglBuffer*) gegl_operation_context_dup_object (context, "input");
+ aux = (GeglBuffer*) gegl_operation_context_dup_object (context, "aux");
+ aux2 = (GeglBuffer*) gegl_operation_context_dup_object (context, "aux2");
+
+ if (!input && !aux && !aux2)
+ return FALSE;
+
+ pipeline = gegl_operation_pipeline_ensure (operation, context, input);
+
+ gegl_operation_pipeline_add (pipeline, operation, 3,
+ gegl_operation_get_format (operation, "input"),
+ gegl_operation_get_format (operation, "output"),
+ gegl_operation_get_format (operation, "aux"),
+ gegl_operation_get_format (operation, "aux2"),
+ aux, aux2,
+ point_composer3_class->process);
+
+ if (gegl_operation_pipeline_is_intermediate_node (operation, pipeline))
+ {
+ gegl_operation_context_take_object (context, "output", G_OBJECT (input));
+
+ return TRUE;
+ }
+
output = gegl_operation_context_get_output_maybe_in_place (operation,
- context,
- input,
- result);
+ context,
+ input,
+ result);
+ gegl_operation_pipeline_process (pipeline, output, result, level);
+ g_free (pipeline);
+ gegl_operation_context_set_pipeline (context, NULL);
+ return TRUE;
aux = (GeglBuffer*) gegl_operation_context_dup_object (context, "aux");
aux2 = (GeglBuffer*) gegl_operation_context_dup_object (context, "aux2");
diff --git a/gegl/operation/gegl-operation-point-filter.c b/gegl/operation/gegl-operation-point-filter.c
index 399e6f39a..f055ac07f 100644
--- a/gegl/operation/gegl-operation-point-filter.c
+++ b/gegl/operation/gegl-operation-point-filter.c
@@ -25,6 +25,7 @@
#include "gegl-debug.h"
#include "gegl-operation-point-filter.h"
#include "gegl-operation-context.h"
+#include "gegl-operation-pipeline.h"
#include "gegl-config.h"
#include "gegl-types-internal.h"
#include "gegl-buffer-private.h"
@@ -87,17 +88,20 @@ static GThreadPool *thread_pool (void)
return pool;
}
+
static gboolean
gegl_operation_filter_process (GeglOperation *operation,
- GeglOperationContext *context,
- const gchar *output_prop,
- const GeglRectangle *result,
- gint level)
+ GeglOperationContext *context,
+ const gchar *output_prop,
+ const GeglRectangle *result,
+ gint level)
{
GeglOperationFilterClass *klass = GEGL_OPERATION_FILTER_GET_CLASS (operation);
+ GeglOperationPointFilterClass *point_filter_class = GEGL_OPERATION_POINT_FILTER_GET_CLASS (operation);
GeglBuffer *input;
GeglBuffer *output;
gboolean success = FALSE;
+ PipeLine *pipeline;
GeglRectangle scaled_result = *result;
if (level)
@@ -122,11 +126,39 @@ gegl_operation_filter_process (GeglOperation *operation,
}
input = (GeglBuffer*)gegl_operation_context_dup_object (context, "input");
+ if (!input)
+ {
+ return FALSE;
+ }
+
+ pipeline = gegl_operation_pipeline_ensure (operation, context, input);
+
+
+ gegl_operation_pipeline_add (pipeline, operation, 1,
+ gegl_operation_get_format (operation, "input"),
+ gegl_operation_get_format (operation, "output"),
+ NULL, NULL, NULL, NULL, // auxes are not set
+ point_filter_class->process);
+
+ if (gegl_operation_pipeline_is_intermediate_node (operation, pipeline))
+ {
+ gegl_operation_context_take_object (context, "output", G_OBJECT (input));
+
+ return TRUE;
+ }
+
output = gegl_operation_context_get_output_maybe_in_place (operation,
context,
input,
result);
+ gegl_operation_pipeline_process (pipeline, output, result, level);
+ g_free (pipeline);
+ gegl_operation_context_set_pipeline (context, NULL);
+
+ return TRUE;
+
+
if (input != NULL)
{
success = klass->process (operation, input, output, result, level);
@@ -247,13 +279,13 @@ error:
static void
gegl_operation_point_filter_class_init (GeglOperationPointFilterClass *klass)
{
- GeglOperationClass *operation_class = GEGL_OPERATION_CLASS (klass);
- GeglOperationFilterClass *filter_class = GEGL_OPERATION_FILTER_CLASS (klass);
+ GeglOperationClass *operation_class = GEGL_OPERATION_CLASS (klass);
+ GeglOperationFilterClass *filter_class = GEGL_OPERATION_FILTER_CLASS (klass);
- filter_class->process = gegl_operation_point_filter_process;
- operation_class->process = gegl_operation_filter_process;
- operation_class->prepare = prepare;
- operation_class->no_cache =TRUE;
+ filter_class->process = gegl_operation_point_filter_process;
+ operation_class->process = gegl_operation_filter_process;
+ operation_class->prepare = prepare;
+ operation_class->no_cache = TRUE;
operation_class->want_in_place = TRUE;
operation_class->threaded = TRUE;
}
@@ -276,7 +308,6 @@ gegl_operation_point_filter_process (GeglOperation *operation,
const Babl *in_format = gegl_operation_get_format (operation, "input");
const Babl *out_format = gegl_operation_get_format (operation, "output");
-
if ((result->width > 0) && (result->height > 0))
{
if (gegl_operation_use_opencl (operation) && (operation_class->cl_data ||
point_filter_class->cl_process))
@@ -285,6 +316,8 @@ gegl_operation_point_filter_process (GeglOperation *operation,
return TRUE;
}
+
+
if (gegl_operation_use_threading (operation, result) && result->height > 1)
{
gint threads = gegl_config_threads ();
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]