[gnome-shell] shell-util: Fix capturing scaled views



commit b099e9a69cc1a2ebb0f5feaedf9b973dccd3005b
Author: Jonas Ådahl <jadahl gmail com>
Date:   Wed Jun 7 14:53:25 2017 +0800

    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

 src/shell-util.c |   25 +++++++++++++++----------
 1 files changed, 15 insertions(+), 10 deletions(-)
---
diff --git a/src/shell-util.c b/src/shell-util.c
index f72645c..02db9b1 100644
--- a/src/shell-util.c
+++ b/src/shell-util.c
@@ -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);
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]