From 8c52b431bbc0190b7256d0cc7fbe10a62ea7dcab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20Dre=C3=9Fler?= Date: Fri, 6 Mar 2020 11:56:19 +0100 Subject: [PATCH] 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 --- clutter/clutter/cogl/clutter-stage-cogl.c | 66 +++-------------------- 1 file changed, 8 insertions(+), 58 deletions(-) diff --git a/clutter/clutter/cogl/clutter-stage-cogl.c b/clutter/clutter/cogl/clutter-stage-cogl.c index 7f01587d0..3ac09038d 100644 --- a/clutter/clutter/cogl/clutter-stage-cogl.c +++ b/clutter/clutter/cogl/clutter-stage-cogl.c @@ -555,28 +555,6 @@ transform_swap_region_to_onscreen (ClutterStageView *view, 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 is_buffer_age_enabled (void) { @@ -611,7 +589,6 @@ clutter_stage_cogl_redraw_view (ClutterStageWindow *stage_window, cairo_rectangle_int_t redraw_rect; gboolean clip_region_empty; float fb_scale; - int subpixel_compensation = 0; int fb_width, fb_height; int buffer_age; @@ -662,27 +639,6 @@ clutter_stage_cogl_redraw_view (ClutterStageWindow *stage_window, -view_rect.x, -view_rect.y, 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 { @@ -770,29 +726,23 @@ clutter_stage_cogl_redraw_view (ClutterStageWindow *stage_window, else if (use_clipped_redraw) { cairo_rectangle_int_t clip_rect; - cairo_rectangle_int_t scissor_rect; if (cairo_region_num_rectangles (fb_clip_region) == 1) { 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, "Stage clip pushed: x=%d, y=%d, width=%d, height=%d\n", - scissor_rect.x, - scissor_rect.y, - scissor_rect.width, - scissor_rect.height); + clip_rect.x, + clip_rect.y, + clip_rect.width, + clip_rect.height); cogl_framebuffer_push_scissor_clip (fb, - scissor_rect.x, - scissor_rect.y, - scissor_rect.width, - scissor_rect.height); + clip_rect.x, + clip_rect.y, + clip_rect.width, + clip_rect.height); } else {