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



commit 9edf708f478dd7e1a173fd4878edc35e4f46ba5e
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 if 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 7aa7ee331..16e9c963d 100644
--- a/src/compositor/meta-window-actor.c
+++ b/src/compositor/meta-window-actor.c
@@ -1297,13 +1297,9 @@ meta_window_actor_blit_to_framebuffer (MetaScreenCastWindow *screen_cast_window,
 
   cogl_color_init_from_4ub (&clear_color, 0, 0, 0, 0);
 
-  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,
@@ -1320,12 +1316,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);
 
   cogl_framebuffer_finish (framebuffer);
 


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