diff options
Diffstat (limited to 'src/gpu/effects')
-rw-r--r-- | src/gpu/effects/GrBitmapTextGeoProc.cpp | 10 | ||||
-rw-r--r-- | src/gpu/effects/GrDistanceFieldGeoProc.cpp | 38 |
2 files changed, 19 insertions, 29 deletions
diff --git a/src/gpu/effects/GrBitmapTextGeoProc.cpp b/src/gpu/effects/GrBitmapTextGeoProc.cpp index 263676d353..b4f6b7ecaf 100644 --- a/src/gpu/effects/GrBitmapTextGeoProc.cpp +++ b/src/gpu/effects/GrBitmapTextGeoProc.cpp @@ -31,16 +31,12 @@ public: // compute numbers to be hardcoded to convert texture coordinates from int to float SkASSERT(cte.numTextures() == 1); - GrTexture* atlas = cte.textureAccess(0).getTexture(); + SkDEBUGCODE(GrTexture* atlas = cte.textureAccess(0).getTexture()); SkASSERT(atlas && SkIsPow2(atlas->width()) && SkIsPow2(atlas->height())); - SkScalar recipWidth = 1.0f / atlas->width(); - SkScalar recipHeight = 1.0f / atlas->height(); GrGLSLVertToFrag v(kVec2f_GrSLType); varyingHandler->addVarying("TextureCoords", &v); - vertBuilder->codeAppendf("%s = vec2(%.*f, %.*f) * %s;", v.vsOut(), - GR_SIGNIFICANT_POW2_DECIMAL_DIG, recipWidth, - GR_SIGNIFICANT_POW2_DECIMAL_DIG, recipHeight, + vertBuilder->codeAppendf("%s = %s;", v.vsOut(), cte.inTextureCoords()->fName); GrGLSLPPFragmentBuilder* fragBuilder = args.fFragBuilder; @@ -150,7 +146,7 @@ GrBitmapTextGeoProc::GrBitmapTextGeoProc(GrColor color, GrTexture* texture, fInColor = &this->addVertexAttrib(Attribute("inColor", kVec4ub_GrVertexAttribType)); } fInTextureCoords = &this->addVertexAttrib(Attribute("inTextureCoords", - kVec2s_GrVertexAttribType)); + kVec2us_GrVertexAttribType)); this->addTextureAccess(&fTextureAccess); } diff --git a/src/gpu/effects/GrDistanceFieldGeoProc.cpp b/src/gpu/effects/GrDistanceFieldGeoProc.cpp index 50e78ccb44..dc01b627e0 100644 --- a/src/gpu/effects/GrDistanceFieldGeoProc.cpp +++ b/src/gpu/effects/GrDistanceFieldGeoProc.cpp @@ -78,23 +78,20 @@ public: // add varyings GrGLSLVertToFrag recipScale(kFloat_GrSLType); - GrGLSLVertToFrag st(kVec2f_GrSLType); + GrGLSLVertToFrag uv(kVec2f_GrSLType); bool isSimilarity = SkToBool(dfTexEffect.getFlags() & kSimilarity_DistanceFieldEffectFlag); - varyingHandler->addVarying("IntTextureCoords", &st, kHigh_GrSLPrecision); - vertBuilder->codeAppendf("%s = %s;", st.vsOut(), dfTexEffect.inTextureCoords()->fName); + varyingHandler->addVarying("TextureCoords", &uv, kHigh_GrSLPrecision); + vertBuilder->codeAppendf("%s = %s;", uv.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 && SkIsPow2(atlas->width()) && SkIsPow2(atlas->height())); - SkScalar recipWidth = 1.0f / atlas->width(); - SkScalar recipHeight = 1.0f / atlas->height(); - GrGLSLVertToFrag uv(kVec2f_GrSLType); - varyingHandler->addVarying("TextureCoords", &uv, kHigh_GrSLPrecision); - vertBuilder->codeAppendf("%s = vec2(%.*f, %.*f) * %s;", uv.vsOut(), - GR_SIGNIFICANT_POW2_DECIMAL_DIG, recipWidth, - GR_SIGNIFICANT_POW2_DECIMAL_DIG, recipHeight, + GrGLSLVertToFrag st(kVec2f_GrSLType); + varyingHandler->addVarying("IntTextureCoords", &st, kHigh_GrSLPrecision); + vertBuilder->codeAppendf("%s = vec2(%d, %d) * %s;", st.vsOut(), + atlas->width(), atlas->height(), dfTexEffect.inTextureCoords()->fName); // Use highp to work around aliasing issues @@ -224,7 +221,7 @@ GrDistanceFieldA8TextGeoProc::GrDistanceFieldA8TextGeoProc(GrColor color, kHigh_GrSLPrecision)); fInColor = &this->addVertexAttrib(Attribute("inColor", kVec4ub_GrVertexAttribType)); fInTextureCoords = &this->addVertexAttrib(Attribute("inTextureCoords", - kVec2s_GrVertexAttribType)); + kVec2us_GrVertexAttribType)); this->addTextureAccess(&fTextureAccess); } @@ -522,22 +519,19 @@ public: // set up varyings bool isUniformScale = SkToBool(dfTexEffect.getFlags() & kUniformScale_DistanceFieldEffectMask); GrGLSLVertToFrag recipScale(kFloat_GrSLType); - GrGLSLVertToFrag st(kVec2f_GrSLType); - varyingHandler->addVarying("IntTextureCoords", &st, kHigh_GrSLPrecision); - vertBuilder->codeAppendf("%s = %s;", st.vsOut(), dfTexEffect.inTextureCoords()->fName); + GrGLSLVertToFrag uv(kVec2f_GrSLType); + varyingHandler->addVarying("TextureCoords", &uv, kHigh_GrSLPrecision); + vertBuilder->codeAppendf("%s = %s;", uv.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 && SkIsPow2(atlas->width()) && SkIsPow2(atlas->height())); - SkScalar recipWidth = 1.0f / atlas->width(); - SkScalar recipHeight = 1.0f / atlas->height(); - GrGLSLVertToFrag uv(kVec2f_GrSLType); - varyingHandler->addVarying("TextureCoords", &uv, kHigh_GrSLPrecision); - vertBuilder->codeAppendf("%s = vec2(%.*f, %.*f) * %s;", uv.vsOut(), - GR_SIGNIFICANT_POW2_DECIMAL_DIG, recipWidth, - GR_SIGNIFICANT_POW2_DECIMAL_DIG, recipHeight, + GrGLSLVertToFrag st(kVec2f_GrSLType); + varyingHandler->addVarying("IntTextureCoords", &st, kHigh_GrSLPrecision); + vertBuilder->codeAppendf("%s = vec2(%d, %d) * %s;", st.vsOut(), + atlas->width(), atlas->height(), dfTexEffect.inTextureCoords()->fName); // add frag shader code @@ -708,7 +702,7 @@ GrDistanceFieldLCDTextGeoProc::GrDistanceFieldLCDTextGeoProc( kHigh_GrSLPrecision)); fInColor = &this->addVertexAttrib(Attribute("inColor", kVec4ub_GrVertexAttribType)); fInTextureCoords = &this->addVertexAttrib(Attribute("inTextureCoords", - kVec2s_GrVertexAttribType)); + kVec2us_GrVertexAttribType)); this->addTextureAccess(&fTextureAccess); } |