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



commit 1a34160e08a1141faa3fe99fe0cfa0cdce1bf1b3
Author: Øyvind Kolås <pippin gimp org>
Date:   Fri Mar 3 17:27:36 2017 +0100

    scale-size: port from custom chant to gegl-op.h

 operations/transform/module.c     |    4 +-
 operations/transform/scale-size.c |   58 ++++++++++++++++++++++++++++---------
 2 files changed, 46 insertions(+), 16 deletions(-)
---
diff --git a/operations/transform/module.c b/operations/transform/module.c
index 61292c4..d22b640 100644
--- a/operations/transform/module.c
+++ b/operations/transform/module.c
@@ -43,7 +43,7 @@ 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 scale_size_get_type   (void);
+GType gegl_op_scale_size_register_type  (GTypeModule *module);
 GType scale_size_keepaspect_get_type   (void);
 GType shear_get_type       (void);
 GType translate_get_type   (void);
@@ -58,12 +58,12 @@ gegl_module_register (GTypeModule *module)
   transform_module = module;
 
   dummy = op_transform_get_type ();
-  dummy = scale_size_get_type ();
   dummy = scale_size_keepaspect_get_type ();
   dummy = shear_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);
   dummy = gegl_op_rotate_register_type (module);
   dummy = gegl_op_reflect_register_type (module);
   dummy = gegl_op_rotate_on_center_register_type (module);
diff --git a/operations/transform/scale-size.c b/operations/transform/scale-size.c
index e2f05f3..3252629 100644
--- a/operations/transform/scale-size.c
+++ b/operations/transform/scale-size.c
@@ -13,27 +13,37 @@
  * You should have received a copy of the GNU Lesser General Public
  * License along with GEGL; if not, see <http://www.gnu.org/licenses/>.
  *
- * Copyright 2012 Michael Muré <batolettre gmail com>
+ * 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"), 100.0)
+    description (_("Horizontal size"))
+    ui_range (0.0, 20.0)
+    value_range (-9000.0, 9000.0)
 
-gegl_chant_double (x, -G_MAXDOUBLE, G_MAXDOUBLE, 100.0,
-                   _("Horizontal size"))
-gegl_chant_double (y, -G_MAXDOUBLE, G_MAXDOUBLE, 100.0,
-                   _("Vertical size"))
+property_double (y, _("Y"), 100.0)
+    description (_("Vertical size"))
+    ui_range (0.0, 20.0)
+    value_range (-9000.0, 9000.0)
 
 #else
 
-#define GEGL_CHANT_NAME scale_size
-#define GEGL_CHANT_OPERATION_NAME "gegl:scale-size"
-#define GEGL_CHANT_DESCRIPTION _("Scales the buffer according to a size.")
-#define GEGL_CHANT_SELF "scale-size.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    scale_size
+#define GEGL_OP_BUNDLE
+#define GEGL_OP_C_FILE  "scale-size.c"
+
+#include "gegl-op.h"
 
 #include <math.h>
 
@@ -41,7 +51,7 @@ static void
 create_matrix (OpTransform *op,
                GeglMatrix3 *matrix)
 {
-  GeglChantOperation *chant = GEGL_CHANT_OPERATION (op);
+  GeglProperties *o = GEGL_PROPERTIES (op);
   GeglOperation *operation  = GEGL_OPERATION (op);
   GeglRectangle  in_rect = {0,0,0,0};
 
@@ -53,8 +63,28 @@ create_matrix (OpTransform *op,
   if(in_rect.height < 1)
     in_rect.height = 1;
 
-  matrix->coeff [0][0] = chant->x / (gdouble) in_rect.width;
-  matrix->coeff [1][1] = chant->y / (gdouble) in_rect.height;
+  matrix->coeff [0][0] = o->x / (gdouble) in_rect.width;
+  matrix->coeff [1][1] = o->y / (gdouble) in_rect.height;
+}
+
+#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:scale-size",
+    "title", _("Scale size"),
+    "categories", "transform",
+    "description", _("Scales the buffer according to a size."),
+    NULL);
 }
 
 #endif


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