[gimp/soc-2010-cage-2] renaming of GimpOperationCage to GimpOperationCagePreview + cleaning
- From: Michael Muré <mmure src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp/soc-2010-cage-2] renaming of GimpOperationCage to GimpOperationCagePreview + cleaning
- Date: Thu, 12 Aug 2010 12:40:23 +0000 (UTC)
commit 9b3dbf9f3ecd9123bb8b0e2078db09dc7065f27a
Author: Michael Muré <batolettre gmail com>
Date: Thu Aug 12 14:34:19 2010 +0200
renaming of GimpOperationCage to GimpOperationCagePreview + cleaning
app/gegl/Makefile.am | 4 +-
app/gegl/gimp-gegl-types.h | 2 +-
app/gegl/gimp-gegl.c | 4 +-
app/gegl/gimpoperationcage.h | 58 ------
...poperationcage.c => gimpoperationcagepreview.c} | 200 ++++++++++----------
app/gegl/gimpoperationcagepreview.h | 58 ++++++
app/gegl/makefile.msc | 2 +-
7 files changed, 165 insertions(+), 163 deletions(-)
---
diff --git a/app/gegl/Makefile.am b/app/gegl/Makefile.am
index d3b902b..384a6ca 100644
--- a/app/gegl/Makefile.am
+++ b/app/gegl/Makefile.am
@@ -53,10 +53,10 @@ libappgegl_a_SOURCES = \
gimpoperationcolorbalance.h \
gimpoperationcolorize.c \
gimpoperationcolorize.h \
- gimpoperationcage.c \
- gimpoperationcage.h \
gimpoperationcagecoefcalc.c \
gimpoperationcagecoefcalc.h \
+ gimpoperationcagepreview.c \
+ gimpoperationcagepreview.h \
gimpoperationcagetransform.c \
gimpoperationcagetransform.h \
gimpoperationcurves.c \
diff --git a/app/gegl/gimp-gegl-types.h b/app/gegl/gimp-gegl-types.h
index e4a0e0d..c5cf70f 100644
--- a/app/gegl/gimp-gegl-types.h
+++ b/app/gegl/gimp-gegl-types.h
@@ -31,8 +31,8 @@ typedef struct _GimpOperationTileSource GimpOperationTileSource;
typedef struct _GimpOperationPointFilter GimpOperationPointFilter;
typedef struct _GimpOperationColorBalance GimpOperationColorBalance;
typedef struct _GimpOperationColorize GimpOperationColorize;
-typedef struct _GimpOperationCage GimpOperationCage;
typedef struct _GimpOperationCageCoefCalc GimpOperationCageCoefCalc;
+typedef struct _GimpOperationCagePreview GimpOperationCagePreview;
typedef struct _GimpOperationCageTransform GimpOperationCageTransform;
typedef struct _GimpOperationCurves GimpOperationCurves;
typedef struct _GimpOperationDesaturate GimpOperationDesaturate;
diff --git a/app/gegl/gimp-gegl.c b/app/gegl/gimp-gegl.c
index 90eb84e..9f94dfd 100644
--- a/app/gegl/gimp-gegl.c
+++ b/app/gegl/gimp-gegl.c
@@ -31,8 +31,8 @@
#include "core/gimp.h"
#include "gimp-gegl.h"
-#include "gimpoperationcage.h"
#include "gimpoperationcagecoefcalc.h"
+#include "gimpoperationcagepreview.h"
#include "gimpoperationcagetransform.h"
#include "gimpoperationcolorbalance.h"
#include "gimpoperationcolorize.h"
@@ -98,8 +98,8 @@ gimp_gegl_init (Gimp *gimp)
g_type_class_ref (GIMP_TYPE_OPERATION_TILE_SINK);
g_type_class_ref (GIMP_TYPE_OPERATION_TILE_SOURCE);
- g_type_class_ref (GIMP_TYPE_OPERATION_CAGE);
g_type_class_ref (GIMP_TYPE_OPERATION_CAGE_COEF_CALC);
+ g_type_class_ref (GIMP_TYPE_OPERATION_CAGE_PREVIEW);
g_type_class_ref (GIMP_TYPE_OPERATION_CAGE_TRANSFORM);
g_type_class_ref (GIMP_TYPE_OPERATION_COLOR_BALANCE);
g_type_class_ref (GIMP_TYPE_OPERATION_COLORIZE);
diff --git a/app/gegl/gimpoperationcage.c b/app/gegl/gimpoperationcagepreview.c
similarity index 54%
rename from app/gegl/gimpoperationcage.c
rename to app/gegl/gimpoperationcagepreview.c
index 8c0a674..c302946 100644
--- a/app/gegl/gimpoperationcage.c
+++ b/app/gegl/gimpoperationcagepreview.c
@@ -1,6 +1,6 @@
/* GIMP - The GNU Image Manipulation Program
*
- * gimpoperationcage.c
+ * gimpoperationcagepreview.c
* Copyright (C) 2010 Michael Muré <batolettre gmail com>
*
* This program is free software: you can redistribute it and/or modify
@@ -26,79 +26,81 @@
#include "libgimpcolor/gimpcolor.h"
#include "libgimpmath/gimpmath.h"
-#include "gimpoperationcage.h"
+#include "gimpoperationcagepreview.h"
#include "gimpcageconfig.h"
-static void gimp_operation_cage_finalize (GObject *object);
-static void gimp_operation_cage_get_property (GObject *object,
- guint property_id,
- GValue *value,
- GParamSpec *pspec);
-static void gimp_operation_cage_set_property (GObject *object,
- guint property_id,
- const GValue *value,
- GParamSpec *pspec);
-static void gimp_operation_cage_prepare (GeglOperation *operation);
-static gboolean gimp_operation_cage_process (GeglOperation *operation,
- GeglBuffer *in_buf,
- GeglBuffer *aux_buf,
- GeglBuffer *out_buf,
- const GeglRectangle *roi);
-GeglRectangle gimp_operation_cage_get_cached_region (GeglOperation *operation,
- const GeglRectangle *roi);
-GeglRectangle gimp_operation_cage_get_required_for_output (GeglOperation *operation,
- const gchar *input_pad,
- const GeglRectangle *roi);
-
-G_DEFINE_TYPE (GimpOperationCage, gimp_operation_cage,
+static void gimp_operation_cage_preview_finalize (GObject *object);
+static void gimp_operation_cage_preview_get_property (GObject *object,
+ guint property_id,
+ GValue *value,
+ GParamSpec *pspec);
+static void gimp_operation_cage_preview_set_property (GObject *object,
+ guint property_id,
+ const GValue *value,
+ GParamSpec *pspec);
+static void gimp_operation_cage_preview_prepare (GeglOperation *operation);
+static gboolean gimp_operation_cage_preview_process (GeglOperation *operation,
+ GeglBuffer *in_buf,
+ GeglBuffer *aux_buf,
+ GeglBuffer *out_buf,
+ const GeglRectangle *roi);
+GeglRectangle gimp_operation_cage_preview_get_cached_region (GeglOperation *operation,
+ const GeglRectangle *roi);
+GeglRectangle gimp_operation_cage_preview_get_required_for_output (GeglOperation *operation,
+ const gchar *input_pad,
+ const GeglRectangle *roi);
+GeglRectangle gimp_operation_cage_preview_get_bounding_box (GeglOperation *operation);
+
+G_DEFINE_TYPE (GimpOperationCagePreview, gimp_operation_cage_preview,
GEGL_TYPE_OPERATION_COMPOSER)
-#define parent_class gimp_operation_cage_parent_class
+#define parent_class gimp_operation_cage_preview_parent_class
static void
-gimp_operation_cage_class_init (GimpOperationCageClass *klass)
+gimp_operation_cage_preview_class_init (GimpOperationCagePreviewClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
GeglOperationClass *operation_class = GEGL_OPERATION_CLASS (klass);
GeglOperationComposerClass *composer_class = GEGL_OPERATION_COMPOSER_CLASS (klass);
- object_class->get_property = gimp_operation_cage_get_property;
- object_class->set_property = gimp_operation_cage_set_property;
- object_class->finalize = gimp_operation_cage_finalize;
+ object_class->get_property = gimp_operation_cage_preview_get_property;
+ object_class->set_property = gimp_operation_cage_preview_set_property;
+ object_class->finalize = gimp_operation_cage_preview_finalize;
/* FIXME: wrong categories and name, to appears in the gegl tool */
- operation_class->name = "gegl:cage";
- operation_class->categories = "color";
- operation_class->description = "GIMP cage transform";
+ operation_class->name = "gimp:cage_preview";
+ operation_class->categories = "transform";
+ operation_class->description = "GIMP cage transform preview";
- operation_class->prepare = gimp_operation_cage_prepare;
-
- operation_class->get_required_for_output = gimp_operation_cage_get_required_for_output;
- operation_class->get_cached_region = gimp_operation_cage_get_cached_region;
- operation_class->no_cache = FALSE;
-
- composer_class->process = gimp_operation_cage_process;
+ operation_class->prepare = gimp_operation_cage_preview_prepare;
+ operation_class->get_required_for_output = gimp_operation_cage_preview_get_required_for_output;
+ operation_class->get_cached_region = gimp_operation_cage_preview_get_cached_region;
+ operation_class->no_cache = FALSE;
+ operation_class->get_bounding_box = gimp_operation_cage_preview_get_bounding_box;
+
+ composer_class->process = gimp_operation_cage_preview_process;
+
g_object_class_install_property (object_class,
- GIMP_OPERATION_CAGE_PROP_CONFIG,
- g_param_spec_object ("config", NULL, NULL,
- GIMP_TYPE_CAGE_CONFIG,
- G_PARAM_READWRITE |
- G_PARAM_CONSTRUCT));
+ GIMP_OPERATION_CAGE_PREVIEW_PROP_CONFIG,
+ g_param_spec_object ("config", NULL, NULL,
+ GIMP_TYPE_CAGE_CONFIG,
+ G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT));
}
static void
-gimp_operation_cage_init (GimpOperationCage *self)
+gimp_operation_cage_preview_init (GimpOperationCagePreview *self)
{
}
static void
-gimp_operation_cage_finalize (GObject *object)
+gimp_operation_cage_preview_finalize (GObject *object)
{
- GimpOperationCage *self = GIMP_OPERATION_CAGE (object);
+ GimpOperationCagePreview *self = GIMP_OPERATION_CAGE_PREVIEW (object);
if (self->config)
{
@@ -110,16 +112,16 @@ gimp_operation_cage_finalize (GObject *object)
}
static void
-gimp_operation_cage_get_property (GObject *object,
- guint property_id,
- GValue *value,
- GParamSpec *pspec)
+gimp_operation_cage_preview_get_property (GObject *object,
+ guint property_id,
+ GValue *value,
+ GParamSpec *pspec)
{
- GimpOperationCage *self = GIMP_OPERATION_CAGE (object);
+ GimpOperationCagePreview *self = GIMP_OPERATION_CAGE_PREVIEW (object);
switch (property_id)
{
- case GIMP_OPERATION_CAGE_PROP_CONFIG:
+ case GIMP_OPERATION_CAGE_PREVIEW_PROP_CONFIG:
g_value_set_object (value, self->config);
break;
@@ -130,19 +132,19 @@ gimp_operation_cage_get_property (GObject *object,
}
static void
-gimp_operation_cage_set_property (GObject *object,
+gimp_operation_cage_preview_set_property (GObject *object,
guint property_id,
const GValue *value,
GParamSpec *pspec)
{
- GimpOperationCage *self = GIMP_OPERATION_CAGE (object);
+ GimpOperationCagePreview *self = GIMP_OPERATION_CAGE_PREVIEW (object);
switch (property_id)
{
- case GIMP_OPERATION_CAGE_PROP_CONFIG:
+ case GIMP_OPERATION_CAGE_PREVIEW_PROP_CONFIG:
if (self->config)
g_object_unref (self->config);
- self->config = g_value_dup_object (value);
+ self->config = g_value_dup_object (value);
break;
default:
@@ -153,44 +155,44 @@ gimp_operation_cage_set_property (GObject *object,
static void
-gimp_operation_cage_prepare (GeglOperation *operation)
+gimp_operation_cage_preview_prepare (GeglOperation *operation)
{
gegl_operation_set_format (operation, "input", babl_format ("RGBA float"));
gegl_operation_set_format (operation, "output", babl_format ("RGBA float"));
}
static gboolean
-gimp_operation_cage_process (GeglOperation *operation,
- GeglBuffer *in_buf,
- GeglBuffer *aux_buf,
- GeglBuffer *out_buf,
- const GeglRectangle *roi)
+gimp_operation_cage_preview_process (GeglOperation *operation,
+ GeglBuffer *in_buf,
+ GeglBuffer *aux_buf,
+ GeglBuffer *out_buf,
+ const GeglRectangle *roi)
{
- GimpOperationCage *oc = GIMP_OPERATION_CAGE (operation);
- GimpCageConfig *config = GIMP_CAGE_CONFIG (oc->config);
-
+ GimpOperationCagePreview *ocp = GIMP_OPERATION_CAGE_PREVIEW (operation);
+ GimpCageConfig *config = GIMP_CAGE_CONFIG (ocp->config);
+
Babl *format_io = babl_format ("RGBA float");
Babl *format_coef = babl_format_n (babl_type ("float"), 2 * config->cage_vertice_number);
-
+
gint in_index, coef_index;
gint i;
-
+
GeglRectangle rect, bb_cage;
GeglBufferIterator *it;
-
+
rect.height = 1;
rect.width = 1;
-
+
bb_cage = gimp_cage_config_get_bounding_box (config);
-
+
it = gegl_buffer_iterator_new (in_buf, &bb_cage, format_io, GEGL_BUFFER_READ);
in_index = 0;
-
+
coef_index = gegl_buffer_iterator_add (it, aux_buf, &bb_cage, format_coef, GEGL_BUFFER_READ);
-
+
/* pre-copy the input buffer to the out buffer */
- //gegl_buffer_copy (aux_buf, roi, out_buf, roi);
-
+ gegl_buffer_copy (in_buf, roi, out_buf, roi);
+
/* iterate on GeglBuffer */
while (gegl_buffer_iterator_next (it))
{
@@ -199,51 +201,43 @@ gimp_operation_cage_process (GeglOperation *operation,
gint x = it->roi->x; /* initial x */
gint y = it->roi->y; /* and y coordinates */
gint cvn = config->cage_vertice_number;
-
+
gfloat *source = it->data[in_index];
gfloat *coef = it->data[coef_index];
-
+
while(n_pixels--)
{
/* computing of the final position of the source pixel */
gdouble pos_x, pos_y;
-
+
pos_x = 0;
pos_y = 0;
-
+
for(i = 0; i < cvn; i++)
{
pos_x += coef[i] * config->cage_vertices_d[i].x;
pos_y += coef[i] * config->cage_vertices_d[i].y;
}
-
+
for(i = 0; i < cvn; i++)
{
pos_x += coef[i + cvn] * config->scaling_factor[i] * gimp_cage_config_get_edge_normal (config, i).x;
pos_y += coef[i + cvn] * config->scaling_factor[i] * gimp_cage_config_get_edge_normal (config, i).y;
}
-
+
rect.x = (gint) rint(pos_x);
rect.y = (gint) rint(pos_y);
-
- /*if (sqrt ((pos_x-x) * (pos_x-x) + (pos_y-y) * (pos_y-y)) < 20)
- {
- if (rect.x != x || rect.y != y)
- {
- printf("x: %d y: %d\n", rect.x, rect.y);
- }
- }*/
-
+
/* copy the source pixel in the out buffer */
gegl_buffer_set(out_buf,
&rect,
format_io,
source,
GEGL_AUTO_ROWSTRIDE);
-
- source += 4;
- coef += 2 * cvn;
-
+
+ source += 4;
+ coef += 2 * cvn;
+
/* update x and y coordinates */
x++;
if (x >= (it->roi->x + it->roi->width))
@@ -251,27 +245,35 @@ gimp_operation_cage_process (GeglOperation *operation,
x = it->roi->x;
y++;
}
-
+
}
}
return TRUE;
}
GeglRectangle
-gimp_operation_cage_get_cached_region (GeglOperation *operation,
+gimp_operation_cage_preview_get_cached_region (GeglOperation *operation,
const GeglRectangle *roi)
{
GeglRectangle result = *gegl_operation_source_get_bounding_box (operation, "input");
-
+
return result;
}
GeglRectangle
-gimp_operation_cage_get_required_for_output (GeglOperation *operation,
+gimp_operation_cage_preview_get_required_for_output (GeglOperation *operation,
const gchar *input_pad,
const GeglRectangle *roi)
{
GeglRectangle result = *gegl_operation_source_get_bounding_box (operation, "input");
-
+
+ return result;
+}
+
+GeglRectangle
+gimp_operation_cage_preview_get_bounding_box (GeglOperation *operation)
+{
+ GeglRectangle result = *gegl_operation_source_get_bounding_box (operation, "input");
+
return result;
}
diff --git a/app/gegl/gimpoperationcagepreview.h b/app/gegl/gimpoperationcagepreview.h
new file mode 100644
index 0000000..c480f47
--- /dev/null
+++ b/app/gegl/gimpoperationcagepreview.h
@@ -0,0 +1,58 @@
+/* GIMP - The GNU Image Manipulation Program
+ *
+ * gimpoperationcagepreview.h
+ * Copyright (C) 2010 Michael Muré <batolettre gmail com>
+ *
+ * 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_CAGE_PREVIEW_H__
+#define __GIMP_OPERATION_CAGE_PREVIEW_H__
+
+#include <gegl-plugin.h>
+#include <operation/gegl-operation-composer.h>
+
+enum
+{
+ GIMP_OPERATION_CAGE_PREVIEW_PROP_0,
+ GIMP_OPERATION_CAGE_PREVIEW_PROP_CONFIG
+};
+
+#define GIMP_TYPE_OPERATION_CAGE_PREVIEW (gimp_operation_cage_preview_get_type ())
+#define GIMP_OPERATION_CAGE_PREVIEW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_OPERATION_CAGE_PREVIEW, GimpOperationCagePreview))
+#define GIMP_OPERATION_CAGE_PREVIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_OPERATION_CAGE_PREVIEW, GimpOperationCagePreviewClass))
+#define GIMP_IS_OPERATION_CAGE_PREVIEW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GIMP_TYPE_OPERATION_CAGE_PREVIEW))
+#define GIMP_IS_OPERATION_CAGE_PREVIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_OPERATION_CAGE_PREVIEW))
+#define GIMP_OPERATION_CAGE_PREVIEW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GIMP_TYPE_OPERATION_CAGE_PREVIEW, GimpOperationCagePreviewClass))
+
+
+typedef struct _GimpOperationCagePreviewClass GimpOperationCagePreviewClass;
+
+struct _GimpOperationCagePreview
+{
+ GeglOperationComposer parent_instance;
+
+ GimpCageConfig *config;
+};
+
+struct _GimpOperationCagePreviewClass
+{
+ GeglOperationComposerClass parent_class;
+};
+
+
+GType gimp_operation_cage_preview_get_type (void) G_GNUC_CONST;
+
+
+#endif /* __GIMP_OPERATION_CAGE_PREVIEW_H__ */
diff --git a/app/gegl/makefile.msc b/app/gegl/makefile.msc
index 3e84fa7..b616f94 100644
--- a/app/gegl/makefile.msc
+++ b/app/gegl/makefile.msc
@@ -37,8 +37,8 @@ OBJECTS = \
gimphuesaturationconfig.obj \
gimplevelsconfig.obj \
gimpoperationcolorbalance.obj \
- gimpoperationcage.obj \
gimpoperationcagecoefcalc.obj \
+ gimpoperationcagepreview.obj \
gimpoperationcagetransform.obj \
gimpoperationcurves.obj \
gimpoperationhuesaturation.obj \
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]