gegl r1989 - in trunk: . gegl gegl/operation



Author: ok
Date: Sat Feb  9 22:50:48 2008
New Revision: 1989
URL: http://svn.gnome.org/viewvc/gegl?rev=1989&view=rev

Log:
* gegl/operation/gegl-operation.[ch]: moved
gegl_operation_set_source_region() ..
* gegl/operation/gegl-operations.c: .. here and made static.
* gegl/gegl-plugin.h: updated copy from gegl-operation.h


Modified:
   trunk/ChangeLog
   trunk/gegl/gegl-plugin.h
   trunk/gegl/operation/gegl-operation.c
   trunk/gegl/operation/gegl-operation.h
   trunk/gegl/operation/gegl-operations.c

Modified: trunk/gegl/gegl-plugin.h
==============================================================================
--- trunk/gegl/gegl-plugin.h	(original)
+++ trunk/gegl/gegl-plugin.h	Sat Feb  9 22:50:48 2008
@@ -104,8 +104,6 @@
 #include <glib-object.h>
 #include <babl/babl.h>
 
-
-
 #define GEGL_TYPE_OPERATION            (gegl_operation_get_type ())
 #define GEGL_OPERATION(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), GEGL_TYPE_OPERATION, GeglOperation))
 #define GEGL_OPERATION_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass),  GEGL_TYPE_OPERATION, GeglOperationClass))
@@ -124,56 +122,48 @@
                       with through */
 };
 
