| Index: src/gpu/effects/GrDistanceFieldTextureEffect.cpp
 | 
| diff --git a/src/gpu/effects/GrCustomCoordsTextureEffect.cpp b/src/gpu/effects/GrDistanceFieldTextureEffect.cpp
 | 
| old mode 100644
 | 
| new mode 100755
 | 
| similarity index 60%
 | 
| copy from src/gpu/effects/GrCustomCoordsTextureEffect.cpp
 | 
| copy to src/gpu/effects/GrDistanceFieldTextureEffect.cpp
 | 
| index f85a927abab2eb6baf4b939022481511afd0c47b..fd27f2b31da6113371ad184792a6a3d6512789b5
 | 
| --- a/src/gpu/effects/GrCustomCoordsTextureEffect.cpp
 | 
| +++ b/src/gpu/effects/GrDistanceFieldTextureEffect.cpp
 | 
| @@ -5,7 +5,7 @@
 | 
|   * found in the LICENSE file.
 | 
|   */
 | 
|  
 | 
| -#include "GrCustomCoordsTextureEffect.h"
 | 
| +#include "GrDistanceFieldTextureEffect.h"
 | 
|  #include "gl/GrGLEffect.h"
 | 
|  #include "gl/GrGLSL.h"
 | 
|  #include "gl/GrGLTexture.h"
 | 
| @@ -13,9 +13,13 @@
 | 
|  #include "GrTBackendEffectFactory.h"
 | 
|  #include "GrTexture.h"
 | 
|  
 | 
