fixup precision with configurable atlas
BUG=skia: Review URL: https://codereview.chromium.org/1276383003
This commit is contained in:
parent
0df0e43488
commit
7375d6bab2
@ -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
|
||||
|
@ -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
|
||||
|
@ -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.
|
||||
|
Loading…
Reference in New Issue
Block a user