kathenas / rpms / mutter

Forked from rpms/mutter 5 years ago
Clone

Blame SOURCES/0001-window-actor-Use-actual-image-size-for-capture.patch

776610
From 1587447b47130affe437acce4770f82d13176227 Mon Sep 17 00:00:00 2001
776610
From: Olivier Fourdan <ofourdan@redhat.com>
776610
Date: Tue, 22 Jan 2019 10:22:27 +0100
776610
Subject: [PATCH] window-actor: Use actual image size for capture
776610
776610
Previously, the clipping rectangle passed to
776610
`meta_surface_actor_get_image()` was updated with the actual texture
776610
size, but recent changes in `meta_shaped_texture_get_image()` now keep
776610
the caller's clipping rectangle unchanged.
776610
776610
The implementation of `meta_window_actor_capture_into()` was relying on
776610
the old behavior of updating the passed clipping rectangle, but now that
776610
it's kept unchanged, the actual clipping rectangle used to copy the data
776610
is wrong, which causes either a distorded image or worse, a crash of
776610
mutter.
776610
776610
Use the resulting cairo image size to copy the data instead of the
776610
clipping rectangle to avoid the issue and get the expected size.
776610
776610
Fixes: https://gitlab.gnome.org/GNOME/mutter/issues/442
776610
---
776610
 src/compositor/meta-window-actor.c | 18 ++++++++++--------
776610
 1 file changed, 10 insertions(+), 8 deletions(-)
776610
776610
diff --git a/src/compositor/meta-window-actor.c b/src/compositor/meta-window-actor.c
776610
index 396fef1..756e6c0 100644
776610
--- a/src/compositor/meta-window-actor.c
776610
+++ b/src/compositor/meta-window-actor.c
776610
@@ -2260,36 +2260,38 @@ meta_window_actor_capture_into (MetaScreenCastWindow *screen_cast_window,
776610
 {
776610
   MetaWindowActor *window_actor = META_WINDOW_ACTOR (screen_cast_window);
776610
   cairo_surface_t *image;
776610
-  MetaRectangle clip_rect;
776610
   uint8_t *cr_data;
776610
   int cr_stride;
776610
+  int cr_width;
776610
+  int cr_height;
776610
   int bpp = 4;
776610
 
776610
   if (meta_window_actor_is_destroyed (window_actor))
776610
     return;
776610
 
776610
-  clip_rect = *bounds;
776610
-  image = meta_surface_actor_get_image (window_actor->priv->surface, &clip_rect);
776610
+  image = meta_surface_actor_get_image (window_actor->priv->surface, bounds);
776610
   cr_data = cairo_image_surface_get_data (image);
776610
+  cr_width = cairo_image_surface_get_width (image);
776610
+  cr_height = cairo_image_surface_get_height (image);
776610
   cr_stride = cairo_image_surface_get_stride (image);
776610
 
776610
-  if (clip_rect.width < bounds->width || clip_rect.height < bounds->height)
776610
+  if (cr_width < bounds->width || cr_height < bounds->height)
776610
     {
776610
       uint8_t *src, *dst;
776610
       src = cr_data;
776610
       dst = data;
776610
 
776610
-      for (int i = 0; i < clip_rect.height; i++)
776610
+      for (int i = 0; i < cr_height; i++)
776610
         {
776610
           memcpy (dst, src, cr_stride);
776610
-          if (clip_rect.width < bounds->width)
776610
+          if (cr_width < bounds->width)
776610
             memset (dst + cr_stride, 0, (bounds->width * bpp) - cr_stride);
776610
 
776610
           src += cr_stride;
776610
           dst += bounds->width * bpp;
776610
         }
776610
 
776610
-      for (int i = clip_rect.height; i < bounds->height; i++)
776610
+      for (int i = cr_height; i < bounds->height; i++)
776610
         {
776610
           memset (dst, 0, bounds->width * bpp);
776610
           dst += bounds->width * bpp;
776610
@@ -2297,7 +2299,7 @@ meta_window_actor_capture_into (MetaScreenCastWindow *screen_cast_window,
776610
     }
776610
   else
776610
     {
776610
-      memcpy (data, cr_data, clip_rect.height * cr_stride);
776610
+      memcpy (data, cr_data, cr_height * cr_stride);
776610
     }
776610
 
776610
   cairo_surface_destroy (image);
776610
-- 
776610
2.20.1
776610