OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2011 Google Inc. | 2 * Copyright 2011 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 | 8 |
9 #include "GrGLGpu.h" | 9 #include "GrGLGpu.h" |
10 #include "GrGLGLSL.h" | 10 #include "GrGLGLSL.h" |
(...skipping 2802 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2813 | 2813 |
2814 GrGLShaderVar aVertex("a_vertex", kVec2f_GrSLType, GrShaderVar::kAttribute_T
ypeModifier); | 2814 GrGLShaderVar aVertex("a_vertex", kVec2f_GrSLType, GrShaderVar::kAttribute_T
ypeModifier); |
2815 GrGLShaderVar uTexCoordXform("u_texCoordXform", kVec4f_GrSLType, | 2815 GrGLShaderVar uTexCoordXform("u_texCoordXform", kVec4f_GrSLType, |
2816 GrShaderVar::kUniform_TypeModifier); | 2816 GrShaderVar::kUniform_TypeModifier); |
2817 GrGLShaderVar uPosXform("u_posXform", kVec4f_GrSLType, GrShaderVar::kUniform
_TypeModifier); | 2817 GrGLShaderVar uPosXform("u_posXform", kVec4f_GrSLType, GrShaderVar::kUniform
_TypeModifier); |
2818 GrGLShaderVar uTexture("u_texture", kSampler2D_GrSLType, GrShaderVar::kUnifo
rm_TypeModifier); | 2818 GrGLShaderVar uTexture("u_texture", kSampler2D_GrSLType, GrShaderVar::kUnifo
rm_TypeModifier); |
2819 GrGLShaderVar vTexCoord("v_texCoord", kVec2f_GrSLType, GrShaderVar::kVarying
Out_TypeModifier); | 2819 GrGLShaderVar vTexCoord("v_texCoord", kVec2f_GrSLType, GrShaderVar::kVarying
Out_TypeModifier); |
2820 GrGLShaderVar oFragColor("o_FragColor", kVec4f_GrSLType, GrShaderVar::kOut_T
ypeModifier); | 2820 GrGLShaderVar oFragColor("o_FragColor", kVec4f_GrSLType, GrShaderVar::kOut_T
ypeModifier); |
2821 | 2821 |
2822 SkString vshaderTxt(version); | 2822 SkString vshaderTxt(version); |
2823 aVertex.appendDecl(this->ctxInfo(), &vshaderTxt); | 2823 aVertex.appendDecl(this->glCaps().glslCaps(), &vshaderTxt); |
2824 vshaderTxt.append(";"); | 2824 vshaderTxt.append(";"); |
2825 uTexCoordXform.appendDecl(this->ctxInfo(), &vshaderTxt); | 2825 uTexCoordXform.appendDecl(this->glCaps().glslCaps(), &vshaderTxt); |
2826 vshaderTxt.append(";"); | 2826 vshaderTxt.append(";"); |
2827 uPosXform.appendDecl(this->ctxInfo(), &vshaderTxt); | 2827 uPosXform.appendDecl(this->glCaps().glslCaps(), &vshaderTxt); |
2828 vshaderTxt.append(";"); | 2828 vshaderTxt.append(";"); |
2829 vTexCoord.appendDecl(this->ctxInfo(), &vshaderTxt); | 2829 vTexCoord.appendDecl(this->glCaps().glslCaps(), &vshaderTxt); |
2830 vshaderTxt.append(";"); | 2830 vshaderTxt.append(";"); |
2831 | 2831 |
2832 vshaderTxt.append( | 2832 vshaderTxt.append( |
2833 "// Copy Program VS\n" | 2833 "// Copy Program VS\n" |
2834 "void main() {" | 2834 "void main() {" |
2835 " v_texCoord = a_vertex.xy * u_texCoordXform.xy + u_texCoordXform.zw;" | 2835 " v_texCoord = a_vertex.xy * u_texCoordXform.xy + u_texCoordXform.zw;" |
2836 " gl_Position.xy = a_vertex * u_posXform.xy + u_posXform.zw;" | 2836 " gl_Position.xy = a_vertex * u_posXform.xy + u_posXform.zw;" |
2837 " gl_Position.zw = vec2(0, 1);" | 2837 " gl_Position.zw = vec2(0, 1);" |
2838 "}" | 2838 "}" |
2839 ); | 2839 ); |
2840 | 2840 |
2841 SkString fshaderTxt(version); | 2841 SkString fshaderTxt(version); |
2842 GrGLAppendGLSLDefaultFloatPrecisionDeclaration(kDefault_GrSLPrecision, this-
>glStandard(), | 2842 GrGLAppendGLSLDefaultFloatPrecisionDeclaration(kDefault_GrSLPrecision, this-
>glStandard(), |
2843 &fshaderTxt); | 2843 &fshaderTxt); |
2844 vTexCoord.setTypeModifier(GrShaderVar::kVaryingIn_TypeModifier); | 2844 vTexCoord.setTypeModifier(GrShaderVar::kVaryingIn_TypeModifier); |
2845 vTexCoord.appendDecl(this->ctxInfo(), &fshaderTxt); | 2845 vTexCoord.appendDecl(this->glCaps().glslCaps(), &fshaderTxt); |
2846 fshaderTxt.append(";"); | 2846 fshaderTxt.append(";"); |
2847 uTexture.appendDecl(this->ctxInfo(), &fshaderTxt); | 2847 uTexture.appendDecl(this->glCaps().glslCaps(), &fshaderTxt); |
2848 fshaderTxt.append(";"); | 2848 fshaderTxt.append(";"); |
2849 const char* fsOutName; | 2849 const char* fsOutName; |
2850 if (this->glCaps().glslCaps()->mustDeclareFragmentShaderOutput()) { | 2850 if (this->glCaps().glslCaps()->mustDeclareFragmentShaderOutput()) { |
2851 oFragColor.appendDecl(this->ctxInfo(), &fshaderTxt); | 2851 oFragColor.appendDecl(this->glCaps().glslCaps(), &fshaderTxt); |
2852 fshaderTxt.append(";"); | 2852 fshaderTxt.append(";"); |
2853 fsOutName = oFragColor.c_str(); | 2853 fsOutName = oFragColor.c_str(); |
2854 } else { | 2854 } else { |
2855 fsOutName = "gl_FragColor"; | 2855 fsOutName = "gl_FragColor"; |
2856 } | 2856 } |
2857 fshaderTxt.appendf( | 2857 fshaderTxt.appendf( |
2858 "// Copy Program FS\n" | 2858 "// Copy Program FS\n" |
2859 "void main() {" | 2859 "void main() {" |
2860 " %s = %s(u_texture, v_texCoord);" | 2860 " %s = %s(u_texture, v_texCoord);" |
2861 "}", | 2861 "}", |
(...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3182 this->setVertexArrayID(gpu, 0); | 3182 this->setVertexArrayID(gpu, 0); |
3183 } | 3183 } |
3184 int attrCount = gpu->glCaps().maxVertexAttributes(); | 3184 int attrCount = gpu->glCaps().maxVertexAttributes(); |
3185 if (fDefaultVertexArrayAttribState.count() != attrCount) { | 3185 if (fDefaultVertexArrayAttribState.count() != attrCount) { |
3186 fDefaultVertexArrayAttribState.resize(attrCount); | 3186 fDefaultVertexArrayAttribState.resize(attrCount); |
3187 } | 3187 } |
3188 attribState = &fDefaultVertexArrayAttribState; | 3188 attribState = &fDefaultVertexArrayAttribState; |
3189 } | 3189 } |
3190 return attribState; | 3190 return attribState; |
3191 } | 3191 } |
OLD | NEW |