| 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 30 matching lines...) Expand all Loading... |
| 41 const char* fsVaryingNamePtr; | 41 const char* fsVaryingNamePtr; |
| 42 builder->addVarying(kVec2f_GrSLType, "textureCoords", &vsVaryingName
, &fsVaryingNamePtr); | 42 builder->addVarying(kVec2f_GrSLType, "textureCoords", &vsVaryingName
, &fsVaryingNamePtr); |
| 43 fsCoordName = fsVaryingNamePtr; | 43 fsCoordName = fsVaryingNamePtr; |
| 44 const char* attrName = | 44 const char* attrName = |
| 45 builder->getEffectAttributeName(drawEffect.getVertexAttribIndice
s()[0])->c_str(); | 45 builder->getEffectAttributeName(drawEffect.getVertexAttribIndice
s()[0])->c_str(); |
| 46 builder->vsCodeAppendf("\t%s = %s;\n", vsVaryingName, attrName); | 46 builder->vsCodeAppendf("\t%s = %s;\n", vsVaryingName, attrName); |
| 47 } else { | 47 } else { |
| 48 fsCoordSLType = fEffectMatrix.get()->emitCode(builder, key, &fsCoord
Name); | 48 fsCoordSLType = fEffectMatrix.get()->emitCode(builder, key, &fsCoord
Name); |
| 49 } | 49 } |
| 50 builder->fsCodeAppendf("\t%s = ", outputColor); | 50 builder->fsCodeAppendf("\t%s = ", outputColor); |
| 51 builder->appendTextureLookupAndModulate(GrGLShaderBuilder::kFragment_Sha
derType, | 51 builder->fsAppendTextureLookupAndModulate(inputColor, |
| 52 inputColor, | 52 samplers[0], |
| 53 samplers[0], | 53 fsCoordName.c_str(), |
| 54 fsCoordName.c_str(), | 54 fsCoordSLType); |
| 55 fsCoordSLType); | |
| 56 builder->fsCodeAppend(";\n"); | 55 builder->fsCodeAppend(";\n"); |
| 57 } | 56 } |
| 58 | 57 |
| 59 static inline EffectKey GenKey(const GrDrawEffect& drawEffect, const GrGLCap
s&) { | 58 static inline EffectKey GenKey(const GrDrawEffect& drawEffect, const GrGLCap
s&) { |
| 60 const GrSimpleTextureEffect& ste = drawEffect.castEffect<GrSimpleTexture
Effect>(); | 59 const GrSimpleTextureEffect& ste = drawEffect.castEffect<GrSimpleTexture
Effect>(); |
| 61 if (GrEffect::kCustom_CoordsType == ste.coordsType()) { | 60 if (GrEffect::kCustom_CoordsType == ste.coordsType()) { |
| 62 return 1 << GrGLEffectMatrix::kKeyBits; | 61 return 1 << GrGLEffectMatrix::kKeyBits; |
| 63 } else { | 62 } else { |
| 64 return GrGLEffectMatrix::GenKey(ste.getMatrix(), | 63 return GrGLEffectMatrix::GenKey(ste.getMatrix(), |
| 65 drawEffect, | 64 drawEffect, |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 122 }; | 121 }; |
| 123 CoordsType coordsType = kCoordsTypes[random->nextULessThan(GR_ARRAY_COUNT(kC
oordsTypes))]; | 122 CoordsType coordsType = kCoordsTypes[random->nextULessThan(GR_ARRAY_COUNT(kC
oordsTypes))]; |
| 124 | 123 |
| 125 if (kCustom_CoordsType == coordsType) { | 124 if (kCustom_CoordsType == coordsType) { |
| 126 return GrSimpleTextureEffect::CreateWithCustomCoords(textures[texIdx], p
arams); | 125 return GrSimpleTextureEffect::CreateWithCustomCoords(textures[texIdx], p
arams); |
| 127 } else { | 126 } else { |
| 128 const SkMatrix& matrix = GrEffectUnitTest::TestMatrix(random); | 127 const SkMatrix& matrix = GrEffectUnitTest::TestMatrix(random); |
| 129 return GrSimpleTextureEffect::Create(textures[texIdx], matrix); | 128 return GrSimpleTextureEffect::Create(textures[texIdx], matrix); |
| 130 } | 129 } |
| 131 } | 130 } |
| OLD | NEW |