Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(942)

Unified Diff: src/gpu/effects/GrDistanceFieldGeoProc.cpp

Issue 1709133003: Revert of Use unorm shorts for texture coordinates when rendering text. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/gpu/effects/GrBitmapTextGeoProc.cpp ('k') | src/gpu/gl/GrGLVertexArray.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/effects/GrDistanceFieldGeoProc.cpp
diff --git a/src/gpu/effects/GrDistanceFieldGeoProc.cpp b/src/gpu/effects/GrDistanceFieldGeoProc.cpp
index 4e903eb90f9d27ac8819309641bd539d8e66e15d..395de32786e6a6ce63f2faa534ef4ea4b9fb020b 100644
--- a/src/gpu/effects/GrDistanceFieldGeoProc.cpp
+++ b/src/gpu/effects/GrDistanceFieldGeoProc.cpp
@@ -78,20 +78,23 @@
// add varyings
GrGLSLVertToFrag recipScale(kFloat_GrSLType);
- GrGLSLVertToFrag uv(kVec2f_GrSLType);
+ GrGLSLVertToFrag st(kVec2f_GrSLType);
bool isSimilarity = SkToBool(dfTexEffect.getFlags() & kSimilarity_DistanceFieldEffectFlag);
- varyingHandler->addVarying("TextureCoords", &uv, kHigh_GrSLPrecision);
- vertBuilder->codeAppendf("%s = %s;", uv.vsOut(), dfTexEffect.inTextureCoords()->fName);
+ varyingHandler->addVarying("IntTextureCoords", &st, kHigh_GrSLPrecision);
+ vertBuilder->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 && SkIsPow2(atlas->width()) && SkIsPow2(atlas->height()));
-
- GrGLSLVertToFrag st(kVec2f_GrSLType);
- varyingHandler->addVarying("IntTextureCoords", &st, kHigh_GrSLPrecision);
- vertBuilder->codeAppendf("%s = vec2(%d, %d) * %s;", st.vsOut(),
- atlas->width(), 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,
dfTexEffect.inTextureCoords()->fName);
// Use highp to work around aliasing issues
@@ -221,7 +224,7 @@
kHigh_GrSLPrecision));
fInColor = &this->addVertexAttrib(Attribute("inColor", kVec4ub_GrVertexAttribType));
fInTextureCoords = &this->addVertexAttrib(Attribute("inTextureCoords",
- kVec2us_GrVertexAttribType));
+ kVec2s_GrVertexAttribType));
this->addTextureAccess(&fTextureAccess);
}
@@ -519,19 +522,22 @@
// set up varyings
bool isUniformScale = SkToBool(dfTexEffect.getFlags() & kUniformScale_DistanceFieldEffectMask);
GrGLSLVertToFrag recipScale(kFloat_GrSLType);
- GrGLSLVertToFrag uv(kVec2f_GrSLType);
- varyingHandler->addVarying("TextureCoords", &uv, kHigh_GrSLPrecision);
- vertBuilder->codeAppendf("%s = %s;", uv.vsOut(), dfTexEffect.inTextureCoords()->fName);
+ GrGLSLVertToFrag st(kVec2f_GrSLType);
+ varyingHandler->addVarying("IntTextureCoords", &st, kHigh_GrSLPrecision);
+ vertBuilder->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 && SkIsPow2(atlas->width()) && SkIsPow2(atlas->height()));
-
- GrGLSLVertToFrag st(kVec2f_GrSLType);
- varyingHandler->addVarying("IntTextureCoords", &st, kHigh_GrSLPrecision);
- vertBuilder->codeAppendf("%s = vec2(%d, %d) * %s;", st.vsOut(),
- atlas->width(), 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,
dfTexEffect.inTextureCoords()->fName);
// add frag shader code
@@ -702,7 +708,7 @@
kHigh_GrSLPrecision));
fInColor = &this->addVertexAttrib(Attribute("inColor", kVec4ub_GrVertexAttribType));
fInTextureCoords = &this->addVertexAttrib(Attribute("inTextureCoords",
- kVec2us_GrVertexAttribType));
+ kVec2s_GrVertexAttribType));
this->addTextureAccess(&fTextureAccess);
}
« no previous file with comments | « src/gpu/effects/GrBitmapTextGeoProc.cpp ('k') | src/gpu/gl/GrGLVertexArray.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698