Signed-off-by: Sebastian Ramacher <sebastian+dev@ramacher.at>
This commit is contained in:
Sebastian Ramacher 2014-10-26 21:32:20 +01:00
parent 70482cc08f
commit 42c1780aef
2 changed files with 10 additions and 5 deletions

View file

@ -594,15 +594,17 @@ surface_small_enough(cairo_surface_t* surface, cairo_surface_t* old)
const unsigned int width = cairo_image_surface_get_width(surface); const unsigned int width = cairo_image_surface_get_width(surface);
const unsigned int height = cairo_image_surface_get_height(surface); const unsigned int height = cairo_image_surface_get_height(surface);
if (width * height > THUMBNAIL_MAX_SIZE) if (width * height > THUMBNAIL_MAX_SIZE) {
return false; return false;
}
if (old != NULL) { if (old != NULL) {
const unsigned int width_old = cairo_image_surface_get_width(old); const unsigned int width_old = cairo_image_surface_get_width(old);
const unsigned int height_old = cairo_image_surface_get_height(old); const unsigned int height_old = cairo_image_surface_get_height(old);
if (width * height < width_old * height_old) if (width * height < width_old * height_old) {
return false; return false;
} }
}
return true; return true;
} }
@ -613,8 +615,9 @@ draw_thumbnail_image(cairo_surface_t* surface)
unsigned int width = cairo_image_surface_get_width(surface); unsigned int width = cairo_image_surface_get_width(surface);
unsigned int height = cairo_image_surface_get_height(surface); unsigned int height = cairo_image_surface_get_height(surface);
double scale = sqrt((double)THUMBNAIL_INITIAL_SIZE / (width * height)); double scale = sqrt((double)THUMBNAIL_INITIAL_SIZE / (width * height));
if (scale > THUMBNAIL_MAX_SCALE) if (scale > THUMBNAIL_MAX_SCALE) {
scale = THUMBNAIL_MAX_SCALE; scale = THUMBNAIL_MAX_SCALE;
}
width = width * scale; width = width * scale;
height = height * scale; height = height * scale;
@ -647,8 +650,9 @@ zathura_page_widget_update_surface(ZathuraPage* widget, cairo_surface_t* surface
cairo_surface_reference(surface); cairo_surface_reference(surface);
if (surface_small_enough(surface, priv->thumbnail)) { if (surface_small_enough(surface, priv->thumbnail)) {
if (priv->thumbnail != NULL) if (priv->thumbnail != NULL) {
cairo_surface_destroy(priv->thumbnail); cairo_surface_destroy(priv->thumbnail);
}
priv->thumbnail = surface; priv->thumbnail = surface;
cairo_surface_reference(surface); cairo_surface_reference(surface);
} else if (new_render) { } else if (new_render) {

View file

@ -1406,8 +1406,9 @@ sc_zoom(girara_session_t* session, girara_argument_t* argument, girara_event_t*
} }
const double new_zoom = zathura_document_get_scale(zathura->document); const double new_zoom = zathura_document_get_scale(zathura->document);
if (fabs(new_zoom - old_zoom) <= DBL_EPSILON) if (fabs(new_zoom - old_zoom) <= DBL_EPSILON) {
return false; return false;
}
render_all(zathura); render_all(zathura);
refresh_view(zathura); refresh_view(zathura);