Commit 990a8ee0 authored by Eric Anholt's avatar Eric Anholt

glamor: Clean up formatting of RepeatFix shader code.

All sorts of weird indentation, and some cuddled conditional
statements deep in the if tree.
Signed-off-by: Eric Anholt's avatarEric Anholt <eric@anholt.net>
Reviewed-by: default avatarDave Airlie <airlied@redhat.com>
Reviewed-by: Kenneth Graunke's avatarKenneth Graunke <kenneth@whitecape.org>
parent 20cb5b2d
......@@ -74,30 +74,33 @@ glamor_create_composite_fs(struct shader_key *key)
const char *relocate_texture =
"vec2 rel_tex_coord(vec2 texture, vec4 wh, int repeat) \n"
"{\n"
" vec2 rel_tex; \n"
" rel_tex = texture * wh.xy; \n"
" vec2 rel_tex; \n"
" rel_tex = texture * wh.xy; \n"
" if (repeat == RepeatNone)\n"
" return rel_tex; \n"
" else if (repeat == RepeatNormal) \n"
" rel_tex = floor(rel_tex) + (fract(rel_tex) / wh.xy); \n"
" else if(repeat == RepeatPad) { \n"
" if (rel_tex.x >= 1.0) rel_tex.x = 1.0 - wh.z * wh.x / 2.; \n"
" else if(rel_tex.x < 0.0) rel_tex.x = 0.0; \n"
" if (rel_tex.y >= 1.0) rel_tex.y = 1.0 - wh.w * wh.y / 2.; \n"
" else if(rel_tex.y < 0.0) rel_tex.y = 0.0; \n"
" rel_tex = rel_tex / wh.xy; \n"
" } \n"
" else if(repeat == RepeatReflect) {\n"
" else if (repeat == RepeatNormal) \n"
" rel_tex = floor(rel_tex) + (fract(rel_tex) / wh.xy); \n"
" else if (repeat == RepeatPad) { \n"
" if (rel_tex.x >= 1.0) \n"
" rel_tex.x = 1.0 - wh.z * wh.x / 2.; \n"
" else if (rel_tex.x < 0.0) \n"
" rel_tex.x = 0.0; \n"
" if (rel_tex.y >= 1.0) \n"
" rel_tex.y = 1.0 - wh.w * wh.y / 2.; \n"
" else if (rel_tex.y < 0.0) \n"
" rel_tex.y = 0.0; \n"
" rel_tex = rel_tex / wh.xy; \n"
" } else if (repeat == RepeatReflect) {\n"
" if ((1.0 - mod(abs(floor(rel_tex.x)), 2.0)) < 0.001)\n"
" rel_tex.x = 2.0 - (1.0 - fract(rel_tex.x))/wh.x;\n"
" rel_tex.x = 2.0 - (1.0 - fract(rel_tex.x)) / wh.x;\n"
" else \n"
" rel_tex.x = fract(rel_tex.x)/wh.x;\n"
" rel_tex.x = fract(rel_tex.x) / wh.x;\n"
" if ((1.0 - mod(abs(floor(rel_tex.y)), 2.0)) < 0.001)\n"
" rel_tex.y = 2.0 - (1.0 - fract(rel_tex.y))/wh.y;\n"
" rel_tex.y = 2.0 - (1.0 - fract(rel_tex.y)) / wh.y;\n"
" else \n"
" rel_tex.y = fract(rel_tex.y)/wh.y;\n"
" } \n"
" return rel_tex; \n"
" rel_tex.y = fract(rel_tex.y) / wh.y;\n"
" } \n"
" return rel_tex; \n"
"}\n";
/* The texture and the pixmap size is not match eaxctly, so can't sample it directly.
* rel_sampler will recalculate the texture coords.*/
......@@ -105,7 +108,7 @@ glamor_create_composite_fs(struct shader_key *key)
" vec4 rel_sampler(sampler2D tex_image, vec2 tex, vec4 wh, int repeat, int set_alpha)\n"
"{\n"
" tex = rel_tex_coord(tex, wh, repeat - RepeatFix);\n"
" if (repeat == RepeatFix) {\n"
" if (repeat == RepeatFix) {\n"
" if (!(tex.x >= 0.0 && tex.x < 1.0 \n"
" && tex.y >= 0.0 && tex.y < 1.0))\n"
" return vec4(0.0, 0.0, 0.0, set_alpha);\n"
......@@ -129,9 +132,9 @@ glamor_create_composite_fs(struct shader_key *key)
"uniform vec4 source_wh;"
"vec4 get_source()\n"
"{\n"
" if (source_repeat_mode < RepeatFix)\n"
" if (source_repeat_mode < RepeatFix)\n"
" return texture2D(source_sampler, source_texture);\n"
" else \n"
" else \n"
" return rel_sampler(source_sampler, source_texture,\n"
" source_wh, source_repeat_mode, 0);\n"
"}\n";
......@@ -141,7 +144,7 @@ glamor_create_composite_fs(struct shader_key *key)
"uniform vec4 source_wh;\n"
"vec4 get_source()\n"
"{\n"
" if (source_repeat_mode < RepeatFix) \n"
" if (source_repeat_mode < RepeatFix) \n"
" return vec4(texture2D(source_sampler, source_texture).rgb, 1);\n"
" else \n"
" return rel_sampler(source_sampler, source_texture,\n"
......@@ -164,9 +167,9 @@ glamor_create_composite_fs(struct shader_key *key)
"uniform vec4 mask_wh;\n"
"vec4 get_mask()\n"
"{\n"
" if (mask_repeat_mode < RepeatFix) \n"
" if (mask_repeat_mode < RepeatFix) \n"
" return texture2D(mask_sampler, mask_texture);\n"
" else \n"
" else \n"
" return rel_sampler(mask_sampler, mask_texture,\n"
" mask_wh, mask_repeat_mode, 0);\n"
"}\n";
......@@ -176,9 +179,9 @@ glamor_create_composite_fs(struct shader_key *key)
"uniform vec4 mask_wh;\n"
"vec4 get_mask()\n"
"{\n"
" if (mask_repeat_mode < RepeatFix) \n"
" return vec4(texture2D(mask_sampler, mask_texture).rgb, 1);\n"
" else \n"
" if (mask_repeat_mode < RepeatFix) \n"
" return vec4(texture2D(mask_sampler, mask_texture).rgb, 1);\n"
" else \n"
" return rel_sampler(mask_sampler, mask_texture,\n"
" mask_wh, mask_repeat_mode, 1);\n"
"}\n";
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment