[gegl] operation: make in-place handling happen in filter/composer ancestral classes
- From: Øyvind Kolås <ok src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gegl] operation: make in-place handling happen in filter/composer ancestral classes
- Date: Mon, 30 Jun 2014 19:56:50 +0000 (UTC)
commit e4bbc51ead4161e31f36ef4c1b56d0be8475a5e1
Author: Øyvind Kolås <pippin gimp org>
Date: Mon Jun 30 06:10:31 2014 +0200
operation: make in-place handling happen in filter/composer ancestral classes
gegl/operation/gegl-operation-composer.c | 10 +++-
gegl/operation/gegl-operation-composer3.c | 16 ++-----
gegl/operation/gegl-operation-context.c | 23 +++++++++
gegl/operation/gegl-operation-context.h | 6 ++
gegl/operation/gegl-operation-filter.c | 5 ++-
gegl/operation/gegl-operation-point-composer.c | 60 ------------------------
gegl/operation/gegl-operation-point-filter.c | 41 +----------------
7 files changed, 46 insertions(+), 115 deletions(-)
---
diff --git a/gegl/operation/gegl-operation-composer.c b/gegl/operation/gegl-operation-composer.c
index 739e914..66c0353 100644
--- a/gegl/operation/gegl-operation-composer.c
+++ b/gegl/operation/gegl-operation-composer.c
@@ -116,7 +116,10 @@ gegl_operation_composer_process (GeglOperation *operation,
input = gegl_operation_context_get_source (context, "input");
aux = gegl_operation_context_get_source (context, "aux");
- output = gegl_operation_context_get_target (context, "output");
+ output = gegl_operation_context_get_output_maybe_in_place (operation,
+ context,
+ input,
+ result);
/* A composer with a NULL aux, can still be valid, the
* subclass has to handle it.
@@ -124,7 +127,10 @@ gegl_operation_composer_process (GeglOperation *operation,
if (input != NULL ||
aux != NULL)
{
- success = klass->process (operation, input, aux, output, result, level);
+ if (result->width == 0 || result->height == 0)
+ success = TRUE;
+ else
+ success = klass->process (operation, input, aux, output, result, level);
if (input)
g_object_unref (input);
diff --git a/gegl/operation/gegl-operation-composer3.c b/gegl/operation/gegl-operation-composer3.c
index 7a52849..a7417e1 100644
--- a/gegl/operation/gegl-operation-composer3.c
+++ b/gegl/operation/gegl-operation-composer3.c
@@ -113,7 +113,6 @@ gegl_operation_composer3_process (GeglOperation *operation,
gint level)
{
GeglOperationComposer3Class *klass = GEGL_OPERATION_COMPOSER3_GET_CLASS (operation);
- GeglOperationClass *op_class = GEGL_OPERATION_CLASS (klass);
GeglBuffer *input;
GeglBuffer *aux;
GeglBuffer *aux2;
@@ -137,17 +136,10 @@ gegl_operation_composer3_process (GeglOperation *operation,
}
input = gegl_operation_context_get_source (context, "input");
-
- if (op_class->want_in_place &&
- gegl_can_do_inplace_processing (operation, input, result))
- {
- output = g_object_ref (input);
- gegl_operation_context_take_object (context, "output", G_OBJECT (output));
- }
- else
- {
- output = gegl_operation_context_get_target (context, "output");
- }
+ output = gegl_operation_context_get_output_maybe_in_place (operation,
+ context,
+ input,
+ result);
aux = gegl_operation_context_get_source (context, "aux");
aux2 = gegl_operation_context_get_source (context, "aux2");
diff --git a/gegl/operation/gegl-operation-context.c b/gegl/operation/gegl-operation-context.c
index 6b903a5..ddf4bea 100644
--- a/gegl/operation/gegl-operation-context.c
+++ b/gegl/operation/gegl-operation-context.c
@@ -366,3 +366,26 @@ gegl_operation_context_get_level (GeglOperationContext *ctxt)
{
return ctxt->level;
}
+
+
+GeglBuffer *
+gegl_operation_context_get_output_maybe_in_place (GeglOperation *operation,
+ GeglOperationContext *context,
+ GeglBuffer *input,
+ const GeglRectangle *roi)
+{
+ GeglOperationClass *klass = GEGL_OPERATION_GET_CLASS (operation);
+ GeglBuffer *output;
+
+ if (klass->want_in_place &&
+ gegl_can_do_inplace_processing (operation, input, roi))
+ {
+ output = g_object_ref (input);
+ gegl_operation_context_take_object (context, "output", G_OBJECT (output));
+ }
+ else
+ {
+ output = gegl_operation_context_get_target (context, "output");
+ }
+ return output;
+}
diff --git a/gegl/operation/gegl-operation-context.h b/gegl/operation/gegl-operation-context.h
index fa8f011..e15a738 100644
--- a/gegl/operation/gegl-operation-context.h
+++ b/gegl/operation/gegl-operation-context.h
@@ -43,6 +43,12 @@ gint gegl_operation_context_get_level (GeglOperationContext *se
/* the rest of these functions are for internal use only */
+GeglBuffer * gegl_operation_context_get_output_maybe_in_place (GeglOperation *operation,
+ GeglOperationContext *context,
+ GeglBuffer *input,
+ const GeglRectangle *roi);
+
+
G_END_DECLS
#endif /* __GEGL_OPERATION_CONTEXT_H__ */
diff --git a/gegl/operation/gegl-operation-filter.c b/gegl/operation/gegl-operation-filter.c
index f3c924c..c23236b 100644
--- a/gegl/operation/gegl-operation-filter.c
+++ b/gegl/operation/gegl-operation-filter.c
@@ -126,7 +126,10 @@ gegl_operation_filter_process (GeglOperation *operation,
}
input = gegl_operation_context_get_source (context, "input");
- output = gegl_operation_context_get_target (context, "output");
+ output = gegl_operation_context_get_output_maybe_in_place (operation,
+ context,
+ input,
+ result);
success = klass->process (operation, input, output, result, level);
diff --git a/gegl/operation/gegl-operation-point-composer.c b/gegl/operation/gegl-operation-point-composer.c
index 8c52c08..b3c11e8 100644
--- a/gegl/operation/gegl-operation-point-composer.c
+++ b/gegl/operation/gegl-operation-point-composer.c
@@ -38,13 +38,6 @@ static gboolean gegl_operation_point_composer_process
const GeglRectangle *result,
gint level);
-static gboolean
-gegl_operation_composer_process2 (GeglOperation *operation,
- GeglOperationContext *context,
- const gchar *output_prop,
- const GeglRectangle *result,
- gint level);
-
G_DEFINE_TYPE (GeglOperationPointComposer, gegl_operation_point_composer, GEGL_TYPE_OPERATION_COMPOSER)
static void prepare (GeglOperation *operation)
@@ -65,7 +58,6 @@ gegl_operation_point_composer_class_init (GeglOperationPointComposerClass *klass
composer_class->process = gegl_operation_point_composer_process;
operation_class->prepare = prepare;
operation_class->no_cache = FALSE;
- operation_class->process = gegl_operation_composer_process2;
operation_class->want_in_place = TRUE;
klass->process = NULL;
@@ -78,58 +70,6 @@ gegl_operation_point_composer_init (GeglOperationPointComposer *self)
}
-/* we replicate the process function from GeglOperationComposer to be
- * able to bail out earlier for some common processing time pitfalls
- */
-static gboolean
-gegl_operation_composer_process2 (GeglOperation *operation,
- GeglOperationContext *context,
- const gchar *output_prop,
- const GeglRectangle *result,
- gint level)
-{
- GeglOperationComposerClass *klass = GEGL_OPERATION_COMPOSER_GET_CLASS (operation);
- GeglOperationClass *op_class = (void*)klass;
- GeglBuffer *input;
- GeglBuffer *aux;
- GeglBuffer *output;
- gboolean success = FALSE;
-
- if (strcmp (output_prop, "output"))
- {
- g_warning ("requested processing of %s pad on a composer", output_prop);
- return FALSE;
- }
-
- input = gegl_operation_context_get_source (context, "input");
- aux = gegl_operation_context_get_source (context, "aux");
-
- if (op_class->want_in_place &&
- gegl_can_do_inplace_processing (operation, input, result))
- {
- output = g_object_ref (input);
- gegl_operation_context_take_object (context, "output", G_OBJECT (output));
- }
- else
- {
- output = gegl_operation_context_get_target (context, "output");
- }
-
- {
- if (result->width == 0 || result->height == 0)
- success = TRUE;
- else
- success = klass->process (operation, input, aux, output, result, level);
-
- if (input)
- g_object_unref (input);
- if (aux)
- g_object_unref (aux);
- }
-
- return success;
-}
-
static gboolean
gegl_operation_point_composer_cl_process (GeglOperation *operation,
GeglBuffer *input,
diff --git a/gegl/operation/gegl-operation-point-filter.c b/gegl/operation/gegl-operation-point-filter.c
index a30abbb..0fbbf1c 100644
--- a/gegl/operation/gegl-operation-point-filter.c
+++ b/gegl/operation/gegl-operation-point-filter.c
@@ -37,13 +37,6 @@ static gboolean gegl_operation_point_filter_process
const GeglRectangle *result,
gint level);
-static gboolean gegl_operation_point_filter_op_process
- (GeglOperation *operation,
- GeglOperationContext *context,
- const gchar *output_pad,
- const GeglRectangle *roi,
- gint level);
-
G_DEFINE_TYPE (GeglOperationPointFilter, gegl_operation_point_filter, GEGL_TYPE_OPERATION_FILTER)
static void prepare (GeglOperation *operation)
@@ -57,7 +50,7 @@ gegl_operation_point_filter_class_init (GeglOperationPointFilterClass *klass)
{
GeglOperationClass *operation_class = GEGL_OPERATION_CLASS (klass);
- operation_class->process = gegl_operation_point_filter_op_process;
+ GEGL_OPERATION_FILTER_CLASS(klass)->process = gegl_operation_point_filter_process;
operation_class->prepare = prepare;
operation_class->no_cache = TRUE;
operation_class->want_in_place = TRUE;
@@ -191,35 +184,3 @@ gegl_operation_point_filter_process (GeglOperation *operation,
}
return TRUE;
}
-
-static gboolean gegl_operation_point_filter_op_process
- (GeglOperation *operation,
- GeglOperationContext *context,
- const gchar *output_pad,
- const GeglRectangle *roi,
- gint level)
-{
- GeglOperationClass *klass = GEGL_OPERATION_GET_CLASS (operation);
- GeglBuffer *input;
- GeglBuffer *output;
- gboolean success = FALSE;
-
- input = gegl_operation_context_get_source (context, "input");
-
- if (klass->want_in_place &&
- gegl_can_do_inplace_processing (operation, input, roi))
- {
- output = g_object_ref (input);
- gegl_operation_context_take_object (context, "output", G_OBJECT (output));
- }
- else
- {
- output = gegl_operation_context_get_target (context, "output");
- }
-
- success = gegl_operation_point_filter_process (operation, input, output, roi, level);
-
- if (input != NULL)
- g_object_unref (input);
- return success;
-}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]