summaryrefslogtreecommitdiff
path: root/render/matrix.c
diff options
context:
space:
mode:
authorKeith Packard <keithp@keithp.com>2008-03-18 15:15:40 -0700
committerKeith Packard <keithp@keithp.com>2008-11-24 13:24:39 -0800
commit97ab0c6eff870b52c0383b63a78cec49059b2545 (patch)
treeb2f6c25a95b2cd18dd94cfefc40d2cedb01d5645 /render/matrix.c
parent6d3a9e40a4b9ec455af11cce31e4aa616c93db32 (diff)
When converting from double to fixed, round carefully.
This reduces the matrix representation error after inverting a transformation matrix (although it doesn't eliminate it entirely). Perhaps we should extend Render to include 64-bit floating point transforms...
Diffstat (limited to 'render/matrix.c')
-rw-r--r--render/matrix.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/render/matrix.c b/render/matrix.c
index 6e502057c..0d5d96267 100644
--- a/render/matrix.c
+++ b/render/matrix.c
@@ -72,9 +72,9 @@ PictureTransformPoint3d (PictTransformPtr transform,
return FALSE;
result.vector[j] = (xFixed) v;
}
+ *vector = result;
if (!result.vector[2])
return FALSE;
- *vector = result;
return TRUE;
}
@@ -286,7 +286,8 @@ from_doubles (PictTransformPtr t, double m[3][3])
double d = m[j][i];
if (d < -32767.0 || d > 32767.0)
return FALSE;
- t->matrix[j][i] = pixman_double_to_fixed (d);
+ d = d * 65536.0 + 0.5;
+ t->matrix[j][i] = (xFixed) floor (d);
}
return TRUE;
}
@@ -294,7 +295,7 @@ from_doubles (PictTransformPtr t, double m[3][3])
static Bool
invert (double r[3][3], double m[3][3])
{
- double det, norm;
+ double det;
int i, j;
static int a[3] = { 2, 2, 1 };
static int b[3] = { 1, 0, 0 };