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 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
105 GL_CALL(BindAttribLocation(programId, index, fInputs[i].c_str())); | 105 GL_CALL(BindAttribLocation(programId, index, fInputs[i].c_str())); |
106 i++; | 106 i++; |
107 } | 107 } |
108 // Make sure we bound everything | 108 // Make sure we bound everything |
109 SkASSERT(fInputs.count() == i); | 109 SkASSERT(fInputs.count() == i); |
110 } | 110 } |
111 | 111 |
112 bool GrGLVertexShaderBuilder::compileAndAttachShaders(GrGLuint programId, | 112 bool GrGLVertexShaderBuilder::compileAndAttachShaders(GrGLuint programId, |
113 SkTDArray<GrGLuint>* shaderIds) const { | 113 SkTDArray<GrGLuint>* shaderIds) const { |
114 GrGpuGL* gpu = fProgramBuilder->gpu(); | 114 GrGpuGL* gpu = fProgramBuilder->gpu(); |
115 const GrGLContext& glCtx = gpu->glContext(); | |
116 const GrGLContextInfo& ctxInfo = gpu->ctxInfo(); | 115 const GrGLContextInfo& ctxInfo = gpu->ctxInfo(); |
117 SkString vertShaderSrc(GrGetGLSLVersionDecl(ctxInfo)); | 116 SkString vertShaderSrc(GrGetGLSLVersionDecl(ctxInfo)); |
118 fProgramBuilder->appendUniformDecls(GrGLProgramBuilder::kVertex_Visibility,
&vertShaderSrc); | 117 fProgramBuilder->appendUniformDecls(GrGLProgramBuilder::kVertex_Visibility,
&vertShaderSrc); |
119 fProgramBuilder->appendDecls(fInputs, &vertShaderSrc); | 118 fProgramBuilder->appendDecls(fInputs, &vertShaderSrc); |
120 fProgramBuilder->appendDecls(fOutputs, &vertShaderSrc); | 119 fProgramBuilder->appendDecls(fOutputs, &vertShaderSrc); |
121 vertShaderSrc.append("void main() {\n"); | 120 vertShaderSrc.append("void main() {\n"); |
122 vertShaderSrc.append(fCode); | 121 vertShaderSrc.append(fCode); |
123 vertShaderSrc.append("}\n"); | 122 vertShaderSrc.append("}\n"); |
124 GrGLuint vertShaderId = GrGLCompileAndAttachShader(glCtx, programId, | 123 GrGLuint vertShaderId = GrGLCompileAndAttachShader(gpu, programId, |
125 GR_GL_VERTEX_SHADER, vertShaderSrc); | 124 GR_GL_VERTEX_SHADER, vert
ShaderSrc); |
126 if (!vertShaderId) { | 125 if (!vertShaderId) { |
127 return false; | 126 return false; |
128 } | 127 } |
129 *shaderIds->append() = vertShaderId; | 128 *shaderIds->append() = vertShaderId; |
130 return true; | 129 return true; |
131 } | 130 } |
132 | 131 |
133 void GrGLVertexShaderBuilder::emitCodeAfterEffects() { | 132 void GrGLVertexShaderBuilder::emitCodeAfterEffects() { |
134 const char* rtAdjustName; | 133 const char* rtAdjustName; |
135 fProgramBuilder->fUniformHandles.fRTAdjustmentUni = | 134 fProgramBuilder->fUniformHandles.fRTAdjustmentUni = |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
192 this->addAttribute(GrShaderVar(coverage_attribute_name(), | 191 this->addAttribute(GrShaderVar(coverage_attribute_name(), |
193 kVec4f_GrSLType, | 192 kVec4f_GrSLType, |
194 GrShaderVar::kAttribute_TypeModifier)); | 193 GrShaderVar::kAttribute_TypeModifier)); |
195 const char *vsName, *fsName; | 194 const char *vsName, *fsName; |
196 fFullProgramBuilder->addVarying(kVec4f_GrSLType, "Coverage", &vsName, &f
sName); | 195 fFullProgramBuilder->addVarying(kVec4f_GrSLType, "Coverage", &vsName, &f
sName); |
197 this->codeAppendf("\t%s = %s;\n", vsName, coverage_attribute_name()); | 196 this->codeAppendf("\t%s = %s;\n", vsName, coverage_attribute_name()); |
198 *coverage = fsName; | 197 *coverage = fsName; |
199 } | 198 } |
200 fEffectAttribOffset = fInputs.count(); | 199 fEffectAttribOffset = fInputs.count(); |
201 } | 200 } |
OLD | NEW |