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: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1897>
This commit is contained in:
Daniel van Vugt 2021-06-24 18:19:09 +08:00 committed by Marge Bot
parent c08c142f95
commit 48d5740443

View File

@ -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);