1
0
Fork 0

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
This commit is contained in:
Marco Trevisan (Treviño) 2017-12-23 00:57:03 +01:00 committed by Marco Trevisan
parent 1e1cb4961b
commit 97a3b88f25

View file

@ -4769,6 +4769,8 @@ capture_view (ClutterStage *stage,
CoglBitmap *bitmap; CoglBitmap *bitmap;
cairo_rectangle_int_t view_layout; cairo_rectangle_int_t view_layout;
float view_scale; float view_scale;
float texture_width;
float texture_height;
framebuffer = clutter_stage_view_get_framebuffer (view); framebuffer = clutter_stage_view_get_framebuffer (view);
@ -4780,9 +4782,10 @@ capture_view (ClutterStage *stage,
} }
view_scale = clutter_stage_view_get_scale (view); 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, image = cairo_image_surface_create (CAIRO_FORMAT_ARGB32,
rect->width * view_scale, texture_width, texture_height);
rect->height * view_scale);
cairo_surface_set_device_scale (image, view_scale, view_scale); cairo_surface_set_device_scale (image, view_scale, view_scale);
data = cairo_image_surface_get_data (image); data = cairo_image_surface_get_data (image);
@ -4790,9 +4793,7 @@ capture_view (ClutterStage *stage,
backend = clutter_get_default_backend (); backend = clutter_get_default_backend ();
context = clutter_backend_get_cogl_context (backend); context = clutter_backend_get_cogl_context (backend);
bitmap = cogl_bitmap_new_for_data (context, bitmap = cogl_bitmap_new_for_data (context, texture_width, texture_height,
rect->width * view_scale,
rect->height * view_scale,
CLUTTER_CAIRO_FORMAT_ARGB32, CLUTTER_CAIRO_FORMAT_ARGB32,
stride, stride,
data); data);
@ -4800,8 +4801,8 @@ capture_view (ClutterStage *stage,
clutter_stage_view_get_layout (view, &view_layout); clutter_stage_view_get_layout (view, &view_layout);
cogl_framebuffer_read_pixels_into_bitmap (framebuffer, cogl_framebuffer_read_pixels_into_bitmap (framebuffer,
(rect->x - view_layout.x) * view_scale, roundf ((rect->x - view_layout.x) * view_scale),
(rect->y - view_layout.y) * view_scale, roundf ((rect->y - view_layout.y) * view_scale),
COGL_READ_PIXELS_COLOR_BUFFER, COGL_READ_PIXELS_COLOR_BUFFER,
bitmap); bitmap);