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: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1571>
This commit is contained in:
Daniel van Vugt 2020-11-18 17:49:59 +08:00 committed by Marge Bot
parent a0dbf3b84c
commit 96a185d8bc

View File

@ -442,15 +442,6 @@ transform_swap_region_to_onscreen (ClutterStageView *view,
return transformed_region; 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 static void
clutter_stage_cogl_redraw_view_primary (ClutterStageCogl *stage_cogl, clutter_stage_cogl_redraw_view_primary (ClutterStageCogl *stage_cogl,
ClutterStageView *view) ClutterStageView *view)
@ -484,7 +475,9 @@ clutter_stage_cogl_redraw_view_primary (ClutterStageCogl *stage_cogl,
COGL_IS_ONSCREEN (onscreen) && COGL_IS_ONSCREEN (onscreen) &&
cogl_clutter_winsys_has_feature (COGL_WINSYS_FEATURE_SWAP_REGION); 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); redraw_clip = clutter_stage_view_take_redraw_clip (view);
if (G_UNLIKELY (clutter_paint_debug_flags & CLUTTER_DEBUG_PAINT_DAMAGE_REGION)) 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); 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); cogl_framebuffer_push_region_clip (fb, fb_clip_region);