| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2014 Google Inc. | 2 * Copyright 2014 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 "GrSwizzle.h" | 8 #include "GrSwizzle.h" |
| 9 #include "glsl/GrGLSLShaderBuilder.h" | 9 #include "glsl/GrGLSLShaderBuilder.h" |
| 10 #include "glsl/GrGLSLCaps.h" | 10 #include "glsl/GrGLSLCaps.h" |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 62 this->functions().append("}\n\n"); | 62 this->functions().append("}\n\n"); |
| 63 } | 63 } |
| 64 | 64 |
| 65 void GrGLSLShaderBuilder::appendTextureLookup(SkString* out, | 65 void GrGLSLShaderBuilder::appendTextureLookup(SkString* out, |
| 66 SamplerHandle samplerHandle, | 66 SamplerHandle samplerHandle, |
| 67 const char* coordName, | 67 const char* coordName, |
| 68 GrSLType varyingType) const { | 68 GrSLType varyingType) const { |
| 69 const GrGLSLCaps* glslCaps = fProgramBuilder->glslCaps(); | 69 const GrGLSLCaps* glslCaps = fProgramBuilder->glslCaps(); |
| 70 const GrGLSLSampler& sampler = fProgramBuilder->getSampler(samplerHandle); | 70 const GrGLSLSampler& sampler = fProgramBuilder->getSampler(samplerHandle); |
| 71 GrSLType samplerType = sampler.type(); | 71 GrSLType samplerType = sampler.type(); |
| 72 if (samplerType == kSampler2DRect_GrSLType) { | 72 if (samplerType == kTexture2DRectSampler_GrSLType) { |
| 73 if (varyingType == kVec2f_GrSLType) { | 73 if (varyingType == kVec2f_GrSLType) { |
| 74 out->appendf("%s(%s, textureSize(%s) * %s)", | 74 out->appendf("%s(%s, textureSize(%s) * %s)", |
| 75 GrGLSLTexture2DFunctionName(varyingType, samplerType, | 75 GrGLSLTexture2DFunctionName(varyingType, samplerType, |
| 76 glslCaps->generation()), | 76 glslCaps->generation()), |
| 77 sampler.getSamplerNameForTexture2D(), | 77 sampler.getSamplerNameForTexture2D(), |
| 78 sampler.getSamplerNameForTexture2D(), | 78 sampler.getSamplerNameForTexture2D(), |
| 79 coordName); | 79 coordName); |
| 80 } else { | 80 } else { |
| 81 out->appendf("%s(%s, vec3(textureSize(%s) * %s.xy, %s.z))", | 81 out->appendf("%s(%s, vec3(textureSize(%s) * %s.xy, %s.z))", |
| 82 GrGLSLTexture2DFunctionName(varyingType, samplerType, | 82 GrGLSLTexture2DFunctionName(varyingType, samplerType, |
| (...skipping 26 matching lines...) Expand all Loading... |
| 109 SkString lookup; | 109 SkString lookup; |
| 110 this->appendTextureLookup(&lookup, samplerHandle, coordName, varyingType); | 110 this->appendTextureLookup(&lookup, samplerHandle, coordName, varyingType); |
| 111 this->codeAppend((GrGLSLExpr4(modulation) * GrGLSLExpr4(lookup)).c_str()); | 111 this->codeAppend((GrGLSLExpr4(modulation) * GrGLSLExpr4(lookup)).c_str()); |
| 112 } | 112 } |
| 113 | 113 |
| 114 void GrGLSLShaderBuilder::appendTexelFetch(SkString* out, | 114 void GrGLSLShaderBuilder::appendTexelFetch(SkString* out, |
| 115 SamplerHandle samplerHandle, | 115 SamplerHandle samplerHandle, |
| 116 const char* coordExpr) const { | 116 const char* coordExpr) const { |
| 117 const GrGLSLSampler& sampler = fProgramBuilder->getSampler(samplerHandle); | 117 const GrGLSLSampler& sampler = fProgramBuilder->getSampler(samplerHandle); |
| 118 SkASSERT(fProgramBuilder->glslCaps()->texelFetchSupport()); | 118 SkASSERT(fProgramBuilder->glslCaps()->texelFetchSupport()); |
| 119 SkASSERT(GrSLTypeIsSamplerType(sampler.type())); | 119 SkASSERT(GrSLTypeIsCombinedSamplerType(sampler.type())); |
| 120 | 120 |
| 121 out->appendf("texelFetch(%s, %s)", sampler.getSamplerNameForTexelFetch(), co
ordExpr); | 121 out->appendf("texelFetch(%s, %s)", sampler.getSamplerNameForTexelFetch(), co
ordExpr); |
| 122 | 122 |
| 123 this->appendTextureSwizzle(out, sampler.config()); | 123 this->appendTextureSwizzle(out, sampler.config()); |
| 124 } | 124 } |
| 125 | 125 |
| 126 void GrGLSLShaderBuilder::appendTexelFetch(SamplerHandle samplerHandle, const ch
ar* coordExpr) { | 126 void GrGLSLShaderBuilder::appendTexelFetch(SamplerHandle samplerHandle, const ch
ar* coordExpr) { |
| 127 this->appendTexelFetch(&this->code(), samplerHandle, coordExpr); | 127 this->appendTexelFetch(&this->code(), samplerHandle, coordExpr); |
| 128 } | 128 } |
| 129 | 129 |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 190 // append the 'footer' to code | 190 // append the 'footer' to code |
| 191 this->code().append("}"); | 191 this->code().append("}"); |
| 192 | 192 |
| 193 for (int i = 0; i <= fCodeIndex; i++) { | 193 for (int i = 0; i <= fCodeIndex; i++) { |
| 194 fCompilerStrings[i] = fShaderStrings[i].c_str(); | 194 fCompilerStrings[i] = fShaderStrings[i].c_str(); |
| 195 fCompilerStringLengths[i] = (int)fShaderStrings[i].size(); | 195 fCompilerStringLengths[i] = (int)fShaderStrings[i].size(); |
| 196 } | 196 } |
| 197 | 197 |
| 198 fFinalized = true; | 198 fFinalized = true; |
| 199 } | 199 } |
| OLD | NEW |