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 369 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
380 | 380 |
381 source += "}\n"; | 381 source += "}\n"; |
382 return header + source; | 382 return header + source; |
383 } | 383 } |
384 | 384 |
385 FragmentShader::FragmentShader() {} | 385 FragmentShader::FragmentShader() {} |
386 | 386 |
387 std::string FragmentShader::GetShaderString() const { | 387 std::string FragmentShader::GetShaderString() const { |
388 // TODO(ccameron): Merge YUV shaders into the main shader generator. | 388 // TODO(ccameron): Merge YUV shaders into the main shader generator. |
389 std::string source; | 389 std::string source; |
390 if (input_color_type_ == INPUT_COLOR_SOURCE_YUV_TEXTURES) | 390 if (color_conversion_mode_ == COLOR_CONVERSION_MODE_2D_LUT_AS_3D_FROM_YUV) |
391 source = GetShaderStringYUVVideo(); | 391 source = GetShaderStringYUVVideo(); |
392 else | 392 else |
393 source = GetShaderSource(); | 393 source = GetShaderSource(); |
394 | 394 |
395 TexCoordPrecision precision = tex_coord_precision_; | 395 TexCoordPrecision precision = tex_coord_precision_; |
396 // The AA shader values will use TexCoordPrecision. | 396 // The AA shader values will use TexCoordPrecision. |
397 if (aa_mode_ == USE_AA && precision == TEX_COORD_PRECISION_NA) | 397 if (aa_mode_ == USE_AA && precision == TEX_COORD_PRECISION_NA) |
398 precision = TEX_COORD_PRECISION_MEDIUM; | 398 precision = TEX_COORD_PRECISION_MEDIUM; |
399 return SetFragmentTexCoordPrecision( | 399 return SetFragmentTexCoordPrecision( |
400 precision, | 400 precision, |
401 SetFragmentSamplerType(sampler_type_, SetBlendModeFunctions(source))); | 401 SetFragmentSamplerType(sampler_type_, SetBlendModeFunctions(source))); |
402 } | 402 } |
403 | 403 |
404 void FragmentShader::Init(GLES2Interface* context, | 404 void FragmentShader::Init(GLES2Interface* context, |
405 unsigned program, | 405 unsigned program, |
406 int* base_uniform_index) { | 406 int* base_uniform_index) { |
407 // TODO(ccameron): Merge YUV shaders into the main shader generator. | 407 // TODO(ccameron): Merge YUV shaders into the main shader generator. |
408 if (input_color_type_ == INPUT_COLOR_SOURCE_YUV_TEXTURES) { | 408 if (color_conversion_mode_ == COLOR_CONVERSION_MODE_2D_LUT_AS_3D_FROM_YUV) { |
409 InitYUVVideo(context, program, base_uniform_index); | 409 InitYUVVideo(context, program, base_uniform_index); |
410 return; | 410 return; |
411 } | 411 } |
412 | 412 |
413 std::vector<const char*> uniforms; | 413 std::vector<const char*> uniforms; |
414 std::vector<int> locations; | 414 std::vector<int> locations; |
415 if (has_blend_mode()) { | 415 if (has_blend_mode()) { |
416 uniforms.push_back("s_backdropTexture"); | 416 uniforms.push_back("s_backdropTexture"); |
417 uniforms.push_back("s_originalBackdropTexture"); | 417 uniforms.push_back("s_originalBackdropTexture"); |
418 uniforms.push_back("backdropRect"); | 418 uniforms.push_back("backdropRect"); |
(...skipping 11 matching lines...) Expand all Loading... |
430 uniforms.push_back("alpha"); | 430 uniforms.push_back("alpha"); |
431 if (has_background_color_) | 431 if (has_background_color_) |
432 uniforms.push_back("background_color"); | 432 uniforms.push_back("background_color"); |
433 switch (input_color_type_) { | 433 switch (input_color_type_) { |
434 case INPUT_COLOR_SOURCE_RGBA_TEXTURE: | 434 case INPUT_COLOR_SOURCE_RGBA_TEXTURE: |
435 uniforms.push_back("s_texture"); | 435 uniforms.push_back("s_texture"); |
436 if (has_rgba_fragment_tex_transform_) | 436 if (has_rgba_fragment_tex_transform_) |
437 uniforms.push_back("fragmentTexTransform"); | 437 uniforms.push_back("fragmentTexTransform"); |
438 break; | 438 break; |
439 case INPUT_COLOR_SOURCE_YUV_TEXTURES: | 439 case INPUT_COLOR_SOURCE_YUV_TEXTURES: |
440 NOTREACHED(); | 440 uniforms.push_back("y_texture"); |
| 441 if (uv_texture_mode_ == UV_TEXTURE_MODE_UV) |
| 442 uniforms.push_back("uv_texture"); |
| 443 if (uv_texture_mode_ == UV_TEXTURE_MODE_U_V) { |
| 444 uniforms.push_back("u_texture"); |
| 445 uniforms.push_back("v_texture"); |
| 446 } |
| 447 if (yuv_alpha_texture_mode_ == YUV_HAS_ALPHA_TEXTURE) |
| 448 uniforms.push_back("a_texture"); |
| 449 uniforms.push_back("ya_clamp_rect"); |
| 450 uniforms.push_back("uv_clamp_rect"); |
| 451 uniforms.push_back("yuv_matrix"); |
| 452 uniforms.push_back("yuv_adj"); |
441 break; | 453 break; |
442 case INPUT_COLOR_SOURCE_UNIFORM: | 454 case INPUT_COLOR_SOURCE_UNIFORM: |
443 uniforms.push_back("color"); | 455 uniforms.push_back("color"); |
444 break; | 456 break; |
445 } | 457 } |
446 | 458 |
447 locations.resize(uniforms.size()); | 459 locations.resize(uniforms.size()); |
448 | 460 |
449 GetProgramUniformLocations(context, program, uniforms.size(), uniforms.data(), | 461 GetProgramUniformLocations(context, program, uniforms.size(), uniforms.data(), |
450 locations.data(), base_uniform_index); | 462 locations.data(), base_uniform_index); |
(...skipping 17 matching lines...) Expand all Loading... |
468 alpha_location_ = locations[index++]; | 480 alpha_location_ = locations[index++]; |
469 if (has_background_color_) | 481 if (has_background_color_) |
470 background_color_location_ = locations[index++]; | 482 background_color_location_ = locations[index++]; |
471 switch (input_color_type_) { | 483 switch (input_color_type_) { |
472 case INPUT_COLOR_SOURCE_RGBA_TEXTURE: | 484 case INPUT_COLOR_SOURCE_RGBA_TEXTURE: |
473 sampler_location_ = locations[index++]; | 485 sampler_location_ = locations[index++]; |
474 if (has_rgba_fragment_tex_transform_) | 486 if (has_rgba_fragment_tex_transform_) |
475 fragment_tex_transform_location_ = locations[index++]; | 487 fragment_tex_transform_location_ = locations[index++]; |
476 break; | 488 break; |
477 case INPUT_COLOR_SOURCE_YUV_TEXTURES: | 489 case INPUT_COLOR_SOURCE_YUV_TEXTURES: |
478 NOTREACHED(); | 490 y_texture_location_ = locations[index++]; |
| 491 if (uv_texture_mode_ == UV_TEXTURE_MODE_UV) |
| 492 uv_texture_location_ = locations[index++]; |
| 493 if (uv_texture_mode_ == UV_TEXTURE_MODE_U_V) { |
| 494 u_texture_location_ = locations[index++]; |
| 495 v_texture_location_ = locations[index++]; |
| 496 } |
| 497 if (yuv_alpha_texture_mode_ == YUV_HAS_ALPHA_TEXTURE) |
| 498 a_texture_location_ = locations[index++]; |
| 499 ya_clamp_rect_location_ = locations[index++]; |
| 500 uv_clamp_rect_location_ = locations[index++]; |
| 501 yuv_matrix_location_ = locations[index++]; |
| 502 yuv_adj_location_ = locations[index++]; |
479 break; | 503 break; |
480 case INPUT_COLOR_SOURCE_UNIFORM: | 504 case INPUT_COLOR_SOURCE_UNIFORM: |
481 color_location_ = locations[index++]; | 505 color_location_ = locations[index++]; |
482 break; | 506 break; |
483 } | 507 } |
484 DCHECK_EQ(index, locations.size()); | 508 DCHECK_EQ(index, locations.size()); |
485 } | 509 } |
486 | 510 |
487 std::string FragmentShader::SetBlendModeFunctions( | 511 std::string FragmentShader::SetBlendModeFunctions( |
488 const std::string& shader_string) const { | 512 const std::string& shader_string) const { |
(...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
801 DCHECK(!ignore_sampler_type_); | 825 DCHECK(!ignore_sampler_type_); |
802 } else { | 826 } else { |
803 SRC("// Texture lookup"); | 827 SRC("// Texture lookup"); |
804 if (ignore_sampler_type_) | 828 if (ignore_sampler_type_) |
805 SRC("vec4 texColor = texture2D(s_texture, v_texCoord);"); | 829 SRC("vec4 texColor = texture2D(s_texture, v_texCoord);"); |
806 else | 830 else |
807 SRC("vec4 texColor = TextureLookup(s_texture, v_texCoord);"); | 831 SRC("vec4 texColor = TextureLookup(s_texture, v_texCoord);"); |
808 } | 832 } |
809 break; | 833 break; |
810 case INPUT_COLOR_SOURCE_YUV_TEXTURES: | 834 case INPUT_COLOR_SOURCE_YUV_TEXTURES: |
811 NOTREACHED(); | 835 HDR("uniform SamplerType y_texture;"); |
| 836 SRC("vec2 ya_clamped ="); |
| 837 SRC(" max(ya_clamp_rect.xy, min(ya_clamp_rect.zw, v_yaTexCoord));"); |
| 838 SRC("vec2 uv_clamped ="); |
| 839 SRC(" max(uv_clamp_rect.xy, min(uv_clamp_rect.zw, v_uvTexCoord));"); |
| 840 SRC("vec3 yuv;"); |
| 841 SRC("yuv.x = TextureLookup(y_texture, ya_clamped).x;"); |
| 842 if (uv_texture_mode_ == UV_TEXTURE_MODE_UV) { |
| 843 HDR("uniform SamplerType uv_texture;"); |
| 844 SRC("yuv.yz = TextureLookup(uv_texture, uv_clamped).xy;"); |
| 845 } |
| 846 if (uv_texture_mode_ == UV_TEXTURE_MODE_U_V) { |
| 847 HDR("uniform SamplerType u_texture;"); |
| 848 HDR("uniform SamplerType v_texture;"); |
| 849 SRC("yuv.y = TextureLookup(u_texture, uv_clamped).x;"); |
| 850 SRC("yuv.z = TextureLookup(v_texture, uv_clamped).x;"); |
| 851 } |
| 852 if (yuv_alpha_texture_mode_ == YUV_HAS_ALPHA_TEXTURE) |
| 853 HDR("uniform SamplerType a_texture;"); |
| 854 HDR("uniform vec4 ya_clamp_rect;"); |
| 855 HDR("uniform vec4 uv_clamp_rect;"); |
| 856 HDR("uniform mat3 yuv_matrix;"); |
| 857 HDR("uniform vec3 yuv_adj;"); |
| 858 HDR("varying TexCoordPrecision vec2 v_yaTexCoord;"); |
| 859 HDR("varying TexCoordPrecision vec2 v_uvTexCoord;"); |
| 860 SRC("vec4 texColor = vec4(yuv_matrix * (yuv + yuv_adj), 1.0);"); |
812 break; | 861 break; |
813 case INPUT_COLOR_SOURCE_UNIFORM: | 862 case INPUT_COLOR_SOURCE_UNIFORM: |
814 DCHECK(!ignore_sampler_type_); | 863 DCHECK(!ignore_sampler_type_); |
815 DCHECK(!has_rgba_fragment_tex_transform_); | 864 DCHECK(!has_rgba_fragment_tex_transform_); |
816 HDR("uniform vec4 color;"); | 865 HDR("uniform vec4 color;"); |
817 SRC("// Uniform color"); | 866 SRC("// Uniform color"); |
818 SRC("vec4 texColor = color;"); | 867 SRC("vec4 texColor = color;"); |
819 break; | 868 break; |
820 } | 869 } |
821 // Apply the color matrix to texColor. | 870 // Apply the color matrix to texColor. |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
884 SRC("// Apply alpha from uniform, varying, aa, and mask."); | 933 SRC("// Apply alpha from uniform, varying, aa, and mask."); |
885 std::string line = " texColor = texColor"; | 934 std::string line = " texColor = texColor"; |
886 if (has_varying_alpha_) | 935 if (has_varying_alpha_) |
887 line += " * v_alpha"; | 936 line += " * v_alpha"; |
888 if (has_uniform_alpha_) | 937 if (has_uniform_alpha_) |
889 line += " * alpha"; | 938 line += " * alpha"; |
890 if (aa_mode_ == USE_AA) | 939 if (aa_mode_ == USE_AA) |
891 line += " * aa"; | 940 line += " * aa"; |
892 if (mask_mode_ != NO_MASK) | 941 if (mask_mode_ != NO_MASK) |
893 line += " * maskColor.a"; | 942 line += " * maskColor.a"; |
| 943 if (yuv_alpha_texture_mode_ == YUV_HAS_ALPHA_TEXTURE) |
| 944 line += " * TextureLookup(a_texture, ya_clamped).x"; |
894 line += ";\n"; | 945 line += ";\n"; |
895 source += line; | 946 source += line; |
896 } | 947 } |
897 | 948 |
898 // Write the fragment color. | 949 // Write the fragment color. |
899 SRC("// Write the fragment color"); | 950 SRC("// Write the fragment color"); |
900 switch (frag_color_mode_) { | 951 switch (frag_color_mode_) { |
901 case FRAG_COLOR_MODE_DEFAULT: | 952 case FRAG_COLOR_MODE_DEFAULT: |
902 DCHECK_EQ(blend_mode_, BLEND_MODE_NONE); | 953 DCHECK_EQ(blend_mode_, BLEND_MODE_NONE); |
903 SRC("gl_FragColor = texColor;"); | 954 SRC("gl_FragColor = texColor;"); |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
938 }; | 989 }; |
939 int locations[arraysize(uniforms)]; | 990 int locations[arraysize(uniforms)]; |
940 | 991 |
941 GetProgramUniformLocations(context, | 992 GetProgramUniformLocations(context, |
942 program, | 993 program, |
943 arraysize(uniforms), | 994 arraysize(uniforms), |
944 uniforms, | 995 uniforms, |
945 locations, | 996 locations, |
946 base_uniform_index); | 997 base_uniform_index); |
947 y_texture_location_ = locations[0]; | 998 y_texture_location_ = locations[0]; |
948 if (!use_nv12_) { | 999 if (uv_texture_mode_ == UV_TEXTURE_MODE_U_V) { |
949 u_texture_location_ = locations[1]; | 1000 u_texture_location_ = locations[1]; |
950 v_texture_location_ = locations[2]; | 1001 v_texture_location_ = locations[2]; |
951 } else { | 1002 } |
| 1003 if (uv_texture_mode_ == UV_TEXTURE_MODE_UV) { |
952 uv_texture_location_ = locations[3]; | 1004 uv_texture_location_ = locations[3]; |
953 } | 1005 } |
954 if (use_alpha_texture_) { | 1006 if (yuv_alpha_texture_mode_ == YUV_HAS_ALPHA_TEXTURE) { |
955 a_texture_location_ = locations[4]; | 1007 a_texture_location_ = locations[4]; |
956 } | 1008 } |
957 if (use_color_lut_) { | 1009 if (color_conversion_mode_ == COLOR_CONVERSION_MODE_2D_LUT_AS_3D_FROM_YUV) { |
958 lut_texture_location_ = locations[5]; | 1010 lut_texture_location_ = locations[5]; |
959 resource_multiplier_location_ = locations[6]; | 1011 resource_multiplier_location_ = locations[6]; |
960 resource_offset_location_ = locations[7]; | 1012 resource_offset_location_ = locations[7]; |
961 } else { | 1013 } |
| 1014 if (color_conversion_mode_ == COLOR_CONVERSION_MODE_NONE) { |
962 yuv_matrix_location_ = locations[8]; | 1015 yuv_matrix_location_ = locations[8]; |
963 yuv_adj_location_ = locations[9]; | 1016 yuv_adj_location_ = locations[9]; |
964 } | 1017 } |
965 alpha_location_ = locations[10]; | 1018 alpha_location_ = locations[10]; |
966 ya_clamp_rect_location_ = locations[11]; | 1019 ya_clamp_rect_location_ = locations[11]; |
967 uv_clamp_rect_location_ = locations[12]; | 1020 uv_clamp_rect_location_ = locations[12]; |
968 } | 1021 } |
969 | 1022 |
970 std::string FragmentShader::GetShaderStringYUVVideo() const { | 1023 std::string FragmentShader::GetShaderStringYUVVideo() const { |
971 std::string head = SHADER0([]() { | 1024 std::string head = SHADER0([]() { |
972 precision mediump float; | 1025 precision mediump float; |
973 precision mediump int; | 1026 precision mediump int; |
974 varying TexCoordPrecision vec2 v_yaTexCoord; | 1027 varying TexCoordPrecision vec2 v_yaTexCoord; |
975 varying TexCoordPrecision vec2 v_uvTexCoord; | 1028 varying TexCoordPrecision vec2 v_uvTexCoord; |
976 uniform SamplerType y_texture; | 1029 uniform SamplerType y_texture; |
977 uniform float alpha; | 1030 uniform float alpha; |
978 uniform vec4 ya_clamp_rect; | 1031 uniform vec4 ya_clamp_rect; |
979 uniform vec4 uv_clamp_rect; | 1032 uniform vec4 uv_clamp_rect; |
980 }); | 1033 }); |
981 | 1034 |
982 std::string functions = ""; | 1035 std::string functions = ""; |
983 if (use_nv12_) { | 1036 if (uv_texture_mode_ == UV_TEXTURE_MODE_UV) { |
984 head += " uniform SamplerType uv_texture;\n"; | 1037 head += " uniform SamplerType uv_texture;\n"; |
985 functions += SHADER0([]() { | 1038 functions += SHADER0([]() { |
986 vec2 GetUV(vec2 uv_clamped) { | 1039 vec2 GetUV(vec2 uv_clamped) { |
987 return TextureLookup(uv_texture, uv_clamped).xy; | 1040 return TextureLookup(uv_texture, uv_clamped).xy; |
988 } | 1041 } |
989 }); | 1042 }); |
990 } else { | 1043 } |
| 1044 if (uv_texture_mode_ == UV_TEXTURE_MODE_U_V) { |
991 head += " uniform SamplerType u_texture;\n"; | 1045 head += " uniform SamplerType u_texture;\n"; |
992 head += " uniform SamplerType v_texture;\n"; | 1046 head += " uniform SamplerType v_texture;\n"; |
993 functions += SHADER0([]() { | 1047 functions += SHADER0([]() { |
994 vec2 GetUV(vec2 uv_clamped) { | 1048 vec2 GetUV(vec2 uv_clamped) { |
995 return vec2(TextureLookup(u_texture, uv_clamped).x, | 1049 return vec2(TextureLookup(u_texture, uv_clamped).x, |
996 TextureLookup(v_texture, uv_clamped).x); | 1050 TextureLookup(v_texture, uv_clamped).x); |
997 } | 1051 } |
998 }); | 1052 }); |
999 } | 1053 } |
1000 | 1054 |
1001 if (use_alpha_texture_) { | 1055 if (yuv_alpha_texture_mode_ == YUV_HAS_ALPHA_TEXTURE) { |
1002 head += " uniform SamplerType a_texture;\n"; | 1056 head += " uniform SamplerType a_texture;\n"; |
1003 functions += SHADER0([]() { | 1057 functions += SHADER0([]() { |
1004 float GetAlpha(vec2 ya_clamped) { | 1058 float GetAlpha(vec2 ya_clamped) { |
1005 return alpha * TextureLookup(a_texture, ya_clamped).x; | 1059 return alpha * TextureLookup(a_texture, ya_clamped).x; |
1006 } | 1060 } |
1007 }); | 1061 }); |
1008 } else { | 1062 } else { |
1009 functions += SHADER0([]() { | 1063 functions += SHADER0([]() { |
1010 float GetAlpha(vec2 ya_clamped) { return alpha; } | 1064 float GetAlpha(vec2 ya_clamped) { return alpha; } |
1011 }); | 1065 }); |
1012 } | 1066 } |
1013 | 1067 |
1014 if (use_color_lut_) { | 1068 if (color_conversion_mode_ == COLOR_CONVERSION_MODE_2D_LUT_AS_3D_FROM_YUV) { |
1015 head += " uniform sampler2D lut_texture;\n"; | 1069 head += " uniform sampler2D lut_texture;\n"; |
1016 head += " uniform float resource_multiplier;\n"; | 1070 head += " uniform float resource_multiplier;\n"; |
1017 head += " uniform float resource_offset;\n"; | 1071 head += " uniform float resource_offset;\n"; |
1018 functions += SHADER0([]() { | 1072 functions += SHADER0([]() { |
1019 vec4 LUT(sampler2D sampler, vec3 pos, float size) { | 1073 vec4 LUT(sampler2D sampler, vec3 pos, float size) { |
1020 pos *= size - 1.0; | 1074 pos *= size - 1.0; |
1021 // Select layer | 1075 // Select layer |
1022 float layer = min(floor(pos.z), size - 2.0); | 1076 float layer = min(floor(pos.z), size - 2.0); |
1023 // Compress the xy coordinates so they stay within | 1077 // Compress the xy coordinates so they stay within |
1024 // [0.5 .. 31.5] / 17 (assuming a LUT size of 17^3) | 1078 // [0.5 .. 31.5] / 17 (assuming a LUT size of 17^3) |
1025 pos.xy = (pos.xy + vec2(0.5)) / size; | 1079 pos.xy = (pos.xy + vec2(0.5)) / size; |
1026 pos.y = (pos.y + layer) / size; | 1080 pos.y = (pos.y + layer) / size; |
1027 return mix(texture2D(sampler, pos.xy), | 1081 return mix(texture2D(sampler, pos.xy), |
1028 texture2D(sampler, pos.xy + vec2(0, 1.0 / size)), | 1082 texture2D(sampler, pos.xy + vec2(0, 1.0 / size)), |
1029 pos.z - layer); | 1083 pos.z - layer); |
1030 } | 1084 } |
1031 | 1085 |
1032 vec3 yuv2rgb(vec3 yuv) { | 1086 vec3 yuv2rgb(vec3 yuv) { |
1033 yuv = (yuv - vec3(resource_offset)) * resource_multiplier; | 1087 yuv = (yuv - vec3(resource_offset)) * resource_multiplier; |
1034 return LUT(lut_texture, yuv, 17.0).xyz; | 1088 return LUT(lut_texture, yuv, 17.0).xyz; |
1035 } | 1089 } |
1036 }); | 1090 }); |
1037 } else { | 1091 } |
| 1092 if (color_conversion_mode_ == COLOR_CONVERSION_MODE_NONE) { |
1038 head += " uniform mat3 yuv_matrix;\n"; | 1093 head += " uniform mat3 yuv_matrix;\n"; |
1039 head += " uniform vec3 yuv_adj;\n"; | 1094 head += " uniform vec3 yuv_adj;\n"; |
1040 functions += SHADER0([]() { | 1095 functions += SHADER0([]() { |
1041 vec3 yuv2rgb(vec3 yuv) { return yuv_matrix * (yuv + yuv_adj); } | 1096 vec3 yuv2rgb(vec3 yuv) { return yuv_matrix * (yuv + yuv_adj); } |
1042 }); | 1097 }); |
1043 } | 1098 } |
1044 | 1099 |
1045 functions += SHADER0([]() { | 1100 functions += SHADER0([]() { |
1046 void main() { | 1101 void main() { |
1047 vec2 ya_clamped = | 1102 vec2 ya_clamped = |
1048 max(ya_clamp_rect.xy, min(ya_clamp_rect.zw, v_yaTexCoord)); | 1103 max(ya_clamp_rect.xy, min(ya_clamp_rect.zw, v_yaTexCoord)); |
1049 float y_raw = TextureLookup(y_texture, ya_clamped).x; | 1104 float y_raw = TextureLookup(y_texture, ya_clamped).x; |
1050 vec2 uv_clamped = | 1105 vec2 uv_clamped = |
1051 max(uv_clamp_rect.xy, min(uv_clamp_rect.zw, v_uvTexCoord)); | 1106 max(uv_clamp_rect.xy, min(uv_clamp_rect.zw, v_uvTexCoord)); |
1052 vec3 yuv = vec3(y_raw, GetUV(uv_clamped)); | 1107 vec3 yuv = vec3(y_raw, GetUV(uv_clamped)); |
1053 gl_FragColor = vec4(yuv2rgb(yuv), 1.0) * GetAlpha(ya_clamped); | 1108 gl_FragColor = vec4(yuv2rgb(yuv), 1.0) * GetAlpha(ya_clamped); |
1054 } | 1109 } |
1055 }); | 1110 }); |
1056 | 1111 |
1057 return head + functions; | 1112 return head + functions; |
1058 } | 1113 } |
1059 | 1114 |
1060 } // namespace cc | 1115 } // namespace cc |
OLD | NEW |