From fed5f4d9aae29eba97e6e7ca58912962e5ac22e1 Mon Sep 17 00:00:00 2001 From: Georges Basile Stavracas Neto Date: Wed, 18 Mar 2020 21:14:58 -0300 Subject: [PATCH] window-actor: Inhibit culling when blitting to screencast This allows us to screencast any window continuously, even without it being visible. Because it's still being painted, clients continue to receive frame callbacks, and people are happy again. https://gitlab.gnome.org/GNOME/mutter/merge_requests/1129 --- src/compositor/meta-window-actor.c | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/src/compositor/meta-window-actor.c b/src/compositor/meta-window-actor.c index 143c5ac6b..9724c0243 100644 --- a/src/compositor/meta-window-actor.c +++ b/src/compositor/meta-window-actor.c @@ -1287,6 +1287,8 @@ meta_window_actor_blit_to_framebuffer (MetaScreenCastWindow *screen_cast_window, if (!clutter_actor_get_resource_scale (actor, &resource_scale)) return FALSE; + clutter_actor_inhibit_culling (actor); + width = ceilf (width * resource_scale); height = ceilf (height * resource_scale); @@ -1322,6 +1324,8 @@ meta_window_actor_blit_to_framebuffer (MetaScreenCastWindow *screen_cast_window, cogl_framebuffer_pop_matrix (framebuffer); cogl_framebuffer_pop_clip (framebuffer); + clutter_actor_uninhibit_culling (actor); + return TRUE; } @@ -1399,11 +1403,13 @@ meta_window_actor_get_image (MetaWindowActor *self, float x, y; MetaRectangle scaled_clip; ClutterPaintContext *paint_context; - cairo_surface_t *surface; + cairo_surface_t *surface = NULL; if (!priv->surface) return NULL; + clutter_actor_inhibit_culling (actor); + if (clutter_actor_get_n_children (actor) == 1) { MetaShapedTexture *stex; @@ -1425,23 +1431,24 @@ meta_window_actor_get_image (MetaWindowActor *self, } stex = meta_surface_actor_get_texture (priv->surface); - return meta_shaped_texture_get_image (stex, surface_clip); + surface = meta_shaped_texture_get_image (stex, surface_clip); + goto out; } clutter_actor_get_size (actor, &width, &height); if (width == 0 || height == 0) - return NULL; + goto out; if (!clutter_actor_get_resource_scale (actor, &resource_scale)) - return NULL; + goto out; width = ceilf (width * resource_scale); height = ceilf (height * resource_scale); texture = cogl_texture_2d_new_with_size (cogl_context, width, height); if (!texture) - return NULL; + goto out; cogl_primitive_texture_set_auto_mipmap (COGL_PRIMITIVE_TEXTURE (texture), FALSE); @@ -1457,7 +1464,7 @@ meta_window_actor_get_image (MetaWindowActor *self, error->message); cogl_object_unref (framebuffer); cogl_object_unref (texture); - return NULL; + goto out; } cogl_color_init_from_4ub (&clear_color, 0, 0, 0, 0); @@ -1504,5 +1511,7 @@ meta_window_actor_get_image (MetaWindowActor *self, cairo_surface_mark_dirty (surface); +out: + clutter_actor_uninhibit_culling (actor); return surface; }