[mutter] backends: Set up swap_region without damage history



commit 932351c2bb4444f3094b493ad6010f25d1f97cc6
Author: Erico Nunes <nunes erico gmail com>
Date:   Mon Jan 10 22:50:13 2022 +0100

    backends: Set up swap_region without damage history
    
    Following the EGL_KHR_swap_buffers_with_damage specification, the
    surface damage used by eglSwapBuffersWithDamage does not need to
    contain the damage history.
    Rework that to initialize swap_region earlier, before appending the
    damage history.
    This may help optimizing the composition process in some cases (at least
    on X11 when EGL_KHR_swap_buffers_with_damage is available) by not
    accumulating additional regions as damaged unnecessarily.
    
    Signed-off-by: Erico Nunes <nunes erico gmail com>
    Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2241>

 src/backends/meta-stage-impl.c | 27 ++++++++++++++-------------
 1 file changed, 14 insertions(+), 13 deletions(-)
---
diff --git a/src/backends/meta-stage-impl.c b/src/backends/meta-stage-impl.c
index 6cc7e78fdb..b3f60645ab 100644
--- a/src/backends/meta-stage-impl.c
+++ b/src/backends/meta-stage-impl.c
@@ -542,6 +542,20 @@ meta_stage_impl_redraw_view_primary (MetaStageImpl    *stage_impl,
 
   g_return_if_fail (!cairo_region_is_empty (fb_clip_region));
 
+  /* XXX: It seems there will be a race here in that the stage
+   * window may be resized before the cogl_onscreen_swap_region
+   * is handled and so we may copy the wrong region. I can't
+   * really see how we can handle this with the current state of X
+   * but at least in this case a full redraw should be queued by
+   * the resize anyway so it should only exhibit temporary
+   * artefacts.
+   */
+  /* swap_region does not need damage history, set it up before that */
+  if (use_clipped_redraw)
+    swap_region = cairo_region_copy (fb_clip_region);
+  else
+    swap_region = cairo_region_create ();
+
   swap_with_damage = FALSE;
   if (has_buffer_age)
     {
@@ -613,19 +627,6 @@ meta_stage_impl_redraw_view_primary (MetaStageImpl    *stage_impl,
       paint_stage (stage_impl, stage_view, redraw_clip);
     }
 
-  /* XXX: It seems there will be a race here in that the stage
-   * window may be resized before the cogl_onscreen_swap_region
-   * is handled and so we may copy the wrong region. I can't
-   * really see how we can handle this with the current state of X
-   * but at least in this case a full redraw should be queued by
-   * the resize anyway so it should only exhibit temporary
-   * artefacts.
-   */
-  if (use_clipped_redraw)
-    swap_region = cairo_region_reference (fb_clip_region);
-  else
-    swap_region = cairo_region_create ();
-
   g_clear_pointer (&redraw_clip, cairo_region_destroy);
   g_clear_pointer (&fb_clip_region, cairo_region_destroy);
 


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