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 "GrGLVertexShaderBuilder.h" | 8 #include "GrGLVertexShaderBuilder.h" |
9 #include "GrGLProgramBuilder.h" | 9 #include "GrGLProgramBuilder.h" |
10 #include "GrGLShaderStringBuilder.h" | 10 #include "GrGLShaderStringBuilder.h" |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
50 fProgramBuilder->fUniformHandles.fViewMatrixUni = | 50 fProgramBuilder->fUniformHandles.fViewMatrixUni = |
51 fProgramBuilder->addUniform(GrGLProgramBuilder::kVertex_Visibility, | 51 fProgramBuilder->addUniform(GrGLProgramBuilder::kVertex_Visibility, |
52 kMat33f_GrSLType, | 52 kMat33f_GrSLType, |
53 "ViewM", | 53 "ViewM", |
54 &viewMName); | 54 &viewMName); |
55 | 55 |
56 // Transform the position into Skia's device coords. | 56 // Transform the position into Skia's device coords. |
57 this->codeAppendf("vec3 pos3 = %s * vec3(%s, 1);", viewMName, fPositionVar->
c_str()); | 57 this->codeAppendf("vec3 pos3 = %s * vec3(%s, 1);", viewMName, fPositionVar->
c_str()); |
58 } | 58 } |
59 | 59 |
| 60 void GrGLVertexBuilder::setupBuiltinVertexAttribute(const char* inName, GrGLSLEx
pr1* out) { |
| 61 GrGLVertToFrag v(kFloat_GrSLType); |
| 62 fProgramBuilder->addVarying(inName, &v); |
| 63 SkString name(inName); |
| 64 name.prepend("in"); |
| 65 this->addAttribute(GrShaderVar(name.c_str(), |
| 66 kFloat_GrSLType, |
| 67 GrShaderVar::kAttribute_TypeModifier)); |
| 68 this->codeAppendf("%s = %s;", v.vsOut(), name.c_str()); |
| 69 *out = v.fsIn(); |
| 70 fEffectAttribOffset++; |
| 71 } |
| 72 |
60 void GrGLVertexBuilder::setupBuiltinVertexAttribute(const char* inName, GrGLSLEx
pr4* out) { | 73 void GrGLVertexBuilder::setupBuiltinVertexAttribute(const char* inName, GrGLSLEx
pr4* out) { |
61 GrGLVertToFrag v(kVec4f_GrSLType); | 74 GrGLVertToFrag v(kVec4f_GrSLType); |
62 fProgramBuilder->addVarying(inName, &v); | 75 fProgramBuilder->addVarying(inName, &v); |
63 SkString name(inName); | 76 SkString name(inName); |
64 name.prepend("in"); | 77 name.prepend("in"); |
65 this->addAttribute(GrShaderVar(name.c_str(), | 78 this->addAttribute(GrShaderVar(name.c_str(), |
66 kVec4f_GrSLType, | 79 kVec4f_GrSLType, |
67 GrShaderVar::kAttribute_TypeModifier)); | 80 GrShaderVar::kAttribute_TypeModifier)); |
68 this->codeAppendf("%s = %s;", v.vsOut(), name.c_str()); | 81 this->codeAppendf("%s = %s;", v.vsOut(), name.c_str()); |
69 *out = v.fsIn(); | 82 *out = v.fsIn(); |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
164 for (int i = 0; i < fInputs.count(); ++i) { | 177 for (int i = 0; i < fInputs.count(); ++i) { |
165 const GrGLShaderVar& attr = fInputs[i]; | 178 const GrGLShaderVar& attr = fInputs[i]; |
166 // if attribute already added, don't add it again | 179 // if attribute already added, don't add it again |
167 if (attr.getName().equals(var.getName())) { | 180 if (attr.getName().equals(var.getName())) { |
168 return false; | 181 return false; |
169 } | 182 } |
170 } | 183 } |
171 fInputs.push_back(var); | 184 fInputs.push_back(var); |
172 return true; | 185 return true; |
173 } | 186 } |
OLD | NEW |