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/shader.h" | 5 #include "cc/shader.h" |
6 | 6 |
7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "third_party/WebKit/Source/Platform/chromium/public/WebGraphicsContext3
D.h" | 9 #include "third_party/WebKit/Source/Platform/chromium/public/WebGraphicsContext3
D.h" |
10 | 10 |
(...skipping 824 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
835 return SHADER( | 835 return SHADER( |
836 precision mediump float; | 836 precision mediump float; |
837 uniform vec4 color; | 837 uniform vec4 color; |
838 void main() | 838 void main() |
839 { | 839 { |
840 gl_FragColor = color; | 840 gl_FragColor = color; |
841 } | 841 } |
842 ); | 842 ); |
843 } | 843 } |
844 | 844 |
| 845 FragmentShaderColorAA::FragmentShaderColorAA() |
| 846 : m_edgeLocation(-1) |
| 847 , m_colorLocation(-1) |
| 848 { |
| 849 } |
| 850 |
| 851 void FragmentShaderColorAA::init(WebGraphicsContext3D* context, unsigned program
, bool usingBindUniform, int* baseUniformIndex) |
| 852 { |
| 853 static const char* shaderUniforms[] = { |
| 854 "edge", |
| 855 "color", |
| 856 }; |
| 857 int locations[2]; |
| 858 |
| 859 getProgramUniformLocations(context, program, shaderUniforms, arraysize(shade
rUniforms), arraysize(locations), locations, usingBindUniform, baseUniformIndex)
; |
| 860 |
| 861 m_edgeLocation = locations[0]; |
| 862 m_colorLocation = locations[1]; |
| 863 DCHECK(m_edgeLocation != -1 && m_colorLocation != -1); |
| 864 } |
| 865 |
| 866 std::string FragmentShaderColorAA::getShaderString() const |
| 867 { |
| 868 return SHADER( |
| 869 precision mediump float; |
| 870 uniform vec4 color; |
| 871 uniform vec3 edge[8]; |
| 872 void main() |
| 873 { |
| 874 vec3 pos = vec3(gl_FragCoord.xy, 1); |
| 875 float a0 = clamp(dot(edge[0], pos), 0.0, 1.0); |
| 876 float a1 = clamp(dot(edge[1], pos), 0.0, 1.0); |
| 877 float a2 = clamp(dot(edge[2], pos), 0.0, 1.0); |
| 878 float a3 = clamp(dot(edge[3], pos), 0.0, 1.0); |
| 879 float a4 = clamp(dot(edge[4], pos), 0.0, 1.0); |
| 880 float a5 = clamp(dot(edge[5], pos), 0.0, 1.0); |
| 881 float a6 = clamp(dot(edge[6], pos), 0.0, 1.0); |
| 882 float a7 = clamp(dot(edge[7], pos), 0.0, 1.0); |
| 883 gl_FragColor = color * min(min(a0, a2) * min(a1, a3), min(a4, a6) *
min(a5, a7)); |
| 884 } |
| 885 ); |
| 886 } |
| 887 |
845 FragmentShaderCheckerboard::FragmentShaderCheckerboard() | 888 FragmentShaderCheckerboard::FragmentShaderCheckerboard() |
846 : m_alphaLocation(-1) | 889 : m_alphaLocation(-1) |
847 , m_texTransformLocation(-1) | 890 , m_texTransformLocation(-1) |
848 , m_frequencyLocation(-1) | 891 , m_frequencyLocation(-1) |
849 { | 892 { |
850 } | 893 } |
851 | 894 |
852 void FragmentShaderCheckerboard::init(WebGraphicsContext3D* context, unsigned pr
ogram, bool usingBindUniform, int* baseUniformIndex) | 895 void FragmentShaderCheckerboard::init(WebGraphicsContext3D* context, unsigned pr
ogram, bool usingBindUniform, int* baseUniformIndex) |
853 { | 896 { |
854 static const char* shaderUniforms[] = { | 897 static const char* shaderUniforms[] = { |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
886 vec4 color2 = color; | 929 vec4 color2 = color; |
887 vec2 texCoord = clamp(v_texCoord, 0.0, 1.0) * texTransform.zw + texT
ransform.xy; | 930 vec2 texCoord = clamp(v_texCoord, 0.0, 1.0) * texTransform.zw + texT
ransform.xy; |
888 vec2 coord = mod(floor(texCoord * frequency * 2.0), 2.0); | 931 vec2 coord = mod(floor(texCoord * frequency * 2.0), 2.0); |
889 float picker = abs(coord.x - coord.y); | 932 float picker = abs(coord.x - coord.y); |
890 gl_FragColor = mix(color1, color2, picker) * alpha; | 933 gl_FragColor = mix(color1, color2, picker) * alpha; |
891 } | 934 } |
892 ); | 935 ); |
893 } | 936 } |
894 | 937 |
895 } // namespace cc | 938 } // namespace cc |
OLD | NEW |