| 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 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 105 | 105 |
| 106 void GrGLSLShaderBuilder::appendTextureLookupAndModulate(const char* modulation, | 106 void GrGLSLShaderBuilder::appendTextureLookupAndModulate(const char* modulation, |
| 107 const GrGLSLTextureSamp
ler& sampler, | 107 const GrGLSLTextureSamp
ler& sampler, |
| 108 const char* coordName, | 108 const char* coordName, |
| 109 GrSLType varyingType) { | 109 GrSLType varyingType) { |
| 110 SkString lookup; | 110 SkString lookup; |
| 111 this->appendTextureLookup(&lookup, sampler, coordName, varyingType); | 111 this->appendTextureLookup(&lookup, sampler, coordName, varyingType); |
| 112 this->codeAppend((GrGLSLExpr4(modulation) * GrGLSLExpr4(lookup)).c_str()); | 112 this->codeAppend((GrGLSLExpr4(modulation) * GrGLSLExpr4(lookup)).c_str()); |
| 113 } | 113 } |
| 114 | 114 |
| 115 void GrGLSLShaderBuilder::addFeature(uint32_t featureBit, const char* extensionN
ame) { | 115 bool GrGLSLShaderBuilder::addFeature(uint32_t featureBit, const char* extensionN
ame) { |
| 116 if (!(featureBit & fFeaturesAddedMask)) { | 116 if (featureBit & fFeaturesAddedMask) { |
| 117 this->extensions().appendf("#extension %s: require\n", extensionName); | 117 return false; |
| 118 fFeaturesAddedMask |= featureBit; | |
| 119 } | 118 } |
| 119 this->extensions().appendf("#extension %s: require\n", extensionName); |
| 120 fFeaturesAddedMask |= featureBit; |
| 121 return true; |
| 120 } | 122 } |
| 121 | 123 |
| 122 void GrGLSLShaderBuilder::appendDecls(const VarArray& vars, SkString* out) const
{ | 124 void GrGLSLShaderBuilder::appendDecls(const VarArray& vars, SkString* out) const
{ |
| 123 for (int i = 0; i < vars.count(); ++i) { | 125 for (int i = 0; i < vars.count(); ++i) { |
| 124 vars[i].appendDecl(fProgramBuilder->glslCaps(), out); | 126 vars[i].appendDecl(fProgramBuilder->glslCaps(), out); |
| 125 out->append(";\n"); | 127 out->append(";\n"); |
| 126 } | 128 } |
| 127 } | 129 } |
| 128 | 130 |
| 129 void GrGLSLShaderBuilder::addLayoutQualifier(const char* param, InterfaceQualifi
er interface) { | 131 void GrGLSLShaderBuilder::addLayoutQualifier(const char* param, InterfaceQualifi
er interface) { |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 166 this->code().append("}"); | 168 this->code().append("}"); |
| 167 | 169 |
| 168 for (int i = 0; i <= fCodeIndex; i++) { | 170 for (int i = 0; i <= fCodeIndex; i++) { |
| 169 fCompilerStrings[i] = fShaderStrings[i].c_str(); | 171 fCompilerStrings[i] = fShaderStrings[i].c_str(); |
| 170 fCompilerStringLengths[i] = (int)fShaderStrings[i].size(); | 172 fCompilerStringLengths[i] = (int)fShaderStrings[i].size(); |
| 171 } | 173 } |
| 172 | 174 |
| 173 fFinalized = true; | 175 fFinalized = true; |
| 174 } | 176 } |
| 175 | 177 |
| OLD | NEW |