clutter/stage-cogl: Check for DISABLE_CLIPPED_REDRAWS earlier

Right now we're checking for the DISABLE_CLIPPED_REDRAWS debug flag
after creating the fb_clip_region and adjusting the redraw_clip. That
means that if may_use_clipped_redraw was TRUE, the redraw_clip will
still be set to the region and thus cause the stage to only be partially
redrawn. Since we don't push a clip to the framebuffer though
(use_clipped_redraw is now FALSE), parts of the view will get corrupted.

To fix that, disable clipped redraws right away if the debug flag is
set. This also allows removing the may_use_clipped_redraw bool and
replacing it entirely with use_clipped_redraw.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1113
This commit is contained in:
Jonas Dreßler 2020-03-06 12:15:55 +01:00 committed by Jonas Ådahl
parent afe4cd482e
commit 08f47fee16

View File

@ -575,7 +575,6 @@ clutter_stage_cogl_redraw_view (ClutterStageWindow *stage_window,
CoglFramebuffer *fb = clutter_stage_view_get_framebuffer (view); CoglFramebuffer *fb = clutter_stage_view_get_framebuffer (view);
cairo_rectangle_int_t view_rect; cairo_rectangle_int_t view_rect;
gboolean is_full_redraw; gboolean is_full_redraw;
gboolean may_use_clipped_redraw;
gboolean use_clipped_redraw; gboolean use_clipped_redraw;
gboolean can_blit_sub_buffer; gboolean can_blit_sub_buffer;
gboolean has_buffer_age; gboolean has_buffer_age;
@ -611,7 +610,21 @@ clutter_stage_cogl_redraw_view (ClutterStageWindow *stage_window,
else else
is_full_redraw = FALSE; is_full_redraw = FALSE;
may_use_clipped_redraw = if (has_buffer_age)
{
buffer_age = cogl_onscreen_get_buffer_age (COGL_ONSCREEN (fb));
if (!valid_buffer_age (view_cogl, buffer_age))
{
CLUTTER_NOTE (CLIPPING,
"Invalid back buffer(age=%d): forcing full redraw\n",
buffer_age);
use_clipped_redraw = FALSE;
}
}
use_clipped_redraw =
use_clipped_redraw &&
!(clutter_paint_debug_flags & CLUTTER_DEBUG_DISABLE_CLIPPED_REDRAWS) &&
_clutter_stage_window_can_clip_redraws (stage_window) && _clutter_stage_window_can_clip_redraws (stage_window) &&
(can_blit_sub_buffer || has_buffer_age) && (can_blit_sub_buffer || has_buffer_age) &&
!is_full_redraw && !is_full_redraw &&
@ -619,17 +632,7 @@ clutter_stage_cogl_redraw_view (ClutterStageWindow *stage_window,
* frames when starting up... */ * frames when starting up... */
cogl_onscreen_get_frame_counter (COGL_ONSCREEN (fb)) > 3; cogl_onscreen_get_frame_counter (COGL_ONSCREEN (fb)) > 3;
if (has_buffer_age) if (use_clipped_redraw)
{
buffer_age = cogl_onscreen_get_buffer_age (COGL_ONSCREEN (fb));
if (!valid_buffer_age (view_cogl, buffer_age))
{
CLUTTER_NOTE (CLIPPING, "Invalid back buffer(age=%d): forcing full redraw\n", buffer_age);
may_use_clipped_redraw = FALSE;
}
}
if (may_use_clipped_redraw)
{ {
fb_clip_region = offset_scale_and_clamp_region (redraw_clip, fb_clip_region = offset_scale_and_clamp_region (redraw_clip,
-view_rect.x, -view_rect.x,
@ -650,13 +653,8 @@ clutter_stage_cogl_redraw_view (ClutterStageWindow *stage_window,
redraw_clip = cairo_region_create_rectangle (&view_rect); redraw_clip = cairo_region_create_rectangle (&view_rect);
} }
if (may_use_clipped_redraw && clip_region_empty = (use_clipped_redraw &&
G_LIKELY (!(clutter_paint_debug_flags & CLUTTER_DEBUG_DISABLE_CLIPPED_REDRAWS))) cairo_region_is_empty (fb_clip_region));
use_clipped_redraw = TRUE;
else
use_clipped_redraw = FALSE;
clip_region_empty = may_use_clipped_redraw && cairo_region_is_empty (fb_clip_region);
swap_with_damage = FALSE; swap_with_damage = FALSE;
if (has_buffer_age) if (has_buffer_age)