shell-util: Fix capturing scaled views

libmutter-clutter fixed stage capturing when views are scaled, and for
that to work properly when compositing the screenshot, we need to deal
with the cairo device scale here too.

https://bugzilla.gnome.org/show_bug.cgi?id=765011
This commit is contained in:
Jonas Ådahl 2017-06-07 14:53:25 +08:00
parent 5962be3904
commit b099e9a69c

View File

@ -456,27 +456,32 @@ shell_util_composite_capture_images (ClutterCapture *captures,
int height)
{
int i;
double target_scale;
cairo_format_t format;
cairo_surface_t *image;
cairo_t *cr;
target_scale = 0.0;
for (i = 0; i < n_captures; i++)
{
ClutterCapture *capture = &captures[i];
double capture_scale = 1.0;
cairo_surface_get_device_scale (capture->image, &capture_scale, NULL);
target_scale = MAX (target_scale, capture_scale);
}
format = cairo_image_surface_get_format (captures[0].image);
image = cairo_image_surface_create (format, width, height);
image = cairo_image_surface_create (format,
width * target_scale,
height * target_scale);
cairo_surface_set_device_scale (image, target_scale, target_scale);
cr = cairo_create (image);
for (i = 0; i < n_captures; i++)
{
ClutterCapture *capture = &captures[i];
double capture_scale = 1.0;
/*
* Ignore capture regions with scale other than 1 for now; mutter can't
* produce them yet, so there is no way to test them.
*/
cairo_surface_get_device_scale (capture->image, &capture_scale, NULL);
if ((int) capture_scale != 1)
continue;
cairo_save (cr);