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

parent c3a1b50d
...@@ -46,7 +46,7 @@ GType gegl_op_scale_ratio_register_type (GTypeModule *module); ...@@ -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_register_type (GTypeModule *module);
GType gegl_op_scale_size_keepaspect_register_type (GTypeModule *module); GType gegl_op_scale_size_keepaspect_register_type (GTypeModule *module);
GType gegl_op_shear_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); GType transform_get_type (void);
#include <stdio.h> #include <stdio.h>
...@@ -58,7 +58,6 @@ gegl_module_register (GTypeModule *module) ...@@ -58,7 +58,6 @@ gegl_module_register (GTypeModule *module)
transform_module = module; transform_module = module;
dummy = op_transform_get_type (); dummy = op_transform_get_type ();
dummy = translate_get_type ();
dummy = transform_get_type (); dummy = transform_get_type ();
dummy = gegl_op_scale_ratio_register_type (module); dummy = gegl_op_scale_ratio_register_type (module);
dummy = gegl_op_scale_size_register_type (module); dummy = gegl_op_scale_size_register_type (module);
...@@ -66,6 +65,7 @@ gegl_module_register (GTypeModule *module) ...@@ -66,6 +65,7 @@ gegl_module_register (GTypeModule *module)
dummy = gegl_op_rotate_register_type (module); dummy = gegl_op_rotate_register_type (module);
dummy = gegl_op_reflect_register_type (module); dummy = gegl_op_reflect_register_type (module);
dummy = gegl_op_shear_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 = gegl_op_rotate_on_center_register_type (module);
dummy ++; /* silence gcc, having it is required to avoid optimizing dummy ++; /* silence gcc, having it is required to avoid optimizing
......
...@@ -14,34 +14,65 @@ ...@@ -14,34 +14,65 @@
* License along with GEGL; if not, see <http://www.gnu.org/licenses/>. * License along with GEGL; if not, see <http://www.gnu.org/licenses/>.
* *
* Copyright 2006 Philip Lafleur * Copyright 2006 Philip Lafleur
* 2017 Øyvind Kolås
*/ */
#include "config.h" #include "config.h"
#include <glib/gi18n-lib.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, property_double (y, _("Y"), 0.0)
_("Horizontal translation")) description (_("Vertical translation"))
gegl_chant_double (y, -G_MAXDOUBLE, G_MAXDOUBLE, 0.0, ui_range (-1000.0, 1000.0)
_("Vertical translation"))
#else #else
#define GEGL_CHANT_NAME translate #include "gegl-operation-filter.h"
#define GEGL_CHANT_DESCRIPTION _("Repositions the buffer (with subpixel precision), if integer coordinates are passed a fast-path without resampling is used") #include "transform-core.h"
#define GEGL_CHANT_SELF "translate.c" #define GEGL_OP_NO_SOURCE
#include "chant.h" #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 static void
create_matrix (OpTransform *op, create_matrix (OpTransform *op,
GeglMatrix3 *matrix) 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; gegl_operation_class_set_keys (operation_class,
matrix->coeff [1][2] = chant->y; "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 #endif
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment