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 "GrGLGLSL.h" | 9 #include "GrGLGLSL.h" |
10 #include "GrGLStencilAttachment.h" | 10 #include "GrGLStencilAttachment.h" |
(...skipping 3301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3312 " v_texCoord = a_vertex.xy * u_texCoordXform.xy + u_texCoordXform.z
w;" | 3312 " v_texCoord = a_vertex.xy * u_texCoordXform.xy + u_texCoordXform.z
w;" |
3313 " gl_Position.xy = a_vertex * u_posXform.xy + u_posXform.zw;" | 3313 " gl_Position.xy = a_vertex * u_posXform.xy + u_posXform.zw;" |
3314 " gl_Position.zw = vec2(0, 1);" | 3314 " gl_Position.zw = vec2(0, 1);" |
3315 "}" | 3315 "}" |
3316 ); | 3316 ); |
3317 | 3317 |
3318 SkString fshaderTxt(version); | 3318 SkString fshaderTxt(version); |
3319 if (kSamplerTypes[i] == kSamplerExternal_GrSLType) { | 3319 if (kSamplerTypes[i] == kSamplerExternal_GrSLType) { |
3320 fshaderTxt.appendf("#extension %s : require\n", | 3320 fshaderTxt.appendf("#extension %s : require\n", |
3321 this->glCaps().glslCaps()->externalTextureExtensi
onString()); | 3321 this->glCaps().glslCaps()->externalTextureExtensi
onString()); |
| 3322 } else if (kSamplerTypes[i] == kSampler2DRect_GrSLType) { |
| 3323 const char* rectangleFeatureString = |
| 3324 this->glCaps().glslCaps()->rectangleTextureExtensionString()
; |
| 3325 if (rectangleFeatureString) { |
| 3326 fshaderTxt.appendf("#extension %s : require\n", |
| 3327 rectangleFeatureString); |
| 3328 } |
3322 } | 3329 } |
| 3330 |
3323 GrGLSLAppendDefaultFloatPrecisionDeclaration(kDefault_GrSLPrecision, | 3331 GrGLSLAppendDefaultFloatPrecisionDeclaration(kDefault_GrSLPrecision, |
3324 *this->glCaps().glslCaps(), | 3332 *this->glCaps().glslCaps(), |
3325 &fshaderTxt); | 3333 &fshaderTxt); |
3326 vTexCoord.setTypeModifier(GrShaderVar::kVaryingIn_TypeModifier); | 3334 vTexCoord.setTypeModifier(GrShaderVar::kVaryingIn_TypeModifier); |
3327 vTexCoord.appendDecl(this->glCaps().glslCaps(), &fshaderTxt); | 3335 vTexCoord.appendDecl(this->glCaps().glslCaps(), &fshaderTxt); |
3328 fshaderTxt.append(";"); | 3336 fshaderTxt.append(";"); |
3329 uTexture.appendDecl(this->glCaps().glslCaps(), &fshaderTxt); | 3337 uTexture.appendDecl(this->glCaps().glslCaps(), &fshaderTxt); |
3330 fshaderTxt.append(";"); | 3338 fshaderTxt.append(";"); |
3331 const char* fsOutName; | 3339 const char* fsOutName; |
3332 if (this->glCaps().glslCaps()->mustDeclareFragmentShaderOutput()) { | 3340 if (this->glCaps().glslCaps()->mustDeclareFragmentShaderOutput()) { |
3333 oFragColor.appendDecl(this->glCaps().glslCaps(), &fshaderTxt); | 3341 oFragColor.appendDecl(this->glCaps().glslCaps(), &fshaderTxt); |
3334 fshaderTxt.append(";"); | 3342 fshaderTxt.append(";"); |
3335 fsOutName = oFragColor.c_str(); | 3343 fsOutName = oFragColor.c_str(); |
3336 } else { | 3344 } else { |
3337 fsOutName = "gl_FragColor"; | 3345 fsOutName = "gl_FragColor"; |
3338 } | 3346 } |
3339 fshaderTxt.appendf( | 3347 fshaderTxt.appendf( |
3340 "// Copy Program FS\n" | 3348 "// Copy Program FS\n" |
3341 "void main() {" | 3349 "void main() {" |
3342 " %s = %s(u_texture, v_texCoord);" | 3350 " %s = %s(u_texture, v_texCoord);" |
3343 "}", | 3351 "}", |
3344 fsOutName, | 3352 fsOutName, |
3345 GrGLSLTexture2DFunctionName(kVec2f_GrSLType, kSamplerTypes[i], this-
>glslGeneration()) | 3353 GrGLSLTexture2DFunctionName(kVec2f_GrSLType, kSamplerTypes[i], |
3346 ); | 3354 *this->glCaps().glslCaps())); |
3347 | 3355 |
3348 GL_CALL_RET(fCopyPrograms[i].fProgram, CreateProgram()); | 3356 GL_CALL_RET(fCopyPrograms[i].fProgram, CreateProgram()); |
3349 const char* str; | 3357 const char* str; |
3350 GrGLint length; | 3358 GrGLint length; |
3351 | 3359 |
3352 str = vshaderTxt.c_str(); | 3360 str = vshaderTxt.c_str(); |
3353 length = SkToInt(vshaderTxt.size()); | 3361 length = SkToInt(vshaderTxt.size()); |
3354 GrGLuint vshader = GrGLCompileAndAttachShader(*fGLContext, fCopyPrograms
[i].fProgram, | 3362 GrGLuint vshader = GrGLCompileAndAttachShader(*fGLContext, fCopyPrograms
[i].fProgram, |
3355 GR_GL_VERTEX_SHADER, &str,
&length, 1, | 3363 GR_GL_VERTEX_SHADER, &str,
&length, 1, |
3356 &fStats); | 3364 &fStats); |
(...skipping 534 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3891 if (GR_GL_TEXTURE_EXTERNAL == glTexture->target() || | 3899 if (GR_GL_TEXTURE_EXTERNAL == glTexture->target() || |
3892 GR_GL_TEXTURE_RECTANGLE == glTexture->target()) { | 3900 GR_GL_TEXTURE_RECTANGLE == glTexture->target()) { |
3893 copyParams->fFilter = GrTextureParams::kNone_FilterMode; | 3901 copyParams->fFilter = GrTextureParams::kNone_FilterMode; |
3894 copyParams->fWidth = texture->width(); | 3902 copyParams->fWidth = texture->width(); |
3895 copyParams->fHeight = texture->height(); | 3903 copyParams->fHeight = texture->height(); |
3896 return true; | 3904 return true; |
3897 } | 3905 } |
3898 } | 3906 } |
3899 return false; | 3907 return false; |
3900 } | 3908 } |
OLD | NEW |