| -class GrGLCustomCoordsTextureEffect : public GrGLVertexEffect {
 | 
| +// The distance field is constructed as unsigned char values, so that the zero value is at 128.
 | 
| +// Hence our zero threshold is 128/255. 
 | 
| +#define THRESHOLD "0.50196078431"
 | 
| +
 | 
| +class GrGLDistanceFieldTextureEffect : public GrGLVertexEffect {
 | 
|  public:
 | 
| -    GrGLCustomCoordsTextureEffect(const GrBackendEffectFactory& factory, const GrDrawEffect& drawEffect)
 | 
| +    GrGLDistanceFieldTextureEffect(const GrBackendEffectFactory& factory, const GrDrawEffect& drawEffect)
 | 
|          : INHERITED (factory) {}
 | 
|  
 | 
|      virtual void emitCode(GrGLFullShaderBuilder* builder,
 | 
| @@ -25,7 +29,7 @@ public:
 | 
|                            const char* inputColor,
 | 
|                            const TransformedCoordsArray&,
 | 
|                            const TextureSamplerArray& samplers) SK_OVERRIDE {
 | 
| -        SkASSERT(1 == drawEffect.castEffect<GrCustomCoordsTextureEffect>().numVertexAttribs());
 | 
| +        SkASSERT(1 == drawEffect.castEffect<GrDistanceFieldTextureEffect>().numVertexAttribs());
 | 
|  
 | 
|          SkString fsCoordName;
 | 
|          const char* vsVaryingName;
 | 
| @@ -37,12 +41,19 @@ public:
 | 
|              builder->getEffectAttributeName(drawEffect.getVertexAttribIndices()[0])->c_str();
 | 
|          builder->vsCodeAppendf("\t%s = %s;\n", vsVaryingName, attrName);
 | 
|  
 | 
| -        builder->fsCodeAppendf("\t%s = ", outputColor);
 | 
| -        builder->fsAppendTextureLookupAndModulate(inputColor,
 | 
| -                                                  samplers[0],
 | 
| -                                                  fsCoordName.c_str(),
 | 
| -                                                  kVec2f_GrSLType);
 | 
| +        builder->fsCodeAppend("\tvec4 texColor = ");
 | 
| +        builder->fsAppendTextureLookup(samplers[0],
 | 
| +                                       fsCoordName.c_str(),
 | 
| +                                       kVec2f_GrSLType);
 | 
|          builder->fsCodeAppend(";\n");
 | 
| +        builder->fsCodeAppend("\tfloat distance = texColor.r;\n");
 | 
| +        // this gives us a smooth step across approximately one fragment 
 | 
| +        // (assuming a radius of the diagonal of the fragment, hence a factor of sqrt(2)/2)
 | 
| +        builder->fsCodeAppend("\tfloat afwidth = 0.7071*length(vec2(dFdx(distance), dFdy(distance)));\n");
 | 
| +        builder->fsCodeAppend("\tfloat val = smoothstep("THRESHOLD"-afwidth, "THRESHOLD"+afwidth, distance);\n");
 | 
| +
 | 
| +        builder->fsCodeAppendf("\t%s = %s;\n", outputColor,
 | 
| +                                   (GrGLSLExpr4(inputColor) * GrGLSLExpr1("val")).c_str());
 | 
|      }
 | 
|  
 | 
|      virtual void setData(const GrGLUniformManager& uman,
 | 
| @@ -54,19 +65,19 @@ private:
 | 
|  
 | 
|  ///////////////////////////////////////////////////////////////////////////////
 | 
|  
 | 
| -GrCustomCoordsTextureEffect::GrCustomCoordsTextureEffect(GrTexture* texture,
 | 
| +GrDistanceFieldTextureEffect::GrDistanceFieldTextureEffect(GrTexture* texture,
 | 
|                                                           const GrTextureParams& params)
 | 
|      : fTextureAccess(texture, params) {
 | 
|      this->addTextureAccess(&fTextureAccess);
 | 
|      this->addVertexAttrib(kVec2f_GrSLType);
 | 
|  }
 | 
|  
 | 
| -bool GrCustomCoordsTextureEffect::onIsEqual(const GrEffect& other) const {
 | 
| -    const GrCustomCoordsTextureEffect& cte = CastEffect<GrCustomCoordsTextureEffect>(other);
 | 
| +bool GrDistanceFieldTextureEffect::onIsEqual(const GrEffect& other) const {
 | 
| +    const GrDistanceFieldTextureEffect& cte = CastEffect<GrDistanceFieldTextureEffect>(other);
 | 
|      return fTextureAccess == cte.fTextureAccess;
 | 
|  }
 | 
|  
 | 
| -void GrCustomCoordsTextureEffect::getConstantColorComponents(GrColor* color,
 | 
| +void GrDistanceFieldTextureEffect::getConstantColorComponents(GrColor* color,
 | 
|                                                               uint32_t* validFlags) const {
 | 
|      if ((*validFlags & kA_GrColorComponentFlag) && 0xFF == GrColorUnpackA(*color) &&
 | 
|          GrPixelConfigIsOpaque(this->texture(0)->config())) {
 | 
| @@ -76,15 +87,15 @@ void GrCustomCoordsTextureEffect::getConstantColorComponents(GrColor* color,
 | 
|      }
 | 
|  }
 | 
|  
 | 
| -const GrBackendEffectFactory& GrCustomCoordsTextureEffect::getFactory() const {
 | 
| -    return GrTBackendEffectFactory<GrCustomCoordsTextureEffect>::getInstance();
 | 
| +const GrBackendEffectFactory& GrDistanceFieldTextureEffect::getFactory() const {
 | 
| +    return GrTBackendEffectFactory<GrDistanceFieldTextureEffect>::getInstance();
 | 
|  }
 | 
|  
 | 
|  ///////////////////////////////////////////////////////////////////////////////
 | 
|  
 | 
| -GR_DEFINE_EFFECT_TEST(GrCustomCoordsTextureEffect);
 | 
| +GR_DEFINE_EFFECT_TEST(GrDistanceFieldTextureEffect);
 | 
|  
 | 
| -GrEffectRef* GrCustomCoordsTextureEffect::TestCreate(SkRandom* random,
 | 
| +GrEffectRef* GrDistanceFieldTextureEffect::TestCreate(SkRandom* random,
 | 
|                                                       GrContext*,
 | 
|                                                       const GrDrawTargetCaps&,
 | 
|                                                       GrTexture* textures[]) {
 | 
| @@ -102,5 +113,5 @@ GrEffectRef* GrCustomCoordsTextureEffect::TestCreate(SkRandom* random,
 | 
|      GrTextureParams params(tileModes, random->nextBool() ? GrTextureParams::kBilerp_FilterMode :
 | 
|                                                             GrTextureParams::kNone_FilterMode);
 | 
|  
 | 
| -    return GrCustomCoordsTextureEffect::Create(textures[texIdx], params);
 | 
| +    return GrDistanceFieldTextureEffect::Create(textures[texIdx], params);
 | 
|  }
 | 
| 
 |