[gegl] reflect: use gegl-op.h instead of custom chant



commit cf3e2d4d580dfe69725a85b558ce5c49063d5a7e
Author: Øyvind Kolås <pippin gimp org>
Date:   Fri Mar 3 14:26:11 2017 +0100

    reflect: use gegl-op.h instead of custom chant

 operations/transform/module.c  |    4 +-
 operations/transform/reflect.c |   60 ++++++++++++++++++++++++++++++---------
 2 files changed, 48 insertions(+), 16 deletions(-)
---
diff --git a/operations/transform/module.c b/operations/transform/module.c
index 81bc3fd..2270b53 100644
--- a/operations/transform/module.c
+++ b/operations/transform/module.c
@@ -41,12 +41,12 @@ gegl_module_query (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 scale_ratio_get_type  (void);
 GType scale_size_get_type   (void);
 GType scale_size_keepaspect_get_type   (void);
 GType shear_get_type       (void);
 GType translate_get_type   (void);
-GType reflect_get_type     (void);
 GType transform_get_type   (void);
 
 #include <stdio.h>
@@ -63,9 +63,9 @@ gegl_module_register (GTypeModule *module)
   dummy = scale_size_keepaspect_get_type ();
   dummy = shear_get_type ();
   dummy = translate_get_type ();
-  dummy = reflect_get_type ();
   dummy = transform_get_type ();
   dummy = gegl_op_rotate_register_type (module);
+  dummy = gegl_op_reflect_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/reflect.c b/operations/transform/reflect.c
index 3f62d21..42cfacb 100644
--- a/operations/transform/reflect.c
+++ b/operations/transform/reflect.c
@@ -15,35 +15,45 @@
  *
  * Copyright 2006 Dominik Ernst
  *           2012 Nicolas Robidoux
- *
- * Reflect an image about a line, whose direction is specified by the
- * vector that is defined by the x and y properties.
+ *           2017 Øyvind Kolås
  */
 
 #include "config.h"
 #include <glib/gi18n-lib.h>
 
+#ifdef GEGL_PROPERTIES
+
+property_double (x, _("X"), 0.0)
+    description (_("Direction vector's X component"))
+    ui_range (-100.0, 100.0)
 
-#ifdef GEGL_CHANT_PROPERTIES
+property_double (y, _("Y"), 0.0)
+    description (_("Direction vector's Y component"))
+    ui_range (-100.0, 100.0)
 
-gegl_chant_double (x, -G_MAXDOUBLE, G_MAXDOUBLE, 0.0,
-                   _("Direction vector's X component"))
-gegl_chant_double (y, -G_MAXDOUBLE, G_MAXDOUBLE, 0.0,
-                   _("Direction vector's Y component"))
 
 #else
 
-#define GEGL_CHANT_NAME reflect
-#define GEGL_CHANT_SELF "reflect.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    reflect
+#define GEGL_OP_BUNDLE
+#define GEGL_OP_C_FILE  "reflect.c"
+
+#include "gegl-op.h"
+
+#include <math.h>
 
 static void
 create_matrix (OpTransform *op,
                GeglMatrix3 *matrix)
 {
-  GeglChantOperation *chant = GEGL_CHANT_OPERATION (op);
-  const gdouble ux = chant->x;
-  const gdouble uy = chant->y;
+  GeglProperties *o = GEGL_PROPERTIES (op);
+  const gdouble ux = o->x;
+  const gdouble uy = o->y;
 
   /*
    * There probably should be an assertion or check+fix that
@@ -57,4 +67,26 @@ create_matrix (OpTransform *op,
   matrix->coeff [0][1] = matrix->coeff [1][0] = ux*uy * two_over_length_squared;
 }
 
+#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;
+
+  gegl_operation_class_set_keys (operation_class,
+    "name", "gegl:reflect",
+    "title", _("Reflect"),
+    "categories", "transform",
+    "description", _("Reflect an image about a line, whose direction is "
+                     "specified by the vector that is defined by the "
+                     "x and y properties. "),
+    NULL);
+}
+
 #endif


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