summaryrefslogtreecommitdiff
path: root/source/fitz/geometry.c
diff options
context:
space:
mode:
authorRobin Watts <robin.watts@artifex.com>2015-03-30 13:09:26 +0100
committerRobin Watts <robin.watts@artifex.com>2015-03-30 13:09:26 +0100
commit5bc11ccfcdfd1421b968446d85ac4de4ea785acb (patch)
treeaf6d11b5c55f1bf77d5010f4b7c20eb940ed1b7b /source/fitz/geometry.c
parenta570160061f27cdf8ec11a7693d8b1432d288c25 (diff)
downloadmupdf-5bc11ccfcdfd1421b968446d85ac4de4ea785acb.tar.xz
Bug 695556: Use doubles when inverting matrices.
When inverting matrices, use doubles for inversion calculations. This prevents floats over/underflowing and causing stroked content to go missing.
Diffstat (limited to 'source/fitz/geometry.c')
-rw-r--r--source/fitz/geometry.c28
1 files changed, 18 insertions, 10 deletions
diff --git a/source/fitz/geometry.c b/source/fitz/geometry.c
index b6b6533e..073536ff 100644
--- a/source/fitz/geometry.c
+++ b/source/fitz/geometry.c
@@ -217,18 +217,26 @@ int
fz_try_invert_matrix(fz_matrix *dst, const fz_matrix *src)
{
/* Be careful to cope with dst == src */
- float a = src->a;
- float det = a * src->d - src->b * src->c;
- if (det >= -FLT_EPSILON && det <= FLT_EPSILON)
+ double sa = (double)src->a;
+ double sb = (double)src->b;
+ double sc = (double)src->c;
+ double sd = (double)src->d;
+ double da, db, dc, dd;
+ double det = sa * sd - sb * sc;
+ if (det >= -DBL_EPSILON && det <= DBL_EPSILON)
return 1;
det = 1 / det;
- dst->a = src->d * det;
- dst->b = -src->b * det;
- dst->c = -src->c * det;
- dst->d = a * det;
- a = -src->e * dst->a - src->f * dst->c;
- dst->f = -src->e * dst->b - src->f * dst->d;
- dst->e = a;
+ da = sd * det;
+ dst->a = (float)da;
+ db = -sb * det;
+ dst->b = (float)db;
+ dc = -sc * det;
+ dst->c = (float)dc;
+ dd = sa * det;
+ dst->d = (float)dd;
+ da = -src->e * da - src->f * dc;
+ dst->f = (float)(-src->e * db - src->f * dd);
+ dst->e = (float)da;
return 0;
}