-/***
- * fnord
- */
-
-/***
- * fnord
- */
 struct _GeglOperationClass
 {
-  GObjectClass  parent_class;
+  GObjectClass    parent_class;
 
-  const gchar  *name;            /* name used to refer to this type of
-                                    operation in GEGL */
-  const gchar  *description;     /* textual description of the operation */
-  const gchar  *categories;      /* a colon seperated list of categories */
+  const gchar    *name;        /* name(string) used to create/indetify
+                                    this type of operation in GEGL*/
+  const gchar    *description; /* textual description of the operation */
+  const gchar    *categories;  /* a colon seperated list of categories */
 
-
-  gboolean          no_cache;    /* do not create a cache for this operation */
+  gboolean        no_cache;    /* do not create a cache for this operation */
 
   /* attach this operation with a GeglNode, override this if you are creating a
    * GeglGraph, it is already defined for Filters/Sources/Composers.
    */
-  void            (*attach)               (GeglOperation *operation);
+  void          (*attach)                    (GeglOperation *operation);
 
   /* prepare() is called on each operation providing data to a node that
    * is requested to provide a rendered result. When prepare is called all
    * properties are known. This is the time to set desired pixel formats
    * for input and output pads.
    */
-  void            (*prepare)              (GeglOperation *operation);
+  void          (*prepare)                   (GeglOperation *operation);
 
   /* Returns the bounding rectangle for the data that is defined by this op.
    * (is already implemented in GeglOperationPointFilter and
    * GeglOperationPointComposer, GeglOperationAreaFilter base classes.
    */
-  GeglRectangle   (*get_bounding_box)   (GeglOperation *operation);
+  GeglRectangle (*get_bounding_box)          (GeglOperation *operation);
 
   /* Computes the region in output (same affected rect assumed for all outputs)
    * when a given region has changed on an input. Used to aggregate dirt in the
    * graph. A default implementation of this, if not provided should probably
    * be to report that the entire defined region is dirtied.
    */
-  GeglRectangle   (*get_invalidated_by_change)(GeglOperation        *operation,
-                                               const gchar         *input_pad,
-                                               const GeglRectangle *input_region);
+  GeglRectangle (*get_invalidated_by_change) (GeglOperation       *operation,
+                                              const gchar         *input_pad,
+                                              const GeglRectangle *input_region);
 
-  /* computes the rectangle needed to be correctly computed in a buffer
-   * on the named input_pad, for a given result rectangle
+  /* Computes the rectangle needed to be correctly computed in a buffer
+   * on the named input_pad, for a given region of interest.
    */
-  GeglRectangle   (*get_required_for_output) (GeglOperation        *operation,
+  GeglRectangle (*get_required_for_output)   (GeglOperation       *operation,
                                               const gchar         *input_pad,
                                               const GeglRectangle *roi);
 
@@ -181,93 +171,95 @@
    * (useful for global operations like contrast stretching, as well as
    * file loaders to force caching of the full raster).
    */
-  GeglRectangle   (*get_cached_region)     (GeglOperation       *operation,
-                                            const GeglRectangle *roi);
+  GeglRectangle (*get_cached_region)         (GeglOperation       *operation,
+                                              const GeglRectangle *roi);
+
+  /* Perform processing for the @output_pad, pad The result_rect provides the
+   * region to process. For sink operations @output_pad can be ignored but the
+   * result_rect is then then indicating the data available for consumption.
+   */
+  gboolean      (*process)                   (GeglOperation       *operation,
+                                              GeglNodeContext     *context,
+                                              const gchar         *output_pad,
+                                              const GeglRectangle *result_rect);
 
   /* XXX: What is GeglNode doing in this part of the API?
    * Returns the node providing data for a specific location within the
-   * operations output. Does this recurse?, perhaps it should only point
-   * out which pad the data is coming from?
+   * operations output. Does this recurse?, perhaps it should only point out
+   * which pad the data is coming from?
    */
-  GeglNode*       (*detect)                (GeglOperation       *operation,
-                                            gint                 x,
-                                            gint                 y);
-
-  /* Perform processing for the @output_pad, pad The result_rect provides
-   * the region to process. For sink operations @output_pad can be ignored
-   * but the result_rect is then then indicating the data available for
-   * consumption.
-   */
-  gboolean        (*process)               (GeglOperation       *operation,
-                                            GeglNodeContext     *context,
-                                            const gchar         *output_pad,
-                                            const GeglRectangle *result_rect);
+  GeglNode*     (*detect)                    (GeglOperation       *operation,
+                                              gint                 x,
+                                              gint                 y);
 };
 
-GType           gegl_operation_get_type             (void) G_GNUC_CONST;
 
-/* retrieves the bounding box of a connected input */
-GeglRectangle * gegl_operation_source_get_bounding_box (GeglOperation *operation,
-                                                          const gchar   *pad_name);
 
 
-/* sets the ROI needed to be computed on one of the sources */
-void            gegl_operation_set_source_region    (GeglOperation       *operation,
-                                                     gpointer             context_id,
-                                                     const gchar         *pad_name,
-                                                     const GeglRectangle *region);
+GType           gegl_operation_get_type        (void) G_GNUC_CONST;
 
+GeglRectangle   gegl_operation_get_invalidated_by_change
+                                                 (GeglOperation *operation,
+                                                  const gchar   *input_pad,
+                                                  const GeglRectangle *input_region);
+GeglRectangle   gegl_operation_get_bounding_box  (GeglOperation *operation);
 
-/* retrieves the node providing data to a named input pad */
-GeglNode      * gegl_operation_get_source_node           (GeglOperation *operation,
-                                                          const gchar   *pad_name);
-GeglRectangle   gegl_operation_get_invalidated_by_change   (GeglOperation *operation,
-                                                          const gchar   *input_pad,
-                                                          const GeglRectangle *input_region);
-GeglRectangle   gegl_operation_get_bounding_box          (GeglOperation *operation);
-GeglRectangle   gegl_operation_get_cached_region         (GeglOperation *operation,
-                                                          const GeglRectangle *roi);
-
-GeglRectangle   gegl_operation_get_required_for_output (GeglOperation *operation,
-                                                          const gchar   *input_pad,
-                                                          const GeglRectangle *roi);
-
-GeglNode       *gegl_operation_detect                    (GeglOperation *operation,
-                                                          gint           x,
-                                                          gint           y);
+/* retrieves the bounding box of an input pad */
+GeglRectangle * gegl_operation_source_get_bounding_box
+                                                 (GeglOperation *operation,
+                                                  const gchar   *pad_name);
+
+
+GeglRectangle   gegl_operation_get_cached_region (GeglOperation *operation,
+                                                  const GeglRectangle *roi);
+
+GeglRectangle   gegl_operation_get_required_for_output
+                                                 (GeglOperation *operation,
+                                                  const gchar   *input_pad,
+                                                  const GeglRectangle *roi);
+
+GeglNode       *gegl_operation_detect            (GeglOperation *operation,
+                                                  gint           x,
+                                                  gint           y);
 
 
 /* virtual method invokers that change behavior based on the roi being computed,
  * needs a context_id being based that is used for storing context data.
  */
 
-void            gegl_operation_attach               (GeglOperation       *operation,
-                                                     GeglNode            *node);
-void            gegl_operation_prepare              (GeglOperation       *operation);
-gboolean        gegl_operation_process              (GeglOperation       *operation,
-                                                     GeglNodeContext     *context,
-                                                     const gchar         *output_pad,
-                                                     const GeglRectangle *result_rect);
+void            gegl_operation_attach            (GeglOperation       *operation,
+                                                  GeglNode            *node);
+void            gegl_operation_prepare           (GeglOperation       *operation);
+gboolean        gegl_operation_process           (GeglOperation       *operation,
+                                                 GeglNodeContext     *context,
+                                                  const gchar         *output_pad,
+                                                  const GeglRectangle *result_rect);
 
 /* create a pad for a specified property for this operation, this method is
  * to be called from the attach method of operations, most operations do not
  * have to care about this since a super class like filter, sink, source or
  * composer already does so.
  */
-void       gegl_operation_create_pad                (GeglOperation *operation,
-                                                     GParamSpec    *param_spec);
+void       gegl_operation_create_pad             (GeglOperation *operation,
+                                                  GParamSpec    *param_spec);
 
 /* specify the bablformat for a pad on this operation (XXX: document when
  * this is legal, at the moment, only used internally in some ops,. but might
  * turn into a global mechanism) */
-void       gegl_operation_set_format                (GeglOperation *operation,
-                                                     const gchar   *pad_name,
-                                                     const Babl    *format);
+void       gegl_operation_set_format             (GeglOperation *operation,
+                                                  const gchar   *pad_name,
+                                                  const Babl    *format);
+
+
+const Babl * gegl_operation_get_format           (GeglOperation *operation,
+                                                  const gchar   *pad_name);
 
-const Babl * gegl_operation_get_format              (GeglOperation *operation,
-                                                     const gchar   *pad_name);
 
 
+/* retrieves the node providing data to a named input pad */
+GeglNode      * gegl_operation_get_source_node   (GeglOperation *operation,
+                                                  const gchar   *pad_name);
+
 
 #define GEGL_TYPE_OPERATION_SOURCE            (gegl_operation_source_get_type ())
 #define GEGL_OPERATION_SOURCE(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), GEGL_TYPE_OPERATION_SOURCE, GeglOperationSource))

Modified: trunk/gegl/operation/gegl-operation.c
==============================================================================
--- trunk/gegl/operation/gegl-operation.c	(original)
+++ trunk/gegl/operation/gegl-operation.c	Sat Feb  9 22:50:48 2008
@@ -278,60 +278,6 @@
   return NULL;
 }
 
