OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2013 Google Inc. | 2 * Copyright 2013 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/builders/GrGLProgramBuilder.h" | 8 #include "gl/builders/GrGLProgramBuilder.h" |
9 #include "GrGLProgramEffects.h" | 9 #include "GrGLProgramEffects.h" |
10 #include "GrDrawEffect.h" | 10 #include "GrDrawEffect.h" |
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
208 | 208 |
209 void GrGLProgramEffects::emitSamplers(GrGLProgramBuilder* builder, | 209 void GrGLProgramEffects::emitSamplers(GrGLProgramBuilder* builder, |
210 const GrEffect* effect, | 210 const GrEffect* effect, |
211 TextureSamplerArray* outSamplers) { | 211 TextureSamplerArray* outSamplers) { |
212 SkTArray<Sampler, true>& samplers = fSamplers.push_back(); | 212 SkTArray<Sampler, true>& samplers = fSamplers.push_back(); |
213 int numTextures = effect->numTextures(); | 213 int numTextures = effect->numTextures(); |
214 samplers.push_back_n(numTextures); | 214 samplers.push_back_n(numTextures); |
215 SkString name; | 215 SkString name; |
216 for (int t = 0; t < numTextures; ++t) { | 216 for (int t = 0; t < numTextures; ++t) { |
217 name.printf("Sampler%d", t); | 217 name.printf("Sampler%d", t); |
| 218 const GrTextureAccess& textureAccess = effect->textureAccess(t); |
218 samplers[t].fUniform = builder->addUniform(GrGLProgramBuilder::kFragment
_Visibility, | 219 samplers[t].fUniform = builder->addUniform(GrGLProgramBuilder::kFragment
_Visibility, |
219 kSampler2D_GrSLType, | 220 SkToBool(textureAccess.getTexture()->desc().fFlags & k3DTexture_GrTe
xtureFlagBit) ? |
220 name.c_str()); | 221 kSampler3D_GrSLType : kSampler2D_GrSLType, name.c_str()); |
221 SkNEW_APPEND_TO_TARRAY(outSamplers, TextureSampler, | 222 SkNEW_APPEND_TO_TARRAY(outSamplers, TextureSampler, |
222 (samplers[t].fUniform, effect->textureAccess(t)))
; | 223 (samplers[t].fUniform, textureAccess)); |
223 } | 224 } |
224 } | 225 } |
225 | 226 |
226 void GrGLProgramEffects::initSamplers(const GrGLProgramDataManager& programResou
rceManager, int* texUnitIdx) { | 227 void GrGLProgramEffects::initSamplers(const GrGLProgramDataManager& programResou
rceManager, int* texUnitIdx) { |
227 int numEffects = fGLEffects.count(); | 228 int numEffects = fGLEffects.count(); |
228 SkASSERT(numEffects == fSamplers.count()); | 229 SkASSERT(numEffects == fSamplers.count()); |
229 for (int e = 0; e < numEffects; ++e) { | 230 for (int e = 0; e < numEffects; ++e) { |
230 SkTArray<Sampler, true>& samplers = fSamplers[e]; | 231 SkTArray<Sampler, true>& samplers = fSamplers[e]; |
231 int numSamplers = samplers.count(); | 232 int numSamplers = samplers.count(); |
232 for (int s = 0; s < numSamplers; ++s) { | 233 for (int s = 0; s < numSamplers; ++s) { |
(...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
567 } | 568 } |
568 void GrGLPathTexGenProgramEffectsBuilder::emitEffect(const GrEffectStage& stage, | 569 void GrGLPathTexGenProgramEffectsBuilder::emitEffect(const GrEffectStage& stage, |
569 const GrEffectKey& key, | 570 const GrEffectKey& key, |
570 const char* outColor, | 571 const char* outColor, |
571 const char* inColor, | 572 const char* inColor, |
572 int stageIndex) { | 573 int stageIndex) { |
573 SkASSERT(fProgramEffects.get()); | 574 SkASSERT(fProgramEffects.get()); |
574 fProgramEffects->emitEffect(fBuilder, stage, key, outColor, inColor, stageIn
dex); | 575 fProgramEffects->emitEffect(fBuilder, stage, key, outColor, inColor, stageIn
dex); |
575 } | 576 } |
576 | 577 |
OLD | NEW |