[gegl] shear: port from custom chant to gegl-op.h



commit c3a1b50df85a8bcdcf4510c5e845b1dc69dfec17
Author: Øyvind Kolås <pippin gimp org>
Date:   Sat Mar 4 11:43:15 2017 +0100

    shear: port from custom chant to gegl-op.h

 operations/transform/module.c |   14 +++++-----
 operations/transform/shear.c  |   53 +++++++++++++++++++++++++++++++---------
 2 files changed, 48 insertions(+), 19 deletions(-)
---
diff --git a/operations/transform/module.c b/operations/transform/module.c
index 530ef11..b018234 100644
--- a/operations/transform/module.c
+++ b/operations/transform/module.c
@@ -39,13 +39,13 @@ gegl_module_query (GTypeModule *module)
   return &modinfo;
 }
 
-GType gegl_op_rotate_register_type (GTypeModule *module);
-GType gegl_op_rotate_on_center_register_type (GTypeModule *module);
-GType gegl_op_reflect_register_type (GTypeModule *module);
-GType gegl_op_scale_ratio_register_type  (GTypeModule *module);
-GType gegl_op_scale_size_register_type  (GTypeModule *module);
+GType gegl_op_rotate_register_type                (GTypeModule *module);
+GType gegl_op_rotate_on_center_register_type      (GTypeModule *module);
+GType gegl_op_reflect_register_type               (GTypeModule *module);
+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 shear_get_type       (void);
+GType gegl_op_shear_register_type                 (GTypeModule *module);
 GType translate_get_type   (void);
 GType transform_get_type   (void);
 
@@ -58,7 +58,6 @@ gegl_module_register (GTypeModule *module)
   transform_module = module;
 
   dummy = op_transform_get_type ();
-  dummy = shear_get_type ();
   dummy = translate_get_type ();
   dummy = transform_get_type ();
   dummy = gegl_op_scale_ratio_register_type (module);
@@ -66,6 +65,7 @@ gegl_module_register (GTypeModule *module)
   dummy = gegl_op_scale_size_keepaspect_register_type (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_rotate_on_center_register_type (module);
 
   dummy ++; /* silence gcc, having it is required to avoid optimizing
diff --git a/operations/transform/shear.c b/operations/transform/shear.c
index e0fbda7..11a16b2 100644
--- a/operations/transform/shear.c
+++ b/operations/transform/shear.c
@@ -14,25 +14,34 @@
  * 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 shear amount"))
+    ui_range (-100.0, 100.0)
 
-gegl_chant_double (x, -G_MAXDOUBLE, G_MAXDOUBLE, 0.0,
-                   _("Horizontal shear amount"))
-gegl_chant_double (y, -G_MAXDOUBLE, G_MAXDOUBLE, 0.0,
-                   _("Vertical shear amount"))
+property_double (y, _("Y"), 0.0)
+    description (_("Vertical shear amount"))
+    ui_range (-100.0, 100.0)
 
 #else
 
-#define GEGL_CHANT_NAME shear
-#define GEGL_CHANT_DESCRIPTION    _("Shears the buffer")
-#define GEGL_CHANT_SELF "shear.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    shear
+#define GEGL_OP_BUNDLE
+#define GEGL_OP_C_FILE  "shear.c"
+
+#include "gegl-op.h"
 
 #include <math.h>
 
@@ -40,10 +49,30 @@ static void
 create_matrix (OpTransform *op,
                GeglMatrix3 *matrix)
 {
-  GeglChantOperation *chant = GEGL_CHANT_OPERATION (op);
+  GeglProperties *o = GEGL_PROPERTIES (op);
+
+  matrix->coeff [0][1] = o->x;
+  matrix->coeff [1][0] = 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][1] = chant->x;
-  matrix->coeff [1][0] = chant->y;
+  gegl_operation_class_set_keys (operation_class,
+    "name", "gegl:shear",
+    "title", _("Shear"),
+    "categories", "transform",
+    "description", _("Shears the buffer. "),
+    NULL);
 }
 
 #endif


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