-void
-gegl_operation_set_source_region (GeglOperation        *operation,
-                                  gpointer              context_id,
-                                  const gchar         *input_pad_name,
-                                  const GeglRectangle *region)
-{
-  GeglNode     *child;         /* the node which need rect we are affecting */
-  GeglRectangle child_need;    /* the need rect of the child */
-
-  g_return_if_fail (GEGL_IS_OPERATION (operation));
-  g_return_if_fail (GEGL_IS_NODE (operation->node));
-  g_return_if_fail (input_pad_name != NULL);
-
-  {
-    GeglPad *pad = gegl_node_get_pad (operation->node, input_pad_name);
-    if (!pad)
-      return;
-    pad = gegl_pad_get_internal_connected_to (pad);
-    if (!pad)
-      return;
-    child = gegl_pad_get_node (pad);
-    if (!child)
-      return;
-  }
-
-  {
-    GeglNodeContext *child_context = gegl_node_get_context (child, context_id);
-    gegl_rectangle_bounding_box (&child_need, &child_context->need_rect, region);
-    gegl_rectangle_intersect (&child_need, &child->have_rect, &child_need);
-
-      /* If we're cached */
-      if (child->cache)
-        {
-          GeglCache *cache = child->cache;
-          GeglRectangle valid_box;
-          gegl_region_get_clipbox (cache->valid_region, &valid_box);
-
-          if (child_need.width == 0  ||
-              child_need.height == 0 ||
-              gegl_region_rect_in (cache->valid_region, &child_need) == GEGL_OVERLAP_RECTANGLE_IN)
-            {
-              child_context->result_rect = child_need;
-              child_context->cached = TRUE;
-              child_need.width = 0;
-              child_need.height = 0;
-            }
-        }
-
-    gegl_node_set_need_rect (child, context_id,
-                             child_need.x,     child_need.y,
-                             child_need.width, child_need.height);
-  }
-}
-
 static GeglRectangle
 get_bounding_box (GeglOperation *self)
 {

Modified: trunk/gegl/operation/gegl-operation.h
==============================================================================
--- trunk/gegl/operation/gegl-operation.h	(original)
+++ trunk/gegl/operation/gegl-operation.h	Sat Feb  9 22:50:48 2008
@@ -117,71 +117,73 @@
                                               gint                 y);
 };
 
