summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeff Smith <whydoubt@gmail.com>2018-01-26 06:25:19 -0600
committerAdam Jackson <ajax@redhat.com>2018-01-29 16:18:04 -0500
commit3e377e238f7257fd01e56a4a25dfd77e033673e4 (patch)
treee69bfd1929922e2af7dd12418c0765965a9be118
parent9b7b8720ebc8028b14796a66d0a21b002682a83c (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>
-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 2f2a5cc9b..d492f6951 100644
--- a/glamor/glamor_gradient.c
+++ b/glamor/glamor_gradient.c
@@ -456,7 +456,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"\
@@ -482,19 +481,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"\