gegl r1871 - in trunk: . gegl/operation



Author: ok
Date: Sat Jan 19 18:32:51 2008
New Revision: 1871
URL: http://svn.gnome.org/viewvc/gegl?rev=1871&view=rev

Log:
* gegl/operation/gegl-operation.[ch]: moved some code that doesn't
belong in the base GeglOperation implementation,.
* gegl/operation/gegl-operations.[ch]: .. here to a separate file
pertaining to all operations.
* gegl/operation/Makefile.am: added gegl-operations.[ch]


Added:
   trunk/gegl/operation/gegl-operations.c
   trunk/gegl/operation/gegl-operations.h
Modified:
   trunk/ChangeLog
   trunk/gegl/operation/Makefile.am
   trunk/gegl/operation/gegl-operation.c
   trunk/gegl/operation/gegl-operation.h

Modified: trunk/gegl/operation/Makefile.am
==============================================================================
--- trunk/gegl/operation/Makefile.am	(original)
+++ trunk/gegl/operation/Makefile.am	Sat Jan 19 18:32:51 2008
@@ -2,7 +2,7 @@
 
 OPERATION_sources = \
 	gegl-extension-handler.c	\
-    	gegl-operation.c        	\
+	gegl-operation.c        	\
 	gegl-operation-area-filter.c    \
 	gegl-operation-composer.c     	\
 	gegl-operation-filter.c       	\
@@ -10,7 +10,8 @@
 	gegl-operation-point-composer.c \
 	gegl-operation-point-filter.c   \
 	gegl-operation-sink.c       	\
-	gegl-operation-source.c
+	gegl-operation-source.c		\
+	gegl-operations.c
 
 
 OPERATION_headers = \
@@ -23,7 +24,8 @@
 	gegl-operation-point-composer.h \
 	gegl-operation-point-filter.h   \
 	gegl-operation-sink.h       	\
-	gegl-operation-source.h
+	gegl-operation-source.h		\
+	gegl-operations.c
 
 public_headers = \
 	gegl-operation.h        	\

Modified: trunk/gegl/operation/gegl-operation.c
==============================================================================
--- trunk/gegl/operation/gegl-operation.c	(original)
+++ trunk/gegl/operation/gegl-operation.c	Sat Jan 19 18:32:51 2008
@@ -13,8 +13,8 @@
  * You should have received a copy of the GNU Lesser General Public
  * License along with GEGL; if not, see <http://www.gnu.org/licenses/>.
  *
- * Copyright 2003 Calvin Williamson
- *           2005, 2006 Ãyvind KolÃs
+ * Copyright 2003      Calvin Williamson
+ *           2005-2008 Ãyvind KolÃs
  */
 
 #define GEGL_INTERNAL
@@ -32,6 +32,7 @@
 #include "graph/gegl-pad.h"
 #include "buffer/gegl-region.h"
 #include "buffer/gegl-buffer.h"
+#include "gegl-operations.h"
 
 static void          attach                  (GeglOperation       *self);
 
@@ -190,28 +191,6 @@
 }
 
 
-gboolean
-gegl_operation_calc_source_regions (GeglOperation *operation,
-                                    gpointer       context_id)
-{
-  GSList          *input_pads;
-  GeglNodeContext *context;
-  GeglRectangle    request;
-
-  context = gegl_node_get_context (operation->node, context_id);
-  request = context->need_rect;/**gegl_operation_need_rect (operation, context_id);*/
-
-  /* for each input, compute_input_request use gegl_operation_set_source_region() */
-  for (input_pads = operation->node->input_pads;input_pads;input_pads=input_pads->next)
-    {
-      const gchar *pad_name = gegl_pad_get_name (input_pads->data);
-      GeglRectangle rect;
-      rect = gegl_operation_compute_input_request (operation, pad_name, &request); 
-
-      gegl_operation_set_source_region (operation, context_id, pad_name, &rect);
-    }
-  return TRUE;
-}
 
 GeglRectangle
 gegl_operation_adjust_result_region (GeglOperation       *operation,
@@ -398,88 +377,6 @@
   klass->name = name_copy;
 }
 
