[gegl] translate: port from custom chant to gegl-op.h
- From: Øyvind Kolås <ok src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gegl] translate: port from custom chant to gegl-op.h
- Date: Sat, 4 Mar 2017 10:52:50 +0000 (UTC)
commit 86affa517f675587162a7c3362750a30b079bfec
Author: Øyvind Kolås <pippin gimp org>
Date: Sat Mar 4 11:46:28 2017 +0100
translate: port from custom chant to gegl-op.h
operations/transform/module.c | 4 +-
operations/transform/translate.c | 55 +++++++++++++++++++++++++++++--------
2 files changed, 45 insertions(+), 14 deletions(-)
---
diff --git a/operations/transform/module.c b/operations/transform/module.c
index b018234..8a6bc2f 100644
--- a/operations/transform/module.c
+++ b/operations/transform/module.c
@@ -46,7 +46,7 @@ GType gegl_op_scale_ratio_register_type (GTypeModule *module);
GType gegl_op_scale_size_register_type (GTypeModule *module);
GType gegl_op_scale_size_keepaspect_register_type (GTypeModule *module);
GType gegl_op_shear_register_type (GTypeModule *module);
-GType translate_get_type (void);
+GType gegl_op_translate_register_type (GTypeModule *module);
GType transform_get_type (void);
#include <stdio.h>
@@ -58,7 +58,6 @@ gegl_module_register (GTypeModule *module)
transform_module = module;
dummy = op_transform_get_type ();
- dummy = translate_get_type ();
dummy = transform_get_type ();
dummy = gegl_op_scale_ratio_register_type (module);
dummy = gegl_op_scale_size_register_type (module);
@@ -66,6 +65,7 @@ gegl_module_register (GTypeModule *module)
dummy = gegl_op_rotate_register_type (module);
dummy = gegl_op_reflect_register_type (module);
dummy = gegl_op_shear_register_type (module);
+ dummy = gegl_op_translate_register_type (module);
dummy = gegl_op_rotate_on_center_register_type (module);
dummy ++; /* silence gcc, having it is required to avoid optimizing
diff --git a/operations/transform/translate.c b/operations/transform/translate.c
index 493e04e..749c5c5 100644
--- a/operations/transform/translate.c
+++ b/operations/transform/translate.c
@@ -14,34 +14,65 @@
* License along with GEGL; if not, see <http://www.gnu.org/licenses/>.
*
* Copyright 2006 Philip Lafleur
+ * 2017 Øyvind Kolås
*/
#include "config.h"
#include <glib/gi18n-lib.h>
+#ifdef GEGL_PROPERTIES
-#ifdef GEGL_CHANT_PROPERTIES
+property_double (x, _("X"), 0.0)
+ description (_("Horizontal translation"))
+ ui_range (-1000.0, 1000.0)
-gegl_chant_double (x, -G_MAXDOUBLE, G_MAXDOUBLE, 0.0,
- _("Horizontal translation"))
-gegl_chant_double (y, -G_MAXDOUBLE, G_MAXDOUBLE, 0.0,
- _("Vertical translation"))
+property_double (y, _("Y"), 0.0)
+ description (_("Vertical translation"))
+ ui_range (-1000.0, 1000.0)
#else
-#define GEGL_CHANT_NAME translate
-#define GEGL_CHANT_DESCRIPTION _("Repositions the buffer (with subpixel precision), if integer coordinates
are passed a fast-path without resampling is used")
-#define GEGL_CHANT_SELF "translate.c"
-#include "chant.h"
+#include "gegl-operation-filter.h"
+#include "transform-core.h"
+#define GEGL_OP_NO_SOURCE
+#define GEGL_OP_Parent OpTransform
+#define GEGL_OP_PARENT TYPE_OP_TRANSFORM
+#define GEGL_OP_NAME translate
+#define GEGL_OP_BUNDLE
+#define GEGL_OP_C_FILE "translate.c"
+
+#include "gegl-op.h"
+
+#include <math.h>
static void
create_matrix (OpTransform *op,
GeglMatrix3 *matrix)
{
- GeglChantOperation *chant = GEGL_CHANT_OPERATION (op);
+ GeglProperties *o = GEGL_PROPERTIES (op);
+
+ matrix->coeff [0][2] = o->x;
+ matrix->coeff [1][2] = o->y;
+}
+
+#include <stdio.h>
+
+static void
+gegl_op_class_init (GeglOpClass *klass)
+{
+ GeglOperationClass *operation_class;
+ OpTransformClass *transform_class;
+
+ operation_class = GEGL_OPERATION_CLASS (klass);
+ transform_class = OP_TRANSFORM_CLASS (klass);
+ transform_class->create_matrix = create_matrix;
- matrix->coeff [0][2] = chant->x;
- matrix->coeff [1][2] = chant->y;
+ gegl_operation_class_set_keys (operation_class,
+ "name", "gegl:translate",
+ "title", _("Translate"),
+ "categories", "transform",
+ "description", _("Repositions the buffer (with subpixel precision), if integer coordinates are passed a
fast-path without resampling is used"),
+ NULL);
}
#endif
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]