[gegl] Added macros for annotating objects passed in graph.



commit 6f6681d4f72c68c4d8bf0b5ece1be74dc0f95e98
Author: �yvind Kolås <pippin gimp org>
Date:   Tue Dec 8 22:37:55 2009 +0000

    Added macros for annotating objects passed in graph.
    
    Wrapping g_object_get and set data, but the code using it is
    clearer using these macros.

 gegl/graph/gegl-node.h                         |    7 +++++++
 gegl/operation/gegl-operation-point-composer.c |    8 ++++----
 gegl/operation/gegl-operation-point-filter.c   |   16 ++++++++--------
 gegl/process/gegl-eval-mgr.c                   |   12 ++++++------
 gegl/process/gegl-eval-visitor.c               |    2 +-
 operations/affine/affine.c                     |    7 ++-----
 operations/core/crop.c                         |    5 +++--
 7 files changed, 31 insertions(+), 26 deletions(-)
---
diff --git a/gegl/graph/gegl-node.h b/gegl/graph/gegl-node.h
index 1c2bbf7..f20dc62 100644
--- a/gegl/graph/gegl-node.h
+++ b/gegl/graph/gegl-node.h
@@ -222,6 +222,13 @@ const gchar * gegl_node_get_name            (GeglNode      *self);
 void          gegl_node_set_name            (GeglNode      *self,
                                              const gchar   *name);
 
+/* macros used to set flags on objects passed in the graph */
+
+#define gegl_object_set_has_forked(object) \
+      g_object_set_data(G_OBJECT(object), "gegl has-forked", (void*)0xf)
+#define gegl_object_get_has_forked(object) \
+      (g_object_get_data(G_OBJECT(object), "gegl has-forked")!=NULL)
+
 
 G_END_DECLS
 
diff --git a/gegl/operation/gegl-operation-point-composer.c b/gegl/operation/gegl-operation-point-composer.c
index 50828a0..e8a4717 100644
--- a/gegl/operation/gegl-operation-point-composer.c
+++ b/gegl/operation/gegl-operation-point-composer.c
@@ -71,9 +71,9 @@ gegl_operation_point_composer_init (GeglOperationPointComposer *self)
 
 }
 
-gboolean gegl_can_passthrough (GeglOperation       *operation,
-                               GeglBuffer          *input,
-                               const GeglRectangle *result);
+gboolean gegl_can_do_inplace_processing (GeglOperation       *operation,
+                                         GeglBuffer          *input,
+                                         const GeglRectangle *result);
 
 /* we replicate the process function from GeglOperationComposer to be
  * able to bail out earlier for some common processing time pitfalls
@@ -99,7 +99,7 @@ gegl_operation_composer_process2 (GeglOperation        *operation,
   input = gegl_operation_context_get_source (context, "input");
   aux   = gegl_operation_context_get_source (context, "aux");
 
-  if (gegl_can_passthrough (operation, input, result))
+  if (gegl_can_do_inplace_processing (operation, input, result))
     {
       output = g_object_ref (input);
       gegl_operation_context_take_object (context, "output", G_OBJECT (output));
diff --git a/gegl/operation/gegl-operation-point-filter.c b/gegl/operation/gegl-operation-point-filter.c
index 8af22a6..c04224e 100644
--- a/gegl/operation/gegl-operation-point-filter.c
+++ b/gegl/operation/gegl-operation-point-filter.c
@@ -96,18 +96,18 @@ gegl_operation_point_filter_process (GeglOperation       *operation,
   return TRUE;
 }
 
-gboolean gegl_can_passthrough (GeglOperation       *operation,
-                               GeglBuffer          *input,
-                               const GeglRectangle *result);
+gboolean gegl_can_do_inplace_processing (GeglOperation       *operation,
+                                         GeglBuffer          *input,
+                                         const GeglRectangle *result);
 
-gboolean gegl_can_passthrough (GeglOperation       *operation,
-                               GeglBuffer          *input,
-                               const GeglRectangle *result)
+gboolean gegl_can_do_inplace_processing (GeglOperation       *operation,
+                                         GeglBuffer          *input,
+                                         const GeglRectangle *result)
 {
   if (!input || 
       GEGL_IS_CACHE (input))
     return FALSE;
-  if (g_object_get_data (G_OBJECT (input), "no in-place"))
+  if (gegl_object_get_has_forked (input))
     return FALSE;
       
 
@@ -133,7 +133,7 @@ static gboolean gegl_operation_point_filter_op_process
 
   input = gegl_operation_context_get_source (context, "input");
 
-  if (gegl_can_passthrough (operation, input, roi))
+  if (gegl_can_do_inplace_processing (operation, input, roi))
     {
       output = g_object_ref (input);
       gegl_operation_context_take_object (context, "output", G_OBJECT (output));
diff --git a/gegl/process/gegl-eval-mgr.c b/gegl/process/gegl-eval-mgr.c
index 9c96ff0..989aca1 100644
--- a/gegl/process/gegl-eval-mgr.c
+++ b/gegl/process/gegl-eval-mgr.c
@@ -127,7 +127,7 @@ GeglBuffer *
 gegl_eval_mgr_apply (GeglEvalMgr *self)
 {
   GeglNode    *root;
-  GeglBuffer  *buffer;
+  GeglBuffer  *object;
   GeglPad     *pad;
   glong        time       = gegl_ticks ();
   gpointer     context_id = self;
@@ -219,13 +219,13 @@ gegl_eval_mgr_apply (GeglEvalMgr *self)
 
   if (pad)
     {
-      /* extract return buffer before running finish visitor */
+      /* extract returned object before running finish visitor */
       GValue value = { 0, };
       g_value_init (&value, G_TYPE_OBJECT);
       gegl_operation_context_get_property (gegl_node_get_context (root, context_id),
                                       "output", &value);
