[gegl] Bug 609869 - Invalid position of layer content when using GEGL
- From: Michael Natterer <mitch src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [gegl] Bug 609869 - Invalid position of layer content when using GEGL
- Date: Sun, 14 Feb 2010 19:41:48 +0000 (UTC)
commit 7320d07fecf4036b2d024e4c9bb021e7d519fd73
Author: Michael Natterer <mitch gimp org>
Date: Sun Feb 14 20:31:56 2010 +0100
Bug 609869 - Invalid position of layer content when using GEGL
gegl_affine_get_bounding_box() called OpAffine::create_matrix() on a
local variable instead of on affine->matrix, leaving subsequent users
of affine->matrix with an identity matrix.
Also, cleanup up the entite create_matrix() atuff:
- add a wrapper function in affine.c which does not g_assert() if
the function is not set.
- remove typedef OpAffineCreateMatrixFunc because its signature
was broken.
- adapt chant.h accordingly.
- adapt all subclasses to use the fixed signature.
Plus some random code cleanups in affine.c
operations/affine/affine.c | 42 ++++++++++++++++++++++------------------
operations/affine/affine.h | 13 ++++++-----
operations/affine/chant.h | 6 ++--
operations/affine/reflect.c | 9 ++++---
operations/affine/rotate.c | 7 +++--
operations/affine/scale.c | 10 +++++---
operations/affine/shear.c | 10 +++++---
operations/affine/transform.c | 8 ++++--
operations/affine/translate.c | 10 +++++---
9 files changed, 65 insertions(+), 50 deletions(-)
---
diff --git a/operations/affine/affine.c b/operations/affine/affine.c
index 47df3ba..840f499 100644
--- a/operations/affine/affine.c
+++ b/operations/affine/affine.c
@@ -342,6 +342,16 @@ gegl_affine_set_property (GObject *object,
}
static void
+gegl_affine_create_matrix (OpAffine *affine,
+ GeglMatrix3 matrix)
+{
+ gegl_matrix3_identity (matrix);
+
+ if (OP_AFFINE_GET_CLASS (affine))
+ OP_AFFINE_GET_CLASS (affine)->create_matrix (affine, matrix);
+}
+
+static void
gegl_affine_bounding_box (gdouble *points,
gint num_points,
GeglRectangle *output)
@@ -445,8 +455,7 @@ gegl_affine_get_source_matrix (OpAffine *affine,
static GeglRectangle
gegl_affine_get_bounding_box (GeglOperation *op)
{
- OpAffine *affine = (OpAffine *) op;
- OpAffineClass *klass = OP_AFFINE_GET_CLASS (affine);
+ OpAffine *affine = OP_AFFINE (op);
GeglMatrix3 matrix;
GeglRectangle in_rect = {0,0,0,0},
have_rect;
@@ -463,10 +472,9 @@ gegl_affine_get_bounding_box (GeglOperation *op)
if (gegl_operation_source_get_bounding_box (op, "input"))
in_rect = *gegl_operation_source_get_bounding_box (op, "input");
- /* invoke child's matrix creation function */
- g_assert (klass->create_matrix);
- gegl_matrix3_identity (matrix);
- klass->create_matrix (op, matrix);
+ gegl_affine_create_matrix (affine, affine->matrix);
+
+ gegl_matrix3_copy (matrix, affine->matrix);
if (affine->origin_x || affine->origin_y)
gegl_matrix3_originate (matrix, affine->origin_x, affine->origin_y);
@@ -514,12 +522,11 @@ gegl_affine_detect (GeglOperation *operation,
gint x,
gint y)
{
- GeglNode *source_node = gegl_operation_get_source_node (operation, "input");
-
- OpAffine *affine = (OpAffine *) operation;
- GeglMatrix3 inverse;
- gdouble need_points [2];
- gint i;
+ OpAffine *affine = OP_AFFINE (operation);
+ GeglNode *source_node = gegl_operation_get_source_node (operation, "input");
+ GeglMatrix3 inverse;
+ gdouble need_points [2];
+ gint i;
if (gegl_affine_is_intermediate_node (affine) ||
gegl_matrix3_is_identity (inverse))
@@ -546,7 +553,7 @@ gegl_affine_get_required_for_output (GeglOperation *op,
const gchar *input_pad,
const GeglRectangle *region)
{
- OpAffine *affine = (OpAffine *) op;
+ OpAffine *affine = OP_AFFINE (op);
GeglMatrix3 inverse;
GeglRectangle requested_rect,
need_rect;
@@ -601,8 +608,7 @@ gegl_affine_get_invalidated_by_change (GeglOperation *op,
const gchar *input_pad,
const GeglRectangle *input_region)
{
- OpAffine *affine = (OpAffine *) op;
- OpAffineClass *klass = OP_AFFINE_GET_CLASS (affine);
+ OpAffine *affine = OP_AFFINE (op);
GeglRectangle affected_rect;
GeglRectangle context_rect;
GeglSampler *sampler;
@@ -613,10 +619,8 @@ gegl_affine_get_invalidated_by_change (GeglOperation *op,
sampler = op_affine_sampler (OP_AFFINE (op));
context_rect = sampler->context_rect;
g_object_unref (sampler);
- /* invoke child's matrix creation function */
- g_assert (klass->create_matrix);
- gegl_matrix3_identity (affine->matrix);
- klass->create_matrix (op, affine->matrix);
+
+ gegl_affine_create_matrix (affine, affine->matrix);
if (affine->origin_x || affine->origin_y)
gegl_matrix3_originate (affine->matrix, affine->origin_x, affine->origin_y);
diff --git a/operations/affine/affine.h b/operations/affine/affine.h
index 9a1ee31..028cf83 100644
--- a/operations/affine/affine.h
+++ b/operations/affine/affine.h
@@ -13,27 +13,28 @@ G_BEGIN_DECLS
#define IS_OP_AFFINE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_OP_AFFINE))
#define OP_AFFINE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_OP_AFFINE, OpAffineClass))
-typedef void (*OpAffineCreateMatrixFunc) (GeglOperation *op,
- GeglMatrix3 matrix);
typedef struct _OpAffine OpAffine;
+
struct _OpAffine
{
- GeglOperationFilter parent;
+ GeglOperationFilter parent_instance;
GeglMatrix3 matrix;
- gdouble origin_x,
- origin_y;
+ gdouble origin_x;
+ gdouble origin_y;
gchar *filter;
gboolean hard_edges;
gint lanczos_width;
};
typedef struct _OpAffineClass OpAffineClass;
+
struct _OpAffineClass
{
GeglOperationFilterClass parent_class;
- OpAffineCreateMatrixFunc create_matrix;
+ void (* create_matrix) (OpAffine *affine,
+ GeglMatrix3 matrix);
};
GType op_affine_get_type (void) G_GNUC_CONST;
diff --git a/operations/affine/chant.h b/operations/affine/chant.h
index 20d47b8..b2708a8 100644
--- a/operations/affine/chant.h
+++ b/operations/affine/chant.h
@@ -252,8 +252,8 @@ gegl_chant_constructor (GType type,
static void class_init (GeglOperationClass *operation_class);
#endif
-static void create_matrix (GeglChantOperation *operation,
- GeglMatrix3 matrix);
+static void create_matrix (OpAffine *affine,
+ GeglMatrix3 matrix);
static void
gegl_chant_class_init (ChantClass * klass)
@@ -267,7 +267,7 @@ gegl_chant_class_init (ChantClass * klass)
object_class->set_property = set_property;
object_class->get_property = get_property;
- parent_class->create_matrix = (OpAffineCreateMatrixFunc) create_matrix;
+ parent_class->create_matrix = create_matrix;
#ifdef GEGL_CHANT_INIT
object_class->constructor = gegl_chant_constructor;
diff --git a/operations/affine/reflect.c b/operations/affine/reflect.c
index da1b2d6..6857dff 100644
--- a/operations/affine/reflect.c
+++ b/operations/affine/reflect.c
@@ -39,14 +39,15 @@ gegl_chant_double (y, -G_MAXDOUBLE, G_MAXDOUBLE, 0.0,
#include <math.h>
static void
-create_matrix (GeglChantOperation *op,
- GeglMatrix3 matrix)
+create_matrix (OpAffine *op,
+ GeglMatrix3 matrix)
{
+ GeglChantOperation *chant = GEGL_CHANT_OPERATION (op);
gdouble ux=0, uy=0;
gdouble l;
- ux = op->x;
- uy = op->y;
+ ux = chant->x;
+ uy = chant->y;
l = sqrt(uy*uy + ux*ux);
ux /= l;
diff --git a/operations/affine/rotate.c b/operations/affine/rotate.c
index 39e8d2c..2e763e5 100644
--- a/operations/affine/rotate.c
+++ b/operations/affine/rotate.c
@@ -35,10 +35,11 @@ gegl_chant_double (degrees, -G_MAXDOUBLE, G_MAXDOUBLE, 0.,
#include <math.h>
static void
-create_matrix (GeglChantOperation *op,
- GeglMatrix3 matrix)
+create_matrix (OpAffine *op,
+ GeglMatrix3 matrix)
{
- gdouble radians = op->degrees * (2 * G_PI / 360.);
+ GeglChantOperation *chant = GEGL_CHANT_OPERATION (op);
+ gdouble radians = chant->degrees * (2 * G_PI / 360.);
matrix [0][0] = matrix [1][1] = cos (radians);
matrix [0][1] = sin (radians);
diff --git a/operations/affine/scale.c b/operations/affine/scale.c
index 31a7340..3fcdf1c 100644
--- a/operations/affine/scale.c
+++ b/operations/affine/scale.c
@@ -35,11 +35,13 @@ gegl_chant_double (y, -G_MAXDOUBLE, G_MAXDOUBLE, 1., _("Vertical scale factor.")
#include <math.h>
static void
-create_matrix (GeglChantOperation *op,
- GeglMatrix3 matrix)
+create_matrix (OpAffine *op,
+ GeglMatrix3 matrix)
{
- matrix [0][0] = op->x;
- matrix [1][1] = op->y;
+ GeglChantOperation *chant = GEGL_CHANT_OPERATION (op);
+
+ matrix [0][0] = chant->x;
+ matrix [1][1] = chant->y;
}
#endif
diff --git a/operations/affine/shear.c b/operations/affine/shear.c
index 3b6f8b5..b8c8d2d 100644
--- a/operations/affine/shear.c
+++ b/operations/affine/shear.c
@@ -37,11 +37,13 @@ gegl_chant_double (y, -G_MAXDOUBLE, G_MAXDOUBLE, 1.,
#include <math.h>
static void
-create_matrix (GeglChantOperation *op,
- GeglMatrix3 matrix)
+create_matrix (OpAffine *op,
+ GeglMatrix3 matrix)
{
- matrix [0][1] = op->x;
- matrix [1][0] = op->y;
+ GeglChantOperation *chant = GEGL_CHANT_OPERATION (op);
+
+ matrix [0][1] = chant->x;
+ matrix [1][0] = chant->y;
}
#endif
diff --git a/operations/affine/transform.c b/operations/affine/transform.c
index 2291770..828abb5 100644
--- a/operations/affine/transform.c
+++ b/operations/affine/transform.c
@@ -34,10 +34,12 @@ gegl_chant_string (transform, "", _("Transformation string"))
#include <math.h>
static void
-create_matrix (GeglChantOperation *op,
- GeglMatrix3 matrix)
+create_matrix (OpAffine *op,
+ GeglMatrix3 matrix)
{
- gegl_matrix3_parse_string (matrix, op->transform);
+ GeglChantOperation *chant = GEGL_CHANT_OPERATION (op);
+
+ gegl_matrix3_parse_string (matrix, chant->transform);
}
#endif
diff --git a/operations/affine/translate.c b/operations/affine/translate.c
index 54fd7f6..469252d 100644
--- a/operations/affine/translate.c
+++ b/operations/affine/translate.c
@@ -37,11 +37,13 @@ gegl_chant_double (y, -G_MAXDOUBLE, G_MAXDOUBLE, 1.,
#include <math.h>
static void
-create_matrix (GeglChantOperation *op,
- GeglMatrix3 matrix)
+create_matrix (OpAffine *op,
+ GeglMatrix3 matrix)
{
- matrix [0][2] = op->x;
- matrix [1][2] = op->y;
+ GeglChantOperation *chant = GEGL_CHANT_OPERATION (op);
+
+ matrix [0][2] = chant->x;
+ matrix [1][2] = chant->y;
}
#endif
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]