[Pixman] [PATCH] Allow src and dst to be identical in pixman_f_transform_invert()
Søren Sandmann
sandmann at cs.au.dk
Sun Nov 11 11:45:51 PST 2012
From: Søren Sandmann Pedersen <ssp at redhat.com>
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.
---
pixman/pixman-matrix.c | 15 +++++++++------
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;
}
--
1.7.4
More information about the Pixman
mailing list