-static void
-add_operations (GHashTable *hash,
-                GType       parent)
-{
-  GType *types;
-  guint  count;
-  gint   no;
-
-  types = g_type_children (parent, &count);
-  if (!types)
-    return;
-
-  for (no = 0; no < count; no++)
-    {
-      GeglOperationClass *operation_class = g_type_class_ref (types[no]);
-      if (operation_class->name)
-        {
-          g_hash_table_insert (hash, g_strdup (operation_class->name), (gpointer) types[no]);
-        }
-      add_operations (hash, types[no]);
-    }
-  g_free (types);
-}
-
-static GHashTable *gtype_hash = NULL;
-GType
-gegl_operation_gtype_from_name (const gchar *name)
-{
-  if (!gtype_hash)
-    {
-      gtype_hash = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);
-
-      add_operations (gtype_hash, GEGL_TYPE_OPERATION);
-    }
-  return (GType) g_hash_table_lookup (gtype_hash, name);
-}
-
-static GSList *operations_list = NULL;
-static void addop (gpointer key,
-                   gpointer value,
-                   gpointer user_data)
-{
-  operations_list = g_slist_prepend (operations_list, key);
-}
-
-gchar **gegl_list_operations (guint *n_operations_p)
-{
-  gchar **pasp = NULL;
-  gint    n_operations;
-  gint    i;
-  GSList *iter;
-  gint    pasp_size = 0;
-  gint    pasp_pos;
-
-  if (!operations_list)
-    {
-      gegl_operation_gtype_from_name ("");
-      g_hash_table_foreach (gtype_hash, addop, NULL);
-      operations_list = g_slist_sort (operations_list, (GCompareFunc) strcmp);
-    }
-
-  n_operations = g_slist_length (operations_list);
-  pasp_size   += (n_operations + 1) * sizeof (gchar *);
-  for (iter = operations_list; iter != NULL; iter = g_slist_next (iter))
-    {
-      const gchar *name = iter->data;
-      pasp_size += strlen (name) + 1;
-    }
-  pasp     = g_malloc (pasp_size);
-  pasp_pos = (n_operations + 1) * sizeof (gchar *);
-  for (iter = operations_list, i = 0; iter != NULL; iter = g_slist_next (iter), i++)
-    {
-      const gchar *name = iter->data;
-      pasp[i] = ((gchar *) pasp) + pasp_pos;
-      strcpy (pasp[i], name);
-      pasp_pos += strlen (name) + 1;
-    }
-  pasp[i] = NULL;
-  if (n_operations_p)
-    *n_operations_p = n_operations;
-  return pasp;
-}
 
 /* returns a freshly allocated list of the properties of the object, does not list
  * the regular gobject properties of GeglNode ('name' and 'operation') */
@@ -568,23 +465,3 @@
   return pad->format;
 }
 
-void
-gegl_operation_vector_prop_changed (GeglVector    *vector,
-                                    GeglOperation *operation)
-{
-  /* In the end forces a re-render, should be adapted to
-   * allow a smaller region to be forced for re-rendering
-   * when the vector is incrementally grown
-   */
-  g_object_notify (G_OBJECT (operation), "vector"); 
-}
-
-void
-gegl_operation_gtype_cleanup (void)
-{
-  if (gtype_hash)
-    {
-      g_hash_table_destroy (gtype_hash);
-      gtype_hash = NULL;
-    }
-}

Modified: trunk/gegl/operation/gegl-operation.h
==============================================================================
--- trunk/gegl/operation/gegl-operation.h	(original)
+++ trunk/gegl/operation/gegl-operation.h	Sat Jan 19 18:32:51 2008
@@ -14,7 +14,7 @@
  * License along with GEGL; if not, see <http://www.gnu.org/licenses/>.
  *
  * Copyright 2003 Calvin Williamson
- *           2005, 2006 Ãyvind KolÃs
+ *           2005-2008 Ãyvind KolÃs
  */
 
 #ifndef __GEGL_OPERATION_H__
@@ -171,7 +171,6 @@
                                                      const gchar         *output_pad,
                                                      const GeglRectangle *result_rect);
 
-gchar        ** gegl_list_operations                (guint *n_operations_p);
 GParamSpec   ** gegl_list_properties                (const gchar *operation_type,
                                                      guint       *n_properties_p);
 
@@ -196,18 +195,7 @@
 const Babl * gegl_operation_get_format              (GeglOperation *operation,
                                                      const gchar   *pad_name);
 
-/* Used to look up the gtype when changing the type of operation associated
- * a GeglNode using just a string with the registered name.
- */
-GType      gegl_operation_gtype_from_name           (const gchar *name);
-
-gboolean gegl_operation_calc_source_regions  (GeglOperation *operation,
-                                              gpointer       context_id);
-
-void     gegl_operation_vector_prop_changed  (GeglVector    *vector,
-                                              GeglOperation *operation);
 
-void     gegl_operation_gtype_cleanup        (void);
 
 G_END_DECLS
 

