summaryrefslogtreecommitdiff
path: root/glamor
diff options
context:
space:
mode:
authorJeff Smith <whydoubt@gmail.com>2018-01-26 06:25:19 -0600
committerAdam Jackson <ajax@redhat.com>2018-02-12 14:52:09 -0500
commit38e6fb757386e2cb2c51a27e52346473d4ffb9a1 (patch)
tree440c48e31086fa294974c481ddce65c3297bd8f1 /glamor
parentf6cd99ed79c17e3aa04b8821d10ca95939bd8675 (diff)
glamor: fix repeat-reflect case in linear gradient shader
If _pt_distance is negative, it causes the final distance to be negative in the repeat-reflect case. Moving the scaling by _pt_distance earlier avoids this problem, and simplifies some equations as a bonus. Bugzilla: https://bugs.freedesktop.org/98508 Signed-off-by: Jeff Smith <whydoubt@gmail.com> Reviewed-by: Adam Jackson <ajax@redhat.com> (cherry picked from commit 3e377e238f7257fd01e56a4a25dfd77e033673e4)
Diffstat (limited to 'glamor')
-rw-r--r--glamor/glamor_gradient.c11
1 files changed, 4 insertions, 7 deletions
diff --git a/glamor/glamor_gradient.c b/glamor/glamor_gradient.c
index 0c97ce7cb..14ff9173f 100644
--- a/glamor/glamor_gradient.c
+++ b/glamor/glamor_gradient.c
@@ -458,7 +458,6 @@ _glamor_create_linear_gradient_program(ScreenPtr screen, int stops_count,
"float get_stop_len()\n"\
"{\n"\
" vec3 tmp = vec3(source_texture.x, source_texture.y, 1.0);\n"\
- " float len_percentage;\n"\
" float distance;\n"\
" float _p1_distance;\n"\
" float _pt_distance;\n"\
@@ -484,19 +483,17 @@ _glamor_create_linear_gradient_program(ScreenPtr screen, int stops_count,
" _pt_distance = pt_distance * source_texture_trans.z;\n"\
" } \n"\
" \n"\
- " distance = distance - _p1_distance; \n"\
+ " distance = (distance - _p1_distance) / _pt_distance;\n"\
" \n"\
" if(repeat_type == %d){\n" /* repeat normal*/\
- " distance = mod(distance, _pt_distance);\n"\
+ " distance = fract(distance);\n"\
" }\n"\
" \n"\
" if(repeat_type == %d) {\n" /* repeat reflect*/\
- " distance = abs(mod(distance + _pt_distance, 2.0 * _pt_distance) - _pt_distance);\n"\
+ " distance = abs(fract(distance * 0.5 + 0.5) * 2.0 - 1.0);\n"\
" }\n"\
" \n"\
- " len_percentage = distance/(_pt_distance);\n"\
- " \n"\
- " return len_percentage;\n"\
+ " return distance;\n"\
"}\n"\
"\n"\
"void main()\n"\