diff options
author | Eric Anholt <eric@anholt.net> | 2013-12-24 15:59:14 -0800 |
---|---|---|
committer | Eric Anholt <eric@anholt.net> | 2014-01-27 09:30:47 -0800 |
commit | 5f57d436c391c51f3f90958b033f6ee3eb7a1136 (patch) | |
tree | f8363af8e3c514195a37865582ed377caa7320e6 | |
parent | d84d71029ae9e462559d64eff7259e2cc7732fac (diff) |
glamor: Fix some mangling of shader strings by indent.
Signed-off-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Zhigang Gong <zhigang.gong@linux.intel.com>
Reviewed-by: Keith Packard <keithp@keithp.com>
-rw-r--r-- | glamor/glamor_core.c | 9 | ||||
-rw-r--r-- | glamor/glamor_fill.c | 13 | ||||
-rw-r--r-- | glamor/glamor_gradient.c | 89 | ||||
-rw-r--r-- | glamor/glamor_putimage.c | 23 | ||||
-rw-r--r-- | glamor/glamor_render.c | 60 | ||||
-rw-r--r-- | glamor/glamor_tile.c | 6 | ||||
-rw-r--r-- | glamor/glamor_trapezoid.c | 13 | ||||
-rw-r--r-- | glamor/glamor_xv.c | 14 |
8 files changed, 183 insertions, 44 deletions
diff --git a/glamor/glamor_core.c b/glamor/glamor_core.c index 42139613a..4eac85603 100644 --- a/glamor/glamor_core.c +++ b/glamor/glamor_core.c @@ -151,7 +151,8 @@ glamor_init_finish_access_shaders(ScreenPtr screen) "void main()\n" "{\n" " gl_Position = v_position;\n" - " source_texture = v_texcoord0.xy;\n" "}\n"; + " source_texture = v_texcoord0.xy;\n" + "}\n"; const char *common_source = GLAMOR_DEFAULT_PRECISION @@ -186,7 +187,8 @@ glamor_init_finish_access_shaders(ScreenPtr screen) " gl_FragColor = texture2D(sampler, source_texture).gbar;\n" " else if (swap_rb == SWAP_NONE_UPLOADING)\n" " gl_FragColor = texture2D(sampler, source_texture).abgr;\n" - " } \n" "}\n"; + " } \n" + "}\n"; const char *set_alpha_source = "void main()\n" @@ -208,7 +210,8 @@ glamor_init_finish_access_shaders(ScreenPtr screen) " gl_FragColor = vec4(texture2D(sampler, source_texture).gba, 1);\n" " else if (swap_rb == SWAP_NONE_UPLOADING)\n" " gl_FragColor = vec4(texture2D(sampler, source_texture).abg, 1);\n" - " } \n" "}\n"; + " } \n" + "}\n"; GLint fs_prog, vs_prog, avs_prog, set_alpha_prog; GLint sampler_uniform_location; char *source; diff --git a/glamor/glamor_fill.c b/glamor/glamor_fill.c index 47d27bc32..3aef7fcef 100644 --- a/glamor/glamor_fill.c +++ b/glamor/glamor_fill.c @@ -140,10 +140,17 @@ glamor_init_solid_shader(ScreenPtr screen) glamor_gl_dispatch *dispatch; const char *solid_vs = "attribute vec4 v_position;" - "void main()\n" "{\n" " gl_Position = v_position;\n" "}\n"; + "void main()\n" + "{\n" + " gl_Position = v_position;\n" + "}\n"; const char *solid_fs = - GLAMOR_DEFAULT_PRECISION "uniform vec4 color;\n" - "void main()\n" "{\n" " gl_FragColor = color;\n" "}\n"; + GLAMOR_DEFAULT_PRECISION + "uniform vec4 color;\n" + "void main()\n" + "{\n" + " gl_FragColor = color;\n" + "}\n"; GLint fs_prog, vs_prog; glamor_priv = glamor_get_screen_private(screen); diff --git a/glamor/glamor_gradient.c b/glamor/glamor_gradient.c index df6c3bbca..e7c872d4d 100644 --- a/glamor/glamor_gradient.c +++ b/glamor/glamor_gradient.c @@ -85,7 +85,84 @@ _glamor_create_getcolor_fs_program(ScreenPtr screen, int stops_count, /* Because the array access for shader is very slow, the performance is very low if use array. So use global uniform to replace for it if the number of n_stops is small. */ - const char *gradient_fs_getcolor_no_array = GLAMOR_DEFAULT_PRECISION "uniform int n_stop;\n" "uniform float stop0;\n" "uniform float stop1;\n" "uniform float stop2;\n" "uniform float stop3;\n" "uniform float stop4;\n" "uniform float stop5;\n" "uniform float stop6;\n" "uniform float stop7;\n" "uniform vec4 stop_color0;\n" "uniform vec4 stop_color1;\n" "uniform vec4 stop_color2;\n" "uniform vec4 stop_color3;\n" "uniform vec4 stop_color4;\n" "uniform vec4 stop_color5;\n" "uniform vec4 stop_color6;\n" "uniform vec4 stop_color7;\n" "\n" "vec4 get_color(float stop_len)\n" "{\n" " float stop_after;\n" " float stop_before;\n" " vec4 stop_color_before;\n" " vec4 stop_color_after;\n" " float new_alpha; \n" " vec4 gradient_color;\n" " float percentage; \n" " \n" " if((stop_len < stop0) && (n_stop >= 1)) {\n" " stop_color_before = stop_color0;\n" " stop_color_after = stop_color0;\n" " stop_after = stop0;\n" " stop_before = stop0;\n" " } else if((stop_len < stop1) && (n_stop >= 2)) {\n" " stop_color_before = stop_color0;\n" " stop_color_after = stop_color1;\n" " stop_after = stop1;\n" " stop_before = stop0;\n" " } else if((stop_len < stop2) && (n_stop >= 3)) {\n" " stop_color_before = stop_color1;\n" " stop_color_after = stop_color2;\n" " stop_after = stop2;\n" " stop_before = stop1;\n" " } else if((stop_len < stop3) && (n_stop >= 4)){\n" " stop_color_before = stop_color2;\n" " stop_color_after = stop_color3;\n" " stop_after = stop3;\n" " stop_before = stop2;\n" " } else if((stop_len < stop4) && (n_stop >= 5)){\n" " stop_color_before = stop_color3;\n" " stop_color_after = stop_color4;\n" " stop_after = stop4;\n" " stop_before = stop3;\n" " } else if((stop_len < stop5) && (n_stop >= 6)){\n" " stop_color_before = stop_color4;\n" " stop_color_after = stop_color5;\n" " stop_after = stop5;\n" " stop_before = stop4;\n" " } else if((stop_len < stop6) && (n_stop >= 7)){\n" " stop_color_before = stop_color5;\n" " stop_color_after = stop_color6;\n" " stop_after = stop6;\n" " stop_before = stop5;\n" " } else if((stop_len < stop7) && (n_stop >= 8)){\n" " stop_color_before = stop_color6;\n" " stop_color_after = stop_color7;\n" " stop_after = stop7;\n" " stop_before = stop6;\n" " } else {\n" " stop_color_before = stop_color7;\n" " stop_color_after = stop_color7;\n" " stop_after = stop7;\n" " stop_before = stop7;\n" " }\n" " if(stop_after - stop_before > 2.0)\n" " percentage = 0.0;\n" //For comply with pixman, walker->stepper overflow. + const char *gradient_fs_getcolor_no_array = + GLAMOR_DEFAULT_PRECISION + "uniform int n_stop;\n" + "uniform float stop0;\n" + "uniform float stop1;\n" + "uniform float stop2;\n" + "uniform float stop3;\n" + "uniform float stop4;\n" + "uniform float stop5;\n" + "uniform float stop6;\n" + "uniform float stop7;\n" + "uniform vec4 stop_color0;\n" + "uniform vec4 stop_color1;\n" + "uniform vec4 stop_color2;\n" + "uniform vec4 stop_color3;\n" + "uniform vec4 stop_color4;\n" + "uniform vec4 stop_color5;\n" + "uniform vec4 stop_color6;\n" + "uniform vec4 stop_color7;\n" + "\n" + "vec4 get_color(float stop_len)\n" + "{\n" + " float stop_after;\n" + " float stop_before;\n" + " vec4 stop_color_before;\n" + " vec4 stop_color_after;\n" + " float new_alpha; \n" + " vec4 gradient_color;\n" + " float percentage; \n" + " \n" + " if((stop_len < stop0) && (n_stop >= 1)) {\n" + " stop_color_before = stop_color0;\n" + " stop_color_after = stop_color0;\n" + " stop_after = stop0;\n" + " stop_before = stop0;\n" + " } else if((stop_len < stop1) && (n_stop >= 2)) {\n" + " stop_color_before = stop_color0;\n" + " stop_color_after = stop_color1;\n" + " stop_after = stop1;\n" + " stop_before = stop0;\n" + " } else if((stop_len < stop2) && (n_stop >= 3)) {\n" + " stop_color_before = stop_color1;\n" + " stop_color_after = stop_color2;\n" + " stop_after = stop2;\n" + " stop_before = stop1;\n" + " } else if((stop_len < stop3) && (n_stop >= 4)){\n" + " stop_color_before = stop_color2;\n" + " stop_color_after = stop_color3;\n" + " stop_after = stop3;\n" + " stop_before = stop2;\n" + " } else if((stop_len < stop4) && (n_stop >= 5)){\n" + " stop_color_before = stop_color3;\n" + " stop_color_after = stop_color4;\n" + " stop_after = stop4;\n" + " stop_before = stop3;\n" + " } else if((stop_len < stop5) && (n_stop >= 6)){\n" + " stop_color_before = stop_color4;\n" + " stop_color_after = stop_color5;\n" + " stop_after = stop5;\n" + " stop_before = stop4;\n" + " } else if((stop_len < stop6) && (n_stop >= 7)){\n" + " stop_color_before = stop_color5;\n" + " stop_color_after = stop_color6;\n" + " stop_after = stop6;\n" + " stop_before = stop5;\n" + " } else if((stop_len < stop7) && (n_stop >= 8)){\n" + " stop_color_before = stop_color6;\n" + " stop_color_after = stop_color7;\n" + " stop_after = stop7;\n" + " stop_before = stop6;\n" + " } else {\n" + " stop_color_before = stop_color7;\n" + " stop_color_after = stop_color7;\n" + " stop_after = stop7;\n" + " stop_before = stop7;\n" + " }\n" + " if(stop_after - stop_before > 2.0)\n" + " percentage = 0.0;\n" //For comply with pixman, walker->stepper overflow. " else if(stop_after - stop_before < 0.000001)\n" " percentage = 0.0;\n" " else \n" @@ -95,7 +172,9 @@ _glamor_create_getcolor_fs_program(ScreenPtr screen, int stops_count, " gradient_color = vec4((percentage * stop_color_after.rgb \n" " + (1.0-percentage) * stop_color_before.rgb)*new_alpha, \n" " new_alpha);\n" - " \n" " return gradient_color;\n" "}\n"; + " \n" + " return gradient_color;\n" + "}\n"; glamor_priv = glamor_get_screen_private(screen); dispatch = glamor_get_dispatch(glamor_priv); @@ -137,7 +216,8 @@ _glamor_create_radial_gradient_program(ScreenPtr screen, int stops_count, "void main()\n" "{\n" " gl_Position = v_position;\n" - " source_texture = v_texcoord.xy;\n" "}\n"; + " source_texture = v_texcoord.xy;\n" + "}\n"; /* * Refer to pixman radial gradient. @@ -375,7 +455,8 @@ _glamor_create_linear_gradient_program(ScreenPtr screen, int stops_count, "void main()\n" "{\n" " gl_Position = v_position;\n" - " source_texture = v_texcoord.xy;\n" "}\n"; + " source_texture = v_texcoord.xy;\n" + "}\n"; /* * | diff --git a/glamor/glamor_putimage.c b/glamor/glamor_putimage.c index 5d069125a..6b25bec84 100644 --- a/glamor/glamor_putimage.c +++ b/glamor/glamor_putimage.c @@ -38,20 +38,29 @@ glamor_init_putimage_shaders(ScreenPtr screen) #if 0 glamor_screen_private *glamor_priv = glamor_get_screen_private(screen); const char *xybitmap_vs = - "uniform float x_bias;\n" "uniform float x_scale;\n" - "uniform float y_bias;\n" "uniform float y_scale;\n" - "varying vec2 bitmap_coords;\n" "void main()\n" "{\n" + "uniform float x_bias;\n" + "uniform float x_scale;\n" + "uniform float y_bias;\n" + "uniform float y_scale;\n" + "varying vec2 bitmap_coords;\n" + "void main()\n" + "{\n" " gl_Position = vec4((gl_Vertex.x + x_bias) * x_scale,\n" " (gl_Vertex.y + y_bias) * y_scale,\n" " 0,\n" " 1);\n" - " bitmap_coords = gl_MultiTexCoord0.xy;\n" "}\n"; + " bitmap_coords = gl_MultiTexCoord0.xy;\n" + "}\n"; const char *xybitmap_fs = - "uniform vec4 fg, bg;\n" "varying vec2 bitmap_coords;\n" - "uniform sampler2D bitmap_sampler;\n" "void main()\n" "{\n" + "uniform vec4 fg, bg;\n" + "varying vec2 bitmap_coords;\n" + "uniform sampler2D bitmap_sampler;\n" + "void main()\n" + "{\n" " float bitmap_value = texture2D(bitmap_sampler,\n" " bitmap_coords).x;\n" - " gl_FragColor = mix(bg, fg, bitmap_value);\n" "}\n"; + " gl_FragColor = mix(bg, fg, bitmap_value);\n" + "}\n"; GLint fs_prog, vs_prog, prog; GLint sampler_uniform_location; diff --git a/glamor/glamor_render.c b/glamor/glamor_render.c index d6ccf8131..10cb24ade 100644 --- a/glamor/glamor_render.c +++ b/glamor/glamor_render.c @@ -99,7 +99,9 @@ glamor_create_composite_fs(glamor_gl_dispatch * dispatch, " 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" "}\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.*/ const char *rel_sampler = @@ -121,7 +123,10 @@ glamor_create_composite_fs(glamor_gl_dispatch * dispatch, const char *source_solid_fetch = GLAMOR_DEFAULT_PRECISION "uniform vec4 source;\n" - "vec4 get_source()\n" "{\n" " return source;\n" "}\n"; + "vec4 get_source()\n" + "{\n" + " return source;\n" + "}\n"; const char *source_alpha_pixmap_fetch = GLAMOR_DEFAULT_PRECISION "varying vec2 source_texture;\n" @@ -136,7 +141,8 @@ glamor_create_composite_fs(glamor_gl_dispatch * dispatch, " source_wh, source_repeat_mode, 0);\n" "}\n"; const char *source_pixmap_fetch = - GLAMOR_DEFAULT_PRECISION "varying vec2 source_texture;\n" + GLAMOR_DEFAULT_PRECISION + "varying vec2 source_texture;\n" "uniform sampler2D source_sampler;\n" "uniform vec4 source_wh;\n" "vec4 get_source()\n" @@ -148,10 +154,15 @@ glamor_create_composite_fs(glamor_gl_dispatch * dispatch, " source_wh, source_repeat_mode, 1);\n" "}\n"; const char *mask_solid_fetch = - GLAMOR_DEFAULT_PRECISION "uniform vec4 mask;\n" - "vec4 get_mask()\n" "{\n" " return mask;\n" "}\n"; + GLAMOR_DEFAULT_PRECISION + "uniform vec4 mask;\n" + "vec4 get_mask()\n" + "{\n" + " return mask;\n" + "}\n"; const char *mask_alpha_pixmap_fetch = - GLAMOR_DEFAULT_PRECISION "varying vec2 mask_texture;\n" + GLAMOR_DEFAULT_PRECISION + "varying vec2 mask_texture;\n" "uniform sampler2D mask_sampler;\n" "uniform vec4 mask_wh;\n" "vec4 get_mask()\n" @@ -163,7 +174,8 @@ glamor_create_composite_fs(glamor_gl_dispatch * dispatch, " mask_wh, mask_repeat_mode, 0);\n" "}\n"; const char *mask_pixmap_fetch = - GLAMOR_DEFAULT_PRECISION "varying vec2 mask_texture;\n" + GLAMOR_DEFAULT_PRECISION + "varying vec2 mask_texture;\n" "uniform sampler2D mask_sampler;\n" "uniform vec4 mask_wh;\n" "vec4 get_mask()\n" @@ -175,17 +187,29 @@ glamor_create_composite_fs(glamor_gl_dispatch * dispatch, " mask_wh, mask_repeat_mode, 1);\n" "}\n"; const char *in_source_only = - GLAMOR_DEFAULT_PRECISION "void main()\n" "{\n" - " gl_FragColor = get_source();\n" "}\n"; + GLAMOR_DEFAULT_PRECISION + "void main()\n" + "{\n" + " gl_FragColor = get_source();\n" + "}\n"; const char *in_normal = - GLAMOR_DEFAULT_PRECISION "void main()\n" "{\n" - " gl_FragColor = get_source() * get_mask().a;\n" "}\n"; + GLAMOR_DEFAULT_PRECISION + "void main()\n" + "{\n" + " gl_FragColor = get_source() * get_mask().a;\n" + "}\n"; const char *in_ca_source = - GLAMOR_DEFAULT_PRECISION "void main()\n" "{\n" - " gl_FragColor = get_source() * get_mask();\n" "}\n"; + GLAMOR_DEFAULT_PRECISION + "void main()\n" + "{\n" + " gl_FragColor = get_source() * get_mask();\n" + "}\n"; const char *in_ca_alpha = - GLAMOR_DEFAULT_PRECISION "void main()\n" "{\n" - " gl_FragColor = get_source().a * get_mask();\n" "}\n"; + GLAMOR_DEFAULT_PRECISION + "void main()\n" + "{\n" + " gl_FragColor = get_source().a * get_mask();\n" + "}\n"; char *source; const char *source_fetch; const char *mask_fetch = ""; @@ -258,7 +282,9 @@ glamor_create_composite_vs(glamor_gl_dispatch * dispatch, "attribute vec4 v_texcoord1;\n" "varying vec2 source_texture;\n" "varying vec2 mask_texture;\n" - "void main()\n" "{\n" " gl_Position = v_position;\n"; + "void main()\n" + "{\n" + " gl_Position = v_position;\n"; const char *source_coords = " source_texture = v_texcoord0.xy;\n"; const char *mask_coords = " mask_texture = v_texcoord1.xy;\n"; const char *main_closing = "}\n"; @@ -1165,7 +1191,7 @@ glamor_composite_choose_shader(CARD8 op, *shader = glamor_lookup_composite_shader(screen, &key); if ((*shader)->prog == 0) { - glamor_fallback("no shader program for this" "render acccel mode\n"); + glamor_fallback("no shader program for this render acccel mode\n"); goto fail; } diff --git a/glamor/glamor_tile.c b/glamor/glamor_tile.c index 00126532b..9c8e521b9 100644 --- a/glamor/glamor_tile.c +++ b/glamor/glamor_tile.c @@ -45,7 +45,8 @@ glamor_init_tile_shader(ScreenPtr screen) "void main()\n" "{\n" " gl_Position = v_position;\n" - " tile_texture = v_texcoord0.xy;\n" "}\n"; + " tile_texture = v_texcoord0.xy;\n" + "}\n"; const char *tile_fs = GLAMOR_DEFAULT_PRECISION "varying vec2 tile_texture;\n" @@ -56,7 +57,8 @@ glamor_init_tile_shader(ScreenPtr screen) " vec2 rel_tex;" " rel_tex = tile_texture * wh; \n" " rel_tex = floor(rel_tex) + (fract(rel_tex) / wh); \n" - " gl_FragColor = texture2D(sampler, rel_tex);\n" "}\n"; + " gl_FragColor = texture2D(sampler, rel_tex);\n" + "}\n"; GLint fs_prog, vs_prog; GLint sampler_uniform_location; diff --git a/glamor/glamor_trapezoid.c b/glamor/glamor_trapezoid.c index c7f7a62ec..2c66cea1b 100644 --- a/glamor/glamor_trapezoid.c +++ b/glamor/glamor_trapezoid.c @@ -1018,7 +1018,8 @@ glamor_init_trapezoid_shader(ScreenPtr screen) const char *trapezoid_vs = GLAMOR_DEFAULT_PRECISION - "attribute vec4 v_position;\n" "attribute vec2 v_texcoord;\n" + "attribute vec4 v_position;\n" + "attribute vec2 v_texcoord;\n" /* v_top_bottom, v_left_param and v_right_param contain the constant value for all the vertex of one rect. Using uniform is more suitable but we need to reset the uniform variables @@ -1056,7 +1057,8 @@ glamor_init_trapezoid_shader(ScreenPtr screen) " trap_right_x = v_right_param.x;\n" " trap_right_y = v_right_param.y;\n" " trap_right_slope = v_right_param.z;\n" - " trap_right_vertical_f = v_right_param.w;\n" "}\n"; + " trap_right_vertical_f = v_right_param.w;\n" + "}\n"; /* * Because some GL fill function do not support the MultSample @@ -1158,7 +1160,9 @@ glamor_init_trapezoid_shader(ScreenPtr screen) " || (x_up_cut_left > source_texture.x + x_per_pix/2.0 && \n" " x_bottom_cut_left > source_texture.x + x_per_pix/2.0)) { \n" // The complete outside. At Left or Right of the trapezoide. - " return 0.0; \n" " } \n" " } \n" + " return 0.0; \n" + " } \n" + " } \n" // Get here, the pix is partly inside the trapezoid. " { \n" " float percent = 0.0; \n" @@ -1336,7 +1340,8 @@ glamor_init_trapezoid_shader(ScreenPtr screen) "void main() \n" "{ \n" " float alpha_val = get_alpha_val(); \n" - " gl_FragColor = vec4(0.0, 0.0, 0.0, alpha_val); \n" "}\n"; + " gl_FragColor = vec4(0.0, 0.0, 0.0, alpha_val); \n" + "}\n"; glamor_priv = glamor_get_screen_private(screen); dispatch = glamor_get_dispatch(glamor_priv); diff --git a/glamor/glamor_xv.c b/glamor/glamor_xv.c index 237a27279..8e4c29221 100644 --- a/glamor/glamor_xv.c +++ b/glamor/glamor_xv.c @@ -58,8 +58,11 @@ typedef struct tagREF_TRANSFORM { static const char *xv_vs = "attribute vec4 v_position;\n" "attribute vec4 v_texcoord0;\n" "varying vec2 tcs;\n" - "void main()\n" "{\n" " gl_Position = v_position;\n" - "tcs = v_texcoord0.xy;\n" "}\n"; + "void main()\n" + "{\n" + " gl_Position = v_position;\n" + "tcs = v_texcoord0.xy;\n" + "}\n"; static const char *xv_ps = GLAMOR_DEFAULT_PRECISION "uniform sampler2D y_sampler;\n" @@ -71,14 +74,17 @@ static const char *xv_ps = GLAMOR_DEFAULT_PRECISION "varying vec2 tcs;\n" "float sample;\n" "vec4 temp1;\n" - "void main()\n" "{\n" + "void main()\n" + "{\n" "sample = texture2D(y_sampler, tcs).w;\n" "temp1.xyz = offsetyco.www * vec3(sample) + offsetyco.xyz;\n" "sample = texture2D(u_sampler, tcs).w;\n" "temp1.xyz = ucogamma.xyz * vec3(sample) + temp1.xyz;\n" "sample = texture2D(v_sampler, tcs).w;\n" "temp1.xyz = clamp(vco.xyz * vec3(sample) + temp1.xyz, 0.0, 1.0);\n" - "temp1.w = 1.0;\n" "gl_FragColor = temp1;\n" "}\n"; + "temp1.w = 1.0;\n" + "gl_FragColor = temp1;\n" + "}\n"; void glamor_init_xv_shader(ScreenPtr screen) |