summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSøren Sandmann Pedersen <ssp@redhat.com>2012-11-11 14:05:54 -0500
committerSøren Sandmann Pedersen <ssp@redhat.com>2012-11-11 14:09:22 -0500
commitd881e1f5801ca0aefecccb43db05db539b3080d5 (patch)
tree192d0f8bbe16b7c542299f9bc78fa2277ef8adee
parent614e7aaf14652c726b067bbc7562ef237dcd50de (diff)
Allow src and dst to be identical in pixman_f_transform_invert()
It is useful to be able to invert a matrix in place, but currently pixman_f_transform_invert() will produce wrong results if you pass the same matrix as both source and destination. Fix that by inverting into a temporary matrix and then copying that to the destination.
-rw-r--r--pixman/pixman-matrix.c15
1 files changed, 9 insertions, 6 deletions
diff --git a/pixman/pixman-matrix.c b/pixman/pixman-matrix.c
index a029ab7..d2ab609 100644
--- a/pixman/pixman-matrix.c
+++ b/pixman/pixman-matrix.c
@@ -336,14 +336,14 @@ PIXMAN_EXPORT pixman_bool_t
pixman_transform_invert (struct pixman_transform * dst,
const struct pixman_transform *src)
{
- struct pixman_f_transform m, r;
+ struct pixman_f_transform m;
pixman_f_transform_from_pixman_transform (&m, src);
- if (!pixman_f_transform_invert (&r, &m))
+ if (!pixman_f_transform_invert (&m, &m))
return FALSE;
- if (!pixman_transform_from_pixman_f_transform (dst, &r))
+ if (!pixman_transform_from_pixman_f_transform (dst, &m))
return FALSE;
return TRUE;
@@ -469,10 +469,11 @@ PIXMAN_EXPORT pixman_bool_t
pixman_f_transform_invert (struct pixman_f_transform * dst,
const struct pixman_f_transform *src)
{
- double det;
- int i, j;
static const int a[3] = { 2, 2, 1 };
static const int b[3] = { 1, 0, 0 };
+ pixman_f_transform_t d;
+ double det;
+ int i, j;
det = 0;
for (i = 0; i < 3; i++)
@@ -507,10 +508,12 @@ pixman_f_transform_invert (struct pixman_f_transform * dst,
if (((i + j) & 1) != 0)
p = -p;
- dst->m[j][i] = det * p;
+ d.m[j][i] = det * p;
}
}
+ *dst = d;
+
return TRUE;
}