Commit 5c4020ed authored by Sven Neumann's avatar Sven Neumann Committed by Sven Neumann

libgimpmath/gimpmathtypes.h moved struct declarations.

2003-07-07  Sven Neumann  <sven@gimp.org>

	* libgimpmath/gimpmathtypes.h
	* libgimpmath/gimpvector.h: moved struct declarations.

	* libgimpmath/gimpmatrix.[ch]: made GimpMatrix3 and GimpMatrix4
	structs instead of typedefs for arrays. Pass them by reference,
	not by value. Added lots of const qualifiers.

	* app/core/gimpchannel.c
	* app/core/gimpdrawable-transform-utils.[ch]
	* app/core/gimpdrawable-transform.[ch]
	* app/core/gimpdrawable.c
	* app/core/gimpitem-linked.[ch]
	* app/core/gimpitem.[ch]
	* app/core/gimplayer.c
	* app/pdb/transform_tools_cmds.c
	* app/tools/gimpperspectivetool.c
	* app/tools/gimprotatetool.c
	* app/tools/gimpscaletool.c
	* app/tools/gimpsheartool.c
	* app/tools/gimptransformtool.c
	* app/vectors/gimpvectors.c
	* tools/pdbgen/pdb/transform_tools.pdb: changed accordingly.
parent 6b99ae04
2003-07-07 Sven Neumann <sven@gimp.org>
* libgimpmath/gimpmathtypes.h
* libgimpmath/gimpvector.h: moved struct declarations.
* libgimpmath/gimpmatrix.[ch]: made GimpMatrix3 and GimpMatrix4
structs instead of typedefs for arrays. Pass them by reference,
not by value. Added lots of const qualifiers.
* app/core/gimpchannel.c
* app/core/gimpdrawable-transform-utils.[ch]
* app/core/gimpdrawable-transform.[ch]
* app/core/gimpdrawable.c
* app/core/gimpitem-linked.[ch]
* app/core/gimpitem.[ch]
* app/core/gimplayer.c
* app/pdb/transform_tools_cmds.c
* app/tools/gimpperspectivetool.c
* app/tools/gimprotatetool.c
* app/tools/gimpscaletool.c
* app/tools/gimpsheartool.c
* app/tools/gimptransformtool.c
* app/vectors/gimpvectors.c
* tools/pdbgen/pdb/transform_tools.pdb: changed accordingly.
2003-07-07 Sven Neumann <sven@gimp.org>
* plug-ins/common/mng.c: applied a patch from S. Mukund that fixes
......@@ -100,7 +100,7 @@ sample_linear(PixelSurround *surround,
TileManager *
gimp_drawable_transform_tiles_affine (GimpDrawable *drawable,
TileManager *orig_tiles,
GimpMatrix3 matrix,
const GimpMatrix3 *matrix,
GimpTransformDirection direction,
GimpInterpolationType interpolation_type,
gboolean clip_result,
......@@ -110,8 +110,8 @@ gimp_drawable_transform_tiles_affine (GimpDrawable *drawable,
GimpImage *gimage;
PixelRegion destPR;
TileManager *new_tiles;
GimpMatrix3 m;
GimpMatrix3 im;
GimpMatrix3 m = *matrix;
GimpMatrix3 inv = *matrix;
PixelSurround surround;
gint x1, y1, x2, y2; /* target bounding box */
......@@ -191,14 +191,12 @@ gimp_drawable_transform_tiles_affine (GimpDrawable *drawable,
/* keep the original matrix here, so we dont need to recalculate
* the inverse later
*/
gimp_matrix3_duplicate (matrix, m);
gimp_matrix3_invert (matrix, im);
matrix = im;
gimp_matrix3_invert (&inv);
}
else
{
/* Find the inverse of the transformation matrix */
gimp_matrix3_invert (matrix, m);
gimp_matrix3_invert (&m);
}
tile_manager_get_offsets (orig_tiles, &u1, &v1);
......@@ -224,10 +222,10 @@ gimp_drawable_transform_tiles_affine (GimpDrawable *drawable,
gdouble dx3, dy3;
gdouble dx4, dy4;
gimp_matrix3_transform_point (matrix, u1, v1, &dx1, &dy1);
gimp_matrix3_transform_point (matrix, u2, v1, &dx2, &dy2);
gimp_matrix3_transform_point (matrix, u1, v2, &dx3, &dy3);
gimp_matrix3_transform_point (matrix, u2, v2, &dx4, &dy4);
gimp_matrix3_transform_point (&inv, u1, v1, &dx1, &dy1);
gimp_matrix3_transform_point (&inv, u2, v1, &dx2, &dy2);
gimp_matrix3_transform_point (&inv, u1, v2, &dx3, &dy3);
gimp_matrix3_transform_point (&inv, u2, v2, &dx4, &dy4);
x1 = ROUND (MIN4 (dx1, dx2, dx3, dx4));
y1 = ROUND (MIN4 (dy1, dy2, dy3, dy4));
......@@ -261,9 +259,9 @@ gimp_drawable_transform_tiles_affine (GimpDrawable *drawable,
dest = g_new (guchar, tile_manager_width (new_tiles) * bytes);
uinc = m[0][0];
vinc = m[1][0];
winc = m[2][0];
uinc = m.coeff[0][0];
vinc = m.coeff[1][0];
winc = m.coeff[2][0];
coords = (interpolation_type != GIMP_INTERPOLATION_NONE) ? 5 : 1;
......@@ -277,30 +275,30 @@ gimp_drawable_transform_tiles_affine (GimpDrawable *drawable,
(* progress_callback) (y1, y2, y, progress_data);
/* set up inverse transform steps */
tu[0] = uinc * (x1 + 0.5) + m[0][1] * (y + 0.5) + m[0][2] - 0.5;
tv[0] = vinc * (x1 + 0.5) + m[1][1] * (y + 0.5) + m[1][2] - 0.5;
tw[0] = winc * (x1 + 0.5) + m[2][1] * (y + 0.5) + m[2][2];
tu[0] = uinc * (x1 + 0.5) + m.coeff[0][1] * (y + 0.5) + m.coeff[0][2] - 0.5;
tv[0] = vinc * (x1 + 0.5) + m.coeff[1][1] * (y + 0.5) + m.coeff[1][2] - 0.5;
tw[0] = winc * (x1 + 0.5) + m.coeff[2][1] * (y + 0.5) + m.coeff[2][2];
if (interpolation_type != GIMP_INTERPOLATION_NONE)
{
gdouble xx = x1 + 0.5;
gdouble yy = y + 0.5;
tu[1] = uinc * (xx - 1) + m[0][1] * (yy ) + m[0][2] - 0.5;
tv[1] = vinc * (xx - 1) + m[1][1] * (yy ) + m[1][2] - 0.5;
tw[1] = winc * (xx - 1) + m[2][1] * (yy ) + m[2][2];
tu[1] = uinc * (xx - 1) + m.coeff[0][1] * (yy ) + m.coeff[0][2] - 0.5;
tv[1] = vinc * (xx - 1) + m.coeff[1][1] * (yy ) + m.coeff[1][2] - 0.5;
tw[1] = winc * (xx - 1) + m.coeff[2][1] * (yy ) + m.coeff[2][2];
tu[2] = uinc * (xx ) + m[0][1] * (yy - 1) + m[0][2] - 0.5;
tv[2] = vinc * (xx ) + m[1][1] * (yy - 1) + m[1][2] - 0.5;
tw[2] = winc * (xx ) + m[2][1] * (yy - 1) + m[2][2];
tu[2] = uinc * (xx ) + m.coeff[0][1] * (yy - 1) + m.coeff[0][2] - 0.5;
tv[2] = vinc * (xx ) + m.coeff[1][1] * (yy - 1) + m.coeff[1][2] - 0.5;
tw[2] = winc * (xx ) + m.coeff[2][1] * (yy - 1) + m.coeff[2][2];
tu[3] = uinc * (xx + 1) + m[0][1] * (yy ) + m[0][2] - 0.5;
tv[3] = vinc * (xx + 1) + m[1][1] * (yy ) + m[1][2] - 0.5;
tw[3] = winc * (xx + 1) + m[2][1] * (yy ) + m[2][2];
tu[3] = uinc * (xx + 1) + m.coeff[0][1] * (yy ) + m.coeff[0][2] - 0.5;
tv[3] = vinc * (xx + 1) + m.coeff[1][1] * (yy ) + m.coeff[1][2] - 0.5;
tw[3] = winc * (xx + 1) + m.coeff[2][1] * (yy ) + m.coeff[2][2];
tu[4] = uinc * (xx ) + m[0][1] * (yy + 1) + m[0][2] - 0.5;
tv[4] = vinc * (xx ) + m[1][1] * (yy + 1) + m[1][2] - 0.5;
tw[4] = winc * (xx ) + m[2][1] * (yy + 1) + m[2][2];
tu[4] = uinc * (xx ) + m.coeff[0][1] * (yy + 1) + m.coeff[0][2] - 0.5;
tv[4] = vinc * (xx ) + m.coeff[1][1] * (yy + 1) + m.coeff[1][2] - 0.5;
tw[4] = winc * (xx ) + m.coeff[2][1] * (yy + 1) + m.coeff[2][2];
}
d = dest;
......@@ -805,7 +803,7 @@ gimp_drawable_transform_tiles_rotate (GimpDrawable *drawable,
gboolean
gimp_drawable_transform_affine (GimpDrawable *drawable,
GimpMatrix3 matrix,
const GimpMatrix3 *matrix,
GimpTransformDirection direction,
GimpInterpolationType interpolation_type,
gboolean clip_result)
......
......@@ -28,12 +28,12 @@
void
gimp_drawable_transform_matrix_rotate (gint x1,
gint y1,
gint x2,
gint y2,
gdouble angle,
GimpMatrix3 result)
gimp_drawable_transform_matrix_rotate (gint x1,
gint y1,
gint x2,
gint y2,
gdouble angle,
GimpMatrix3 *result)
{
gdouble cx;
gdouble cy;
......@@ -48,10 +48,10 @@ gimp_drawable_transform_matrix_rotate (gint x1,
}
void
gimp_drawable_transform_matrix_rotate_center (gdouble cx,
gdouble cy,
gdouble angle,
GimpMatrix3 result)
gimp_drawable_transform_matrix_rotate_center (gdouble cx,
gdouble cy,
gdouble angle,
GimpMatrix3 *result)
{
gimp_matrix3_identity (result);
gimp_matrix3_translate (result, -cx, -cy);
......@@ -60,15 +60,15 @@ gimp_drawable_transform_matrix_rotate_center (gdouble cx,
}
void
gimp_drawable_transform_matrix_scale (gint x1,
gint y1,
gint x2,
gint y2,
gdouble tx1,
gdouble ty1,
gdouble tx2,
gdouble ty2,
GimpMatrix3 result)
gimp_drawable_transform_matrix_scale (gint x1,
gint y1,
gint x2,
gint y2,
gdouble tx1,
gdouble ty1,
gdouble tx2,
gdouble ty2,
GimpMatrix3 *result)
{
gdouble scalex;
gdouble scaley;
......@@ -94,7 +94,7 @@ gimp_drawable_transform_matrix_shear (gint x1,
gint y2,
GimpOrientationType orientation,
gdouble amount,
GimpMatrix3 result)
GimpMatrix3 *result)
{
gint width;
gint height;
......@@ -124,19 +124,19 @@ gimp_drawable_transform_matrix_shear (gint x1,
}
void
gimp_drawable_transform_matrix_perspective (gint x1,
gint y1,
gint x2,
gint y2,
gdouble tx1,
gdouble ty1,
gdouble tx2,
gdouble ty2,
gdouble tx3,
gdouble ty3,
gdouble tx4,
gdouble ty4,
GimpMatrix3 result)
gimp_drawable_transform_matrix_perspective (gint x1,
gint y1,
gint x2,
gint y2,
gdouble tx1,
gdouble ty1,
gdouble tx2,
gdouble ty2,
gdouble tx3,
gdouble ty3,
gdouble tx4,
gdouble ty4,
GimpMatrix3 *result)
{
GimpMatrix3 matrix;
gdouble scalex;
......@@ -167,14 +167,14 @@ gimp_drawable_transform_matrix_perspective (gint x1,
/* Is the mapping affine? */
if ((dx3 == 0.0) && (dy3 == 0.0))
{
matrix[0][0] = tx2 - tx1;
matrix[0][1] = tx4 - tx2;
matrix[0][2] = tx1;
matrix[1][0] = ty2 - ty1;
matrix[1][1] = ty4 - ty2;
matrix[1][2] = ty1;
matrix[2][0] = 0.0;
matrix[2][1] = 0.0;
matrix.coeff[0][0] = tx2 - tx1;
matrix.coeff[0][1] = tx4 - tx2;
matrix.coeff[0][2] = tx1;
matrix.coeff[1][0] = ty2 - ty1;
matrix.coeff[1][1] = ty4 - ty2;
matrix.coeff[1][2] = ty1;
matrix.coeff[2][0] = 0.0;
matrix.coeff[2][1] = 0.0;
}
else
{
......@@ -182,24 +182,24 @@ gimp_drawable_transform_matrix_perspective (gint x1,
det1 = dx3 * dy2 - dy3 * dx2;
det2 = dx1 * dy2 - dy1 * dx2;
matrix[2][0] = det1 / det2;
matrix.coeff[2][0] = det1 / det2;
det1 = dx1 * dy3 - dy1 * dx3;
matrix[2][1] = det1 / det2;
matrix.coeff[2][1] = det1 / det2;
matrix[0][0] = tx2 - tx1 + matrix[2][0] * tx2;
matrix[0][1] = tx3 - tx1 + matrix[2][1] * tx3;
matrix[0][2] = tx1;
matrix.coeff[0][0] = tx2 - tx1 + matrix.coeff[2][0] * tx2;
matrix.coeff[0][1] = tx3 - tx1 + matrix.coeff[2][1] * tx3;
matrix.coeff[0][2] = tx1;
matrix[1][0] = ty2 - ty1 + matrix[2][0] * ty2;
matrix[1][1] = ty3 - ty1 + matrix[2][1] * ty3;
matrix[1][2] = ty1;
matrix.coeff[1][0] = ty2 - ty1 + matrix.coeff[2][0] * ty2;
matrix.coeff[1][1] = ty3 - ty1 + matrix.coeff[2][1] * ty3;
matrix.coeff[1][2] = ty1;
}
matrix[2][2] = 1.0;
matrix.coeff[2][2] = 1.0;
}
gimp_matrix3_identity (result);
gimp_matrix3_translate (result, -x1, -y1);
gimp_matrix3_scale (result, scalex, scaley);
gimp_matrix3_mult (matrix, result);
gimp_matrix3_mult (&matrix, result);
}
......@@ -25,11 +25,11 @@ void gimp_drawable_transform_matrix_rotate (gint x1,
gint x2,
gint y2,
gdouble angle,
GimpMatrix3 result);
GimpMatrix3 *result);
void gimp_drawable_transform_matrix_rotate_center (gdouble cx,
gdouble cy,
gdouble angle,
GimpMatrix3 result);
GimpMatrix3 *result);
void gimp_drawable_transform_matrix_scale (gint x1,
gint y1,
gint x2,
......@@ -38,14 +38,14 @@ void gimp_drawable_transform_matrix_scale (gint x1,
gdouble ty1,
gdouble tx2,
gdouble ty2,
GimpMatrix3 result);
GimpMatrix3 *result);
void gimp_drawable_transform_matrix_shear (gint x1,
gint y1,
gint x2,
gint y2,
GimpOrientationType orientation,
gdouble amount,
GimpMatrix3 result);
GimpMatrix3 *result);
void gimp_drawable_transform_matrix_perspective (gint x1,
gint y1,
gint x2,
......@@ -58,7 +58,7 @@ void gimp_drawable_transform_matrix_perspective (gint x1,
gdouble ty3,
gdouble tx4,
gdouble ty5,
GimpMatrix3 result);
GimpMatrix3 *result);
#endif /* __GIMP_DRAWABLE_TRANSFORM_SHEAR_H__ */
......@@ -83,13 +83,13 @@ static void gimp_channel_rotate (GimpItem *item,
gdouble center_x,
gdouble center_y,
gboolean flip_result);
static void gimp_channel_transform (GimpItem *item,
GimpMatrix3 matrix,
GimpTransformDirection direction,
GimpInterpolationType interpolation_type,
gboolean clip_result,
GimpProgressFunc progress_callback,
gpointer progress_data);
static void gimp_channel_transform (GimpItem *item,
const GimpMatrix3 *matrix,
GimpTransformDirection direction,
GimpInterpolationType interpolation_type,
gboolean clip_result,
GimpProgressFunc progress_callback,
gpointer progress_data);
static void gimp_channel_push_undo (GimpChannel *mask,
const gchar *undo_desc);
......@@ -468,7 +468,7 @@ gimp_channel_rotate (GimpItem *item,
static void
gimp_channel_transform (GimpItem *item,
GimpMatrix3 matrix,
const GimpMatrix3 *matrix,
GimpTransformDirection direction,
GimpInterpolationType interpolation_type,
gboolean clip_result,
......
......@@ -83,13 +83,13 @@ static void gimp_channel_rotate (GimpItem *item,
gdouble center_x,
gdouble center_y,
gboolean flip_result);
static void gimp_channel_transform (GimpItem *item,
GimpMatrix3 matrix,
GimpTransformDirection direction,
GimpInterpolationType interpolation_type,
gboolean clip_result,
GimpProgressFunc progress_callback,
gpointer progress_data);
static void gimp_channel_transform (GimpItem *item,
const GimpMatrix3 *matrix,
GimpTransformDirection direction,
GimpInterpolationType interpolation_type,
gboolean clip_result,
GimpProgressFunc progress_callback,
gpointer progress_data);
static void gimp_channel_push_undo (GimpChannel *mask,
const gchar *undo_desc);
......@@ -468,7 +468,7 @@ gimp_channel_rotate (GimpItem *item,
static void
gimp_channel_transform (GimpItem *item,
GimpMatrix3 matrix,
const GimpMatrix3 *matrix,
GimpTransformDirection direction,
GimpInterpolationType interpolation_type,
gboolean clip_result,
......
......@@ -28,12 +28,12 @@
void
gimp_drawable_transform_matrix_rotate (gint x1,
gint y1,
gint x2,
gint y2,
gdouble angle,
GimpMatrix3 result)
gimp_drawable_transform_matrix_rotate (gint x1,
gint y1,
gint x2,
gint y2,
gdouble angle,
GimpMatrix3 *result)
{
gdouble cx;
gdouble cy;
......@@ -48,10 +48,10 @@ gimp_drawable_transform_matrix_rotate (gint x1,
}
void
gimp_drawable_transform_matrix_rotate_center (gdouble cx,
gdouble cy,
gdouble angle,
GimpMatrix3 result)
gimp_drawable_transform_matrix_rotate_center (gdouble cx,
gdouble cy,
gdouble angle,
GimpMatrix3 *result)
{
gimp_matrix3_identity (result);
gimp_matrix3_translate (result, -cx, -cy);
......@@ -60,15 +60,15 @@ gimp_drawable_transform_matrix_rotate_center (gdouble cx,
}
void
gimp_drawable_transform_matrix_scale (gint x1,
gint y1,
gint x2,
gint y2,
gdouble tx1,
gdouble ty1,
gdouble tx2,
gdouble ty2,
GimpMatrix3 result)
gimp_drawable_transform_matrix_scale (gint x1,
gint y1,
gint x2,
gint y2,
gdouble tx1,
gdouble ty1,
gdouble tx2,
gdouble ty2,
GimpMatrix3 *result)
{
gdouble scalex;
gdouble scaley;
......@@ -94,7 +94,7 @@ gimp_drawable_transform_matrix_shear (gint x1,
gint y2,
GimpOrientationType orientation,
gdouble amount,
GimpMatrix3 result)
GimpMatrix3 *result)
{
gint width;
gint height;
......@@ -124,19 +124,19 @@ gimp_drawable_transform_matrix_shear (gint x1,
}
void
gimp_drawable_transform_matrix_perspective (gint x1,
gint y1,
gint x2,
gint y2,
gdouble tx1,
gdouble ty1,
gdouble tx2,
gdouble ty2,
gdouble tx3,
gdouble ty3,
gdouble tx4,
gdouble ty4,
GimpMatrix3 result)
gimp_drawable_transform_matrix_perspective (gint x1,
gint y1,
gint x2,
gint y2,
gdouble tx1,
gdouble ty1,
gdouble tx2,
gdouble ty2,
gdouble tx3,
gdouble ty3,
gdouble tx4,
gdouble ty4,
GimpMatrix3 *result)
{
GimpMatrix3 matrix;
gdouble scalex;
......@@ -167,14 +167,14 @@ gimp_drawable_transform_matrix_perspective (gint x1,
/* Is the mapping affine? */
if ((dx3 == 0.0) && (dy3 == 0.0))
{
matrix[0][0] = tx2 - tx1;
matrix[0][1] = tx4 - tx2;
matrix[0][2] = tx1;
matrix[1][0] = ty2 - ty1;
matrix[1][1] = ty4 - ty2;
matrix[1][2] = ty1;
matrix[2][0] = 0.0;
matrix[2][1] = 0.0;
matrix.coeff[0][0] = tx2 - tx1;
matrix.coeff[0][1] = tx4 - tx2;
matrix.coeff[0][2] = tx1;
matrix.coeff[1][0] = ty2 - ty1;
matrix.coeff[1][1] = ty4 - ty2;
matrix.coeff[1][2] = ty1;
matrix.coeff[2][0] = 0.0;
matrix.coeff[2][1] = 0.0;
}
else
{
......@@ -182,24 +182,24 @@ gimp_drawable_transform_matrix_perspective (gint x1,
det1 = dx3 * dy2 - dy3 * dx2;
det2 = dx1 * dy2 - dy1 * dx2;
matrix[2][0] = det1 / det2;
matrix.coeff[2][0] = det1 / det2;
det1 = dx1 * dy3 - dy1 * dx3;
matrix[2][1] = det1 / det2;
matrix.coeff[2][1] = det1 / det2;
matrix[0][0] = tx2 - tx1 + matrix[2][0] * tx2;
matrix[0][1] = tx3 - tx1 + matrix[2][1] * tx3;
matrix[0][2] = tx1;
matrix.coeff[0][0] = tx2 - tx1 + matrix.coeff[2][0] * tx2;
matrix.coeff[0][1] = tx3 - tx1 + matrix.coeff[2][1] * tx3;
matrix.coeff[0][2] = tx1;
matrix[1][0] = ty2 - ty1 + matrix[2][0] * ty2;
matrix[1][1] = ty3 - ty1 + matrix[2][1] * ty3;
matrix[1][2] = ty1;
matrix.coeff[1][0] = ty2 - ty1 + matrix.coeff[2][0] * ty2;
matrix.coeff[1][1] = ty3 - ty1 + matrix.coeff[2][1] * ty3;
matrix.coeff[1][2] = ty1;
}
matrix[2][2] = 1.0;
matrix.coeff[2][2] = 1.0;
}
gimp_matrix3_identity (result);
gimp_matrix3_translate (result, -x1, -y1);
gimp_matrix3_scale (result, scalex, scaley);
gimp_matrix3_mult (matrix, result);
gimp_matrix3_mult (&matrix, result);
}
......@@ -25,11 +25,11 @@ void gimp_drawable_transform_matrix_rotate (gint x1,
gint x2,
gint y2,
gdouble angle,
GimpMatrix3 result);
GimpMatrix3 *result);
void gimp_drawable_transform_matrix_rotate_center (gdouble cx,
gdouble cy,
gdouble angle,
GimpMatrix3 result);
GimpMatrix3 *result);
void gimp_drawable_transform_matrix_scale (gint x1,
gint y1,
gint x2,
......@@ -38,14 +38,14 @@ void gimp_drawable_transform_matrix_scale (gint x1,
gdouble ty1,
gdouble tx2,
gdouble ty2,
GimpMatrix3 result);
GimpMatrix3 *result);
void gimp_drawable_transform_matrix_shear (gint x1,
gint y1,
gint x2,
gint y2,
GimpOrientationType orientation,
gdouble amount,
GimpMatrix3 result);
GimpMatrix3 *result);
void gimp_drawable_transform_matrix_perspective (gint x1,
gint y1,
gint x2,
......@@ -58,7 +58,7 @@ void gimp_drawable_transform_matrix_perspective (gint x1,
gdouble ty3,
gdouble tx4,
gdouble ty5,
GimpMatrix3 result);
GimpMatrix3 *result);
#endif /* __GIMP_DRAWABLE_TRANSFORM_SHEAR_H__ */
......@@ -100,7 +100,7 @@ sample_linear(PixelSurround *surround,
TileManager *
gimp_drawable_transform_tiles_affine (GimpDrawable *drawable,
TileManager *orig_tiles,
GimpMatrix3 matrix,
const GimpMatrix3 *matrix,
GimpTransformDirection direction,
GimpInterpolationType interpolation_type,
gboolean clip_result,
......@@ -110,8 +110,8 @@ gimp_drawable_transform_tiles_affine (GimpDrawable *drawable,
GimpImage *gimage;
PixelRegion destPR;
TileManager *new_tiles;
GimpMatrix3 m;
GimpMatrix3 im;
GimpMatrix3 m = *matrix;
GimpMatrix3 inv = *matrix;
PixelSurround surround;
gint x1, y1, x2, y2; /* target bounding box */
......@@ -191,14 +191,12 @@ gimp_drawable_transform_tiles_affine (GimpDrawable *drawable,
/* keep the original matrix here, so we dont need to recalculate
* the inverse later
*/
gimp_matrix3_duplicate (matrix, m);
gimp_matrix3_invert (matrix, im);
matrix = im;
gimp_matrix3_invert (&inv);
}
else
{
/* Find the inverse of the transformation matrix */
gimp_matrix3_invert (matrix, m);
gimp_matrix3_invert (&m);
}
tile_manager_get_offsets (orig_tiles, &u1, &v1);
......@@ -224,10 +222,10 @@ gimp_drawable_transform_tiles_affine (GimpDrawable *drawable,
gdouble dx3, dy3;
gdouble dx4, dy4;
gimp_matrix3_transform_point (matrix, u1, v1, &dx1, &dy1);
gimp_matrix3_transform_point (matrix, u2, v1, &dx2, &dy2);
gimp_matrix3_transform_point (matrix, u1, v2, &dx3, &dy3);
gimp_matrix3_transform_point (matrix, u2, v2, &dx4, &dy4);
gimp_matrix3_transform_point (&inv, u1, v1, &dx1, &dy1);
gimp_matrix3_transform_point (&inv, u2, v1, &dx2, &dy2);
gimp_matrix3_transform_point (&inv, u1, v2, &dx3, &dy3);
gimp_matrix3_transform_point (&inv, u2, v2, &dx4, &dy4);
x1 = ROUND (MIN4 (dx1, dx2, dx3, dx4));
y1 = ROUND (MIN4 (dy1, dy2, dy3, dy4));
......@@ -261,9 +259,9 @@ gimp_drawable_transform_tiles_affine (GimpDrawable *drawable,
dest = g_new (guchar, tile_manager_width (new_tiles) * bytes);
uinc = m[0][0];
vinc = m[1][0];
winc = m[2][0];
uinc = m.coeff[0][0];
vinc = m.coeff[1][0];
winc = m.coeff[2][0];
coords = (interpolation_type != GIMP_INTERPOLATION_NONE) ? 5 : 1;
......@@ -277,30 +275,30 @@ gimp_drawable_transform_tiles_affine (GimpDrawable *drawable,
(* progress_callback) (y1, y2, y, progress_data);
/* set up inverse transform steps */
tu[0] = uinc * (x1 + 0.5) + m[0][1] * (y + 0.5) + m[0][2] - 0.5;
tv[0] = vinc * (x1 + 0.5) + m[1][1] * (y + 0.5) + m[1][2] - 0.5;
tw[0] = winc * (x1 + 0.5) + m[2][1] * (y + 0.5) + m[2][2];
tu[0] = uinc * (x1 + 0.5) + m.coeff[0][1] * (y