st: Make StScrollViewFade a ClutterShaderEffect

The cogl_shader_XXX and cogl_program_YYY APIs have been deprecated
this cycle, so port to ClutterShaderEffect instead.

https://bugzilla.gnome.org/show_bug.cgi?id=707508
This commit is contained in:
Florian Müllner
2013-09-04 18:58:53 +02:00
parent 9d0e00acce
commit b403845d03
2 changed files with 45 additions and 186 deletions

View File

@ -25,16 +25,8 @@ uniform float hfade_offset;
uniform float vvalue;
uniform float hvalue;
/*
* Used to pass the fade area to the shader
*
* [0][0] = x1
* [0][1] = y1
* [1][0] = x2
* [1][1] = y2
*
*/
uniform mat2 fade_area;
uniform vec2 fade_area_topleft;
uniform vec2 fade_area_bottomright;
void main ()
{
@ -47,11 +39,11 @@ void main ()
* 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[0][0] && x < fade_area[1][0] &&
y > fade_area[0][1] && y < fade_area[1][1]) {
if (x > fade_area_topleft[0] && x < fade_area_bottomright[0] &&
y > fade_area_topleft[1] && y < fade_area_bottomright[1]) {
float ratio = 1.0;
float fade_bottom_start = fade_area[1][1] - vfade_offset;
float fade_right_start = fade_area[1][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 && vvalue > 0.0;
bool fade_bottom = y > fade_bottom_start && vvalue < 1.0;
bool fade_left = x < hfade_offset && hvalue > 0.0;
@ -63,7 +55,7 @@ void main ()
}
if (fade_bottom) {
ratio *= (fade_area[1][1] - y) / (fade_area[1][1] - fade_bottom_start);
ratio *= (fade_area_bottomright[1] - y) / (fade_area_bottomright[1] - fade_bottom_start);
}
float hfade_scale = width / hfade_offset;
@ -72,7 +64,7 @@ void main ()
}
if (fade_right) {
ratio *= (fade_area[1][0] - x) / (fade_area[1][0] - fade_right_start);
ratio *= (fade_area_bottomright[0] - x) / (fade_area_bottomright[0] - fade_right_start);
}
cogl_color_out *= ratio;