[gnome-shell/gnome-40] st/private: Set sampling_radius to match the blur radius



commit 71a3d0717fac1091638ebc70786fa72b397f4266
Author: Daniel van Vugt <daniel van vugt canonical com>
Date:   Thu Jun 24 18:19:09 2021 +0800

    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>
    (cherry picked from commit 48d5740443598193b67bfec48d0bb1a32e003572)

 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 5bbefa7631..540bad425e 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);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]