diff options
author | joshualitt <joshualitt@chromium.org> | 2015-08-07 13:36:44 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-08-07 13:36:44 -0700 |
commit | 7375d6bab2ee8b02da276597ed4d60f22f54eb89 (patch) | |
tree | fee12452799fdbf26663b4f6f5e0c456c0e6df1d /src/gpu | |
parent | 0df0e43488dc785815d3234d9bd60bad91532f98 (diff) |
fixup precision with configurable atlas
BUG=skia:
Review URL: https://codereview.chromium.org/1276383003
Diffstat (limited to 'src/gpu')
-rw-r--r-- | src/gpu/effects/GrBitmapTextGeoProc.cpp | 6 | ||||
-rwxr-xr-x | src/gpu/effects/GrDistanceFieldGeoProc.cpp | 12 | ||||
-rw-r--r-- | src/gpu/gl/builders/GrGLProgramBuilder.h | 3 |
3 files changed, 12 insertions, 9 deletions
diff --git a/src/gpu/effects/GrBitmapTextGeoProc.cpp b/src/gpu/effects/GrBitmapTextGeoProc.cpp index 9496dbffc3..d83cf5595a 100644 --- a/src/gpu/effects/GrBitmapTextGeoProc.cpp +++ b/src/gpu/effects/GrBitmapTextGeoProc.cpp @@ -31,15 +31,15 @@ public: // compute numbers to be hardcoded to convert texture coordinates from int to float SkASSERT(cte.numTextures() == 1); GrTexture* atlas = cte.textureAccess(0).getTexture(); - SkASSERT(atlas); + SkASSERT(atlas && SkIsPow2(atlas->width()) && SkIsPow2(atlas->height())); SkScalar recipWidth = 1.0f / atlas->width(); SkScalar recipHeight = 1.0f / atlas->height(); GrGLVertToFrag v(kVec2f_GrSLType); pb->addVarying("TextureCoords", &v); vsBuilder->codeAppendf("%s = vec2(%.*f, %.*f) * %s;", v.vsOut(), - SK_FLT_DECIMAL_DIG, recipWidth, - SK_FLT_DECIMAL_DIG, recipHeight, + GR_SIGNIFICANT_POW2_DECIMAL_DIG, recipWidth, + GR_SIGNIFICANT_POW2_DECIMAL_DIG, recipHeight, cte.inTextureCoords()->fName); // Setup pass through color diff --git a/src/gpu/effects/GrDistanceFieldGeoProc.cpp b/src/gpu/effects/GrDistanceFieldGeoProc.cpp index 0b97bb2b94..d8fbd86cb3 100755 --- a/src/gpu/effects/GrDistanceFieldGeoProc.cpp +++ b/src/gpu/effects/GrDistanceFieldGeoProc.cpp @@ -80,15 +80,15 @@ public: // 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); + SkASSERT(atlas && SkIsPow2(atlas->width()) && SkIsPow2(atlas->height())); SkScalar recipWidth = 1.0f / atlas->width(); SkScalar recipHeight = 1.0f / atlas->height(); GrGLVertToFrag uv(kVec2f_GrSLType); args.fPB->addVarying("TextureCoords", &uv, kHigh_GrSLPrecision); vsBuilder->codeAppendf("%s = vec2(%.*f, %.*f) * %s;", uv.vsOut(), - SK_FLT_DECIMAL_DIG, recipWidth, - SK_FLT_DECIMAL_DIG, recipHeight, + GR_SIGNIFICANT_POW2_DECIMAL_DIG, recipWidth, + GR_SIGNIFICANT_POW2_DECIMAL_DIG, recipHeight, dfTexEffect.inTextureCoords()->fName); // Use highp to work around aliasing issues @@ -542,15 +542,15 @@ public: // 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); + SkASSERT(atlas && SkIsPow2(atlas->width()) && SkIsPow2(atlas->height())); SkScalar recipWidth = 1.0f / atlas->width(); SkScalar recipHeight = 1.0f / atlas->height(); GrGLVertToFrag uv(kVec2f_GrSLType); args.fPB->addVarying("TextureCoords", &uv, kHigh_GrSLPrecision); vsBuilder->codeAppendf("%s = vec2(%.*f, %.*f) * %s;", uv.vsOut(), - SK_FLT_DECIMAL_DIG, recipWidth, - SK_FLT_DECIMAL_DIG, recipHeight, + GR_SIGNIFICANT_POW2_DECIMAL_DIG, recipWidth, + GR_SIGNIFICANT_POW2_DECIMAL_DIG, recipHeight, dfTexEffect.inTextureCoords()->fName); // add frag shader code diff --git a/src/gpu/gl/builders/GrGLProgramBuilder.h b/src/gpu/gl/builders/GrGLProgramBuilder.h index 22b67ae58d..bdd96d212e 100644 --- a/src/gpu/gl/builders/GrGLProgramBuilder.h +++ b/src/gpu/gl/builders/GrGLProgramBuilder.h @@ -19,6 +19,9 @@ #include "../../GrPendingFragmentStage.h" #include "../../GrPipeline.h" +// Enough precision to represent 1 / 2048 accurately in printf +#define GR_SIGNIFICANT_POW2_DECIMAL_DIG 11 + /* * This is the base class for a series of interfaces. This base class *MUST* remain abstract with * NO data members because it is used in multiple interface inheritance. |