From 48d5740443598193b67bfec48d0bb1a32e003572 Mon Sep 17 00:00:00 2001 From: Daniel van Vugt Date: Thu, 24 Jun 2021 18:19:09 +0800 Subject: [PATCH] st/private: Set sampling_radius to match the blur radius From [the spec](https://www.w3.org/TR/css-backgrounds-3/#shadow-blur): > the resulting shadow must approximate (with each pixel being within 5% > of its expected value) the image that would be generated by applying to > the shadow a Gaussian blur with a standard deviation [sigma] equal to > half the blur radius This does not change the value of `sigma`, it only corrects the value of `sampling_radius` used to size the shadow texture. Since the texture is no longer being slightly oversized it won't get scaled down when rendered according to the dimensions provided by `st_shadow_get_box` in `_st_paint_shadow_with_opacity`. Fixes: https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/4409 Part-of: --- src/st/st-private.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/st/st-private.c b/src/st/st-private.c index 5bbefa763..540bad425 100644 --- a/src/st/st-private.c +++ b/src/st/st-private.c @@ -400,8 +400,9 @@ _st_create_shadow_pipeline (StShadow *shadow_spec, g_return_val_if_fail (shadow_spec != NULL, NULL); g_return_val_if_fail (src_texture != NULL, NULL); - sigma = resource_scale * shadow_spec->blur / 2.f; - sampling_radius = ceilf (1.5 * sigma) * 2.0; + sampling_radius = resource_scale * shadow_spec->blur; + sigma = sampling_radius / 2.f; + sampling_radius = ceilf (sampling_radius); src_width = cogl_texture_get_width (src_texture); src_height = cogl_texture_get_height (src_texture);