[gimp/goat-invasion: 494/526] app: clean up and build the histogram op gift
- From: Michael Natterer <mitch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp/goat-invasion: 494/526] app: clean up and build the histogram op gift
- Date: Sun, 22 Apr 2012 13:40:47 +0000 (UTC)
commit 213d1a17bacedfd995b509299d8e8a0c399f3204
Author: Michael Natterer <mitch gimp org>
Date: Sun Apr 15 00:35:44 2012 +0200
app: clean up and build the histogram op gift
app/gegl/Makefile.am | 2 +
app/gegl/gimp-gegl-types.h | 1 +
app/gegl/gimp-gegl.c | 2 +
app/gegl/gimp-operation-histogram-sink.c | 144 ---------------------------
app/gegl/gimp-operation-histogram-sink.h | 43 --------
app/gegl/gimpoperationhistogramsink.c | 159 ++++++++++++++++++++++++++++++
app/gegl/gimpoperationhistogramsink.h | 53 ++++++++++
7 files changed, 217 insertions(+), 187 deletions(-)
---
diff --git a/app/gegl/Makefile.am b/app/gegl/Makefile.am
index 1f2c260..6e9d2ef 100644
--- a/app/gegl/Makefile.am
+++ b/app/gegl/Makefile.am
@@ -64,6 +64,8 @@ libappgegl_a_sources = \
gimpoperationequalize.h \
gimpoperationgrow.c \
gimpoperationgrow.h \
+ gimpoperationhistogramsink.c \
+ gimpoperationhistogramsink.h \
gimpoperationsetalpha.c \
gimpoperationsetalpha.h \
gimpoperationshapeburst.c \
diff --git a/app/gegl/gimp-gegl-types.h b/app/gegl/gimp-gegl-types.h
index be6512f..85dc530 100644
--- a/app/gegl/gimp-gegl-types.h
+++ b/app/gegl/gimp-gegl-types.h
@@ -32,6 +32,7 @@ typedef struct _GimpOperationCageCoefCalc GimpOperationCageCoefCalc;
typedef struct _GimpOperationCageTransform GimpOperationCageTransform;
typedef struct _GimpOperationEqualize GimpOperationEqualize;
typedef struct _GimpOperationGrow GimpOperationGrow;
+typedef struct _GimpOperationHistogramSink GimpOperationHistogramSink;
typedef struct _GimpOperationSetAlpha GimpOperationSetAlpha;
typedef struct _GimpOperationShapeburst GimpOperationShapeburst;
typedef struct _GimpOperationShrink GimpOperationShrink;
diff --git a/app/gegl/gimp-gegl.c b/app/gegl/gimp-gegl.c
index 9d7a1e5..577bef3 100644
--- a/app/gegl/gimp-gegl.c
+++ b/app/gegl/gimp-gegl.c
@@ -37,6 +37,7 @@
#include "gimpoperationcagetransform.h"
#include "gimpoperationequalize.h"
#include "gimpoperationgrow.h"
+#include "gimpoperationhistogramsink.h"
#include "gimpoperationsetalpha.h"
#include "gimpoperationshapeburst.h"
#include "gimpoperationshrink.h"
@@ -138,6 +139,7 @@ gimp_gegl_init (Gimp *gimp)
g_type_class_ref (GIMP_TYPE_OPERATION_CAGE_TRANSFORM);
g_type_class_ref (GIMP_TYPE_OPERATION_EQUALIZE);
g_type_class_ref (GIMP_TYPE_OPERATION_GROW);
+ g_type_class_ref (GIMP_TYPE_OPERATION_HISTOGRAM_SINK);
g_type_class_ref (GIMP_TYPE_OPERATION_SET_ALPHA);
g_type_class_ref (GIMP_TYPE_OPERATION_SHAPEBURST);
g_type_class_ref (GIMP_TYPE_OPERATION_SHRINK);
diff --git a/app/gegl/gimpoperationhistogramsink.c b/app/gegl/gimpoperationhistogramsink.c
new file mode 100644
index 0000000..7e06fd5
--- /dev/null
+++ b/app/gegl/gimpoperationhistogramsink.c
@@ -0,0 +1,159 @@
+/* GIMP - The GNU Image Manipulation Program
+ * Copyright (C) 1995 Spencer Kimball and Peter Mattis
+ *
+ * gimpoperationhistogramsink.c
+ * Copyright (C) 2012 Ãyvind KolÃs
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "config.h"
+
+#include <gegl.h>
+
+#include "gimp-gegl-types.h"
+
+#include "gimpoperationhistogramsink.h"
+
+
+enum
+{
+ PROP_0,
+ PROP_INPUT,
+ PROP_AUX
+};
+
+static void gimp_operation_histogram_sink_get_property (GObject *gobject,
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec);
+static void gimp_operation_histogram_sink_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 gimp_operation_histogram_sink_attach (GeglOperation *operation);
+
+static GeglRectangle gimp_operation_histogram_sink_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 = gimp_operation_histogram_sink_set_property;
+ object_class->get_property = gimp_operation_histogram_sink_get_property;
+
+ operation_class->attach = gimp_operation_histogram_sink_attach;
+ operation_class->get_required_for_output = gimp_operation_histogram_sink_get_required_for_output;
+ operation_class->process = gimp_operation_histogram_sink_process;
+
+ g_object_class_install_property (object_class, PROP_AUX,
+ g_param_spec_object ("aux",
+ "Aux",
+ "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
+gimp_operation_histogram_sink_get_property (GObject *object,
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+}
+
+static void
+gimp_operation_histogram_sink_set_property (GObject *object,
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+}
+
+static void
+gimp_operation_histogram_sink_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 GeglRectangle
+gimp_operation_histogram_sink_get_required_for_output (GeglOperation *self,
+ const gchar *input_pad,
+ const GeglRectangle *roi)
+{
+ /* dunno what to do here, make a wild guess */
+ return *roi;
+}
+
+static gboolean
+gimp_operation_histogram_sink_process (GeglOperation *operation,
+ GeglOperationContext *context,
+ const gchar *output_prop,
+ const GeglRectangle *result,
+ gint level)
+{
+ GeglBuffer *input;
+ GeglBuffer *aux;
+
+ if (strcmp (output_prop, "output"))
+ {
+ g_warning ("requested processing of %s pad on a sink", output_prop);
+ return FALSE;
+ }
+
+ input = gegl_operation_context_get_source (context, "input");
+ aux = gegl_operation_context_get_source (context, "aux");
+
+ if (input)
+ {
+ if (aux)
+ {
+ /* do hist with mask */
+ }
+ else
+ {
+ /* without */
+ }
+
+ return TRUE;
+ }
+
+ g_warning ("received NULL input");
+
+ return FALSE;
+}
diff --git a/app/gegl/gimpoperationhistogramsink.h b/app/gegl/gimpoperationhistogramsink.h
new file mode 100644
index 0000000..c48043d
--- /dev/null
+++ b/app/gegl/gimpoperationhistogramsink.h
@@ -0,0 +1,53 @@
+/* GIMP - The GNU Image Manipulation Program
+ * Copyright (C) 1995 Spencer Kimball and Peter Mattis
+ *
+ * gimpoperationhistogramsink.h
+ * Copyright (C) 2012 Ãyvind KolÃs
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef __GIMP_OPERATION_HISTOGRAM_SINK_H__
+#define __GIMP_OPERATION_HISTOGRAM_SINK_H__
+
+
+#include <gegl-plugin.h>
+#include <operation/gegl-operation-sink.h>
+
+
+#define GIMP_TYPE_OPERATION_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 _GimpOperationHistogramSinkClass GimpOperationHistogramSinkClass;
+
+struct _GimpOperationHistogramSink
+{
+ GeglOperation parent_instance;
+};
+
+struct _GimpOperationHistogramSinkClass
+{
+ GeglOperationSinkClass parent_class;
+};
+
+
+GType gimp_operation_histogram_sink_get_type (void) G_GNUC_CONST;
+
+
+#endif /* __GIMP_OPERATION_HISTOGRAM_SINK_C__ */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]