From 97a3b88f2516efcea868b05903b64797600d2315 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Sat, 23 Dec 2017 00:57:03 +0100 Subject: [PATCH] clutter/stage: Use rounded values to create image surfaces This needs to be an integer, and since the assumptions we have in Monitor this multiplication should always return an integer, however in case of precision loss it could return something very close to the next/prev integer, so let's be sure this won't happen, by just rounding it. https://bugzilla.gnome.org/show_bug.cgi?id=765011 https://gitlab.gnome.org/GNOME/mutter/merge_requests/3 --- clutter/clutter/clutter-stage.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/clutter/clutter/clutter-stage.c b/clutter/clutter/clutter-stage.c index 67992d816..d284692c0 100644 --- a/clutter/clutter/clutter-stage.c +++ b/clutter/clutter/clutter-stage.c @@ -4769,6 +4769,8 @@ capture_view (ClutterStage *stage, CoglBitmap *bitmap; cairo_rectangle_int_t view_layout; float view_scale; + float texture_width; + float texture_height; framebuffer = clutter_stage_view_get_framebuffer (view); @@ -4780,9 +4782,10 @@ capture_view (ClutterStage *stage, } view_scale = clutter_stage_view_get_scale (view); + texture_width = roundf (rect->width * view_scale); + texture_height = roundf (rect->height * view_scale); image = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, - rect->width * view_scale, - rect->height * view_scale); + texture_width, texture_height); cairo_surface_set_device_scale (image, view_scale, view_scale); data = cairo_image_surface_get_data (image); @@ -4790,9 +4793,7 @@ capture_view (ClutterStage *stage, backend = clutter_get_default_backend (); context = clutter_backend_get_cogl_context (backend); - bitmap = cogl_bitmap_new_for_data (context, - rect->width * view_scale, - rect->height * view_scale, + bitmap = cogl_bitmap_new_for_data (context, texture_width, texture_height, CLUTTER_CAIRO_FORMAT_ARGB32, stride, data); @@ -4800,8 +4801,8 @@ capture_view (ClutterStage *stage, clutter_stage_view_get_layout (view, &view_layout); cogl_framebuffer_read_pixels_into_bitmap (framebuffer, - (rect->x - view_layout.x) * view_scale, - (rect->y - view_layout.y) * view_scale, + roundf ((rect->x - view_layout.x) * view_scale), + roundf ((rect->y - view_layout.y) * view_scale), COGL_READ_PIXELS_COLOR_BUFFER, bitmap);