gegl r1826 - in trunk: . operations/core
- From: ok svn gnome org
- To: svn-commits-list gnome org
- Subject: gegl r1826 - in trunk: . operations/core
- Date: Mon, 7 Jan 2008 23:57:37 +0000 (GMT)
Author: ok
Date: Mon Jan 7 23:57:36 2008
New Revision: 1826
URL: http://svn.gnome.org/viewvc/gegl?rev=1826&view=rev
Log:
* operations/core/shift.c: (gegl_operation_shift_class_init): set
categories.
* operations/core/nop.c: turned into a non chanted operation that
derives directly from GeglOperation instead of GeglOperationFilter.
Modified:
trunk/ChangeLog
trunk/operations/core/nop.c
trunk/operations/core/shift.c
Modified: trunk/operations/core/nop.c
==============================================================================
--- trunk/operations/core/nop.c (original)
+++ trunk/operations/core/nop.c Mon Jan 7 23:57:36 2008
@@ -1,4 +1,4 @@
-/* This file is an image processing operation for GEGL
+/* 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
@@ -13,70 +13,270 @@
* 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 2006 Ãyvind KolÃs <pippin gimp org>
+ * Copyright 2006 Ãyvind KolÃs
*/
-#if GEGL_CHANT_PROPERTIES
-#else
+#ifndef __GEGL_OPERATION_NOP_H__
+#define __GEGL_OPERATION_NOP_H__
-#define GEGL_CHANT_FILTER
-#define GEGL_CHANT_NAME nop
-#define GEGL_CHANT_DESCRIPTION "Passthrough operation. Used mostly for routing/place holder purposes internally in GEGL."
-#define GEGL_CHANT_SELF "nop.c"
-#define GEGL_CHANT_CLASS_INIT
-#include "gegl-chant.h"
+#include "operation/gegl-operation.h"
+#include "gegl-module.h"
+G_BEGIN_DECLS
-/* FIXME: rewrtie without chanting, wihtout deriving from GeglOperationFilter, but
- * directly from GeglOperation
- */
+#define GEGL_TYPE_OPERATION_NOP (gegl_operation_nop_get_type ())
+#define GEGL_OPERATION_NOP(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GEGL_TYPE_OPERATION_NOP, GeglOperationNop))
+#define GEGL_OPERATION_NOP_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GEGL_TYPE_OPERATION_NOP, GeglOperationNopClass))
+#define GEGL_IS_OPERATION_NOP(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GEGL_TYPE_OPERATION_NOP))
+#define GEGL_IS_OPERATION_NOP_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GEGL_TYPE_OPERATION_NOP))
+#define GEGL_OPERATION_NOP_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GEGL_TYPE_OPERATION_NOP, GeglOperationNopClass))
-static gboolean
-process (GeglOperation *operation,
- GeglNodeContext *context,
- GeglBuffer *input,
- GeglBuffer *output, /*ignored*/
- const GeglRectangle *process)
+typedef struct _GeglOperationNop GeglOperationNop;
+typedef struct _GeglOperationNopClass GeglOperationNopClass;
+
+struct _GeglOperationNop
+{
+ GeglOperation parent_instance;
+
+ gfloat x;
+ gfloat y;
+};
+
+struct _GeglOperationNopClass
+{
+ GeglOperationClass parent_class;
+
+ gboolean (* process) (GeglOperation *self,
+ GeglNodeContext *context,
+ GeglBuffer *input,
+ GeglBuffer *output,
+ const GeglRectangle *result);
+};
+
+GType gegl_operation_nop_get_type (void) G_GNUC_CONST;
+
+G_END_DECLS
+
+#endif /* __GEGL_OPERATION_NOP_H__ */
+
+/***************************************************************************/
+
+#include "graph/gegl-pad.h"
+#include "graph/gegl-node.h"
+#include <math.h>
+#include <string.h>
+
+
+enum
+{
+ PROP_0,
+ PROP_OUTPUT,
+ PROP_INPUT
+};
+
+static gboolean process (GeglOperation *operation,
+ GeglNodeContext *context,
+ const gchar *output_prop,
+ const GeglRectangle *result);
+static void attach (GeglOperation *operation);
+static GeglNode * detect (GeglOperation *operation,
+ gint x,
+ gint y);
+static GeglRectangle get_defined_region (GeglOperation *operation);
+static GeglRectangle compute_input_request (GeglOperation *operation,
+ const gchar *input_pad,
+ const GeglRectangle *roi);
+static GeglRectangle compute_affected_region (GeglOperation *operation,
+ const gchar *input_pad,
+ const GeglRectangle *input_region);
+static void get_property (GObject *object,
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec);
+static void set_property (GObject *object,
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec);
+
+G_DEFINE_DYNAMIC_TYPE (GeglOperationNop, gegl_operation_nop, GEGL_TYPE_OPERATION)
+
+static void
+gegl_operation_nop_class_init (GeglOperationNopClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ GeglOperationClass *operation_class = GEGL_OPERATION_CLASS (klass);
+
+ object_class->get_property = get_property;
+ object_class->set_property = set_property;
+
+ operation_class->categories = "core";
+ operation_class->no_cache = TRUE;
+ operation_class->process = process;
+ operation_class->attach = attach;
+ operation_class->detect = detect;
+ operation_class->get_defined_region = get_defined_region;
+ operation_class->compute_input_request = compute_input_request;
+ operation_class->compute_affected_region = compute_affected_region;
+
+ gegl_operation_class_set_name (operation_class, "nop");
+
+
+ g_object_class_install_property (object_class, PROP_OUTPUT,
+ g_param_spec_object ("output",
+ "Output",
+ "Ouput pad for generated image buffer.",
+ GEGL_TYPE_BUFFER,
+ G_PARAM_READABLE |
+ GEGL_PARAM_PAD_OUTPUT));
+
+ g_object_class_install_property (object_class, PROP_INPUT,
+ g_param_spec_object ("input",
+ "Input",
+ "Input pad, for image buffer input.",
+ GEGL_TYPE_BUFFER,
+ G_PARAM_READWRITE |
+ GEGL_PARAM_PAD_INPUT));
+
+}
+
+static void
+gegl_operation_nop_class_finalize (GeglOperationNopClass *klass)
{
- gboolean success = FALSE;
- if (input)
- {
- g_object_ref (input);
- /* overrides earlier context_set */
- gegl_node_context_set_object (context, "output", G_OBJECT (input));
- success = TRUE;
- }
- return success;
}
+static void
+gegl_operation_nop_init (GeglOperationNop *self)
+{
+}
+
+static void get_property (GObject *object,
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+}
+
+static void set_property (GObject *object,
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+}
+
+static void
+attach (GeglOperation *operation)
+{
+ GObjectClass *object_class = G_OBJECT_GET_CLASS (operation);
+
+ gegl_operation_create_pad (operation,
+ g_object_class_find_property (object_class,
+ "output"));
+ gegl_operation_create_pad (operation,
+ g_object_class_find_property (object_class,
+ "input"));
+}
+
+
static GeglNode *
detect (GeglOperation *operation,
gint x,
gint y)
{
- GeglNode *input_node;
+ GeglOperationNop *self = GEGL_OPERATION_NOP (operation);
+ GeglNode *input_node;
- const gchar *name = gegl_node_get_name (operation->node);
- if (name && !strcmp (name, "proxynop-output"))
- {
- GeglNode *graph;
- graph = g_object_get_data (G_OBJECT (operation->node), "graph");
- input_node = gegl_operation_detect (graph->operation, x, y);
- if (input_node)
- return input_node;
- }
-
input_node = gegl_operation_get_source_node (operation, "input");
if (input_node)
- return gegl_operation_detect (input_node->operation, x, y);
+ return gegl_operation_detect (input_node->operation,
+ x - floor (self->x),
+ y - floor (self->y));
+
return operation->node;
}
-static void class_init (GeglOperationClass *operation_class)
+
+static gboolean
+process (GeglOperation *operation,
+ GeglNodeContext *context,
+ const gchar *output_prop,
+ const GeglRectangle *result)
{
- operation_class->detect = detect;
- operation_class->no_cache = TRUE;
+ GeglOperationNop *nop = GEGL_OPERATION_NOP (operation);
+ GeglBuffer *input;
+
+ nop->x = floor (nop->x);
+ nop->y = floor (nop->y);
+
+ if (strcmp (output_prop, "output"))
+ {
+ g_warning ("requested processing of %s pad on a nop", output_prop);
+ return FALSE;
+ }
+
+ input = gegl_node_context_get_source (context, "input");
+ if (!input)
+ {
+ g_warning ("nop received NULL input");
+ return FALSE;
+ }
+ g_object_ref (input);
+ gegl_node_context_set_object (context, "output", G_OBJECT (input));
+ return TRUE;
}
-#endif
+static GeglRectangle
+get_defined_region (GeglOperation *operation)
+{
+ GeglRectangle result = { 0, 0, 0, 0 };
+ GeglRectangle *in_rect;
+
+ in_rect = gegl_operation_source_get_defined_region (operation, "input");
+ if (in_rect)
+ {
+ result = *in_rect;
+ }
+
+ return result;
+}
+
+static GeglRectangle
+compute_affected_region (GeglOperation *operation,
+ const gchar *input_pad,
+ const GeglRectangle *input_region)
+{
+ GeglOperationNop *self = GEGL_OPERATION_NOP (operation);
+ GeglRectangle result = *input_region;
+
+ result.x += floor (self->x);
+ result.y += floor (self->y);
+
+ return result;
+}
+
+static GeglRectangle
+compute_input_request (GeglOperation *operation,
+ const gchar *input_pad,
+ const GeglRectangle *roi)
+{
+ return *roi;
+}
+
+static const GeglModuleInfo modinfo =
+{
+ GEGL_MODULE_ABI_VERSION, "nop", "", ""
+};
+
+G_MODULE_EXPORT const GeglModuleInfo *
+gegl_module_query (GTypeModule *module)
+{
+ return &modinfo;
+}
+
+G_MODULE_EXPORT gboolean
+gegl_module_register (GTypeModule *module)
+{
+ gegl_operation_nop_register_type (module);
+
+ return TRUE;
+}
Modified: trunk/operations/core/shift.c
==============================================================================
--- trunk/operations/core/shift.c (original)
+++ trunk/operations/core/shift.c Mon Jan 7 23:57:36 2008
@@ -113,6 +113,7 @@
object_class->set_property = set_property;
object_class->get_property = get_property;
+ operation_class->categories = "core";
operation_class->no_cache = TRUE;
operation_class->process = process;
operation_class->attach = attach;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]