-GType           gegl_operation_get_type        (void) G_GNUC_CONST;
-
-/* retrieves the bounding box of a connected input */
-GeglRectangle * gegl_operation_source_get_bounding_box (GeglOperation *operation,
-                                                          const gchar   *pad_name);
 
 
-/* sets the ROI needed to be computed on one of the sources */
-void            gegl_operation_set_source_region    (GeglOperation       *operation,
-                                                     gpointer             context_id,
-                                                     const gchar         *pad_name,
-                                                     const GeglRectangle *region);
 
+GType           gegl_operation_get_type        (void) G_GNUC_CONST;
 
-/* retrieves the node providing data to a named input pad */
-GeglNode      * gegl_operation_get_source_node         (GeglOperation *operation,
-                                                        const gchar   *pad_name);
-GeglRectangle   gegl_operation_get_invalidated_by_change (GeglOperation *operation,
-                                                        const gchar   *input_pad,
-                                                        const GeglRectangle *input_region);
-GeglRectangle   gegl_operation_get_bounding_box        (GeglOperation *operation);
-GeglRectangle   gegl_operation_get_cached_region       (GeglOperation *operation,
-                                                        const GeglRectangle *roi);
-
-GeglRectangle   gegl_operation_get_required_for_output(GeglOperation *operation,
-                                                         const gchar   *input_pad,
-                                                         const GeglRectangle *roi);
-
-GeglNode       *gegl_operation_detect                   (GeglOperation *operation,
-                                                         gint           x,
-                                                         gint           y);
+GeglRectangle   gegl_operation_get_invalidated_by_change
+                                                 (GeglOperation *operation,
+                                                  const gchar   *input_pad,
+                                                  const GeglRectangle *input_region);
+GeglRectangle   gegl_operation_get_bounding_box  (GeglOperation *operation);
+
+/* retrieves the bounding box of an input pad */
+GeglRectangle * gegl_operation_source_get_bounding_box
+                                                 (GeglOperation *operation,
+                                                  const gchar   *pad_name);
+
+
+GeglRectangle   gegl_operation_get_cached_region (GeglOperation *operation,
+                                                  const GeglRectangle *roi);
+
+GeglRectangle   gegl_operation_get_required_for_output
+                                                 (GeglOperation *operation,
+                                                  const gchar   *input_pad,
+                                                  const GeglRectangle *roi);
+
+GeglNode       *gegl_operation_detect            (GeglOperation *operation,
+                                                  gint           x,
+                                                  gint           y);
 
 
 /* virtual method invokers that change behavior based on the roi being computed,
  * needs a context_id being based that is used for storing context data.
  */
 
-void            gegl_operation_attach               (GeglOperation       *operation,
-                                                     GeglNode            *node);
-void            gegl_operation_prepare              (GeglOperation       *operation);
-gboolean        gegl_operation_process              (GeglOperation       *operation,
-                                                     GeglNodeContext     *context,
-                                                     const gchar         *output_pad,
-                                                     const GeglRectangle *result_rect);
+void            gegl_operation_attach            (GeglOperation       *operation,
+                                                  GeglNode            *node);
+void            gegl_operation_prepare           (GeglOperation       *operation);
+gboolean        gegl_operation_process           (GeglOperation       *operation,
+                                                 GeglNodeContext     *context,
+                                                  const gchar         *output_pad,
+                                                  const GeglRectangle *result_rect);
 
 /* create a pad for a specified property for this operation, this method is
  * to be called from the attach method of operations, most operations do not
  * have to care about this since a super class like filter, sink, source or
  * composer already does so.
  */
