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" |
(...skipping 21 matching lines...) Expand all Loading... |
32 const TextureSamplerArray& samplers) SK_OVERRIDE { | 32 const TextureSamplerArray& samplers) SK_OVERRIDE { |
33 const GrSimpleTextureEffect& ste = drawEffect.castEffect<GrSimpleTexture
Effect>(); | 33 const GrSimpleTextureEffect& ste = drawEffect.castEffect<GrSimpleTexture
Effect>(); |
34 SkString fsCoordName; | 34 SkString fsCoordName; |
35 GrSLType fsCoordSLType; | 35 GrSLType fsCoordSLType; |
36 if (GrEffect::kCustom_CoordsType == ste.coordsType()) { | 36 if (GrEffect::kCustom_CoordsType == ste.coordsType()) { |
37 SkASSERT(ste.getMatrix().isIdentity()); | 37 SkASSERT(ste.getMatrix().isIdentity()); |
38 SkASSERT(1 == ste.numVertexAttribs()); | 38 SkASSERT(1 == ste.numVertexAttribs()); |
39 fsCoordSLType = kVec2f_GrSLType; | 39 fsCoordSLType = kVec2f_GrSLType; |
40 const char* vsVaryingName; | 40 const char* vsVaryingName; |
41 const char* fsVaryingNamePtr; | 41 const char* fsVaryingNamePtr; |
42 builder->addVarying(kVec2f_GrSLType, "textureCoords", &vsVaryingName
, &fsVaryingNamePtr); | 42 GrGLShaderBuilder::VertexBuilder* vertexBuilder = builder->getVertex
Builder(); |
| 43 SkASSERT(NULL != vertexBuilder); |
| 44 vertexBuilder->addVarying(kVec2f_GrSLType, "textureCoords", &vsVaryi
ngName, &fsVaryingNamePtr); |
43 fsCoordName = fsVaryingNamePtr; | 45 fsCoordName = fsVaryingNamePtr; |
44 const char* attrName = | 46 const char* attrName = |
45 builder->getEffectAttributeName(drawEffect.getVertexAttribIndice
s()[0])->c_str(); | 47 vertexBuilder->getEffectAttributeName(drawEffect.getVertexAttrib
Indices()[0])->c_str(); |
46 builder->vsCodeAppendf("\t%s = %s;\n", vsVaryingName, attrName); | 48 vertexBuilder->vsCodeAppendf("\t%s = %s;\n", vsVaryingName, attrName
); |
47 } else { | 49 } else { |
48 fsCoordSLType = fEffectMatrix.get()->emitCode(builder, key, &fsCoord
Name); | 50 fsCoordSLType = fEffectMatrix.get()->emitCode(builder, key, &fsCoord
Name); |
49 } | 51 } |
50 builder->fsCodeAppendf("\t%s = ", outputColor); | 52 builder->fsCodeAppendf("\t%s = ", outputColor); |
51 builder->fsAppendTextureLookupAndModulate(inputColor, | 53 builder->fsAppendTextureLookupAndModulate(inputColor, |
52 samplers[0], | 54 samplers[0], |
53 fsCoordName.c_str(), | 55 fsCoordName.c_str(), |
54 fsCoordSLType); | 56 fsCoordSLType); |
55 builder->fsCodeAppend(";\n"); | 57 builder->fsCodeAppend(";\n"); |
56 } | 58 } |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
121 }; | 123 }; |
122 CoordsType coordsType = kCoordsTypes[random->nextULessThan(GR_ARRAY_COUNT(kC
oordsTypes))]; | 124 CoordsType coordsType = kCoordsTypes[random->nextULessThan(GR_ARRAY_COUNT(kC
oordsTypes))]; |
123 | 125 |
124 if (kCustom_CoordsType == coordsType) { | 126 if (kCustom_CoordsType == coordsType) { |
125 return GrSimpleTextureEffect::CreateWithCustomCoords(textures[texIdx], p
arams); | 127 return GrSimpleTextureEffect::CreateWithCustomCoords(textures[texIdx], p
arams); |
126 } else { | 128 } else { |
127 const SkMatrix& matrix = GrEffectUnitTest::TestMatrix(random); | 129 const SkMatrix& matrix = GrEffectUnitTest::TestMatrix(random); |
128 return GrSimpleTextureEffect::Create(textures[texIdx], matrix); | 130 return GrSimpleTextureEffect::Create(textures[texIdx], matrix); |
129 } | 131 } |
130 } | 132 } |
OLD | NEW |