summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gegl/operation/gegl-operation.c16
-rw-r--r--gegl/operation/gegl-operation.h8
-rw-r--r--operations/common/opacity.c28
3 files changed, 32 insertions, 20 deletions
diff --git a/gegl/operation/gegl-operation.c b/gegl/operation/gegl-operation.c
index 50750113..97604bc0 100644
--- a/gegl/operation/gegl-operation.c
+++ b/gegl/operation/gegl-operation.c
@@ -720,3 +720,19 @@ gegl_operation_get_key (const gchar *operation_name,
g_type_class_unref (klass);
return ret;
}
+
+const Babl *
+gegl_operation_get_source_format (GeglOperation *operation,
+ const gchar *padname)
+{
+ GeglNode *src_node = gegl_operation_get_source_node (operation, padname);
+
+ if (src_node)
+ {
+ GeglOperation *op = src_node->operation;
+ if (op)
+ return gegl_operation_get_format (op, "output");
+ /* XXX: could be a different pad than "output" */
+ }
+ return NULL;
+}
diff --git a/gegl/operation/gegl-operation.h b/gegl/operation/gegl-operation.h
index fc7abfe7..d86d1faf 100644
--- a/gegl/operation/gegl-operation.h
+++ b/gegl/operation/gegl-operation.h
@@ -211,8 +211,14 @@ const Babl * gegl_operation_get_format (GeglOperation *operation,
const gchar * gegl_operation_get_name (GeglOperation *operation);
+/* checks the incoming Babl format on a given pad, can be used in the prepare
+ * stage to make format dependent decisions
+ */
+const Babl * gegl_operation_get_source_format (GeglOperation *operation,
+ const gchar *padname);
+
/* retrieves the node providing data to a named input pad */
-GeglNode * gegl_operation_get_source_node (GeglOperation *operation,
+GeglNode * gegl_operation_get_source_node (GeglOperation *operation,
const gchar *pad_name);
GParamSpec ** gegl_operation_list_properties (const gchar *operation_type,
diff --git a/operations/common/opacity.c b/operations/common/opacity.c
index 5c50cbb8..4df48679 100644
--- a/operations/common/opacity.c
+++ b/operations/common/opacity.c
@@ -30,33 +30,23 @@ gegl_chant_double (value, _("Opacity"), -10.0, 10.0, 1.0,
#define GEGL_CHANT_C_FILE "opacity.c"
#include "gegl-chant.h"
-#include "graph/gegl-node.h"
#include <stdio.h>
+
static void prepare (GeglOperation *self)
{
- GeglNode *src_node = gegl_operation_get_source_node (self, "input");
+ const Babl *fmt = gegl_operation_get_source_format (self, "input");
GeglChantO *o = GEGL_CHANT_PROPERTIES (self);
- if (src_node)
+ if (fmt == babl_format ("RGBA float"))
{
- GeglOperation *op = src_node->operation;
- if (op)
- {
- const Babl *fmt = gegl_operation_get_format (op, "output"); /* XXX: could
- be a different pad */
-
- if (fmt == babl_format ("RGBA float"))
- {
- /* ugly way of communicating that we want the RGBA version */
- o->chant_data = (void*)0xabc;
- gegl_operation_set_format (self, "input", babl_format ("RGBA float"));
- gegl_operation_set_format (self, "output", babl_format ("RGBA float"));
- gegl_operation_set_format (self, "aux", babl_format ("Y float"));
- return;
- }
- }
+ gegl_operation_set_format (self, "input", babl_format ("RGBA float"));
+ gegl_operation_set_format (self, "output", babl_format ("RGBA float"));
+ gegl_operation_set_format (self, "aux", babl_format ("Y float"));
+ /* ugly way of communicating that we want the RGBA version */
+ o->chant_data = (void*)0xabc;
+ return;
}
o->chant_data = NULL;
gegl_operation_set_format (self, "input", babl_format ("RaGaBaA float"));