From: Markus Wick Date: Tue, 18 Mar 2014 08:42:48 +0000 (+0100) Subject: glamor: Use glsl "fract/mod" instead of "while" in gradient shaders. X-Git-Tag: upstream/1.15.99.902~41 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=708fe0625f31ad39ba54f27f04d17ed2aa621cad;p=platform%2Fupstream%2Fxorg-server.git glamor: Use glsl "fract/mod" instead of "while" in gradient shaders. This fixes gtkperf. It seemed to hang forever. Signed-off-by: Eric Anholt Reviewed-by: Eric Anholt --- diff --git a/glamor/glamor_gradient.c b/glamor/glamor_gradient.c index f77d6a8..38dac68 100644 --- a/glamor/glamor_gradient.c +++ b/glamor/glamor_gradient.c @@ -247,7 +247,6 @@ _glamor_create_radial_gradient_program(ScreenPtr screen, int stops_count, "{\n"\ " float t = 0.0;\n"\ " float sqrt_value;\n"\ - " int revserse = 0;\n"\ " t_invalid = 0;\n"\ " \n"\ " vec3 tmp = vec3(source_texture.x, source_texture.y, 1.0);\n"\ @@ -295,30 +294,11 @@ _glamor_create_radial_gradient_program(ScreenPtr screen, int stops_count, " }\n"\ " \n"\ " if(repeat_type == %d){\n" /* repeat normal*/\ - " while(t > 1.0) \n"\ - " t = t - 1.0; \n"\ - " while(t < 0.0) \n"\ - " t = t + 1.0; \n"\ + " t = fract(t);\n"\ " }\n"\ " \n"\ " if(repeat_type == %d) {\n" /* repeat reflect*/\ - " while(t > 1.0) {\n"\ - " t = t - 1.0; \n"\ - " if(revserse == 0)\n"\ - " revserse = 1;\n"\ - " else\n"\ - " revserse = 0;\n"\ - " }\n"\ - " while(t < 0.0) {\n"\ - " t = t + 1.0; \n"\ - " if(revserse == 0)\n"\ - " revserse = 1;\n"\ - " else\n"\ - " revserse = 0;\n"\ - " }\n"\ - " if(revserse == 1) {\n"\ - " t = 1.0 - t; \n"\ - " }\n"\ + " t = abs(fract(t * 0.5 + 0.5) * 2.0 - 1.0);\n"\ " }\n"\ " \n"\ " return t;\n"\ @@ -492,7 +472,6 @@ _glamor_create_linear_gradient_program(ScreenPtr screen, int stops_count, " vec4 stop_color_before;\n"\ " vec4 stop_color_after;\n"\ " float new_alpha; \n"\ - " int revserse = 0;\n"\ " vec4 gradient_color;\n"\ " float percentage; \n"\ " vec3 source_texture_trans = transform_mat * tmp;\n"\ @@ -512,30 +491,11 @@ _glamor_create_linear_gradient_program(ScreenPtr screen, int stops_count, " distance = distance - _p1_distance; \n"\ " \n"\ " if(repeat_type == %d){\n" /* repeat normal*/\ - " while(distance > _pt_distance) \n"\ - " distance = distance - (_pt_distance); \n"\ - " while(distance < 0.0) \n"\ - " distance = distance + (_pt_distance); \n"\ + " distance = mod(distance, _pt_distance);\n"\ " }\n"\ " \n"\ " if(repeat_type == %d) {\n" /* repeat reflect*/\ - " while(distance > _pt_distance) {\n"\ - " distance = distance - (_pt_distance); \n"\ - " if(revserse == 0)\n"\ - " revserse = 1;\n"\ - " else\n"\ - " revserse = 0;\n"\ - " }\n"\ - " while(distance < 0.0) {\n"\ - " distance = distance + (_pt_distance); \n"\ - " if(revserse == 0)\n"\ - " revserse = 1;\n"\ - " else\n"\ - " revserse = 0;\n"\ - " }\n"\ - " if(revserse == 1) {\n"\ - " distance = (_pt_distance) - distance; \n"\ - " }\n"\ + " distance = abs(mod(distance + _pt_distance, 2.0 * _pt_distance) - _pt_distance);\n"\ " }\n"\ " \n"\ " len_percentage = distance/(_pt_distance);\n"\