From f23351f8e452ded2503dd8b14e3cdd2ff1ee2e72 Mon Sep 17 00:00:00 2001 From: Scott Moreau Date: Wed, 31 Oct 2012 04:16:56 -0600 Subject: [PATCH weston] image: Always recalculate image scale and aspect ratio on redraw. Resizing and fullscreen toggle feel buggy without recalculating the image scaling so the image always fills the surface viewport area nicely. --- clients/image.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/clients/image.c b/clients/image.c index 14f0550..fced100 100644 --- a/clients/image.c +++ b/clients/image.c @@ -125,24 +125,24 @@ redraw_handler(struct widget *widget, void *data) cairo_set_source_rgba(cr, 0, 0, 0, 1); cairo_paint(cr); - if (!image->initialized) { + if (!image->initialized) image->initialized = true; - width = cairo_image_surface_get_width(image->image); - height = cairo_image_surface_get_height(image->image); - doc_aspect = width / height; - window_aspect = (double) allocation.width / allocation.height; - if (doc_aspect < window_aspect) - scale = allocation.height / height; - else - scale = allocation.width / width; + width = cairo_image_surface_get_width(image->image); + height = cairo_image_surface_get_height(image->image); - image->width = width; - image->height = height; - cairo_matrix_init_scale(&image->matrix, scale, scale); + doc_aspect = width / height; + window_aspect = (double) allocation.width / allocation.height; + if (doc_aspect < window_aspect) + scale = allocation.height / height; + else + scale = allocation.width / width; - center_view(image); - } + image->width = width; + image->height = height; + cairo_matrix_init_scale(&image->matrix, scale, scale); + + center_view(image); matrix = image->matrix; cairo_matrix_init_translate(&translate, allocation.x, allocation.y); -- 1.7.11.7