Author: Daniel van Vugt Source: https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1915 Editor: Sung Mingi Commit: 6f195a883c84284c4be802f1a74e425ea1264728 Last Updated: 04/02/22 (gnome-shell 42.0-1) diff --git a/data/theme/gnome-shell-sass/_common.scss b/data/theme/gnome-shell-sass/_common.scss index c6e64766e..2b5fccd57 100644 --- a/data/theme/gnome-shell-sass/_common.scss +++ b/data/theme/gnome-shell-sass/_common.scss @@ -35,6 +35,11 @@ $base_border_radius: 8px; // radii of things that display over other things, e.g. popovers $modal_radius: $base_border_radius*2; // 24px +// Chroma key to flag when a background-color is always occluded, not visible. +// This allows any box-shadow behind it to be rendered more efficiently by +// omitting the middle rectangle. +$invisible_occluded_bg_color: rgba(3,2,1,0); + // derived hover colors $hover_bg_color: if($variant=='light', darken($bg_color, 3%), lighten($bg_color, 4%)); $hover_fg_color: if($variant=='light', darken($fg_color, 5%), lighten($fg_color, 4%)); diff --git a/data/theme/gnome-shell-sass/widgets/_window-picker.scss b/data/theme/gnome-shell-sass/widgets/_window-picker.scss index e494f6d8a..7c3a26cd4 100644 --- a/data/theme/gnome-shell-sass/widgets/_window-picker.scss +++ b/data/theme/gnome-shell-sass/widgets/_window-picker.scss @@ -48,5 +48,6 @@ $window_close_button_padding: 3px; .workspace-background { // keep in sync with BACKGROUND_CORNER_RADIUS_PIXELS in workspace.js border-radius: 30px; + background-color: $invisible_occluded_bg_color; box-shadow: 0 4px 16px 4px transparentize(darken($osd_bg_color, 30%), 0.7); } diff --git a/src/st/st-theme-node-drawing.c b/src/st/st-theme-node-drawing.c index b32c76be2..72745ed66 100644 --- a/src/st/st-theme-node-drawing.c +++ b/src/st/st-theme-node-drawing.c @@ -2021,6 +2021,8 @@ st_theme_node_paint_sliced_shadow (StThemeNodePaintState *state, gfloat shadow_blur_radius, x_spread_factor, y_spread_factor; float rectangles[8 * 9]; gint idx; + ClutterColor background_color; + static const ClutterColor invisible_occluded = {3, 2, 1, 0}; if (paint_opacity == 0) return; @@ -2178,16 +2180,23 @@ st_theme_node_paint_sliced_shadow (StThemeNodePaintState *state, rectangles[idx++] = s_bottom; } - /* Center middle */ - rectangles[idx++] = left; - rectangles[idx++] = top; - rectangles[idx++] = right; - rectangles[idx++] = bottom; + /* Center middle is not definitely occluded? */ + st_theme_node_get_background_color (node, &background_color); + if (!clutter_color_equal (&background_color, &invisible_occluded) || + paint_opacity < 255 || + xoffset > shadow_blur_radius || left < 0 || + yoffset > shadow_blur_radius || top < 0) + { + rectangles[idx++] = left; + rectangles[idx++] = top; + rectangles[idx++] = right; + rectangles[idx++] = bottom; - rectangles[idx++] = s_left; - rectangles[idx++] = s_top; - rectangles[idx++] = s_right; - rectangles[idx++] = s_bottom; + rectangles[idx++] = s_left; + rectangles[idx++] = s_top; + rectangles[idx++] = s_right; + rectangles[idx++] = s_bottom; + } if (xend > right) {