OLD | NEW |
1 // Copyright 2011 The Chromium Authors. All rights reserved. | 1 // Copyright 2011 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "cc/output/shader.h" | 5 #include "cc/output/shader.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <vector> | 10 #include <vector> |
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
191 if (is_ya_uv_) { | 191 if (is_ya_uv_) { |
192 uniforms.push_back("yaTexScale"); | 192 uniforms.push_back("yaTexScale"); |
193 uniforms.push_back("yaTexOffset"); | 193 uniforms.push_back("yaTexOffset"); |
194 uniforms.push_back("uvTexScale"); | 194 uniforms.push_back("uvTexScale"); |
195 uniforms.push_back("uvTexOffset"); | 195 uniforms.push_back("uvTexOffset"); |
196 } | 196 } |
197 if (has_matrix_) | 197 if (has_matrix_) |
198 uniforms.push_back("matrix"); | 198 uniforms.push_back("matrix"); |
199 if (has_vertex_opacity_) | 199 if (has_vertex_opacity_) |
200 uniforms.push_back("opacity"); | 200 uniforms.push_back("opacity"); |
201 if (has_aa_) { | 201 if (aa_mode_ == USE_AA) { |
202 uniforms.push_back("viewport"); | 202 uniforms.push_back("viewport"); |
203 uniforms.push_back("edge"); | 203 uniforms.push_back("edge"); |
204 } | 204 } |
205 if (position_source_ == POSITION_SOURCE_ATTRIBUTE_INDEXED_UNIFORM) | 205 if (position_source_ == POSITION_SOURCE_ATTRIBUTE_INDEXED_UNIFORM) |
206 uniforms.push_back("quad"); | 206 uniforms.push_back("quad"); |
207 | 207 |
208 locations.resize(uniforms.size()); | 208 locations.resize(uniforms.size()); |
209 | 209 |
210 GetProgramUniformLocations(context, program, uniforms.size(), uniforms.data(), | 210 GetProgramUniformLocations(context, program, uniforms.size(), uniforms.data(), |
211 locations.data(), base_uniform_index); | 211 locations.data(), base_uniform_index); |
(...skipping 13 matching lines...) Expand all Loading... |
225 if (is_ya_uv_) { | 225 if (is_ya_uv_) { |
226 ya_tex_scale_location_ = locations[index++]; | 226 ya_tex_scale_location_ = locations[index++]; |
227 ya_tex_offset_location_ = locations[index++]; | 227 ya_tex_offset_location_ = locations[index++]; |
228 uv_tex_scale_location_ = locations[index++]; | 228 uv_tex_scale_location_ = locations[index++]; |
229 uv_tex_offset_location_ = locations[index++]; | 229 uv_tex_offset_location_ = locations[index++]; |
230 } | 230 } |
231 if (has_matrix_) | 231 if (has_matrix_) |
232 matrix_location_ = locations[index++]; | 232 matrix_location_ = locations[index++]; |
233 if (has_vertex_opacity_) | 233 if (has_vertex_opacity_) |
234 vertex_opacity_location_ = locations[index++]; | 234 vertex_opacity_location_ = locations[index++]; |
235 if (has_aa_) { | 235 if (aa_mode_ == USE_AA) { |
236 viewport_location_ = locations[index++]; | 236 viewport_location_ = locations[index++]; |
237 edge_location_ = locations[index++]; | 237 edge_location_ = locations[index++]; |
238 } | 238 } |
239 if (position_source_ == POSITION_SOURCE_ATTRIBUTE_INDEXED_UNIFORM) | 239 if (position_source_ == POSITION_SOURCE_ATTRIBUTE_INDEXED_UNIFORM) |
240 quad_location_ = locations[index++]; | 240 quad_location_ = locations[index++]; |
241 } | 241 } |
242 | 242 |
243 void VertexShaderBase::FillLocations(ShaderLocations* locations) const { | 243 void VertexShaderBase::FillLocations(ShaderLocations* locations) const { |
244 locations->quad = quad_location(); | 244 locations->quad = quad_location(); |
245 locations->edge = edge_location(); | 245 locations->edge = edge_location(); |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
291 SRC("gl_Position = matrix[quad_index] * pos;"); | 291 SRC("gl_Position = matrix[quad_index] * pos;"); |
292 } else { | 292 } else { |
293 HDR("uniform mat4 matrix;"); | 293 HDR("uniform mat4 matrix;"); |
294 SRC("gl_Position = matrix * pos;"); | 294 SRC("gl_Position = matrix * pos;"); |
295 } | 295 } |
296 } else { | 296 } else { |
297 SRC("gl_Position = pos;"); | 297 SRC("gl_Position = pos;"); |
298 } | 298 } |
299 | 299 |
300 // Compute the anti-aliasing edge distances. | 300 // Compute the anti-aliasing edge distances. |
301 if (has_aa_) { | 301 if (aa_mode_ == USE_AA) { |
302 HDR("uniform TexCoordPrecision vec3 edge[8];"); | 302 HDR("uniform TexCoordPrecision vec3 edge[8];"); |
303 HDR("uniform vec4 viewport;"); | 303 HDR("uniform vec4 viewport;"); |
304 HDR("varying TexCoordPrecision vec4 edge_dist[2]; // 8 edge distances."); | 304 HDR("varying TexCoordPrecision vec4 edge_dist[2]; // 8 edge distances."); |
305 SRC("// Compute anti-aliasing properties.\n"); | 305 SRC("// Compute anti-aliasing properties.\n"); |
306 SRC("vec2 ndc_pos = 0.5 * (1.0 + gl_Position.xy / gl_Position.w);"); | 306 SRC("vec2 ndc_pos = 0.5 * (1.0 + gl_Position.xy / gl_Position.w);"); |
307 SRC("vec3 screen_pos = vec3(viewport.xy + viewport.zw * ndc_pos, 1.0);"); | 307 SRC("vec3 screen_pos = vec3(viewport.xy + viewport.zw * ndc_pos, 1.0);"); |
308 SRC("edge_dist[0] = vec4(dot(edge[0], screen_pos),"); | 308 SRC("edge_dist[0] = vec4(dot(edge[0], screen_pos),"); |
309 SRC(" dot(edge[1], screen_pos),"); | 309 SRC(" dot(edge[1], screen_pos),"); |
310 SRC(" dot(edge[2], screen_pos),"); | 310 SRC(" dot(edge[2], screen_pos),"); |
311 SRC(" dot(edge[3], screen_pos)) * gl_Position.w;"); | 311 SRC(" dot(edge[3], screen_pos)) * gl_Position.w;"); |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
388 HDR("varying TexCoordPrecision vec2 dummy_varying;"); | 388 HDR("varying TexCoordPrecision vec2 dummy_varying;"); |
389 SRC("dummy_varying = dummy_uniform;"); | 389 SRC("dummy_varying = dummy_uniform;"); |
390 } | 390 } |
391 | 391 |
392 source += "}\n"; | 392 source += "}\n"; |
393 return header + source; | 393 return header + source; |
394 } | 394 } |
395 | 395 |
396 FragmentShaderBase::FragmentShaderBase() {} | 396 FragmentShaderBase::FragmentShaderBase() {} |
397 | 397 |
398 std::string FragmentShaderBase::GetShaderString(TexCoordPrecision precision, | 398 std::string FragmentShaderBase::GetShaderString() const { |
399 SamplerType sampler) const { | 399 TexCoordPrecision precision = tex_coord_precision_; |
400 // The AA shader values will use TexCoordPrecision. | 400 // The AA shader values will use TexCoordPrecision. |
401 if (has_aa_ && precision == TEX_COORD_PRECISION_NA) | 401 if (aa_mode_ == USE_AA && precision == TEX_COORD_PRECISION_NA) |
402 precision = TEX_COORD_PRECISION_MEDIUM; | 402 precision = TEX_COORD_PRECISION_MEDIUM; |
403 return SetFragmentTexCoordPrecision( | 403 return SetFragmentTexCoordPrecision( |
404 precision, SetFragmentSamplerType( | 404 precision, SetFragmentSamplerType( |
405 sampler, SetBlendModeFunctions(GetShaderSource()))); | 405 sampler_type_, SetBlendModeFunctions(GetShaderSource()))); |
406 } | 406 } |
407 | 407 |
408 void FragmentShaderBase::Init(GLES2Interface* context, | 408 void FragmentShaderBase::Init(GLES2Interface* context, |
409 unsigned program, | 409 unsigned program, |
410 int* base_uniform_index) { | 410 int* base_uniform_index) { |
411 std::vector<const char*> uniforms; | 411 std::vector<const char*> uniforms; |
412 std::vector<int> locations; | 412 std::vector<int> locations; |
413 if (has_blend_mode()) { | 413 if (has_blend_mode()) { |
414 uniforms.push_back("s_backdropTexture"); | 414 uniforms.push_back("s_backdropTexture"); |
415 uniforms.push_back("s_originalBackdropTexture"); | 415 uniforms.push_back("s_originalBackdropTexture"); |
416 uniforms.push_back("backdropRect"); | 416 uniforms.push_back("backdropRect"); |
417 } | 417 } |
418 if (has_mask_sampler_) { | 418 if (mask_mode_ != NO_MASK) { |
419 uniforms.push_back("s_mask"); | 419 uniforms.push_back("s_mask"); |
420 uniforms.push_back("maskTexCoordScale"); | 420 uniforms.push_back("maskTexCoordScale"); |
421 uniforms.push_back("maskTexCoordOffset"); | 421 uniforms.push_back("maskTexCoordOffset"); |
422 } | 422 } |
423 if (has_color_matrix_) { | 423 if (has_color_matrix_) { |
424 uniforms.push_back("colorMatrix"); | 424 uniforms.push_back("colorMatrix"); |
425 uniforms.push_back("colorOffset"); | 425 uniforms.push_back("colorOffset"); |
426 } | 426 } |
427 if (has_uniform_alpha_) | 427 if (has_uniform_alpha_) |
428 uniforms.push_back("alpha"); | 428 uniforms.push_back("alpha"); |
(...skipping 14 matching lines...) Expand all Loading... |
443 | 443 |
444 GetProgramUniformLocations(context, program, uniforms.size(), uniforms.data(), | 444 GetProgramUniformLocations(context, program, uniforms.size(), uniforms.data(), |
445 locations.data(), base_uniform_index); | 445 locations.data(), base_uniform_index); |
446 | 446 |
447 size_t index = 0; | 447 size_t index = 0; |
448 if (has_blend_mode()) { | 448 if (has_blend_mode()) { |
449 backdrop_location_ = locations[index++]; | 449 backdrop_location_ = locations[index++]; |
450 original_backdrop_location_ = locations[index++]; | 450 original_backdrop_location_ = locations[index++]; |
451 backdrop_rect_location_ = locations[index++]; | 451 backdrop_rect_location_ = locations[index++]; |
452 } | 452 } |
453 if (has_mask_sampler_) { | 453 if (mask_mode_ != NO_MASK) { |
454 mask_sampler_location_ = locations[index++]; | 454 mask_sampler_location_ = locations[index++]; |
455 mask_tex_coord_scale_location_ = locations[index++]; | 455 mask_tex_coord_scale_location_ = locations[index++]; |
456 mask_tex_coord_offset_location_ = locations[index++]; | 456 mask_tex_coord_offset_location_ = locations[index++]; |
457 } | 457 } |
458 if (has_color_matrix_) { | 458 if (has_color_matrix_) { |
459 color_matrix_location_ = locations[index++]; | 459 color_matrix_location_ = locations[index++]; |
460 color_offset_location_ = locations[index++]; | 460 color_offset_location_ = locations[index++]; |
461 } | 461 } |
462 if (has_uniform_alpha_) | 462 if (has_uniform_alpha_) |
463 alpha_location_ = locations[index++]; | 463 alpha_location_ = locations[index++]; |
(...skipping 10 matching lines...) Expand all Loading... |
474 break; | 474 break; |
475 } | 475 } |
476 DCHECK_EQ(index, locations.size()); | 476 DCHECK_EQ(index, locations.size()); |
477 } | 477 } |
478 | 478 |
479 void FragmentShaderBase::FillLocations(ShaderLocations* locations) const { | 479 void FragmentShaderBase::FillLocations(ShaderLocations* locations) const { |
480 if (has_blend_mode()) { | 480 if (has_blend_mode()) { |
481 locations->backdrop = backdrop_location_; | 481 locations->backdrop = backdrop_location_; |
482 locations->backdrop_rect = backdrop_rect_location_; | 482 locations->backdrop_rect = backdrop_rect_location_; |
483 } | 483 } |
484 if (mask_for_background()) | 484 if (mask_for_background_) |
485 locations->original_backdrop = original_backdrop_location_; | 485 locations->original_backdrop = original_backdrop_location_; |
486 if (has_mask_sampler_) { | 486 if (mask_mode_ != NO_MASK) { |
487 locations->mask_sampler = mask_sampler_location_; | 487 locations->mask_sampler = mask_sampler_location_; |
488 locations->mask_tex_coord_scale = mask_tex_coord_scale_location_; | 488 locations->mask_tex_coord_scale = mask_tex_coord_scale_location_; |
489 locations->mask_tex_coord_offset = mask_tex_coord_offset_location_; | 489 locations->mask_tex_coord_offset = mask_tex_coord_offset_location_; |
490 } | 490 } |
491 if (has_color_matrix_) { | 491 if (has_color_matrix_) { |
492 locations->color_matrix = color_matrix_location_; | 492 locations->color_matrix = color_matrix_location_; |
493 locations->color_offset = color_offset_location_; | 493 locations->color_offset = color_offset_location_; |
494 } | 494 } |
495 if (has_uniform_alpha_) | 495 if (has_uniform_alpha_) |
496 locations->alpha = alpha_location_; | 496 locations->alpha = alpha_location_; |
(...skipping 15 matching lines...) Expand all Loading... |
512 return "#define ApplyBlendMode(X, Y) (X)\n" + shader_string; | 512 return "#define ApplyBlendMode(X, Y) (X)\n" + shader_string; |
513 } | 513 } |
514 | 514 |
515 static const std::string kUniforms = SHADER0([]() { | 515 static const std::string kUniforms = SHADER0([]() { |
516 uniform sampler2D s_backdropTexture; | 516 uniform sampler2D s_backdropTexture; |
517 uniform sampler2D s_originalBackdropTexture; | 517 uniform sampler2D s_originalBackdropTexture; |
518 uniform TexCoordPrecision vec4 backdropRect; | 518 uniform TexCoordPrecision vec4 backdropRect; |
519 }); | 519 }); |
520 | 520 |
521 std::string mixFunction; | 521 std::string mixFunction; |
522 if (mask_for_background()) { | 522 if (mask_for_background_) { |
523 mixFunction = SHADER0([]() { | 523 mixFunction = SHADER0([]() { |
524 vec4 MixBackdrop(TexCoordPrecision vec2 bgTexCoord, float mask) { | 524 vec4 MixBackdrop(TexCoordPrecision vec2 bgTexCoord, float mask) { |
525 vec4 backdrop = texture2D(s_backdropTexture, bgTexCoord); | 525 vec4 backdrop = texture2D(s_backdropTexture, bgTexCoord); |
526 vec4 original_backdrop = | 526 vec4 original_backdrop = |
527 texture2D(s_originalBackdropTexture, bgTexCoord); | 527 texture2D(s_originalBackdropTexture, bgTexCoord); |
528 return mix(original_backdrop, backdrop, mask); | 528 return mix(original_backdrop, backdrop, mask); |
529 } | 529 } |
530 }); | 530 }); |
531 } else { | 531 } else { |
532 mixFunction = SHADER0([]() { | 532 mixFunction = SHADER0([]() { |
(...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
840 HDR("uniform vec4 colorOffset;"); | 840 HDR("uniform vec4 colorOffset;"); |
841 SRC("// Apply color matrix"); | 841 SRC("// Apply color matrix"); |
842 SRC("float nonZeroAlpha = max(texColor.a, 0.00001);"); | 842 SRC("float nonZeroAlpha = max(texColor.a, 0.00001);"); |
843 SRC("texColor = vec4(texColor.rgb / nonZeroAlpha, nonZeroAlpha);"); | 843 SRC("texColor = vec4(texColor.rgb / nonZeroAlpha, nonZeroAlpha);"); |
844 SRC("texColor = colorMatrix * texColor + colorOffset;"); | 844 SRC("texColor = colorMatrix * texColor + colorOffset;"); |
845 SRC("texColor.rgb *= texColor.a;"); | 845 SRC("texColor.rgb *= texColor.a;"); |
846 SRC("texColor = clamp(texColor, 0.0, 1.0);"); | 846 SRC("texColor = clamp(texColor, 0.0, 1.0);"); |
847 } | 847 } |
848 | 848 |
849 // Read the mask texture. | 849 // Read the mask texture. |
850 if (has_mask_sampler_) { | 850 if (mask_mode_ != NO_MASK) { |
851 HDR("uniform SamplerType s_mask;"); | 851 HDR("uniform SamplerType s_mask;"); |
852 HDR("uniform vec2 maskTexCoordScale;"); | 852 HDR("uniform vec2 maskTexCoordScale;"); |
853 HDR("uniform vec2 maskTexCoordOffset;"); | 853 HDR("uniform vec2 maskTexCoordOffset;"); |
854 SRC("// Read the mask"); | 854 SRC("// Read the mask"); |
855 SRC("TexCoordPrecision vec2 maskTexCoord ="); | 855 SRC("TexCoordPrecision vec2 maskTexCoord ="); |
856 SRC(" vec2(maskTexCoordOffset.x + v_texCoord.x * maskTexCoordScale.x,"); | 856 SRC(" vec2(maskTexCoordOffset.x + v_texCoord.x * maskTexCoordScale.x,"); |
857 SRC(" maskTexCoordOffset.y + v_texCoord.y * maskTexCoordScale.y);"); | 857 SRC(" maskTexCoordOffset.y + v_texCoord.y * maskTexCoordScale.y);"); |
858 SRC("vec4 maskColor = TextureLookup(s_mask, maskTexCoord);"); | 858 SRC("vec4 maskColor = TextureLookup(s_mask, maskTexCoord);"); |
859 } | 859 } |
860 | 860 |
861 // Compute AA. | 861 // Compute AA. |
862 if (has_aa_) { | 862 if (aa_mode_ == USE_AA) { |
863 HDR("varying TexCoordPrecision vec4 edge_dist[2]; // 8 edge distances."); | 863 HDR("varying TexCoordPrecision vec4 edge_dist[2]; // 8 edge distances."); |
864 SRC("// Compute AA"); | 864 SRC("// Compute AA"); |
865 SRC("vec4 d4 = min(edge_dist[0], edge_dist[1]);"); | 865 SRC("vec4 d4 = min(edge_dist[0], edge_dist[1]);"); |
866 SRC("vec2 d2 = min(d4.xz, d4.yw);"); | 866 SRC("vec2 d2 = min(d4.xz, d4.yw);"); |
867 SRC("float aa = clamp(gl_FragCoord.w * min(d2.x, d2.y), 0.0, 1.0);"); | 867 SRC("float aa = clamp(gl_FragCoord.w * min(d2.x, d2.y), 0.0, 1.0);"); |
868 } | 868 } |
869 | 869 |
870 // Premultiply by alpha. | 870 // Premultiply by alpha. |
871 if (has_premultiply_alpha_) { | 871 if (premultiply_alpha_mode_ == NON_PREMULTIPLIED_ALPHA) { |
872 SRC("// Premultiply alpha"); | 872 SRC("// Premultiply alpha"); |
873 SRC("texColor.rgb *= texColor.a;"); | 873 SRC("texColor.rgb *= texColor.a;"); |
874 } | 874 } |
875 | 875 |
876 // Apply background texture. | 876 // Apply background texture. |
877 if (has_background_color_) { | 877 if (has_background_color_) { |
878 HDR("uniform vec4 background_color;"); | 878 HDR("uniform vec4 background_color;"); |
879 SRC("// Apply uniform background color blending"); | 879 SRC("// Apply uniform background color blending"); |
880 SRC("texColor += background_color * (1.0 - texColor.a);"); | 880 SRC("texColor += background_color * (1.0 - texColor.a);"); |
881 } | 881 } |
882 | 882 |
883 // Apply swizzle. | 883 // Apply swizzle. |
884 if (has_swizzle_) { | 884 if (swizzle_mode_ == DO_SWIZZLE) { |
885 SRC("// Apply swizzle"); | 885 SRC("// Apply swizzle"); |
886 SRC("texColor = texColor.bgra;\n"); | 886 SRC("texColor = texColor.bgra;\n"); |
887 } | 887 } |
888 | 888 |
889 // Include header text for alpha. | 889 // Include header text for alpha. |
890 if (has_uniform_alpha_) { | 890 if (has_uniform_alpha_) { |
891 HDR("uniform float alpha;"); | 891 HDR("uniform float alpha;"); |
892 } | 892 } |
893 if (has_varying_alpha_) { | 893 if (has_varying_alpha_) { |
894 HDR("varying float v_alpha;"); | 894 HDR("varying float v_alpha;"); |
895 } | 895 } |
896 | 896 |
897 // Apply uniform alpha, aa, varying alpha, and the mask. | 897 // Apply uniform alpha, aa, varying alpha, and the mask. |
898 if (has_varying_alpha_ || has_aa_ || has_uniform_alpha_ || | 898 if (has_varying_alpha_ || aa_mode_ == USE_AA || has_uniform_alpha_ || |
899 has_mask_sampler_) { | 899 mask_mode_ != NO_MASK) { |
900 SRC("// Apply alpha from uniform, varying, aa, and mask."); | 900 SRC("// Apply alpha from uniform, varying, aa, and mask."); |
901 std::string line = " texColor = texColor"; | 901 std::string line = " texColor = texColor"; |
902 if (has_varying_alpha_) | 902 if (has_varying_alpha_) |
903 line += " * v_alpha"; | 903 line += " * v_alpha"; |
904 if (has_uniform_alpha_) | 904 if (has_uniform_alpha_) |
905 line += " * alpha"; | 905 line += " * alpha"; |
906 if (has_aa_) | 906 if (aa_mode_ == USE_AA) |
907 line += " * aa"; | 907 line += " * aa"; |
908 if (has_mask_sampler_) | 908 if (mask_mode_ != NO_MASK) |
909 line += " * maskColor.a"; | 909 line += " * maskColor.a"; |
910 line += ";\n"; | 910 line += ";\n"; |
911 source += line; | 911 source += line; |
912 } | 912 } |
913 | 913 |
914 // Write the fragment color. | 914 // Write the fragment color. |
915 SRC("// Write the fragment color"); | 915 SRC("// Write the fragment color"); |
916 switch (frag_color_mode_) { | 916 switch (frag_color_mode_) { |
917 case FRAG_COLOR_MODE_DEFAULT: | 917 case FRAG_COLOR_MODE_DEFAULT: |
918 DCHECK_EQ(blend_mode_, BLEND_MODE_NONE); | 918 DCHECK_EQ(blend_mode_, BLEND_MODE_NONE); |
919 SRC("gl_FragColor = texColor;"); | 919 SRC("gl_FragColor = texColor;"); |
920 break; | 920 break; |
921 case FRAG_COLOR_MODE_OPAQUE: | 921 case FRAG_COLOR_MODE_OPAQUE: |
922 DCHECK_EQ(blend_mode_, BLEND_MODE_NONE); | 922 DCHECK_EQ(blend_mode_, BLEND_MODE_NONE); |
923 SRC("gl_FragColor = vec4(texColor.rgb, 1.0);"); | 923 SRC("gl_FragColor = vec4(texColor.rgb, 1.0);"); |
924 break; | 924 break; |
925 case FRAG_COLOR_MODE_APPLY_BLEND_MODE: | 925 case FRAG_COLOR_MODE_APPLY_BLEND_MODE: |
926 if (has_mask_sampler_) | 926 if (mask_mode_ != NO_MASK) |
927 SRC("gl_FragColor = ApplyBlendMode(texColor, maskColor.w);"); | 927 SRC("gl_FragColor = ApplyBlendMode(texColor, maskColor.w);"); |
928 else | 928 else |
929 SRC("gl_FragColor = ApplyBlendMode(texColor, 0.0);"); | 929 SRC("gl_FragColor = ApplyBlendMode(texColor, 0.0);"); |
930 break; | 930 break; |
931 } | 931 } |
932 source += "}\n"; | 932 source += "}\n"; |
933 | 933 |
934 return header + source; | 934 return header + source; |
935 } | 935 } |
936 | 936 |
937 FragmentShaderYUVVideo::FragmentShaderYUVVideo() {} | 937 FragmentShaderYUVVideo::FragmentShaderYUVVideo() {} |
938 | 938 |
939 void FragmentShaderYUVVideo::SetFeatures(bool use_alpha_texture, | |
940 bool use_nv12, | |
941 bool use_color_lut) { | |
942 use_alpha_texture_ = use_alpha_texture; | |
943 use_nv12_ = use_nv12; | |
944 use_color_lut_ = use_color_lut; | |
945 } | |
946 | |
947 void FragmentShaderYUVVideo::Init(GLES2Interface* context, | 939 void FragmentShaderYUVVideo::Init(GLES2Interface* context, |
948 unsigned program, | 940 unsigned program, |
949 int* base_uniform_index) { | 941 int* base_uniform_index) { |
950 static const char* uniforms[] = { | 942 static const char* uniforms[] = { |
951 "y_texture", | 943 "y_texture", |
952 "u_texture", | 944 "u_texture", |
953 "v_texture", | 945 "v_texture", |
954 "uv_texture", | 946 "uv_texture", |
955 "a_texture", | 947 "a_texture", |
956 "lut_texture", | 948 "lut_texture", |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1077 max(uv_clamp_rect.xy, min(uv_clamp_rect.zw, v_uvTexCoord)); | 1069 max(uv_clamp_rect.xy, min(uv_clamp_rect.zw, v_uvTexCoord)); |
1078 vec3 yuv = vec3(y_raw, GetUV(uv_clamped)); | 1070 vec3 yuv = vec3(y_raw, GetUV(uv_clamped)); |
1079 gl_FragColor = vec4(yuv2rgb(yuv), 1.0) * GetAlpha(ya_clamped); | 1071 gl_FragColor = vec4(yuv2rgb(yuv), 1.0) * GetAlpha(ya_clamped); |
1080 } | 1072 } |
1081 }); | 1073 }); |
1082 | 1074 |
1083 return head + functions; | 1075 return head + functions; |
1084 } | 1076 } |
1085 | 1077 |
1086 } // namespace cc | 1078 } // namespace cc |
OLD | NEW |