From 96a185d8bc9b904fb253979664ad3e2b7f668eb6 Mon Sep 17 00:00:00 2001 From: Daniel van Vugt Date: Wed, 18 Nov 2020 17:49:59 +0800 Subject: clutter/stage-cogl: Colour fb_clip_region in CLUTTER_DEBUG_PAINT_DAMAGE_REGION Previously when CLUTTER_DEBUG_PAINT_DAMAGE_REGION was set, that would lead to has_buffer_age==FALSE, which would lead to use_clipped_redraw==FALSE which would mean swap_region was always empty. And so the blue region of CLUTTER_DEBUG_PAINT_DAMAGE_REGION was always empty, *and* fb_clip_region was always the full view rectangle which is not useful for debugging. Now when CLUTTER_DEBUG_PAINT_DAMAGE_REGION is set, we don't let that affect use_clipped_redraw, which means fb_clip_region is calculated realistically. But that's not enough. Calculating fb_clip_region properly with CLUTTER_DEBUG_PAINT_DAMAGE_REGION would still lead to colouring artefacts left on screen from previous frames that don't apply to the current frame. So to fix that we also paint_stage for the whole screen every time when using CLUTTER_DEBUG_PAINT_DAMAGE_REGION. So now you will only ever see red and blue shading that's applicable to the current frame, and no artefacts from the previous frames. Fixes: https://gitlab.gnome.org/GNOME/mutter/-/issues/1535 Part-of: --- clutter/clutter/cogl/clutter-stage-cogl.c | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/clutter/clutter/cogl/clutter-stage-cogl.c b/clutter/clutter/cogl/clutter-stage-cogl.c index a5db640b2..92bc6ae51 100644 --- a/clutter/clutter/cogl/clutter-stage-cogl.c +++ b/clutter/clutter/cogl/clutter-stage-cogl.c @@ -442,15 +442,6 @@ transform_swap_region_to_onscreen (ClutterStageView *view, return transformed_region; } -static inline gboolean -is_buffer_age_enabled (void) -{ - /* Buffer age is disabled when running with CLUTTER_PAINT=damage-region, - * to ensure the red damage represents the currently damaged area */ - return !(clutter_paint_debug_flags & CLUTTER_DEBUG_PAINT_DAMAGE_REGION) && - cogl_clutter_winsys_has_feature (COGL_WINSYS_FEATURE_BUFFER_AGE); -} - static void clutter_stage_cogl_redraw_view_primary (ClutterStageCogl *stage_cogl, ClutterStageView *view) @@ -484,7 +475,9 @@ clutter_stage_cogl_redraw_view_primary (ClutterStageCogl *stage_cogl, COGL_IS_ONSCREEN (onscreen) && cogl_clutter_winsys_has_feature (COGL_WINSYS_FEATURE_SWAP_REGION); - has_buffer_age = COGL_IS_ONSCREEN (onscreen) && is_buffer_age_enabled (); + has_buffer_age = + COGL_IS_ONSCREEN (onscreen) && + cogl_clutter_winsys_has_feature (COGL_WINSYS_FEATURE_BUFFER_AGE); redraw_clip = clutter_stage_view_take_redraw_clip (view); if (G_UNLIKELY (clutter_paint_debug_flags & CLUTTER_DEBUG_PAINT_DAMAGE_REGION)) @@ -589,7 +582,15 @@ clutter_stage_cogl_redraw_view_primary (ClutterStageCogl *stage_cogl, clutter_damage_history_step (view_priv->damage_history); } - if (use_clipped_redraw) + if (clutter_paint_debug_flags & CLUTTER_DEBUG_PAINT_DAMAGE_REGION) + { + cairo_region_t *debug_redraw_clip; + + debug_redraw_clip = cairo_region_create_rectangle (&view_rect); + paint_stage (stage_cogl, view, debug_redraw_clip); + cairo_region_destroy (debug_redraw_clip); + } + else if (use_clipped_redraw) { cogl_framebuffer_push_region_clip (fb, fb_clip_region); -- cgit v1.2.1