| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2012 Google Inc. | 2 * Copyright 2012 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 "GrSimpleTextureEffect.h" | 8 #include "GrSimpleTextureEffect.h" |
| 9 #include "gl/GrGLEffect.h" | 9 #include "gl/GrGLEffect.h" |
| 10 #include "gl/GrGLEffectMatrix.h" | 10 #include "gl/GrGLEffectMatrix.h" |
| 11 #include "gl/GrGLSL.h" | 11 #include "gl/GrGLSL.h" |
| 12 #include "gl/GrGLTexture.h" | 12 #include "gl/GrGLTexture.h" |
| 13 #include "GrTBackendEffectFactory.h" | 13 #include "GrTBackendEffectFactory.h" |
| 14 #include "GrTexture.h" | 14 #include "GrTexture.h" |
| 15 | 15 |
| 16 class GrGLSimpleTextureEffect : public GrGLEffect { | 16 class GrGLSimpleTextureEffect : public GrGLEffect { |
| 17 public: | 17 public: |
| 18 GrGLSimpleTextureEffect(const GrBackendEffectFactory& factory, const GrEffec
tRef&) | 18 GrGLSimpleTextureEffect(const GrBackendEffectFactory& factory, const GrEffec
tRef&) |
| 19 : INHERITED (factory) {} | 19 : INHERITED (factory) {} |
| 20 | 20 |
| 21 virtual void emitCode(GrGLShaderBuilder* builder, | 21 virtual void emitCode(GrGLShaderBuilder* builder, |
| 22 const GrEffectStage&, | 22 const GrEffectStage&, |
| 23 EffectKey key, | 23 EffectKey key, |
| 24 const char* vertexCoords, | 24 const char* vertexCoords, |
| 25 const char* outputColor, | 25 const char* outputColor, |
| 26 const char* inputColor, | 26 const char* inputColor, |
| 27 const TextureSamplerArray& samplers) SK_OVERRIDE { | 27 const TextureSamplerArray& samplers) SK_OVERRIDE { |
| 28 const char* coordName; | 28 const char* coordName; |
| 29 GrSLType coordType = fEffectMatrix.emitCode(builder, key, vertexCoords,
&coordName); | 29 GrSLType coordType = fEffectMatrix.emitCode(builder, key, vertexCoords,
&coordName); |
| 30 builder->fFSCode.appendf("\t%s = ", outputColor); | 30 builder->fsCodeAppendf("\t%s = ", outputColor); |
| 31 builder->appendTextureLookupAndModulate(&builder->fFSCode, | 31 builder->appendTextureLookupAndModulate(GrGLShaderBuilder::kFragment_Sha
derType, |
| 32 inputColor, | 32 inputColor, |
| 33 samplers[0], | 33 samplers[0], |
| 34 coordName, | 34 coordName, |
| 35 coordType); | 35 coordType); |
| 36 builder->fFSCode.append(";\n"); | 36 builder->fsCodeAppend(";\n"); |
| 37 } | 37 } |
| 38 | 38 |
| 39 static inline EffectKey GenKey(const GrEffectStage& stage, const GrGLCaps&)
{ | 39 static inline EffectKey GenKey(const GrEffectStage& stage, const GrGLCaps&)
{ |
| 40 const GrSimpleTextureEffect& ste = GetEffectFromStage<GrSimpleTextureEff
ect>(stage); | 40 const GrSimpleTextureEffect& ste = GetEffectFromStage<GrSimpleTextureEff
ect>(stage); |
| 41 return GrGLEffectMatrix::GenKey(ste.getMatrix(), | 41 return GrGLEffectMatrix::GenKey(ste.getMatrix(), |
| 42 stage.getCoordChangeMatrix(), | 42 stage.getCoordChangeMatrix(), |
| 43 ste.texture(0)); | 43 ste.texture(0)); |
| 44 } | 44 } |
| 45 | 45 |
| 46 virtual void setData(const GrGLUniformManager& uman, const GrEffectStage& st
age) SK_OVERRIDE { | 46 virtual void setData(const GrGLUniformManager& uman, const GrEffectStage& st
age) SK_OVERRIDE { |
| (...skipping 21 matching lines...) Expand all Loading... |
| 68 GR_DEFINE_EFFECT_TEST(GrSimpleTextureEffect); | 68 GR_DEFINE_EFFECT_TEST(GrSimpleTextureEffect); |
| 69 | 69 |
| 70 GrEffectRef* GrSimpleTextureEffect::TestCreate(SkMWCRandom* random, | 70 GrEffectRef* GrSimpleTextureEffect::TestCreate(SkMWCRandom* random, |
| 71 GrContext* context, | 71 GrContext* context, |
| 72 GrTexture* textures[]) { | 72 GrTexture* textures[]) { |
| 73 int texIdx = random->nextBool() ? GrEffectUnitTest::kSkiaPMTextureIdx : | 73 int texIdx = random->nextBool() ? GrEffectUnitTest::kSkiaPMTextureIdx : |
| 74 GrEffectUnitTest::kAlphaTextureIdx; | 74 GrEffectUnitTest::kAlphaTextureIdx; |
| 75 const SkMatrix& matrix = GrEffectUnitTest::TestMatrix(random); | 75 const SkMatrix& matrix = GrEffectUnitTest::TestMatrix(random); |
| 76 return GrSimpleTextureEffect::Create(textures[texIdx], matrix); | 76 return GrSimpleTextureEffect::Create(textures[texIdx], matrix); |
| 77 } | 77 } |
| OLD | NEW |