| 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" |
| 11 #include "../GrGpuGL.h" | 11 #include "../GrGpuGL.h" |
| 12 #include "../../GrOptDrawState.h" |
| 12 | 13 |
| 13 #define GL_CALL(X) GR_GL_CALL(gpu->glInterface(), X) | 14 #define GL_CALL(X) GR_GL_CALL(gpu->glInterface(), X) |
| 14 #define GL_CALL_RET(R, X) GR_GL_CALL_RET(gpu->glInterface(), R, X) | 15 #define GL_CALL_RET(R, X) GR_GL_CALL_RET(gpu->glInterface(), R, X) |
| 15 | 16 |
| 16 namespace { | 17 namespace { |
| 17 inline const char* color_attribute_name() { return "inColor"; } | 18 inline const char* color_attribute_name() { return "inColor"; } |
| 18 inline const char* coverage_attribute_name() { return "inCoverage"; } | 19 inline const char* coverage_attribute_name() { return "inCoverage"; } |
| 19 } | 20 } |
| 20 | 21 |
| 21 GrGLVertexShaderBuilder::GrGLVertexShaderBuilder(GrGLFullProgramBuilder* program
) | 22 GrGLVertexShaderBuilder::GrGLVertexShaderBuilder(GrGLFullProgramBuilder* program
) |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 76 GL_CALL(BindAttribLocation(programId, | 77 GL_CALL(BindAttribLocation(programId, |
| 77 header.fColorAttributeIndex, | 78 header.fColorAttributeIndex, |
| 78 color_attribute_name())); | 79 color_attribute_name())); |
| 79 } | 80 } |
| 80 if (-1 != header.fCoverageAttributeIndex) { | 81 if (-1 != header.fCoverageAttributeIndex) { |
| 81 GL_CALL(BindAttribLocation(programId, | 82 GL_CALL(BindAttribLocation(programId, |
| 82 header.fCoverageAttributeIndex, | 83 header.fCoverageAttributeIndex, |
| 83 coverage_attribute_name())); | 84 coverage_attribute_name())); |
| 84 } | 85 } |
| 85 | 86 |
| 86 // We pull the current state of attributes off of drawstate and bind them in
order | 87 // We pull the current state of attributes off of drawstate's optimized stat
e and bind them in |
| 87 const GrRODrawState* ds = fProgramBuilder->gpu()->drawState(); | 88 // order. This assumes that the drawState has not changed since we called fl
ushGraphicsState() |
| 88 const GrVertexAttrib* vaPtr = ds->getVertexAttribs(); | 89 // higher up in the stack. |
| 89 const int vaCount = ds->getVertexAttribCount(); | 90 SkAutoTUnref<GrOptDrawState> optState(fProgramBuilder->gpu()->drawState()->c
reateOptState()); |
| 91 const GrVertexAttrib* vaPtr = optState->getVertexAttribs(); |
| 92 const int vaCount = optState->getVertexAttribCount(); |
| 90 | 93 |
| 91 int i = fEffectAttribOffset; | 94 int i = fEffectAttribOffset; |
| 92 for (int index = 0; index < vaCount; index++) { | 95 for (int index = 0; index < vaCount; index++) { |
| 93 if (kEffect_GrVertexAttribBinding != vaPtr[index].fBinding) { | 96 if (kEffect_GrVertexAttribBinding != vaPtr[index].fBinding) { |
| 94 continue; | 97 continue; |
| 95 } | 98 } |
| 96 SkASSERT(index != header.fPositionAttributeIndex && | 99 SkASSERT(index != header.fPositionAttributeIndex && |
| 97 index != header.fLocalCoordAttributeIndex && | 100 index != header.fLocalCoordAttributeIndex && |
| 98 index != header.fColorAttributeIndex && | 101 index != header.fColorAttributeIndex && |
| 99 index != header.fCoverageAttributeIndex); | 102 index != header.fCoverageAttributeIndex); |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 189 this->addAttribute(GrShaderVar(coverage_attribute_name(), | 192 this->addAttribute(GrShaderVar(coverage_attribute_name(), |
| 190 kVec4f_GrSLType, | 193 kVec4f_GrSLType, |
| 191 GrShaderVar::kAttribute_TypeModifier)); | 194 GrShaderVar::kAttribute_TypeModifier)); |
| 192 const char *vsName, *fsName; | 195 const char *vsName, *fsName; |
| 193 fFullProgramBuilder->addVarying(kVec4f_GrSLType, "Coverage", &vsName, &f
sName); | 196 fFullProgramBuilder->addVarying(kVec4f_GrSLType, "Coverage", &vsName, &f
sName); |
| 194 this->codeAppendf("\t%s = %s;\n", vsName, coverage_attribute_name()); | 197 this->codeAppendf("\t%s = %s;\n", vsName, coverage_attribute_name()); |
| 195 *coverage = fsName; | 198 *coverage = fsName; |
| 196 } | 199 } |
| 197 fEffectAttribOffset = fInputs.count(); | 200 fEffectAttribOffset = fInputs.count(); |
| 198 } | 201 } |
| OLD | NEW |