St: Fix fade effect

Commit 4095a58eb9 introduced a
regression, since we have to take into account four cases,
top, bottom, right, and left, and that can't be merged into
two like that commit did.
So fix it to make fade effect works again.

https://bugzilla.gnome.org/show_bug.cgi?id=708256
This commit is contained in:
Carlos Soriano 2013-09-17 19:41:02 +02:00
parent 7f1b07b76f
commit c23786c73e
2 changed files with 12 additions and 8 deletions

View File

@ -142,11 +142,13 @@ st_scroll_view_fade_paint_target (ClutterOffscreenEffect *effect)
st_adjustment_get_values (self->vadjustment, &value, &lower, &upper, NULL, NULL, &page_size); st_adjustment_get_values (self->vadjustment, &value, &lower, &upper, NULL, NULL, &page_size);
value = (value - lower) / (upper - page_size - lower); value = (value - lower) / (upper - page_size - lower);
clutter_shader_effect_set_uniform (shader, "fade_edges_v", G_TYPE_INT, 1, self->fade_edges ? value >= 0.0 : value > 0.0); clutter_shader_effect_set_uniform (shader, "fade_edges_top", G_TYPE_INT, 1, self->fade_edges ? value >= 0.0 : value > 0.0);
clutter_shader_effect_set_uniform (shader, "fade_edges_bottom", G_TYPE_INT, 1, self->fade_edges ? value <= 1.0 : value < 1.0);
st_adjustment_get_values (self->hadjustment, &value, &lower, &upper, NULL, NULL, &page_size); st_adjustment_get_values (self->hadjustment, &value, &lower, &upper, NULL, NULL, &page_size);
value = (value - lower) / (upper - page_size - lower); value = (value - lower) / (upper - page_size - lower);
clutter_shader_effect_set_uniform (shader, "fade_edges_h", G_TYPE_INT, 1, self->fade_edges ? value >= 0.0 : value > 0.0); clutter_shader_effect_set_uniform (shader, "fade_edges_left", G_TYPE_INT, 1, self->fade_edges ? value >= 0.0 : value > 0.0);
clutter_shader_effect_set_uniform (shader, "fade_edges_right", G_TYPE_INT, 1, self->fade_edges ? value <= 1.0 : value < 1.0);
clutter_shader_effect_set_uniform (shader, "vfade_offset", G_TYPE_FLOAT, 1, self->vfade_offset); clutter_shader_effect_set_uniform (shader, "vfade_offset", G_TYPE_FLOAT, 1, self->vfade_offset);
clutter_shader_effect_set_uniform (shader, "hfade_offset", G_TYPE_FLOAT, 1, self->hfade_offset); clutter_shader_effect_set_uniform (shader, "hfade_offset", G_TYPE_FLOAT, 1, self->hfade_offset);

View File

@ -22,8 +22,10 @@ uniform float height;
uniform float width; uniform float width;
uniform float vfade_offset; uniform float vfade_offset;
uniform float hfade_offset; uniform float hfade_offset;
uniform bool fade_edges_h; uniform bool fade_edges_top;
uniform bool fade_edges_v; uniform bool fade_edges_right;
uniform bool fade_edges_bottom;
uniform bool fade_edges_left;
uniform vec2 fade_area_topleft; uniform vec2 fade_area_topleft;
uniform vec2 fade_area_bottomright; uniform vec2 fade_area_bottomright;
@ -44,10 +46,10 @@ void main ()
float ratio = 1.0; float ratio = 1.0;
float fade_bottom_start = fade_area_bottomright[1] - vfade_offset; float fade_bottom_start = fade_area_bottomright[1] - vfade_offset;
float fade_right_start = fade_area_bottomright[0] - hfade_offset; float fade_right_start = fade_area_bottomright[0] - hfade_offset;
bool fade_top = y < vfade_offset && fade_edges_v; bool fade_top = y < vfade_offset && fade_edges_top;
bool fade_bottom = y > fade_bottom_start && fade_edges_v; bool fade_bottom = y > fade_bottom_start && fade_edges_bottom;
bool fade_left = x < hfade_offset && fade_edges_h; bool fade_left = x < hfade_offset && fade_edges_left;
bool fade_right = x > fade_right_start && fade_edges_h; bool fade_right = x > fade_right_start && fade_edges_right;
float vfade_scale = height / vfade_offset; float vfade_scale = height / vfade_offset;
if (fade_top) { if (fade_top) {