Index: src/gpu/effects/GrDistanceFieldGeoProc.cpp |
diff --git a/src/gpu/effects/GrDistanceFieldGeoProc.cpp b/src/gpu/effects/GrDistanceFieldGeoProc.cpp |
index 8af5631cc50a5c237bf08acdcabe0ea25de21a4d..0b97bb2b94980b225dd2ed7186b6cd70d4f1a4e1 100755 |
--- a/src/gpu/effects/GrDistanceFieldGeoProc.cpp |
+++ b/src/gpu/effects/GrDistanceFieldGeoProc.cpp |
@@ -77,11 +77,18 @@ public: |
args.fPB->addVarying("IntTextureCoords", &st, kHigh_GrSLPrecision); |
vsBuilder->codeAppendf("%s = %s;", st.vsOut(), dfTexEffect.inTextureCoords()->fName); |
+ // compute numbers to be hardcoded to convert texture coordinates from int to float |
+ SkASSERT(dfTexEffect.numTextures() == 1); |
+ GrTexture* atlas = dfTexEffect.textureAccess(0).getTexture(); |
+ SkASSERT(atlas); |
+ SkScalar recipWidth = 1.0f / atlas->width(); |
+ SkScalar recipHeight = 1.0f / atlas->height(); |
+ |
GrGLVertToFrag uv(kVec2f_GrSLType); |
args.fPB->addVarying("TextureCoords", &uv, kHigh_GrSLPrecision); |
- // this is only used with text, so our texture bounds always match the glyph atlas |
- vsBuilder->codeAppendf("%s = vec2(" GR_FONT_ATLAS_A8_RECIP_WIDTH ", " |
- GR_FONT_ATLAS_RECIP_HEIGHT ")*%s;", uv.vsOut(), |
+ vsBuilder->codeAppendf("%s = vec2(%.*f, %.*f) * %s;", uv.vsOut(), |
+ SK_FLT_DECIMAL_DIG, recipWidth, |
+ SK_FLT_DECIMAL_DIG, recipHeight, |
dfTexEffect.inTextureCoords()->fName); |
// Use highp to work around aliasing issues |
@@ -176,6 +183,13 @@ public: |
key |= dfTexEffect.colorIgnored() << 17; |
key |= ComputePosKey(dfTexEffect.viewMatrix()) << 25; |
b->add32(key); |
+ |
+ // Currently we hardcode numbers to convert atlas coordinates to normalized floating point |
+ SkASSERT(gp.numTextures() == 1); |
+ GrTexture* atlas = gp.textureAccess(0).getTexture(); |
+ SkASSERT(atlas); |
+ b->add32(atlas->width()); |
+ b->add32(atlas->height()); |
} |
private: |
@@ -525,11 +539,18 @@ public: |
args.fPB->addVarying("IntTextureCoords", &st, kHigh_GrSLPrecision); |
vsBuilder->codeAppendf("%s = %s;", st.vsOut(), dfTexEffect.inTextureCoords()->fName); |
+ // compute numbers to be hardcoded to convert texture coordinates from int to float |
+ SkASSERT(dfTexEffect.numTextures() == 1); |
+ GrTexture* atlas = dfTexEffect.textureAccess(0).getTexture(); |
+ SkASSERT(atlas); |
+ SkScalar recipWidth = 1.0f / atlas->width(); |
+ SkScalar recipHeight = 1.0f / atlas->height(); |
+ |
GrGLVertToFrag uv(kVec2f_GrSLType); |
args.fPB->addVarying("TextureCoords", &uv, kHigh_GrSLPrecision); |
- // this is only used with text, so our texture bounds always match the glyph atlas |
- vsBuilder->codeAppendf("%s = vec2(" GR_FONT_ATLAS_A8_RECIP_WIDTH ", " |
- GR_FONT_ATLAS_RECIP_HEIGHT ")*%s;", uv.vsOut(), |
+ vsBuilder->codeAppendf("%s = vec2(%.*f, %.*f) * %s;", uv.vsOut(), |
+ SK_FLT_DECIMAL_DIG, recipWidth, |
+ SK_FLT_DECIMAL_DIG, recipHeight, |
dfTexEffect.inTextureCoords()->fName); |
// add frag shader code |
@@ -545,10 +566,12 @@ public: |
fsBuilder->codeAppendf("vec2 uv = %s;\n", uv.fsIn()); |
fsBuilder->codeAppend(GrGLShaderVar::PrecisionString(kHigh_GrSLPrecision, |
pb->ctxInfo().standard())); |
+ |
+ SkScalar lcdDelta = 1.0f / (3.0f * atlas->width()); |
if (dfTexEffect.getFlags() & kBGR_DistanceFieldEffectFlag) { |
- fsBuilder->codeAppend("float delta = -" GR_FONT_ATLAS_LCD_DELTA ";\n"); |
+ fsBuilder->codeAppendf("float delta = -%.*f;\n", SK_FLT_DECIMAL_DIG, lcdDelta); |
} else { |
- fsBuilder->codeAppend("float delta = " GR_FONT_ATLAS_LCD_DELTA ";\n"); |
+ fsBuilder->codeAppendf("float delta = %.*f;\n", SK_FLT_DECIMAL_DIG, lcdDelta); |
} |
if (isUniformScale) { |
fsBuilder->codeAppendf("float dy = abs(dFdy(%s.y));", st.fsIn()); |
@@ -668,6 +691,13 @@ public: |
key |= dfTexEffect.colorIgnored() << 16; |
key |= ComputePosKey(dfTexEffect.viewMatrix()) << 25; |
b->add32(key); |
+ |
+ // Currently we hardcode numbers to convert atlas coordinates to normalized floating point |
+ SkASSERT(gp.numTextures() == 1); |
+ GrTexture* atlas = gp.textureAccess(0).getTexture(); |
+ SkASSERT(atlas); |
+ b->add32(atlas->width()); |
+ b->add32(atlas->height()); |
} |
private: |