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