clutter/stage-cogl: Stop doing subpixel compensation

This was introduced with commit 9ab338d7b6 because the clipping of
fractionally scaled redraws caused glitches, it seems like this is no
longer needed nowadays, so let's remove it.

This should make obscured region culling work a bit better for
fractionally scaled framebuffers because because we overdraw a slightly
smaller region than the actually damaged one. We still do overdraw
though since the clipping region is stored using integers and thus
any non-integer values have to be extended to the bounding rect.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1113
This commit is contained in:
Jonas Dreßler 2020-03-06 11:56:19 +01:00 committed by Jonas Ådahl
parent d9ffbf0576
commit 8c52b431bb

View File

@ -555,28 +555,6 @@ transform_swap_region_to_onscreen (ClutterStageView *view,
return transformed_region; return transformed_region;
} }
static void
calculate_scissor_region (cairo_rectangle_int_t *fb_clip_region,
int subpixel_compensation,
int fb_width,
int fb_height,
cairo_rectangle_int_t *out_scissor_rect)
{
*out_scissor_rect = *fb_clip_region;
if (subpixel_compensation == 0)
return;
if (fb_clip_region->x > 0)
out_scissor_rect->x += subpixel_compensation;
if (fb_clip_region->y > 0)
out_scissor_rect->y += subpixel_compensation;
if (fb_clip_region->x + fb_clip_region->width < fb_width)
out_scissor_rect->width -= 2 * subpixel_compensation;
if (fb_clip_region->y + fb_clip_region->height < fb_height)
out_scissor_rect->height -= 2 * subpixel_compensation;
}
static inline gboolean static inline gboolean
is_buffer_age_enabled (void) is_buffer_age_enabled (void)
{ {
@ -611,7 +589,6 @@ clutter_stage_cogl_redraw_view (ClutterStageWindow *stage_window,
cairo_rectangle_int_t redraw_rect; cairo_rectangle_int_t redraw_rect;
gboolean clip_region_empty; gboolean clip_region_empty;
float fb_scale; float fb_scale;
int subpixel_compensation = 0;
int fb_width, fb_height; int fb_width, fb_height;
int buffer_age; int buffer_age;
@ -662,27 +639,6 @@ clutter_stage_cogl_redraw_view (ClutterStageWindow *stage_window,
-view_rect.x, -view_rect.x,
-view_rect.y, -view_rect.y,
fb_scale); fb_scale);
if (fb_scale != floorf (fb_scale))
{
int n_rects, i;
cairo_rectangle_int_t *rects;
subpixel_compensation = ceilf (fb_scale);
n_rects = cairo_region_num_rectangles (fb_clip_region);
rects = g_newa (cairo_rectangle_int_t, n_rects);
for (i = 0; i < n_rects; i++)
{
cairo_region_get_rectangle (fb_clip_region, i, &rects[i]);
rects[i].x -= subpixel_compensation;
rects[i].y -= subpixel_compensation;
rects[i].width += 2 * subpixel_compensation;
rects[i].height += 2 * subpixel_compensation;
}
cairo_region_destroy (fb_clip_region);
fb_clip_region = cairo_region_create_rectangles (rects, n_rects);
}
} }
else else
{ {
@ -770,29 +726,23 @@ clutter_stage_cogl_redraw_view (ClutterStageWindow *stage_window,
else if (use_clipped_redraw) else if (use_clipped_redraw)
{ {
cairo_rectangle_int_t clip_rect; cairo_rectangle_int_t clip_rect;
cairo_rectangle_int_t scissor_rect;
if (cairo_region_num_rectangles (fb_clip_region) == 1) if (cairo_region_num_rectangles (fb_clip_region) == 1)
{ {
cairo_region_get_extents (fb_clip_region, &clip_rect); cairo_region_get_extents (fb_clip_region, &clip_rect);
calculate_scissor_region (&clip_rect,
subpixel_compensation,
fb_width, fb_height,
&scissor_rect);
CLUTTER_NOTE (CLIPPING, CLUTTER_NOTE (CLIPPING,
"Stage clip pushed: x=%d, y=%d, width=%d, height=%d\n", "Stage clip pushed: x=%d, y=%d, width=%d, height=%d\n",
scissor_rect.x, clip_rect.x,
scissor_rect.y, clip_rect.y,
scissor_rect.width, clip_rect.width,
scissor_rect.height); clip_rect.height);
cogl_framebuffer_push_scissor_clip (fb, cogl_framebuffer_push_scissor_clip (fb,
scissor_rect.x, clip_rect.x,
scissor_rect.y, clip_rect.y,
scissor_rect.width, clip_rect.width,
scissor_rect.height); clip_rect.height);
} }
else else
{ {