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 "../GrGLGLSL.h" |
10 #include "../GrGLGpu.h" | 11 #include "../GrGLGpu.h" |
11 | 12 |
12 #define GL_CALL(X) GR_GL_CALL(fProgramBuilder->gpu()->glInterface(), X) | 13 #define GL_CALL(X) GR_GL_CALL(fProgramBuilder->gpu()->glInterface(), X) |
13 #define GL_CALL_RET(R, X) GR_GL_CALL_RET(fProgramBuilder->gpu()->glInterface(),
R, X) | 14 #define GL_CALL_RET(R, X) GR_GL_CALL_RET(fProgramBuilder->gpu()->glInterface(),
R, X) |
14 | 15 |
15 GrGLVertexBuilder::GrGLVertexBuilder(GrGLProgramBuilder* program) | 16 GrGLVertexBuilder::GrGLVertexBuilder(GrGLProgramBuilder* program) |
16 : INHERITED(program) | 17 : INHERITED(program) |
17 , fRtAdjustName(NULL) { | 18 , fRtAdjustName(NULL) { |
18 } | 19 } |
19 | 20 |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
78 | 79 |
79 int vaCount = primProc.numAttribs(); | 80 int vaCount = primProc.numAttribs(); |
80 for (int i = 0; i < vaCount; i++) { | 81 for (int i = 0; i < vaCount; i++) { |
81 GL_CALL(BindAttribLocation(programID, i, primProc.getAttrib(i).fName)); | 82 GL_CALL(BindAttribLocation(programID, i, primProc.getAttrib(i).fName)); |
82 } | 83 } |
83 return; | 84 return; |
84 } | 85 } |
85 | 86 |
86 bool | 87 bool |
87 GrGLVertexBuilder::compileAndAttachShaders(GrGLuint programId, SkTDArray<GrGLuin
t>* shaderIds) { | 88 GrGLVertexBuilder::compileAndAttachShaders(GrGLuint programId, SkTDArray<GrGLuin
t>* shaderIds) { |
88 this->versionDecl() = GrGetGLSLVersionDecl(fProgramBuilder->ctxInfo()); | 89 this->versionDecl() = GrGLGetGLSLVersionDecl(fProgramBuilder->ctxInfo()); |
89 this->compileAndAppendLayoutQualifiers(); | 90 this->compileAndAppendLayoutQualifiers(); |
90 fProgramBuilder->appendUniformDecls(GrGLProgramBuilder::kVertex_Visibility,
&this->uniforms()); | 91 fProgramBuilder->appendUniformDecls(GrGLProgramBuilder::kVertex_Visibility,
&this->uniforms()); |
91 this->appendDecls(fInputs, &this->inputs()); | 92 this->appendDecls(fInputs, &this->inputs()); |
92 this->appendDecls(fOutputs, &this->outputs()); | 93 this->appendDecls(fOutputs, &this->outputs()); |
93 return this->finalize(programId, GR_GL_VERTEX_SHADER, shaderIds); | 94 return this->finalize(programId, GR_GL_VERTEX_SHADER, shaderIds); |
94 } | 95 } |
95 | 96 |
96 bool GrGLVertexBuilder::addAttribute(const GrShaderVar& var) { | 97 bool GrGLVertexBuilder::addAttribute(const GrShaderVar& var) { |
97 SkASSERT(GrShaderVar::kAttribute_TypeModifier == var.getTypeModifier()); | 98 SkASSERT(GrShaderVar::kAttribute_TypeModifier == var.getTypeModifier()); |
98 for (int i = 0; i < fInputs.count(); ++i) { | 99 for (int i = 0; i < fInputs.count(); ++i) { |
99 const GrGLShaderVar& attr = fInputs[i]; | 100 const GrGLShaderVar& attr = fInputs[i]; |
100 // if attribute already added, don't add it again | 101 // if attribute already added, don't add it again |
101 if (attr.getName().equals(var.getName())) { | 102 if (attr.getName().equals(var.getName())) { |
102 return false; | 103 return false; |
103 } | 104 } |
104 } | 105 } |
105 fInputs.push_back(var); | 106 fInputs.push_back(var); |
106 return true; | 107 return true; |
107 } | 108 } |
OLD | NEW |