From 757f3d82573d1e1b945f840c44d1eafbd36524c8 Mon Sep 17 00:00:00 2001 From: Lingzhu Xiang Date: Tue, 28 Oct 2014 03:46:20 -0400 Subject: [PATCH] Avoid large amount of scaling for pages at low zoom level --- page-widget.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/page-widget.c b/page-widget.c index 8ed2715..6339269 100644 --- a/page-widget.c +++ b/page-widget.c @@ -580,7 +580,7 @@ zathura_page_widget_redraw_canvas(ZathuraPage* pageview) } /* high enough but not causing noticable delay in scaling */ -#define THUMBNAIL_MAX_SIZE (8*1024*1024) +#define THUMBNAIL_MAX_SIZE (4*1024*1024) /* smaller than max to be replaced by actual renders */ #define THUMBNAIL_INITIAL_SIZE (THUMBNAIL_MAX_SIZE/4) /* small enough to make bilinear downscaling fast */ @@ -594,14 +594,16 @@ surface_small_enough(cairo_surface_t* surface, cairo_surface_t* old) const unsigned int width = cairo_image_surface_get_width(surface); const unsigned int height = cairo_image_surface_get_height(surface); - if (width * height > THUMBNAIL_MAX_SIZE) { + const size_t new_size = width * height; + if (new_size > THUMBNAIL_MAX_SIZE) { return false; } if (old != NULL) { const unsigned int width_old = cairo_image_surface_get_width(old); const unsigned int height_old = cairo_image_surface_get_height(old); - if (width * height < width_old * height_old) { + const size_t old_size = width_old * height_old; + if (new_size < old_size && new_size >= old_size * THUMBNAIL_MAX_SCALE * THUMBNAIL_MAX_SCALE) { return false; } }