From 8f7f4981d031ffa907cdfd2767438276ebb6ae7c Mon Sep 17 00:00:00 2001 From: Robin Watts Date: Mon, 21 Mar 2016 20:28:54 +0000 Subject: Bug 696668: Update the downscaling logic. An l2factor of 3 is equivalent to downscaling by a factor of 8. We can get an l2factor of 3 downscale out of the jpeglib. We can reasonably downscale by a further l2factor of 3 manually. Any more than that and we start to completely drop pixels without them having any effect. Therefore it's pointless us keeping any tiles around with l2factors > 6. Fix the bug (which was that we were using < instead of <=) and update the value to a more reasonable one anyway. --- source/fitz/image.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source/fitz') diff --git a/source/fitz/image.c b/source/fitz/image.c index a2f4bed2..81bb5575 100644 --- a/source/fitz/image.c +++ b/source/fitz/image.c @@ -318,7 +318,7 @@ fz_get_pixmap_from_image(fz_context *ctx, fz_image *image, int w, int h) if (w == 0 || h == 0) l2factor = 0; else - for (l2factor=0; image->w>>(l2factor+1) >= w+2 && image->h>>(l2factor+1) >= h+2 && l2factor < 8; l2factor++); + for (l2factor=0; image->w>>(l2factor+1) >= w+2 && image->h>>(l2factor+1) >= h+2 && l2factor < 6; l2factor++); /* Can we find any suitable tiles in the cache? */ key.refs = 1; @@ -339,7 +339,7 @@ fz_get_pixmap_from_image(fz_context *ctx, fz_image *image, int w, int h) tile = image->get_pixmap(ctx, image, w, h, &l2factor_remaining); /* l2factor_remaining is updated to the amount of subscaling left to do */ - assert(l2factor_remaining >= 0 && l2factor_remaining < 8); + assert(l2factor_remaining >= 0 && l2factor_remaining <= 6); if (l2factor_remaining) { fz_subsample_pixmap(ctx, tile, l2factor_remaining); -- cgit v1.2.3