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 "config.h" | 5 #include "config.h" |
6 | 6 |
7 #if USE(ACCELERATED_COMPOSITING) | 7 #if USE(ACCELERATED_COMPOSITING) |
8 | 8 |
9 #include "ShaderChromium.h" | 9 #include "ShaderChromium.h" |
10 | 10 |
(...skipping 828 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
839 , m_frequencyLocation(-1) | 839 , m_frequencyLocation(-1) |
840 { | 840 { |
841 } | 841 } |
842 | 842 |
843 void FragmentShaderCheckerboard::init(WebGraphicsContext3D* context, unsigned pr
ogram, bool usingBindUniform, int* baseUniformIndex) | 843 void FragmentShaderCheckerboard::init(WebGraphicsContext3D* context, unsigned pr
ogram, bool usingBindUniform, int* baseUniformIndex) |
844 { | 844 { |
845 static const char* shaderUniforms[] = { | 845 static const char* shaderUniforms[] = { |
846 "alpha", | 846 "alpha", |
847 "texTransform", | 847 "texTransform", |
848 "frequency", | 848 "frequency", |
| 849 "color", |
849 }; | 850 }; |
850 int locations[3]; | 851 int locations[4]; |
851 | 852 |
852 getProgramUniformLocations(context, program, shaderUniforms, WTF_ARRAY_LENGT
H(shaderUniforms), WTF_ARRAY_LENGTH(locations), locations, usingBindUniform, bas
eUniformIndex); | 853 getProgramUniformLocations(context, program, shaderUniforms, WTF_ARRAY_LENGT
H(shaderUniforms), WTF_ARRAY_LENGTH(locations), locations, usingBindUniform, bas
eUniformIndex); |
853 | 854 |
854 m_alphaLocation = locations[0]; | 855 m_alphaLocation = locations[0]; |
855 m_texTransformLocation = locations[1]; | 856 m_texTransformLocation = locations[1]; |
856 m_frequencyLocation = locations[2]; | 857 m_frequencyLocation = locations[2]; |
857 ASSERT(m_alphaLocation != -1 && m_texTransformLocation != -1 && m_frequencyL
ocation != -1); | 858 m_colorLocation = locations[3]; |
| 859 ASSERT(m_alphaLocation != -1 && m_texTransformLocation != -1 && m_frequencyL
ocation != -1 && m_colorLocation != -1); |
858 } | 860 } |
859 | 861 |
860 std::string FragmentShaderCheckerboard::getShaderString() const | 862 std::string FragmentShaderCheckerboard::getShaderString() const |
861 { | 863 { |
862 // Shader based on Example 13-17 of "OpenGL ES 2.0 Programming Guide" | 864 // Shader based on Example 13-17 of "OpenGL ES 2.0 Programming Guide" |
863 // by Munshi, Ginsburg, Shreiner. | 865 // by Munshi, Ginsburg, Shreiner. |
864 return SHADER( | 866 return SHADER( |
865 precision mediump float; | 867 precision mediump float; |
866 precision mediump int; | 868 precision mediump int; |
867 varying vec2 v_texCoord; | 869 varying vec2 v_texCoord; |
868 uniform float alpha; | 870 uniform float alpha; |
869 uniform float frequency; | 871 uniform float frequency; |
870 uniform vec4 texTransform; | 872 uniform vec4 texTransform; |
| 873 uniform vec4 color; |
871 void main() | 874 void main() |
872 { | 875 { |
873 vec4 color1 = vec4(1.0, 1.0, 1.0, 1.0); | 876 vec4 color1 = vec4(1.0, 1.0, 1.0, 1.0); |
874 vec4 color2 = vec4(0.945, 0.945, 0.945, 1.0); | 877 vec4 color2 = color; |
875 vec2 texCoord = clamp(v_texCoord, 0.0, 1.0) * texTransform.zw + texT
ransform.xy; | 878 vec2 texCoord = clamp(v_texCoord, 0.0, 1.0) * texTransform.zw + texT
ransform.xy; |
876 vec2 coord = mod(floor(texCoord * frequency * 2.0), 2.0); | 879 vec2 coord = mod(floor(texCoord * frequency * 2.0), 2.0); |
877 float picker = abs(coord.x - coord.y); | 880 float picker = abs(coord.x - coord.y); |
878 gl_FragColor = mix(color1, color2, picker) * alpha; | 881 gl_FragColor = mix(color1, color2, picker) * alpha; |
879 } | 882 } |
880 ); | 883 ); |
881 } | 884 } |
882 | 885 |
883 } // namespace cc | 886 } // namespace cc |
884 | 887 |
885 #endif // USE(ACCELERATED_COMPOSITING) | 888 #endif // USE(ACCELERATED_COMPOSITING) |
OLD | NEW |