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:
parent
1e1cb4961b
commit
97a3b88f25
@ -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);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user