mirror of
https://gitlab.freedesktop.org/xorg/xserver.git
synced 2025-12-20 05:50:04 +01:00
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 3e377e238f)
This commit is contained in:
parent
f6cd99ed79
commit
38e6fb7573
1 changed files with 4 additions and 7 deletions
|
|
@ -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"\
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue