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>
This commit is contained in:
Erico Nunes 2022-01-10 22:50:13 +01:00 committed by Marge Bot
parent f305e4fd3f
commit 932351c2bb

View File

@ -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);