| 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 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 75 GL_CALL(BindAttribLocation(programId, | 75 GL_CALL(BindAttribLocation(programId, |
| 76 header.fColorAttributeIndex, | 76 header.fColorAttributeIndex, |
| 77 color_attribute_name())); | 77 color_attribute_name())); |
| 78 } | 78 } |
| 79 if (-1 != header.fCoverageAttributeIndex) { | 79 if (-1 != header.fCoverageAttributeIndex) { |
| 80 GL_CALL(BindAttribLocation(programId, | 80 GL_CALL(BindAttribLocation(programId, |
| 81 header.fCoverageAttributeIndex, | 81 header.fCoverageAttributeIndex, |
| 82 coverage_attribute_name())); | 82 coverage_attribute_name())); |
| 83 } | 83 } |
| 84 | 84 |
| 85 // We pull the current state of attributes off of drawstate's optimized stat
e and bind them in | 85 const GrOptDrawState& optState = fProgramBuilder->optState(); |
| 86 // order. This assumes that the drawState has not changed since we called fl
ushGraphicsState() | 86 const GrVertexAttrib* vaPtr = optState.getVertexAttribs(); |
| 87 // higher up in the stack. | 87 const int vaCount = optState.getVertexAttribCount(); |
| 88 const GrDrawTargetCaps* caps = fProgramBuilder->gpu()->caps(); | |
| 89 const GrDrawState& drawState = *fProgramBuilder->gpu()->drawState(); | |
| 90 SkAutoTUnref<GrOptDrawState> optState(drawState.createOptState(*caps)); | |
| 91 const GrVertexAttrib* vaPtr = optState->getVertexAttribs(); | |
| 92 const int vaCount = optState->getVertexAttribCount(); | |
| 93 | 88 |
| 94 int i = fEffectAttribOffset; | 89 int i = fEffectAttribOffset; |
| 95 for (int index = 0; index < vaCount; index++) { | 90 for (int index = 0; index < vaCount; index++) { |
| 96 if (kGeometryProcessor_GrVertexAttribBinding != vaPtr[index].fBinding) { | 91 if (kGeometryProcessor_GrVertexAttribBinding != vaPtr[index].fBinding) { |
| 97 continue; | 92 continue; |
| 98 } | 93 } |
| 99 SkASSERT(index != header.fPositionAttributeIndex && | 94 SkASSERT(index != header.fPositionAttributeIndex && |
| 100 index != header.fLocalCoordAttributeIndex && | 95 index != header.fLocalCoordAttributeIndex && |
| 101 index != header.fColorAttributeIndex && | 96 index != header.fColorAttributeIndex && |
| 102 index != header.fCoverageAttributeIndex); | 97 index != header.fCoverageAttributeIndex); |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 193 this->addAttribute(GrShaderVar(coverage_attribute_name(), | 188 this->addAttribute(GrShaderVar(coverage_attribute_name(), |
| 194 kVec4f_GrSLType, | 189 kVec4f_GrSLType, |
| 195 GrShaderVar::kAttribute_TypeModifier)); | 190 GrShaderVar::kAttribute_TypeModifier)); |
| 196 const char *vsName, *fsName; | 191 const char *vsName, *fsName; |
| 197 fFullProgramBuilder->addVarying(kVec4f_GrSLType, "Coverage", &vsName, &f
sName); | 192 fFullProgramBuilder->addVarying(kVec4f_GrSLType, "Coverage", &vsName, &f
sName); |
| 198 this->codeAppendf("%s = %s;", vsName, coverage_attribute_name()); | 193 this->codeAppendf("%s = %s;", vsName, coverage_attribute_name()); |
| 199 *coverage = fsName; | 194 *coverage = fsName; |
| 200 } | 195 } |
| 201 fEffectAttribOffset = fInputs.count(); | 196 fEffectAttribOffset = fInputs.count(); |
| 202 } | 197 } |
| OLD | NEW |