Added: trunk/gegl/operation/gegl-operations.c
==============================================================================
--- (empty file)
+++ trunk/gegl/operation/gegl-operations.c	Sat Jan 19 18:32:51 2008
@@ -0,0 +1,159 @@
+/* This file is part of GEGL
+ *
+ * GEGL is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * GEGL is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with GEGL; if not, see <http://www.gnu.org/licenses/>.
+ *
+ * Copyright 2003 Calvin Williamson
+ *           2005-2008 Ãyvind KolÃs
+ */
+
+#define GEGL_INTERNAL
+
+#include "config.h"
+
+#include <glib-object.h>
+#include <string.h>
+
+#include "gegl-types.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"
+
+static void
+add_operations (GHashTable *hash,
+                GType       parent)
+{
+  GType *types;
+  guint  count;
+  gint   no;
+
+  types = g_type_children (parent, &count);
+  if (!types)
+    return;
+
+  for (no = 0; no < count; no++)
+    {
+      GeglOperationClass *operation_class = g_type_class_ref (types[no]);
+      if (operation_class->name)
+        {
+          g_hash_table_insert (hash, g_strdup (operation_class->name), (gpointer) types[no]);
+        }
+      add_operations (hash, types[no]);
+    }
+  g_free (types);
+}
+
+static GHashTable *gtype_hash = NULL;
+GType
+gegl_operation_gtype_from_name (const gchar *name)
+{
+  if (!gtype_hash)
+    {
+      gtype_hash = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);
+
+      add_operations (gtype_hash, GEGL_TYPE_OPERATION);
+    }
+  return (GType) g_hash_table_lookup (gtype_hash, name);
+}
+
+static GSList *operations_list = NULL;
+static void addop (gpointer key,
+                   gpointer value,
+                   gpointer user_data)
+{
+  operations_list = g_slist_prepend (operations_list, key);
+}
+
+gchar **gegl_list_operations (guint *n_operations_p)
+{
+  gchar **pasp = NULL;
+  gint    n_operations;
+  gint    i;
+  GSList *iter;
+  gint    pasp_size = 0;
+  gint    pasp_pos;
+
+  if (!operations_list)
+    {
+      gegl_operation_gtype_from_name ("");
+      g_hash_table_foreach (gtype_hash, addop, NULL);
+      operations_list = g_slist_sort (operations_list, (GCompareFunc) strcmp);
+    }
+
+  n_operations = g_slist_length (operations_list);
+  pasp_size   += (n_operations + 1) * sizeof (gchar *);
+  for (iter = operations_list; iter != NULL; iter = g_slist_next (iter))
+    {
+      const gchar *name = iter->data;
+      pasp_size += strlen (name) + 1;
+    }
+  pasp     = g_malloc (pasp_size);
+  pasp_pos = (n_operations + 1) * sizeof (gchar *);
+  for (iter = operations_list, i = 0; iter != NULL; iter = g_slist_next (iter), i++)
+    {
+      const gchar *name = iter->data;
+      pasp[i] = ((gchar *) pasp) + pasp_pos;
+      strcpy (pasp[i], name);
+      pasp_pos += strlen (name) + 1;
+    }
+  pasp[i] = NULL;
+  if (n_operations_p)
+    *n_operations_p = n_operations;
+  return pasp;
+}
+
+void
+gegl_operation_gtype_cleanup (void)
+{
+  if (gtype_hash)
+    {
+      g_hash_table_destroy (gtype_hash);
+      gtype_hash = NULL;
+    }
+}
+
+gboolean
+gegl_operation_calc_source_regions (GeglOperation *operation,
+                                    gpointer       context_id)
+{
+  GSList          *input_pads;
+  GeglNodeContext *context;
+  GeglRectangle    request;
+
+  context = gegl_node_get_context (operation->node, context_id);
+  request = context->need_rect;
+
+  /* for each input, compute_input_request use gegl_operation_set_source_region() */
+  for (input_pads = operation->node->input_pads;input_pads;input_pads=input_pads->next)
+    {
+      const gchar *pad_name = gegl_pad_get_name (input_pads->data);
+      GeglRectangle rect;
+      rect = gegl_operation_compute_input_request (operation, pad_name, &request); 
+
+      gegl_operation_set_source_region (operation, context_id, pad_name, &rect);
+    }
+  return TRUE;
+}
+
+void
+gegl_operation_vector_prop_changed (GeglVector    *vector,
+                                    GeglOperation *operation)
+{
+  /* In the end forces a re-render, should be adapted to
+   * allow a smaller region to be forced for re-rendering
+   * when the vector is incrementally grown
+   */
+  g_object_notify (G_OBJECT (operation), "vector"); 
+}

Added: trunk/gegl/operation/gegl-operations.h
==============================================================================
--- (empty file)
+++ trunk/gegl/operation/gegl-operations.h	Sat Jan 19 18:32:51 2008
@@ -0,0 +1,38 @@
+/* This file is part of GEGL
+ *
+ * GEGL is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * GEGL is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with GEGL; if not, see <http://www.gnu.org/licenses/>.
+ *
+ * Copyright 2003 Calvin Williamson
+ *           2005-2008 Ãyvind KolÃs
+ */
+
+#ifndef __GEGL_OPERATIONS_H__
+#define __GEGL_OPERATIONS_H__
+
+#include <glib-object.h>
+#include "gegl-types.h"
+
+/* Used to look up the gtype when changing the type of operation associated
+ * a GeglNode using just a string with the registered name.
+ */
+GType      gegl_operation_gtype_from_name   (const gchar *name);
+gchar   ** gegl_list_operations             (guint *n_operations_p);
+void       gegl_operation_gtype_cleanup     (void);
+
+gboolean gegl_operation_calc_source_regions  (GeglOperation *operation,
+                                              gpointer       context_id);
+
+void     gegl_operation_vector_prop_changed  (GeglVector    *vector,
+                                              GeglOperation *operation);
+#endif



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