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 23 matching lines...) Expand all Loading... |
34 const char* fsCoordName; | 34 const char* fsCoordName; |
35 GrSLType fsCoordSLType; | 35 GrSLType fsCoordSLType; |
36 if (GrEffect::kCustom_CoordsType == ste.coordsType()) { | 36 if (GrEffect::kCustom_CoordsType == ste.coordsType()) { |
37 GrAssert(ste.getMatrix().isIdentity()); | 37 GrAssert(ste.getMatrix().isIdentity()); |
38 GrAssert(1 == ste.numVertexAttribs()); | 38 GrAssert(1 == ste.numVertexAttribs()); |
39 fsCoordSLType = kVec2f_GrSLType; | 39 fsCoordSLType = kVec2f_GrSLType; |
40 const char* vsVaryingName; | 40 const char* vsVaryingName; |
41 builder->addVarying(kVec2f_GrSLType, "textureCoords", &vsVaryingName
, &fsCoordName); | 41 builder->addVarying(kVec2f_GrSLType, "textureCoords", &vsVaryingName
, &fsCoordName); |
42 const char* attrName = | 42 const char* attrName = |
43 builder->getEffectAttributeName(drawEffect.getVertexAttribIndice
s()[0])->c_str(); | 43 builder->getEffectAttributeName(drawEffect.getVertexAttribIndice
s()[0])->c_str(); |
44 builder->vsCodeAppendf("\t%s = %s;", vsVaryingName, attrName); | 44 builder->vsCodeAppendf("\t%s = %s;\n", vsVaryingName, attrName); |
45 } else { | 45 } else { |
46 fsCoordSLType = fEffectMatrix.get()->emitCode(builder, key, &fsCoord
Name); | 46 fsCoordSLType = fEffectMatrix.get()->emitCode(builder, key, &fsCoord
Name); |
47 } | 47 } |
48 builder->fsCodeAppendf("\t%s = ", outputColor); | 48 builder->fsCodeAppendf("\t%s = ", outputColor); |
49 builder->appendTextureLookupAndModulate(GrGLShaderBuilder::kFragment_Sha
derType, | 49 builder->appendTextureLookupAndModulate(GrGLShaderBuilder::kFragment_Sha
derType, |
50 inputColor, | 50 inputColor, |
51 samplers[0], | 51 samplers[0], |
52 fsCoordName, | 52 fsCoordName, |
53 fsCoordSLType); | 53 fsCoordSLType); |
54 builder->fsCodeAppend(";\n"); | 54 builder->fsCodeAppend(";\n"); |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
119 }; | 119 }; |
120 CoordsType coordsType = kCoordsTypes[random->nextULessThan(GR_ARRAY_COUNT(kC
oordsTypes))]; | 120 CoordsType coordsType = kCoordsTypes[random->nextULessThan(GR_ARRAY_COUNT(kC
oordsTypes))]; |
121 | 121 |
122 if (kCustom_CoordsType == coordsType) { | 122 if (kCustom_CoordsType == coordsType) { |
123 return GrSimpleTextureEffect::CreateWithCustomCoords(textures[texIdx], p
arams); | 123 return GrSimpleTextureEffect::CreateWithCustomCoords(textures[texIdx], p
arams); |
124 } else { | 124 } else { |
125 const SkMatrix& matrix = GrEffectUnitTest::TestMatrix(random); | 125 const SkMatrix& matrix = GrEffectUnitTest::TestMatrix(random); |
126 return GrSimpleTextureEffect::Create(textures[texIdx], matrix); | 126 return GrSimpleTextureEffect::Create(textures[texIdx], matrix); |
127 } | 127 } |
128 } | 128 } |
OLD | NEW |