-void       gegl_operation_create_pad                (GeglOperation *operation,
-                                                     GParamSpec    *param_spec);
+void       gegl_operation_create_pad             (GeglOperation *operation,
+                                                  GParamSpec    *param_spec);
 
 /* specify the bablformat for a pad on this operation (XXX: document when
  * this is legal, at the moment, only used internally in some ops,. but might
  * turn into a global mechanism) */
-void       gegl_operation_set_format                (GeglOperation *operation,
-                                                     const gchar   *pad_name,
-                                                     const Babl    *format);
+void       gegl_operation_set_format             (GeglOperation *operation,
+                                                  const gchar   *pad_name,
+                                                  const Babl    *format);
 
 
-const Babl * gegl_operation_get_format              (GeglOperation *operation,
-                                                     const gchar   *pad_name);
+const Babl * gegl_operation_get_format           (GeglOperation *operation,
+                                                  const gchar   *pad_name);
 
 
+
+/* retrieves the node providing data to a named input pad */
+GeglNode      * gegl_operation_get_source_node   (GeglOperation *operation,
+                                                  const gchar   *pad_name);
+
 G_END_DECLS
 
 #endif /* __GEGL_OPERATION_H__ */

Modified: trunk/gegl/operation/gegl-operations.c
==============================================================================
--- trunk/gegl/operation/gegl-operations.c	(original)
+++ trunk/gegl/operation/gegl-operations.c	Sat Feb  9 22:50:48 2008
@@ -25,11 +25,13 @@
 #include <string.h>
 
 #include "gegl-types.h"
+#include "gegl-utils.h"
 #include "gegl-operation.h"
 #include "gegl-operations.h"
 #include "graph/gegl-node.h"
 #include "graph/gegl-pad.h"
 #include "graph/gegl-node-context.h"
+#include "buffer/gegl-region.h"
 
 static void
 add_operations (GHashTable *hash,
@@ -124,6 +126,59 @@
     }
 }
 
+static void
+gegl_operation_set_source_region (GeglOperation        *operation,
+                                  gpointer              context_id,
+                                  const gchar         *input_pad_name,
+                                  const GeglRectangle *region)
+{
+  GeglNode     *child;         /* the node which need rect we are affecting */
+  GeglRectangle child_need;    /* the need rect of the child */
+
+  g_return_if_fail (GEGL_IS_OPERATION (operation));
+  g_return_if_fail (GEGL_IS_NODE (operation->node));
+  g_return_if_fail (input_pad_name != NULL);
+
+  {
+    GeglPad *pad = gegl_node_get_pad (operation->node, input_pad_name);
+    if (!pad)
+      return;
+    pad = gegl_pad_get_internal_connected_to (pad);
+    if (!pad)
+      return;
+    child = gegl_pad_get_node (pad);
+    if (!child)
+      return;
+  }
+
+  {
+    GeglNodeContext *child_context = gegl_node_get_context (child, context_id);
+    gegl_rectangle_bounding_box (&child_need, &child_context->need_rect, region);
+    gegl_rectangle_intersect (&child_need, &child->have_rect, &child_need);
+
+      /* If we're cached */
+      if (child->cache)
+        {
+          GeglCache *cache = child->cache;
+          GeglRectangle valid_box;
+          gegl_region_get_clipbox (cache->valid_region, &valid_box);
+
+          if (child_need.width == 0  ||
+              child_need.height == 0 ||
+              gegl_region_rect_in (cache->valid_region, &child_need) == GEGL_OVERLAP_RECTANGLE_IN)
+            {
+              child_context->result_rect = child_need;
+              child_context->cached = TRUE;
+              child_need.width = 0;
+              child_need.height = 0;
+            }
+        }
+
+    gegl_node_set_need_rect (child, context_id,
+                             child_need.x,     child_need.y,
+                             child_need.width, child_need.height);
+  }
+}
 gboolean
 gegl_operation_calc_source_regions (GeglOperation *operation,
                                     gpointer       context_id)



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