[mutter/gbsneto/window-screencast-fixes: 2/8] window-actor: Clip before translate when blitting



commit cc9b6ac2d24c5abe02bb9e6fdaaa3986551ba52d
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date:   Mon Mar 16 19:55:16 2020 -0300

    window-actor: Clip before translate when blitting
    
    cogl_framebuffer_push_rectangle_clip() acts on the current modelview
    matrix. That means the result of clipping then translating will be
    different of the result of translating then clipping.
    
    What we want for window screencasting is the former, not the latter.
    Move the translation code (and associated) to after clipping.
    
    Fixes: https://gitlab.gnome.org/GNOME/mutter/issues/1097
    
    https://gitlab.gnome.org/GNOME/mutter/merge_requests/1129

 src/compositor/meta-window-actor.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
---
diff --git a/src/compositor/meta-window-actor.c b/src/compositor/meta-window-actor.c
index fe6ea870a..143c5ac6b 100644
--- a/src/compositor/meta-window-actor.c
+++ b/src/compositor/meta-window-actor.c
@@ -1292,13 +1292,9 @@ meta_window_actor_blit_to_framebuffer (MetaScreenCastWindow *screen_cast_window,
 
   clutter_actor_get_position (actor, &x, &y);
 
-  cogl_framebuffer_push_matrix (framebuffer);
-
   cogl_color_init_from_4ub (&clear_color, 0, 0, 0, 0);
   cogl_framebuffer_clear (framebuffer, COGL_BUFFER_BIT_COLOR, &clear_color);
   cogl_framebuffer_orthographic (framebuffer, 0, 0, width, height, 0, 1.0);
-  cogl_framebuffer_scale (framebuffer, resource_scale, resource_scale, 1);
-  cogl_framebuffer_translate (framebuffer, -x, -y, 0);
 
   meta_rectangle_scale_double (bounds, resource_scale,
                                META_ROUNDING_STRATEGY_GROW,
@@ -1315,12 +1311,16 @@ meta_window_actor_blit_to_framebuffer (MetaScreenCastWindow *screen_cast_window,
                                         scaled_clip.x + scaled_clip.width,
                                         scaled_clip.y + scaled_clip.height);
 
+  cogl_framebuffer_push_matrix (framebuffer);
+  cogl_framebuffer_scale (framebuffer, resource_scale, resource_scale, 1);
+  cogl_framebuffer_translate (framebuffer, -x, -y, 0);
+
   paint_context = clutter_paint_context_new_for_framebuffer (framebuffer);
   clutter_actor_paint (actor, paint_context);
   clutter_paint_context_destroy (paint_context);
 
-  cogl_framebuffer_pop_clip (framebuffer);
   cogl_framebuffer_pop_matrix (framebuffer);
+  cogl_framebuffer_pop_clip (framebuffer);
 
   return TRUE;
 }


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