Index: src/gpu/effects/GrDistanceFieldTextureEffect.cpp |
diff --git a/src/gpu/effects/GrDistanceFieldTextureEffect.cpp b/src/gpu/effects/GrDistanceFieldTextureEffect.cpp |
index ca38e849eb923db264f4450aac1b0e7da3dfc08c..e90ebfbf752d87262a75f2d92ff7740a88162c9e 100755 |
--- a/src/gpu/effects/GrDistanceFieldTextureEffect.cpp |
+++ b/src/gpu/effects/GrDistanceFieldTextureEffect.cpp |
@@ -49,14 +49,11 @@ public: |
SkAssertResult(fsBuilder->enableFeature( |
GrGLFragmentShaderBuilder::kStandardDerivatives_GLSLFeature)); |
- SkString fsCoordName; |
- const char* vsCoordName; |
- const char* fsCoordNamePtr; |
- args.fPB->addVarying(kVec2f_GrSLType, "textureCoords", &vsCoordName, &fsCoordNamePtr); |
- fsCoordName = fsCoordNamePtr; |
+ GrGLVertToFrag v(kVec2f_GrSLType); |
+ args.fPB->addVarying("TextureCoords", &v); |
GrGLVertexBuilder* vsBuilder = args.fPB->getVertexShaderBuilder(); |
- vsBuilder->codeAppendf("\t%s = %s;\n", vsCoordName, dfTexEffect.inTextureCoords().c_str()); |
+ vsBuilder->codeAppendf("\t%s = %s;\n", v.vsOut(), dfTexEffect.inTextureCoords().c_str()); |
const char* textureSizeUniName = NULL; |
fTextureSizeUni = args.fPB->addUniform(GrGLProgramBuilder::kFragment_Visibility, |
@@ -65,7 +62,7 @@ public: |
fsBuilder->codeAppend("\tvec4 texColor = "); |
fsBuilder->appendTextureLookup(args.fSamplers[0], |
- fsCoordName.c_str(), |
+ v.fsIn(), |
kVec2f_GrSLType); |
fsBuilder->codeAppend(";\n"); |
fsBuilder->codeAppend("\tfloat distance = " |
@@ -75,7 +72,7 @@ public: |
// we adjust for the effect of the transformation on the distance by using |
// the length of the gradient of the texture coordinates. We use st coordinates |
// to ensure we're mapping 1:1 from texel space to pixel space. |
- fsBuilder->codeAppendf("\tvec2 uv = %s;\n", fsCoordName.c_str()); |
+ fsBuilder->codeAppendf("\tvec2 uv = %s;\n", v.fsIn()); |
fsBuilder->codeAppendf("\tvec2 st = uv*%s;\n", textureSizeUniName); |
fsBuilder->codeAppend("\tfloat afwidth;\n"); |
if (dfTexEffect.getFlags() & kSimilarity_DistanceFieldEffectFlag) { |
@@ -264,14 +261,11 @@ public: |
SkAssertResult(fsBuilder->enableFeature( |
GrGLFragmentShaderBuilder::kStandardDerivatives_GLSLFeature)); |
- SkString fsCoordName; |
- const char* vsCoordName; |
- const char* fsCoordNamePtr; |
- args.fPB->addVarying(kVec2f_GrSLType, "textureCoords", &vsCoordName, &fsCoordNamePtr); |
- fsCoordName = fsCoordNamePtr; |
+ GrGLVertToFrag v(kVec2f_GrSLType); |
+ args.fPB->addVarying("TextureCoords", &v); |
GrGLVertexBuilder* vsBuilder = args.fPB->getVertexShaderBuilder(); |
- vsBuilder->codeAppendf("%s = %s;", vsCoordName, dfTexEffect.inTextureCoords().c_str()); |
+ vsBuilder->codeAppendf("%s = %s;", v.vsOut(), dfTexEffect.inTextureCoords().c_str()); |
const char* textureSizeUniName = NULL; |
fTextureSizeUni = args.fPB->addUniform(GrGLProgramBuilder::kFragment_Visibility, |
@@ -280,7 +274,7 @@ public: |
fsBuilder->codeAppend("vec4 texColor = "); |
fsBuilder->appendTextureLookup(args.fSamplers[0], |
- fsCoordName.c_str(), |
+ v.fsIn(), |
kVec2f_GrSLType); |
fsBuilder->codeAppend(";"); |
fsBuilder->codeAppend("float distance = " |
@@ -289,7 +283,7 @@ public: |
// we adjust for the effect of the transformation on the distance by using |
// the length of the gradient of the texture coordinates. We use st coordinates |
// to ensure we're mapping 1:1 from texel space to pixel space. |
- fsBuilder->codeAppendf("vec2 uv = %s;", fsCoordName.c_str()); |
+ fsBuilder->codeAppendf("vec2 uv = %s;", v.fsIn()); |
fsBuilder->codeAppendf("vec2 st = uv*%s;", textureSizeUniName); |
fsBuilder->codeAppend("float afwidth;"); |
if (dfTexEffect.getFlags() & kSimilarity_DistanceFieldEffectFlag) { |
@@ -421,14 +415,11 @@ public: |
args.fGP.cast<GrDistanceFieldLCDTextureEffect>(); |
SkASSERT(1 == dfTexEffect.getVertexAttribs().count()); |
- SkString fsCoordName; |
- const char* vsCoordName; |
- const char* fsCoordNamePtr; |
- args.fPB->addVarying(kVec2f_GrSLType, "textureCoords", &vsCoordName, &fsCoordNamePtr); |
- fsCoordName = fsCoordNamePtr; |
+ GrGLVertToFrag v(kVec2f_GrSLType); |
+ args.fPB->addVarying("TextureCoords", &v); |
GrGLVertexBuilder* vsBuilder = args.fPB->getVertexShaderBuilder(); |
- vsBuilder->codeAppendf("\t%s = %s;\n", vsCoordName, dfTexEffect.inTextureCoords().c_str()); |
+ vsBuilder->codeAppendf("\t%s = %s;\n", v.vsOut(), dfTexEffect.inTextureCoords().c_str()); |
const char* textureSizeUniName = NULL; |
// width, height, 1/(3*width) |
@@ -442,7 +433,7 @@ public: |
GrGLFragmentShaderBuilder::kStandardDerivatives_GLSLFeature)); |
// create LCD offset adjusted by inverse of transform |
- fsBuilder->codeAppendf("\tvec2 uv = %s;\n", fsCoordName.c_str()); |
+ fsBuilder->codeAppendf("\tvec2 uv = %s;\n", v.fsIn()); |
fsBuilder->codeAppendf("\tvec2 st = uv*%s.xy;\n", textureSizeUniName); |
bool isUniformScale = !!(dfTexEffect.getFlags() & kUniformScale_DistanceFieldEffectMask); |
if (isUniformScale) { |