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 GrDrawE
ffect& drawEffect) | 18 GrGLSimpleTextureEffect(const GrBackendEffectFactory& factory, const GrDrawE
ffect& drawEffect) |
19 : INHERITED (factory) { | 19 : INHERITED (factory) { |
20 GrEffect::CoordsType coordsType = | 20 GrEffect::CoordsType coordsType = |
21 drawEffect.castEffect<GrSimpleTextureEffect>().coordsType(); | 21 drawEffect.castEffect<GrSimpleTextureEffect>().coordsType(); |
22 if (GrEffect::kCustom_CoordsType != coordsType) { | 22 if (GrEffect::kCustom_CoordsType != coordsType) { |
23 SkNEW_IN_TLAZY(&fEffectMatrix, GrGLEffectMatrix, (coordsType)); | 23 SkNEW_IN_TLAZY(&fEffectMatrix, GrGLEffectMatrix, (coordsType)); |
24 } | 24 } |
25 } | 25 } |
26 | 26 |
| 27 virtual bool requiresVertexShader(const GrDrawEffect& drawEffect) const SK_O
VERRIDE { |
| 28 const GrSimpleTextureEffect& ste = drawEffect.castEffect<GrSimpleTexture
Effect>(); |
| 29 return GrEffect::kCustom_CoordsType == ste.coordsType(); |
| 30 } |
| 31 |
27 virtual void emitCode(GrGLShaderBuilder* builder, | 32 virtual void emitCode(GrGLShaderBuilder* builder, |
28 const GrDrawEffect& drawEffect, | 33 const GrDrawEffect& drawEffect, |
29 EffectKey key, | 34 EffectKey key, |
30 const char* outputColor, | 35 const char* outputColor, |
31 const char* inputColor, | 36 const char* inputColor, |
32 const TextureSamplerArray& samplers) SK_OVERRIDE { | 37 const TextureSamplerArray& samplers) SK_OVERRIDE { |
33 const GrSimpleTextureEffect& ste = drawEffect.castEffect<GrSimpleTexture
Effect>(); | 38 const GrSimpleTextureEffect& ste = drawEffect.castEffect<GrSimpleTexture
Effect>(); |
34 SkString fsCoordName; | 39 SkString fsCoordName; |
35 GrSLType fsCoordSLType; | 40 GrSLType fsCoordSLType; |
36 if (GrEffect::kCustom_CoordsType == ste.coordsType()) { | 41 if (GrEffect::kCustom_CoordsType == ste.coordsType()) { |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
123 }; | 128 }; |
124 CoordsType coordsType = kCoordsTypes[random->nextULessThan(GR_ARRAY_COUNT(kC
oordsTypes))]; | 129 CoordsType coordsType = kCoordsTypes[random->nextULessThan(GR_ARRAY_COUNT(kC
oordsTypes))]; |
125 | 130 |
126 if (kCustom_CoordsType == coordsType) { | 131 if (kCustom_CoordsType == coordsType) { |
127 return GrSimpleTextureEffect::CreateWithCustomCoords(textures[texIdx], p
arams); | 132 return GrSimpleTextureEffect::CreateWithCustomCoords(textures[texIdx], p
arams); |
128 } else { | 133 } else { |
129 const SkMatrix& matrix = GrEffectUnitTest::TestMatrix(random); | 134 const SkMatrix& matrix = GrEffectUnitTest::TestMatrix(random); |
130 return GrSimpleTextureEffect::Create(textures[texIdx], matrix); | 135 return GrSimpleTextureEffect::Create(textures[texIdx], matrix); |
131 } | 136 } |
132 } | 137 } |
OLD | NEW |