| 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" |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 78 GrGLGpu* gpu = fProgramBuilder->gpu(); | 78 GrGLGpu* gpu = fProgramBuilder->gpu(); |
| 79 const GrGLContext& glCtx = gpu->glContext(); | 79 const GrGLContext& glCtx = gpu->glContext(); |
| 80 const GrGLContextInfo& ctxInfo = gpu->ctxInfo(); | 80 const GrGLContextInfo& ctxInfo = gpu->ctxInfo(); |
| 81 SkString vertShaderSrc(GrGetGLSLVersionDecl(ctxInfo)); | 81 SkString vertShaderSrc(GrGetGLSLVersionDecl(ctxInfo)); |
| 82 fProgramBuilder->appendUniformDecls(GrGLProgramBuilder::kVertex_Visibility,
&vertShaderSrc); | 82 fProgramBuilder->appendUniformDecls(GrGLProgramBuilder::kVertex_Visibility,
&vertShaderSrc); |
| 83 this->appendDecls(fInputs, &vertShaderSrc); | 83 this->appendDecls(fInputs, &vertShaderSrc); |
| 84 this->appendDecls(fOutputs, &vertShaderSrc); | 84 this->appendDecls(fOutputs, &vertShaderSrc); |
| 85 vertShaderSrc.append("void main() {"); | 85 vertShaderSrc.append("void main() {"); |
| 86 vertShaderSrc.append(fCode); | 86 vertShaderSrc.append(fCode); |
| 87 vertShaderSrc.append("}\n"); | 87 vertShaderSrc.append("}\n"); |
| 88 GrGLuint vertShaderId = GrGLCompileAndAttachShader(glCtx, programId, | 88 GrGLuint vertShaderId = GrGLCompileAndAttachShader(glCtx, programId, GR_GL_V
ERTEX_SHADER, |
| 89 GR_GL_VERTEX_SHADER, vert
ShaderSrc, | 89 vertShaderSrc, gpu->stats
()); |
| 90 gpu->gpuStats()); | |
| 91 if (!vertShaderId) { | 90 if (!vertShaderId) { |
| 92 return false; | 91 return false; |
| 93 } | 92 } |
| 94 *shaderIds->append() = vertShaderId; | 93 *shaderIds->append() = vertShaderId; |
| 95 return true; | 94 return true; |
| 96 } | 95 } |
| 97 | 96 |
| 98 bool GrGLVertexBuilder::addAttribute(const GrShaderVar& var) { | 97 bool GrGLVertexBuilder::addAttribute(const GrShaderVar& var) { |
| 99 SkASSERT(GrShaderVar::kAttribute_TypeModifier == var.getTypeModifier()); | 98 SkASSERT(GrShaderVar::kAttribute_TypeModifier == var.getTypeModifier()); |
| 100 for (int i = 0; i < fInputs.count(); ++i) { | 99 for (int i = 0; i < fInputs.count(); ++i) { |
| 101 const GrGLShaderVar& attr = fInputs[i]; | 100 const GrGLShaderVar& attr = fInputs[i]; |
| 102 // if attribute already added, don't add it again | 101 // if attribute already added, don't add it again |
| 103 if (attr.getName().equals(var.getName())) { | 102 if (attr.getName().equals(var.getName())) { |
| 104 return false; | 103 return false; |
| 105 } | 104 } |
| 106 } | 105 } |
| 107 fInputs.push_back(var); | 106 fInputs.push_back(var); |
| 108 return true; | 107 return true; |
| 109 } | 108 } |
| OLD | NEW |