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 "gl/GrGLShaderVar.h" | |
15 #include "glsl/GrGLSLCaps.h" | 14 #include "glsl/GrGLSLCaps.h" |
| 15 #include "glsl/GrGLSLShaderVar.h" |
16 | 16 |
17 namespace { | 17 namespace { |
18 void append_texture_lookup(SkString* out, | 18 void append_texture_lookup(SkString* out, |
19 GrGLGpu* gpu, | 19 GrGLGpu* gpu, |
20 const char* samplerName, | 20 const char* samplerName, |
21 const char* coordName, | 21 const char* coordName, |
22 uint32_t configComponentMask, | 22 uint32_t configComponentMask, |
23 const char* swizzle, | 23 const char* swizzle, |
24 GrSLType varyingType = kVec2f_GrSLType) { | 24 GrSLType varyingType = kVec2f_GrSLType) { |
25 SkASSERT(coordName); | 25 SkASSERT(coordName); |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 // We push back some dummy pointers which will later become our header | 60 // We push back some dummy pointers which will later become our header |
61 for (int i = 0; i <= kCode; i++) { | 61 for (int i = 0; i <= kCode; i++) { |
62 fShaderStrings.push_back(); | 62 fShaderStrings.push_back(); |
63 fCompilerStrings.push_back(nullptr); | 63 fCompilerStrings.push_back(nullptr); |
64 fCompilerStringLengths.push_back(0); | 64 fCompilerStringLengths.push_back(0); |
65 } | 65 } |
66 | 66 |
67 this->main() = "void main() {"; | 67 this->main() = "void main() {"; |
68 } | 68 } |
69 | 69 |
70 void GrGLShaderBuilder::declAppend(const GrGLShaderVar& var) { | 70 void GrGLShaderBuilder::declAppend(const GrGLSLShaderVar& var) { |
71 SkString tempDecl; | 71 SkString tempDecl; |
72 var.appendDecl(fProgramBuilder->glslCaps(), &tempDecl); | 72 var.appendDecl(fProgramBuilder->glslCaps(), &tempDecl); |
73 this->codeAppendf("%s;", tempDecl.c_str()); | 73 this->codeAppendf("%s;", tempDecl.c_str()); |
74 } | 74 } |
75 | 75 |
76 void GrGLShaderBuilder::emitFunction(GrSLType returnType, | 76 void GrGLShaderBuilder::emitFunction(GrSLType returnType, |
77 const char* name, | 77 const char* name, |
78 int argCnt, | 78 int argCnt, |
79 const GrGLShaderVar* args, | 79 const GrGLSLShaderVar* args, |
80 const char* body, | 80 const char* body, |
81 SkString* outName) { | 81 SkString* outName) { |
82 this->functions().append(GrGLSLTypeString(returnType)); | 82 this->functions().append(GrGLSLTypeString(returnType)); |
83 fProgramBuilder->nameVariable(outName, '\0', name); | 83 fProgramBuilder->nameVariable(outName, '\0', name); |
84 this->functions().appendf(" %s", outName->c_str()); | 84 this->functions().appendf(" %s", outName->c_str()); |
85 this->functions().append("("); | 85 this->functions().append("("); |
86 for (int i = 0; i < argCnt; ++i) { | 86 for (int i = 0; i < argCnt; ++i) { |
87 args[i].appendDecl(fProgramBuilder->glslCaps(), &this->functions()); | 87 args[i].appendDecl(fProgramBuilder->glslCaps(), &this->functions()); |
88 if (i < argCnt - 1) { | 88 if (i < argCnt - 1) { |
89 this->functions().append(", "); | 89 this->functions().append(", "); |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
216 fFinalized = true; | 216 fFinalized = true; |
217 | 217 |
218 if (!shaderId) { | 218 if (!shaderId) { |
219 return false; | 219 return false; |
220 } | 220 } |
221 | 221 |
222 *shaderIds->append() = shaderId; | 222 *shaderIds->append() = shaderId; |
223 | 223 |
224 return true; | 224 return true; |
225 } | 225 } |
OLD | NEW |