-      buffer = g_value_get_object (&value);
-      g_object_ref (buffer);/* salvage buffer from finalization */
+      object = g_value_get_object (&value);
+      g_object_ref (object);/* salvage buffer from finalization */
       g_value_unset (&value);
     }
 
@@ -237,11 +237,11 @@ gegl_eval_mgr_apply (GeglEvalMgr *self)
   time = gegl_ticks () - time;
   gegl_instrument ("gegl", "process", time);
 
-  if (!pad || !G_IS_OBJECT (buffer))
+  if (!pad || !G_IS_OBJECT (object))
     {
       return NULL;
     }
-  return buffer;
+  return object;
 }
 
 GeglEvalMgr * gegl_eval_mgr_new     (GeglNode *node,
diff --git a/gegl/process/gegl-eval-visitor.c b/gegl/process/gegl-eval-visitor.c
index cfe1182..b72b30d 100644
--- a/gegl/process/gegl-eval-visitor.c
+++ b/gegl/process/gegl-eval-visitor.c
@@ -103,7 +103,7 @@ gegl_eval_visitor_visit_pad (GeglVisitor *self,
                 {
                   buffer = g_value_get_object (value);
                   if (buffer)
-                    g_object_set_data (G_OBJECT (buffer), "no in-place", (void*)0xf);
+                    gegl_object_set_has_forked (buffer);
                 }
             }
         }
diff --git a/operations/affine/affine.c b/operations/affine/affine.c
index bf11c20..ec64ddf 100644
--- a/operations/affine/affine.c
+++ b/operations/affine/affine.c
@@ -764,11 +764,8 @@ gegl_affine_process (GeglOperation        *operation,
                                                     of source) */
                          NULL);
 
-      /* If the input buffer should not be in-place processed the
-       * shifted sub-buffer shold not either.
-       */
-      if (g_object_get_data (G_OBJECT (input), "no in-place"))
-        g_object_set_data (G_OBJECT (output), "no in-place", (void*)0xf);
+      if (gegl_object_get_has_forked (input))
+        gegl_object_set_has_forked (output);
 
       gegl_operation_context_take_object (context, "output", G_OBJECT (output));
 
diff --git a/operations/core/crop.c b/operations/core/crop.c
index 9efb59a..d5218aa 100644
--- a/operations/core/crop.c
+++ b/operations/core/crop.c
@@ -138,8 +138,9 @@ gegl_crop_process (GeglOperation        *operation,
 
       output = gegl_buffer_create_sub_buffer (input, &extent);
 
-      if (g_object_get_data (G_OBJECT (input), "no in-place"))
-        g_object_set_data (G_OBJECT (output), "no in-place", (void*)0xf);
+      if (gegl_object_get_has_forked (input))
+        gegl_object_set_has_forked (output);
+
       gegl_operation_context_take_object (context, "output", G_OBJECT (output));
 
       g_object_unref (input);



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