st/scroll-view: Make fade effect take ClutterMargin
Instead of taking just vertical/horizontal offsets, take a ClutterMargin to allow us set the fade offsets on each direction specifically. Also, handle negative values in margins, the fade effect will run in the negative space left by the scrollview padding instead. Another difference now is that areas outside the extents of the effect will be transparent, instead of the effect ending abruptly past the given extents. This will be used by the app grid, in order to selectively let see either of next/prev pages while navigating. While at it, fix code style issues in st_scroll_view_update_fade_effect(), and clean up unused variables from the GLSL code. Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1630>
This commit is contained in:

committed by
Marge Bot

parent
8cb3825d48
commit
f60a469a34
@ -20,8 +20,10 @@
|
||||
uniform sampler2D tex;
|
||||
uniform float height;
|
||||
uniform float width;
|
||||
uniform float vfade_offset;
|
||||
uniform float hfade_offset;
|
||||
uniform float fade_offset_top;
|
||||
uniform float fade_offset_bottom;
|
||||
uniform float fade_offset_left;
|
||||
uniform float fade_offset_right;
|
||||
uniform bool fade_edges_top;
|
||||
uniform bool fade_edges_right;
|
||||
uniform bool fade_edges_bottom;
|
||||
@ -37,23 +39,19 @@ void main ()
|
||||
float y = height * cogl_tex_coord_in[0].y;
|
||||
float x = width * cogl_tex_coord_in[0].x;
|
||||
|
||||
/*
|
||||
* We cannot just return here due to a bug in llvmpipe see:
|
||||
* https://bugzilla.freedesktop.org/show_bug.cgi?id=62357
|
||||
*/
|
||||
if (x > fade_area_topleft[0] && x < fade_area_bottomright[0] &&
|
||||
y > fade_area_topleft[1] && y < fade_area_bottomright[1]) {
|
||||
y > fade_area_topleft[1] && y < fade_area_bottomright[1])
|
||||
{
|
||||
float ratio = 1.0;
|
||||
float fade_top_start = fade_area_topleft[1] + vfade_offset;
|
||||
float fade_left_start = fade_area_topleft[0] + hfade_offset;
|
||||
float fade_bottom_start = fade_area_bottomright[1] - vfade_offset;
|
||||
float fade_right_start = fade_area_bottomright[0] - hfade_offset;
|
||||
bool fade_top = y < vfade_offset && fade_edges_top;
|
||||
float fade_top_start = fade_area_topleft[1] + fade_offset_top;
|
||||
float fade_left_start = fade_area_topleft[0] + fade_offset_left;
|
||||
float fade_bottom_start = fade_area_bottomright[1] - fade_offset_bottom;
|
||||
float fade_right_start = fade_area_bottomright[0] - fade_offset_right;
|
||||
bool fade_top = y < fade_top_start && fade_edges_top;
|
||||
bool fade_bottom = y > fade_bottom_start && fade_edges_bottom;
|
||||
bool fade_left = x < fade_left_start && fade_edges_left;
|
||||
bool fade_right = x > fade_right_start && fade_edges_right;
|
||||
|
||||
float vfade_scale = height / vfade_offset;
|
||||
if (fade_top) {
|
||||
ratio *= (fade_area_topleft[1] - y) / (fade_area_topleft[1] - fade_top_start);
|
||||
}
|
||||
@ -62,7 +60,6 @@ void main ()
|
||||
ratio *= (fade_area_bottomright[1] - y) / (fade_area_bottomright[1] - fade_bottom_start);
|
||||
}
|
||||
|
||||
float hfade_scale = width / hfade_offset;
|
||||
if (fade_left) {
|
||||
ratio *= (fade_area_topleft[0] - x) / (fade_area_topleft[0] - fade_left_start);
|
||||
}
|
||||
@ -72,5 +69,7 @@ void main ()
|
||||
}
|
||||
|
||||
cogl_color_out *= ratio;
|
||||
} else {
|
||||
cogl_color_out *= 0;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user