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 "GrGLShaderBuilder.h" | 8 #include "GrGLShaderBuilder.h" |
9 #include "GrGLProgramBuilder.h" | 9 #include "GrGLProgramBuilder.h" |
10 #include "GrGLShaderStringBuilder.h" | 10 #include "GrGLShaderStringBuilder.h" |
11 #include "gl/GrGLCaps.h" | 11 #include "gl/GrGLCaps.h" |
12 #include "gl/GrGLContext.h" | 12 #include "gl/GrGLContext.h" |
13 #include "gl/GrGLGpu.h" | 13 #include "gl/GrGLGpu.h" |
14 #include "glsl/GrGLSLCaps.h" | 14 #include "glsl/GrGLSLCaps.h" |
15 #include "glsl/GrGLSLShaderVar.h" | 15 #include "glsl/GrGLSLShaderVar.h" |
| 16 #include "glsl/GrGLSLTextureSampler.h" |
16 | 17 |
17 namespace { | 18 namespace { |
18 void append_texture_lookup(SkString* out, | 19 void append_texture_lookup(SkString* out, |
19 GrGLGpu* gpu, | 20 GrGLGpu* gpu, |
20 const char* samplerName, | 21 const char* samplerName, |
21 const char* coordName, | 22 const char* coordName, |
22 uint32_t configComponentMask, | 23 uint32_t configComponentMask, |
23 const char* swizzle, | 24 const char* swizzle, |
24 GrSLType varyingType = kVec2f_GrSLType) { | 25 GrSLType varyingType = kVec2f_GrSLType) { |
25 SkASSERT(coordName); | 26 SkASSERT(coordName); |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
88 if (i < argCnt - 1) { | 89 if (i < argCnt - 1) { |
89 this->functions().append(", "); | 90 this->functions().append(", "); |
90 } | 91 } |
91 } | 92 } |
92 this->functions().append(") {\n"); | 93 this->functions().append(") {\n"); |
93 this->functions().append(body); | 94 this->functions().append(body); |
94 this->functions().append("}\n\n"); | 95 this->functions().append("}\n\n"); |
95 } | 96 } |
96 | 97 |
97 void GrGLShaderBuilder::appendTextureLookup(SkString* out, | 98 void GrGLShaderBuilder::appendTextureLookup(SkString* out, |
98 const TextureSampler& sampler, | 99 const GrGLSLTextureSampler& sampler, |
99 const char* coordName, | 100 const char* coordName, |
100 GrSLType varyingType) const { | 101 GrSLType varyingType) const { |
101 append_texture_lookup(out, | 102 append_texture_lookup(out, |
102 fProgramBuilder->gpu(), | 103 fProgramBuilder->gpu(), |
103 fProgramBuilder->getUniformCStr(sampler.fSamplerUnifor
m), | 104 fProgramBuilder->getUniformCStr(sampler.fSamplerUnifor
m), |
104 coordName, | 105 coordName, |
105 sampler.configComponentMask(), | 106 sampler.configComponentMask(), |
106 sampler.swizzle(), | 107 sampler.swizzle(), |
107 varyingType); | 108 varyingType); |
108 } | 109 } |
109 | 110 |
110 void GrGLShaderBuilder::appendTextureLookup(const TextureSampler& sampler, | 111 void GrGLShaderBuilder::appendTextureLookup(const GrGLSLTextureSampler& sampler, |
111 const char* coordName, | 112 const char* coordName, |
112 GrSLType varyingType) { | 113 GrSLType varyingType) { |
113 this->appendTextureLookup(&this->code(), sampler, coordName, varyingType); | 114 this->appendTextureLookup(&this->code(), sampler, coordName, varyingType); |
114 } | 115 } |
115 | 116 |
116 void GrGLShaderBuilder::appendTextureLookupAndModulate(const char* modulation, | 117 void GrGLShaderBuilder::appendTextureLookupAndModulate(const char* modulation, |
117 const TextureSampler& sam
pler, | 118 const GrGLSLTextureSample
r& sampler, |
118 const char* coordName, | 119 const char* coordName, |
119 GrSLType varyingType) { | 120 GrSLType varyingType) { |
120 SkString lookup; | 121 SkString lookup; |
121 this->appendTextureLookup(&lookup, sampler, coordName, varyingType); | 122 this->appendTextureLookup(&lookup, sampler, coordName, varyingType); |
122 this->codeAppend((GrGLSLExpr4(modulation) * GrGLSLExpr4(lookup)).c_str()); | 123 this->codeAppend((GrGLSLExpr4(modulation) * GrGLSLExpr4(lookup)).c_str()); |
123 } | 124 } |
124 | 125 |
125 | 126 |
126 const GrGLenum* GrGLShaderBuilder::GetTexParamSwizzle(GrPixelConfig config, cons
t GrGLCaps& caps) { | 127 const GrGLenum* GrGLShaderBuilder::GetTexParamSwizzle(GrPixelConfig config, cons
t GrGLCaps& caps) { |
127 if (caps.textureSwizzleSupport() && GrPixelConfigIsAlphaOnly(config)) { | 128 if (caps.textureSwizzleSupport() && GrPixelConfigIsAlphaOnly(config)) { |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
216 fFinalized = true; | 217 fFinalized = true; |
217 | 218 |
218 if (!shaderId) { | 219 if (!shaderId) { |
219 return false; | 220 return false; |
220 } | 221 } |
221 | 222 |
222 *shaderIds->append() = shaderId; | 223 *shaderIds->append() = shaderId; |
223 | 224 |
224 return true; | 225 return true; |
225 } | 226 } |
OLD | NEW |