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 #include "GrGLGpu.h" | 8 #include "GrGLGpu.h" |
9 #include "GrGLBuffer.h" | 9 #include "GrGLBuffer.h" |
10 #include "GrGLGLSL.h" | 10 #include "GrGLGLSL.h" |
(...skipping 3757 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3768 fshaderTxt.appendf("#extension %s : require\n", | 3768 fshaderTxt.appendf("#extension %s : require\n", |
3769 glslCaps->externalTextureExtensionString()); | 3769 glslCaps->externalTextureExtensionString()); |
3770 } | 3770 } |
3771 GrGLSLAppendDefaultFloatPrecisionDeclaration(kDefault_GrSLPrecision, *glslCa
ps, | 3771 GrGLSLAppendDefaultFloatPrecisionDeclaration(kDefault_GrSLPrecision, *glslCa
ps, |
3772 &fshaderTxt); | 3772 &fshaderTxt); |
3773 vTexCoord.setTypeModifier(GrShaderVar::kVaryingIn_TypeModifier); | 3773 vTexCoord.setTypeModifier(GrShaderVar::kVaryingIn_TypeModifier); |
3774 vTexCoord.appendDecl(glslCaps, &fshaderTxt); | 3774 vTexCoord.appendDecl(glslCaps, &fshaderTxt); |
3775 fshaderTxt.append(";"); | 3775 fshaderTxt.append(";"); |
3776 uTexture.appendDecl(glslCaps, &fshaderTxt); | 3776 uTexture.appendDecl(glslCaps, &fshaderTxt); |
3777 fshaderTxt.append(";"); | 3777 fshaderTxt.append(";"); |
3778 const char* fsOutName; | |
3779 if (glslCaps->mustDeclareFragmentShaderOutput()) { | |
3780 oFragColor.appendDecl(glslCaps, &fshaderTxt); | |
3781 fshaderTxt.append(";"); | |
3782 fsOutName = oFragColor.c_str(); | |
3783 } else { | |
3784 fsOutName = "gl_FragColor"; | |
3785 } | |
3786 fshaderTxt.appendf( | 3778 fshaderTxt.appendf( |
3787 "// Copy Program FS\n" | 3779 "// Copy Program FS\n" |
3788 "void main() {" | 3780 "void main() {" |
3789 " %s = %s(u_texture, v_texCoord);" | 3781 " sk_FragColor = %s(u_texture, v_texCoord);" |
3790 "}", | 3782 "}", |
3791 fsOutName, | |
3792 GrGLSLTexture2DFunctionName(kVec2f_GrSLType, kSamplerTypes[progIdx], thi
s->glslGeneration()) | 3783 GrGLSLTexture2DFunctionName(kVec2f_GrSLType, kSamplerTypes[progIdx], thi
s->glslGeneration()) |
3793 ); | 3784 ); |
3794 | 3785 |
3795 const char* str; | 3786 const char* str; |
3796 GrGLint length; | 3787 GrGLint length; |
3797 | 3788 |
3798 str = vshaderTxt.c_str(); | 3789 str = vshaderTxt.c_str(); |
3799 length = SkToInt(vshaderTxt.size()); | 3790 length = SkToInt(vshaderTxt.size()); |
3800 GrGLuint vshader = GrGLCompileAndAttachShader(*fGLContext, fCopyPrograms[pro
gIdx].fProgram, | 3791 GrGLuint vshader = GrGLCompileAndAttachShader(*fGLContext, fCopyPrograms[pro
gIdx].fProgram, |
3801 GR_GL_VERTEX_SHADER, &str, &le
ngth, 1, | 3792 GR_GL_VERTEX_SHADER, &str, &le
ngth, 1, |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3914 } | 3905 } |
3915 GrGLSLAppendDefaultFloatPrecisionDeclaration(kDefault_GrSLPrecision, *glslCa
ps, | 3906 GrGLSLAppendDefaultFloatPrecisionDeclaration(kDefault_GrSLPrecision, *glslCa
ps, |
3916 &fshaderTxt); | 3907 &fshaderTxt); |
3917 for (int i = 0; i < numTaps; ++i) { | 3908 for (int i = 0; i < numTaps; ++i) { |
3918 vTexCoords[i].setTypeModifier(GrShaderVar::kVaryingIn_TypeModifier); | 3909 vTexCoords[i].setTypeModifier(GrShaderVar::kVaryingIn_TypeModifier); |
3919 vTexCoords[i].appendDecl(glslCaps, &fshaderTxt); | 3910 vTexCoords[i].appendDecl(glslCaps, &fshaderTxt); |
3920 fshaderTxt.append(";"); | 3911 fshaderTxt.append(";"); |
3921 } | 3912 } |
3922 uTexture.appendDecl(glslCaps, &fshaderTxt); | 3913 uTexture.appendDecl(glslCaps, &fshaderTxt); |
3923 fshaderTxt.append(";"); | 3914 fshaderTxt.append(";"); |
3924 const char* fsOutName; | |
3925 if (glslCaps->mustDeclareFragmentShaderOutput()) { | |
3926 oFragColor.appendDecl(glslCaps, &fshaderTxt); | |
3927 fshaderTxt.append(";"); | |
3928 fsOutName = oFragColor.c_str(); | |
3929 } else { | |
3930 fsOutName = "gl_FragColor"; | |
3931 } | |
3932 const char* sampleFunction = GrGLSLTexture2DFunctionName(kVec2f_GrSLType, | 3915 const char* sampleFunction = GrGLSLTexture2DFunctionName(kVec2f_GrSLType, |
3933 kTexture2DSampler_G
rSLType, | 3916 kTexture2DSampler_G
rSLType, |
3934 this->glslGeneratio
n()); | 3917 this->glslGeneratio
n()); |
3935 fshaderTxt.append( | 3918 fshaderTxt.append( |
3936 "// Mipmap Program FS\n" | 3919 "// Mipmap Program FS\n" |
3937 "void main() {" | 3920 "void main() {" |
3938 ); | 3921 ); |
3939 | 3922 |
3940 if (oddWidth && oddHeight) { | 3923 if (oddWidth && oddHeight) { |
3941 fshaderTxt.appendf( | 3924 fshaderTxt.appendf( |
3942 " %s = (%s(u_texture, v_texCoord0) + %s(u_texture, v_texCoord1) + " | 3925 " sk_FragColor = (%s(u_texture, v_texCoord0) + %s(u_texture, v_texC
oord1) + " |
3943 " %s(u_texture, v_texCoord2) + %s(u_texture, v_texCoord3)) *
0.25;", | 3926 " %s(u_texture, v_texCoord2) + %s(u_texture, v_texC
oord3)) * 0.25;", |
3944 fsOutName, sampleFunction, sampleFunction, sampleFunction, sampleFun
ction | 3927 sampleFunction, sampleFunction, sampleFunction, sampleFunction |
3945 ); | 3928 ); |
3946 } else if (oddWidth || oddHeight) { | 3929 } else if (oddWidth || oddHeight) { |
3947 fshaderTxt.appendf( | 3930 fshaderTxt.appendf( |
3948 " %s = (%s(u_texture, v_texCoord0) + %s(u_texture, v_texCoord1)) *
0.5;", | 3931 " sk_FragColor = (%s(u_texture, v_texCoord0) + %s(u_texture, v_texC
oord1)) * 0.5;", |
3949 fsOutName, sampleFunction, sampleFunction | 3932 sampleFunction, sampleFunction |
3950 ); | 3933 ); |
3951 } else { | 3934 } else { |
3952 fshaderTxt.appendf( | 3935 fshaderTxt.appendf( |
3953 " %s = %s(u_texture, v_texCoord0);", | 3936 " sk_FragColor = %s(u_texture, v_texCoord0);", |
3954 fsOutName, sampleFunction | 3937 sampleFunction |
3955 ); | 3938 ); |
3956 } | 3939 } |
3957 | 3940 |
3958 fshaderTxt.append("}"); | 3941 fshaderTxt.append("}"); |
3959 | 3942 |
3960 const char* str; | 3943 const char* str; |
3961 GrGLint length; | 3944 GrGLint length; |
3962 | 3945 |
3963 str = vshaderTxt.c_str(); | 3946 str = vshaderTxt.c_str(); |
3964 length = SkToInt(vshaderTxt.size()); | 3947 length = SkToInt(vshaderTxt.size()); |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4031 ); | 4014 ); |
4032 | 4015 |
4033 GrGLSLShaderVar oFragColor("o_FragColor", kVec4f_GrSLType, GrShaderVar::kOut
_TypeModifier); | 4016 GrGLSLShaderVar oFragColor("o_FragColor", kVec4f_GrSLType, GrShaderVar::kOut
_TypeModifier); |
4034 | 4017 |
4035 SkString fshaderTxt(version); | 4018 SkString fshaderTxt(version); |
4036 GrGLSLAppendDefaultFloatPrecisionDeclaration(kDefault_GrSLPrecision, | 4019 GrGLSLAppendDefaultFloatPrecisionDeclaration(kDefault_GrSLPrecision, |
4037 *this->glCaps().glslCaps(), | 4020 *this->glCaps().glslCaps(), |
4038 &fshaderTxt); | 4021 &fshaderTxt); |
4039 uColor.appendDecl(this->glCaps().glslCaps(), &fshaderTxt); | 4022 uColor.appendDecl(this->glCaps().glslCaps(), &fshaderTxt); |
4040 fshaderTxt.append(";"); | 4023 fshaderTxt.append(";"); |
4041 const char* fsOutName; | |
4042 if (this->glCaps().glslCaps()->mustDeclareFragmentShaderOutput()) { | |
4043 oFragColor.appendDecl(this->glCaps().glslCaps(), &fshaderTxt); | |
4044 fshaderTxt.append(";"); | |
4045 fsOutName = oFragColor.c_str(); | |
4046 } else { | |
4047 fsOutName = "gl_FragColor"; | |
4048 } | |
4049 fshaderTxt.appendf( | 4024 fshaderTxt.appendf( |
4050 "// Write Rect Program FS\n" | 4025 "// Write Rect Program FS\n" |
4051 "void main() {" | 4026 "void main() {" |
4052 " %s = %s;" | 4027 " sk_FragColor = %s;" |
4053 "}", | 4028 "}", |
4054 fsOutName, | |
4055 uColor.c_str() | 4029 uColor.c_str() |
4056 ); | 4030 ); |
4057 | 4031 |
4058 const char* str; | 4032 const char* str; |
4059 GrGLint length; | 4033 GrGLint length; |
4060 | 4034 |
4061 str = vshaderTxt.c_str(); | 4035 str = vshaderTxt.c_str(); |
4062 length = SkToInt(vshaderTxt.size()); | 4036 length = SkToInt(vshaderTxt.size()); |
4063 GrGLuint vshader = GrGLCompileAndAttachShader(*fGLContext, fWireRectProgram.
fProgram, | 4037 GrGLuint vshader = GrGLCompileAndAttachShader(*fGLContext, fWireRectProgram.
fProgram, |
4064 GR_GL_VERTEX_SHADER, &str, &le
ngth, 1, | 4038 GR_GL_VERTEX_SHADER, &str, &le
ngth, 1, |
(...skipping 607 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4672 if (GR_GL_TEXTURE_EXTERNAL == glTexture->target() || | 4646 if (GR_GL_TEXTURE_EXTERNAL == glTexture->target() || |
4673 GR_GL_TEXTURE_RECTANGLE == glTexture->target()) { | 4647 GR_GL_TEXTURE_RECTANGLE == glTexture->target()) { |
4674 copyParams->fFilter = GrTextureParams::kNone_FilterMode; | 4648 copyParams->fFilter = GrTextureParams::kNone_FilterMode; |
4675 copyParams->fWidth = texture->width(); | 4649 copyParams->fWidth = texture->width(); |
4676 copyParams->fHeight = texture->height(); | 4650 copyParams->fHeight = texture->height(); |
4677 return true; | 4651 return true; |
4678 } | 4652 } |
4679 } | 4653 } |
4680 return false; | 4654 return false; |
4681 } | 4655 } |
OLD | NEW |