HiDPI: zero check using DBL_EPSILON

This commit is contained in:
Jeremie Knuesel 2018-01-23 22:38:45 +01:00
parent e0cf06ff05
commit 9cf3239708
2 changed files with 6 additions and 3 deletions

View File

@ -452,7 +452,7 @@ zathura_page_widget_draw(GtkWidget* widget, cairo_t* cairo)
double device_scale_x;
double device_scale_y;
cairo_surface_get_device_scale(priv->thumbnail, &device_scale_x, &device_scale_y);
if (device_scale_x != 0.0 && device_scale_y != 0.0) {
if (fabs(device_scale_x) >= DBL_EPSILON && fabs(device_scale_y) >= DBL_EPSILON) {
pwidth *= device_scale_x;
pheight *= device_scale_y;
}

View File

@ -745,7 +745,10 @@ render(render_job_t* job, ZathuraRenderRequest* request, ZathuraRenderer* render
double device_scale_y;
zathura_document_get_device_scale(document, &device_scale_x, &device_scale_y);
if (device_scale_x != 0.0 && device_scale_y != 0.0) {
gboolean scales_nonzero = (fabs(device_scale_x) >= DBL_EPSILON &&
fabs(device_scale_y) >= DBL_EPSILON);
if (scales_nonzero) {
page_width *= device_scale_x;
page_height *= device_scale_y;
}
@ -762,7 +765,7 @@ render(render_job_t* job, ZathuraRenderRequest* request, ZathuraRenderer* render
}
#if CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1,14,0)
if (device_scale_x != 0.0 && device_scale_y != 0.0) {
if (scales_nonzero) {
cairo_surface_set_device_scale(surface, device_scale_x, device_scale_y);
if (cairo_surface_status(surface) != CAIRO_STATUS_SUCCESS) {
cairo_surface_destroy(surface);