[gegl] rotate: use the new more generic sub-classing infrastructure
- From: Øyvind Kolås <ok src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gegl] rotate: use the new more generic sub-classing infrastructure
- Date: Fri, 3 Mar 2017 09:10:24 +0000 (UTC)
commit ca359feb2dfc5d9caf2a2c17dea0742053489e85
Author: Øyvind Kolås <pippin gimp org>
Date: Fri Mar 3 09:55:08 2017 +0100
rotate: use the new more generic sub-classing infrastructure
operations/transform/module.c | 6 +++-
operations/transform/rotate.c | 48 ++++++++++++++++++++++++++++++++--------
2 files changed, 42 insertions(+), 12 deletions(-)
---
diff --git a/operations/transform/module.c b/operations/transform/module.c
index 6210d80..ad7c90a 100644
--- a/operations/transform/module.c
+++ b/operations/transform/module.c
@@ -39,7 +39,7 @@ gegl_module_query (GTypeModule *module)
return &modinfo;
}
-GType rotate_get_type (void);
+GType gegl_op_rotate_register_type (GTypeModule *module);
GType rotate_on_center_get_type (void);
GType scale_ratio_get_type (void);
GType scale_size_get_type (void);
@@ -49,6 +49,8 @@ GType translate_get_type (void);
GType reflect_get_type (void);
GType transform_get_type (void);
+#include <stdio.h>
+
G_MODULE_EXPORT gboolean
gegl_module_register (GTypeModule *module)
{
@@ -56,7 +58,6 @@ gegl_module_register (GTypeModule *module)
transform_module = module;
dummy = op_transform_get_type ();
- dummy = rotate_get_type ();
dummy = rotate_on_center_get_type ();
dummy = scale_ratio_get_type ();
dummy = scale_size_get_type ();
@@ -65,6 +66,7 @@ gegl_module_register (GTypeModule *module)
dummy = translate_get_type ();
dummy = reflect_get_type ();
dummy = transform_get_type ();
+ dummy = gegl_op_rotate_register_type (module);
dummy ++; /* silence gcc, having it is required to avoid optimizing
away the _get_type calls themselves */
diff --git a/operations/transform/rotate.c b/operations/transform/rotate.c
index 269834f..5ccfe0a 100644
--- a/operations/transform/rotate.c
+++ b/operations/transform/rotate.c
@@ -14,23 +14,31 @@
* 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
-
-gegl_chant_double (degrees, -G_MAXDOUBLE, G_MAXDOUBLE, 0.0,
- _("Angle to rotate (counter-clockwise)"))
+property_double (degrees, _("Degrees"), 0.0)
+ description(_("Angle to rotate (counter-clockwise)"))
+ value_range (-720.0, 720.0)
+ ui_range (-180.0, 180.0)
#else
-#define GEGL_CHANT_NAME rotate
-#define GEGL_CHANT_DESCRIPTION _("Rotate the buffer around the specified origin.")
-#define GEGL_CHANT_SELF "rotate.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 rotate
+#define GEGL_OP_BUNDLE
+#define GEGL_OP_C_FILE "rotate.c"
+
+#include "gegl-op.h"
#include <math.h>
@@ -38,12 +46,32 @@ static void
create_matrix (OpTransform *op,
GeglMatrix3 *matrix)
{
- GeglChantOperation *chant = GEGL_CHANT_OPERATION (op);
- double radians = chant->degrees * (2 * G_PI / 360.0);
+ GeglProperties *o = GEGL_PROPERTIES (op);
+ double radians = o->degrees * (2 * G_PI / 360.0);
matrix->coeff [0][0] = matrix->coeff [1][1] = cos (radians);
matrix->coeff [0][1] = sin (radians);
matrix->coeff [1][0] = - matrix->coeff [0][1];
}
+#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:rotate",
+ "title", _("Rotate"),
+ "categories", "transform",
+ "description", _("Rotate the buffer around the specified origin."),
+ NULL);
+}
+
#endif
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]