[gegl] nop,buffer-source,transform: set the output format



commit 857e1589cd3cec0a548681ce32fb1754bb675113
Author: Massimo Valentini <mvalentini src gnome org>
Date:   Thu Mar 14 20:44:45 2013 +0100

    nop,buffer-source,transform: set the output format

 operations/common/buffer-source.c     |   13 +++++++++++++
 operations/core/nop.c                 |    8 ++++++++
 operations/transform/transform-core.c |   15 +++++++++++++++
 3 files changed, 36 insertions(+), 0 deletions(-)
---
diff --git a/operations/common/buffer-source.c b/operations/common/buffer-source.c
index 4d414c1..d21ef00 100644
--- a/operations/common/buffer-source.c
+++ b/operations/common/buffer-source.c
@@ -60,6 +60,18 @@ static void buffer_changed (GeglBuffer          *buffer,
 }
 
 
+static void
+gegl_buffer_source_prepare (GeglOperation *operation)
+{
+  const Babl *format = NULL;
+  GeglChantO *o = GEGL_CHANT_PROPERTIES (operation);
+
+  if (o->buffer)
+    format = gegl_buffer_get_format (GEGL_BUFFER (o->buffer));
+
+  gegl_operation_set_format (operation, "output", format);
+}
+
 static GeglRectangle
 get_bounding_box (GeglOperation *operation)
 {
@@ -165,6 +177,7 @@ gegl_chant_class_init (GeglChantClass *klass)
 
   operation_class = GEGL_OPERATION_CLASS (klass);
 
+  operation_class->prepare = gegl_buffer_source_prepare;
   operation_class->process = process;
   operation_class->get_bounding_box = get_bounding_box;
 
diff --git a/operations/core/nop.c b/operations/core/nop.c
index 45ef394..84d2ea3 100644
--- a/operations/core/nop.c
+++ b/operations/core/nop.c
@@ -31,6 +31,13 @@
 
 #include "gegl-chant.h"
 
+static void
+gegl_nop_prepare (GeglOperation *self)
+{
+  const Babl *fmt = gegl_operation_get_source_format (self, "input");
+
+  gegl_operation_set_format (self, "output", fmt);
+}
 
 static gboolean
 gegl_nop_process (GeglOperation        *operation,
@@ -65,6 +72,7 @@ gegl_chant_class_init (GeglChantClass *klass)
 
   operation_class = GEGL_OPERATION_CLASS (klass);
   operation_class->process = gegl_nop_process;
+  operation_class->prepare = gegl_nop_prepare;
 
   gegl_operation_class_set_keys (operation_class,
               "name",        "gegl:nop",
diff --git a/operations/transform/transform-core.c b/operations/transform/transform-core.c
index ed1cbca..984b182 100644
--- a/operations/transform/transform-core.c
+++ b/operations/transform/transform-core.c
@@ -84,6 +84,8 @@ static GeglNode     *gegl_transform_detect                       (GeglOperation
 
 static gboolean      gegl_matrix3_is_affine                      (GeglMatrix3          *matrix);
 static gboolean      gegl_transform_matrix3_allow_fast_translate (GeglMatrix3          *matrix);
+static void          gegl_transform_create_composite_matrix      (OpTransform *transform,
+                                                                  GeglMatrix3 *matrix);
 
 /* ************************* */
 
@@ -131,6 +133,19 @@ static void
 gegl_transform_prepare (GeglOperation *operation)
 {
   const Babl *format = babl_format ("RaGaBaA float");
+  GeglMatrix3  matrix;
+  OpTransform *transform = (OpTransform *) operation;
+
+  gegl_transform_create_composite_matrix (transform, &matrix);
+
+  if (gegl_transform_matrix3_allow_fast_translate (&matrix))
+    {
+      const Babl *fmt = gegl_operation_get_source_format (operation, "input");
+
+      if (fmt)
+        format = fmt;
+    }
+
   gegl_operation_set_format (operation, "input", format);
   gegl_operation_set_format (operation, "output", format);
 }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]