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 "GrGLFullProgramBuilder.h" | 9 #include "GrGLFullProgramBuilder.h" |
10 #include "GrGLShaderStringBuilder.h" | 10 #include "GrGLShaderStringBuilder.h" |
(...skipping 19 matching lines...) Expand all Loading... |
30 const GrGLShaderVar& attr = fInputs[i]; | 30 const GrGLShaderVar& attr = fInputs[i]; |
31 // if attribute already added, don't add it again | 31 // if attribute already added, don't add it again |
32 if (attr.getName().equals(var.getName())) { | 32 if (attr.getName().equals(var.getName())) { |
33 return false; | 33 return false; |
34 } | 34 } |
35 } | 35 } |
36 fInputs.push_back(var); | 36 fInputs.push_back(var); |
37 return true; | 37 return true; |
38 } | 38 } |
39 | 39 |
40 void GrGLVertexShaderBuilder::emitAttributes(const GrEffectStage& stage) { | 40 void GrGLVertexShaderBuilder::emitAttributes(const GrGeometryProcessor& gp) { |
41 const GrEffect& effect = *stage.getEffect(); | 41 const GrGeometryProcessor::VertexAttribArray& vars = gp.getVertexAttribs(); |
42 const GrEffect::VertexAttribArray& vars = | |
43 effect.getVertexAttribs(); | |
44 int numAttributes = vars.count(); | 42 int numAttributes = vars.count(); |
45 for (int a = 0; a < numAttributes; ++a) { | 43 for (int a = 0; a < numAttributes; ++a) { |
46 this->addAttribute(vars[a]); | 44 this->addAttribute(vars[a]); |
47 } | 45 } |
48 } | 46 } |
49 | 47 |
50 void GrGLVertexShaderBuilder::addVarying(GrSLType type, const char* name, const
char** vsOutName) { | 48 void GrGLVertexShaderBuilder::addVarying(GrSLType type, const char* name, const
char** vsOutName) { |
51 fOutputs.push_back(); | 49 fOutputs.push_back(); |
52 fOutputs.back().setType(type); | 50 fOutputs.back().setType(type); |
53 fOutputs.back().setTypeModifier(GrGLShaderVar::kVaryingOut_TypeModifier); | 51 fOutputs.back().setTypeModifier(GrGLShaderVar::kVaryingOut_TypeModifier); |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
86 | 84 |
87 // We pull the current state of attributes off of drawstate's optimized stat
e and bind them in | 85 // We pull the current state of attributes off of drawstate's optimized stat
e and bind them in |
88 // order. This assumes that the drawState has not changed since we called fl
ushGraphicsState() | 86 // order. This assumes that the drawState has not changed since we called fl
ushGraphicsState() |
89 // higher up in the stack. | 87 // higher up in the stack. |
90 SkAutoTUnref<GrOptDrawState> optState(fProgramBuilder->gpu()->drawState()->c
reateOptState()); | 88 SkAutoTUnref<GrOptDrawState> optState(fProgramBuilder->gpu()->drawState()->c
reateOptState()); |
91 const GrVertexAttrib* vaPtr = optState->getVertexAttribs(); | 89 const GrVertexAttrib* vaPtr = optState->getVertexAttribs(); |
92 const int vaCount = optState->getVertexAttribCount(); | 90 const int vaCount = optState->getVertexAttribCount(); |
93 | 91 |
94 int i = fEffectAttribOffset; | 92 int i = fEffectAttribOffset; |
95 for (int index = 0; index < vaCount; index++) { | 93 for (int index = 0; index < vaCount; index++) { |
96 if (kEffect_GrVertexAttribBinding != vaPtr[index].fBinding) { | 94 if (kGeometryProcessor_GrVertexAttribBinding != vaPtr[index].fBinding) { |
97 continue; | 95 continue; |
98 } | 96 } |
99 SkASSERT(index != header.fPositionAttributeIndex && | 97 SkASSERT(index != header.fPositionAttributeIndex && |
100 index != header.fLocalCoordAttributeIndex && | 98 index != header.fLocalCoordAttributeIndex && |
101 index != header.fColorAttributeIndex && | 99 index != header.fColorAttributeIndex && |
102 index != header.fCoverageAttributeIndex); | 100 index != header.fCoverageAttributeIndex); |
103 // We should never find another effect attribute if we have bound everyt
hing | 101 // We should never find another effect attribute if we have bound everyt
hing |
104 SkASSERT(i < fInputs.count()); | 102 SkASSERT(i < fInputs.count()); |
105 GL_CALL(BindAttribLocation(programId, index, fInputs[i].c_str())); | 103 GL_CALL(BindAttribLocation(programId, index, fInputs[i].c_str())); |
106 i++; | 104 i++; |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
193 this->addAttribute(GrShaderVar(coverage_attribute_name(), | 191 this->addAttribute(GrShaderVar(coverage_attribute_name(), |
194 kVec4f_GrSLType, | 192 kVec4f_GrSLType, |
195 GrShaderVar::kAttribute_TypeModifier)); | 193 GrShaderVar::kAttribute_TypeModifier)); |
196 const char *vsName, *fsName; | 194 const char *vsName, *fsName; |
197 fFullProgramBuilder->addVarying(kVec4f_GrSLType, "Coverage", &vsName, &f
sName); | 195 fFullProgramBuilder->addVarying(kVec4f_GrSLType, "Coverage", &vsName, &f
sName); |
198 this->codeAppendf("%s = %s;", vsName, coverage_attribute_name()); | 196 this->codeAppendf("%s = %s;", vsName, coverage_attribute_name()); |
199 *coverage = fsName; | 197 *coverage = fsName; |
200 } | 198 } |
201 fEffectAttribOffset = fInputs.count(); | 199 fEffectAttribOffset = fInputs.count(); |
202 } | 200 } |
OLD | NEW |