summaryrefslogtreecommitdiff
path: root/pdf
diff options
context:
space:
mode:
authorRobin Watts <robin.watts@artifex.com>2011-12-07 17:58:00 +0000
committerRobin Watts <robin.watts@artifex.com>2011-12-07 18:09:23 +0000
commit7a6b60d0ec1abac316917690878011c3228a6fb7 (patch)
tree1d1c9b662ba1b738d08e557558fc9875cbbc1a31 /pdf
parent841533481464ea4cad3dcb8c6dd636c5d455e6eb (diff)
downloadmupdf-7a6b60d0ec1abac316917690878011c3228a6fb7.tar.xz
Fix tile coverage calculations.
The code attempts to spot cases where a pattern tile is so large that only 1 repeat is visible. Due to rounding errors, this test could sometimes fail, and (on badly formed files) we'd attempt to allocate huge pixmaps. The fix is to allow for rounding errors.
Diffstat (limited to 'pdf')
-rw-r--r--pdf/pdf_interpret.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/pdf/pdf_interpret.c b/pdf/pdf_interpret.c
index 55e66e61..f598e9fb 100644
--- a/pdf/pdf_interpret.c
+++ b/pdf/pdf_interpret.c
@@ -1151,10 +1151,15 @@ pdf_show_pattern(pdf_csi *csi, pdf_pattern *pat, fz_rect area, int what)
/* patterns are painted using the ctm in effect at the beginning of the content stream */
/* get bbox of shape in pattern space for stamping */
area = fz_transform_rect(invptm, area);
- x0 = floorf(area.x0 / pat->xstep);
- y0 = floorf(area.y0 / pat->ystep);
- x1 = ceilf(area.x1 / pat->xstep);
- y1 = ceilf(area.y1 / pat->ystep);
+
+ /* When calculating the number of tiles required, we adjust by a small
+ * amount to allow for rounding errors. By choosing this amount to be
+ * smaller than 1/256, we guarantee we won't cause problems that will
+ * be visible even under our most extreme antialiasing. */
+ x0 = floorf(area.x0 / pat->xstep + 0.001);
+ y0 = floorf(area.y0 / pat->ystep + 0.001);
+ x1 = ceilf(area.x1 / pat->xstep - 0.001);
+ y1 = ceilf(area.y1 / pat->ystep - 0.001);
oldtopctm = csi->top_ctm;
oldtop = csi->gtop;