| 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 "gl/GrGLProgram.h" | 8 #include "gl/GrGLProgram.h" |
| 9 #include "gl/GrGLSLPrettyPrint.h" | 9 #include "gl/GrGLSLPrettyPrint.h" |
| 10 #include "gl/GrGLUniformHandle.h" | 10 #include "gl/GrGLUniformHandle.h" |
| (...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 212 | 212 |
| 213 void GrGLProgramBuilder::emitSamplers(const GrProcessor& effect, | 213 void GrGLProgramBuilder::emitSamplers(const GrProcessor& effect, |
| 214 GrGLProcessor::TextureSamplerArray* outSam
plers) { | 214 GrGLProcessor::TextureSamplerArray* outSam
plers) { |
| 215 SkTArray<GrGLProgramEffects::Sampler, true>& samplers = | 215 SkTArray<GrGLProgramEffects::Sampler, true>& samplers = |
| 216 this->getProgramEffects()->addSamplers(); | 216 this->getProgramEffects()->addSamplers(); |
| 217 int numTextures = effect.numTextures(); | 217 int numTextures = effect.numTextures(); |
| 218 samplers.push_back_n(numTextures); | 218 samplers.push_back_n(numTextures); |
| 219 SkString name; | 219 SkString name; |
| 220 for (int t = 0; t < numTextures; ++t) { | 220 for (int t = 0; t < numTextures; ++t) { |
| 221 name.printf("Sampler%d", t); | 221 name.printf("Sampler%d", t); |
| 222 const GrTextureAccess& ta = effect.textureAccess(t); |
| 223 const GrTexture* tex = ta.getTexture(); |
| 224 bool is3D = (tex != NULL) && (tex->desc().fDepth > 0); |
| 222 samplers[t].fUniform = this->addUniform(GrGLProgramBuilder::kFragment_Vi
sibility, | 225 samplers[t].fUniform = this->addUniform(GrGLProgramBuilder::kFragment_Vi
sibility, |
| 223 kSampler2D_GrSLType, | 226 is3D ? kSampler3D_GrSLType : kSa
mpler2D_GrSLType, |
| 224 name.c_str()); | 227 name.c_str()); |
| 225 SkNEW_APPEND_TO_TARRAY(outSamplers, GrGLProcessor::TextureSampler, | 228 SkNEW_APPEND_TO_TARRAY(outSamplers, GrGLProcessor::TextureSampler, |
| 226 (samplers[t].fUniform, effect.textureAccess(t))); | 229 (samplers[t].fUniform, ta)); |
| 227 } | 230 } |
| 228 } | 231 } |
| 229 | 232 |
| 230 bool GrGLProgramBuilder::finish() { | 233 bool GrGLProgramBuilder::finish() { |
| 231 SkASSERT(0 == fProgramID); | 234 SkASSERT(0 == fProgramID); |
| 232 GL_CALL_RET(fProgramID, CreateProgram()); | 235 GL_CALL_RET(fProgramID, CreateProgram()); |
| 233 if (!fProgramID) { | 236 if (!fProgramID) { |
| 234 return false; | 237 return false; |
| 235 } | 238 } |
| 236 | 239 |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 321 GetProgramResourceLocation(programId, | 324 GetProgramResourceLocation(programId, |
| 322 GR_GL_FRAGMENT_INPUT, | 325 GR_GL_FRAGMENT_INPUT, |
| 323 fSeparableVaryingInfos[i].fVariab
le.c_str())); | 326 fSeparableVaryingInfos[i].fVariab
le.c_str())); |
| 324 fSeparableVaryingInfos[i].fLocation = location; | 327 fSeparableVaryingInfos[i].fLocation = location; |
| 325 } | 328 } |
| 326 } | 329 } |
| 327 | 330 |
| 328 const GrGLContextInfo& GrGLProgramBuilder::ctxInfo() const { | 331 const GrGLContextInfo& GrGLProgramBuilder::ctxInfo() const { |
| 329 return fGpu->ctxInfo(); | 332 return fGpu->ctxInfo(); |
| 330 } | 333 } |
| OLD | NEW |