[gimp/goat-invasion] app: histogram sink skeleton gift for mitch



commit c4eba1aad0195fb6dc56cc5b496a07aa3e443a6e
Author: Ãyvind KolÃs <pippin gimp org>
Date:   Sat Apr 14 23:50:40 2012 +0200

    app: histogram sink skeleton gift for mitch

 app/gegl/gimp-operation-histogram-sink.c |  144 ++++++++++++++++++++++++++++++
 app/gegl/gimp-operation-histogram-sink.h |   43 +++++++++
 2 files changed, 187 insertions(+), 0 deletions(-)
---
diff --git a/app/gegl/gimp-operation-histogram-sink.c b/app/gegl/gimp-operation-histogram-sink.c
new file mode 100644
index 0000000..3ace209
--- /dev/null
+++ b/app/gegl/gimp-operation-histogram-sink.c
@@ -0,0 +1,144 @@
+/*
+ * Copyright 2012 Ãyvind KolÃs
+ */
+
+#include "config.h"
+
+#include <glib-object.h>
+#include <string.h>
+
+#include "gegl.h"
+#include "gegl-plugin.h"
+#include "gimp-operation-histogram-sink.h"
+#include "gegl-utils.h"
+#include "buffer/gegl-buffer.h"
+
+enum
+{
+  PROP_0,
+  PROP_OUTPUT,
+  PROP_INPUT,
+  PROP_AUX
+};
+
+static void     get_property (GObject             *gobject,
+                              guint                prop_id,
+                              GValue              *value,
+                              GParamSpec          *pspec);
+static void     set_property (GObject             *gobject,
+                              guint                prop_id,
+                              const GValue        *value,
+                              GParamSpec          *pspec);
+static gboolean gimp_operation_histogram_sink_process (GeglOperation       *operation,
+                              GeglOperationContext     *context,
+                              const gchar         *output_prop,
+                              const GeglRectangle *result,
+                              gint                 level);
+static void     attach       (GeglOperation       *operation);
+
+static GeglRectangle get_required_for_output (GeglOperation        *self,
+                                               const gchar         *input_pad,
+                                               const GeglRectangle *roi);
+
+G_DEFINE_TYPE (GimpOperationHistogramSink, gimp_operation_histogram_sink,
+               GEGL_TYPE_OPERATION_SINK)
+
+
+static void
+gimp_operation_histogram_sink_class_init (GimpOperationHistogramSinkClass * klass)
+{
+  GObjectClass       *object_class    = G_OBJECT_CLASS (klass);
+  GeglOperationClass *operation_class = GEGL_OPERATION_CLASS (klass);
+
+  object_class->set_property = set_property;
+  object_class->get_property = get_property;
+
+  operation_class->process = gimp_operation_histogram_sink_process;
+  operation_class->get_required_for_output = get_required_for_output;
+  operation_class->attach = attach;
+
+  g_object_class_install_property (object_class, PROP_AUX,
+                                   g_param_spec_object ("aux",
+                                                        "Input",
+                                                        "Auxiliary image buffer input pad.",
+                                                        GEGL_TYPE_BUFFER,
+                                                        G_PARAM_READWRITE |
+                                                        GEGL_PARAM_PAD_INPUT));
+}
+
+static void
+gimp_operation_histogram_sink_init (GimpOperationHistogramSink *self)
+{
+}
+
+static void
+attach (GeglOperation *self)
+{
+  GeglOperation *operation    = GEGL_OPERATION (self);
+  GObjectClass  *object_class = G_OBJECT_GET_CLASS (self);
+
+  gegl_operation_create_pad (operation,
+                             g_object_class_find_property (object_class,
+                                                           "aux"));
+}
+
+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 gboolean
+gimp_operation_histogram_sink_process (GeglOperation        *operation,
+                                       GeglOperationContext *context,
+                                       const gchar          *output_prop,
+                                       const GeglRectangle  *result,
+                                       gint                  level)
+{
+  GeglBuffer                 *input;
+  GeglBuffer                 *aux;
+  gboolean                    success = FALSE;
+
+  if (strcmp (output_prop, "output"))
+    {
+      g_warning ("requested processing of %s pad on a composer", output_prop);
+      return FALSE;
+    }
+
+  input = gegl_operation_context_get_source (context, "input");
+  aux   = gegl_operation_context_get_source (context, "aux");
+
+  /* A composer with a NULL aux, can still be valid, the
+   * subclass has to handle it.
+   */
+  if (input != NULL ||
+      aux != NULL)
+    {
+      /* shake and stir bits */
+    }
+  else
+    {
+      g_warning ("received NULL input and aux");
+    }
+
+  return success;
+}
+
+static GeglRectangle
+get_required_for_output (GeglOperation       *self,
+                         const gchar         *input_pad,
+                         const GeglRectangle *roi)
+{
+  /* dunno what to do here, make a wild guess */
+  return *roi;
+}
diff --git a/app/gegl/gimp-operation-histogram-sink.h b/app/gegl/gimp-operation-histogram-sink.h
new file mode 100644
index 0000000..05bbdfb
--- /dev/null
+++ b/app/gegl/gimp-operation-histogram-sink.h
@@ -0,0 +1,43 @@
+/* 
+ * Copyright 2012 Ãyvind KolÃs
+ */
+
+#ifndef __GIMP_OPERATION_HISTOGRAM_SINK_H__
+#define __GIMP_OPERATION_HISTOGRAM_SINK_H__
+
+#include "gegl-operation-sink.h"
+
+G_BEGIN_DECLS
+
+#define GIMP_TYPE_HISTOGRAM_SINK            (gimp_operation_histogram_sink_get_type ())
+#define GIMP_OPERATION_HISTOGRAM_SINK(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_HISTOGRAM_SINK, GimpOperationHistogramSink))
+#define GIMP_OPERATION_HISTOGRAM_SINK_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass),  GIMP_TYPE_HISTOGRAM_SINK, GimpOperationHistogramSinkClass))
+#define GEGL_IS_OPERATION_HISTOGRAM_SINK(obj)         (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GIMP_TYPE_HISTOGRAM_SINK))
+#define GEGL_IS_OPERATION_HISTOGRAM_SINK_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass),  GIMP_TYPE_HISTOGRAM_SINK))
+#define GIMP_OPERATION_HISTOGRAM_SINK_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS ((obj),  GIMP_TYPE_HISTOGRAM_SINK, GimpOperationHistogramSinkClass))
+
+typedef struct _GimpOperationHistogramSink  GimpOperationHistogramSink;
+struct _GimpOperationHistogramSink
+{
+  GeglOperation parent_instance;
+};
+
+typedef struct _GimpOperationHistogramSinkClass GimpOperationHistogramSinkClass;
+struct _GimpOperationHistogramSinkClass
+{
+  GeglOperationSinkClass parent_class;
+
+  gboolean (* process) (GeglOperation       *self,
+                        GeglBuffer          *input,
+                        GeglBuffer          *aux,
+                        GeglBuffer          *output,
+                        const GeglRectangle *result,
+                        gint                 level);
+  gpointer              pad[4];
+};
+
+GType gimp_operation_histogram_sink_get_type (void) G_GNUC_CONST;
+
+G_END_DECLS
+
+#endif



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