From 46a9538b6a8b866d07e63c2ecf28c2046196f53b Mon Sep 17 00:00:00 2001 From: Alexander Mikhaylenko Date: Wed, 4 Aug 2021 14:24:35 +0500 Subject: Shrink shadow extents Long time ago, Cairo shadows in both GTK3 and 4 were drawn at a size about twice their radius. Eventually this was fixed but the shadow extents are still calculated for the previous size and appear unreasonably large: for example, 141px for a 50px radius shadow. This can get very noticeable in places such as invisible window frame which gets included into screenshots. https://gitlab.gnome.org/GNOME/gtk/-/merge_requests/3419 just divides the radius by 2 when drawing a shadow with Cairo, do the same when calculating extents. See https://gitlab.gnome.org/GNOME/gtk/-/issues/3841 --- gsk/gskrendernodeimpl.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'gsk/gskrendernodeimpl.c') diff --git a/gsk/gskrendernodeimpl.c b/gsk/gskrendernodeimpl.c index 9a9705d0fd..8412f4696c 100644 --- a/gsk/gskrendernodeimpl.c +++ b/gsk/gskrendernodeimpl.c @@ -2146,7 +2146,7 @@ gsk_outset_shadow_get_extents (GskOutsetShadowNode *self, { float clip_radius; - clip_radius = gsk_cairo_blur_compute_pixels (self->blur_radius); + clip_radius = gsk_cairo_blur_compute_pixels (self->blur_radius / 2.0); *top = MAX (0, clip_radius + self->spread - self->dy); *right = MAX (0, ceil (clip_radius + self->spread + self->dx)); *bottom = MAX (0, ceil (clip_radius + self->spread + self->dy)); @@ -3852,7 +3852,7 @@ gsk_shadow_node_diff (GskRenderNode *node1, return; } - clip_radius = gsk_cairo_blur_compute_pixels (shadow1->radius); + clip_radius = gsk_cairo_blur_compute_pixels (shadow1->radius / 2.0); top = MAX (top, ceil (clip_radius - shadow1->dy)); right = MAX (right, ceil (clip_radius + shadow1->dx)); bottom = MAX (bottom, ceil (clip_radius + shadow1->dy)); @@ -3886,7 +3886,7 @@ gsk_shadow_node_get_bounds (GskShadowNode *self, for (i = 0; i < self->n_shadows; i++) { - float clip_radius = gsk_cairo_blur_compute_pixels (self->shadows[i].radius); + float clip_radius = gsk_cairo_blur_compute_pixels (self->shadows[i].radius / 2.0); top = MAX (top, clip_radius - self->shadows[i].dy); right = MAX (right, clip_radius + self->shadows[i].dx); bottom = MAX (bottom, clip_radius + self->shadows[i].dy); @@ -4813,7 +4813,7 @@ gsk_blur_node_diff (GskRenderNode *node1, cairo_region_t *sub; int i, n, clip_radius; - clip_radius = ceil (gsk_cairo_blur_compute_pixels (self1->radius)); + clip_radius = ceil (gsk_cairo_blur_compute_pixels (self1->radius / 2.0)); sub = cairo_region_create (); gsk_render_node_diff (self1->child, self2->child, sub); @@ -4860,7 +4860,7 @@ gsk_blur_node_new (GskRenderNode *child, self->child = gsk_render_node_ref (child); self->radius = radius; - clip_radius = gsk_cairo_blur_compute_pixels (radius); + clip_radius = gsk_cairo_blur_compute_pixels (radius / 2.0); graphene_rect_init_from_rect (&node->bounds, &child->bounds); graphene_rect_inset (&self->render_node.bounds, -- cgit v1.2.1