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

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

Issue 1271873002: Break LCD and Bitmap text dependency on hardcoded atlas values (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: tweak names Created 5 years, 4 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/GrFontAtlasSizes.h ('k') | src/gpu/effects/GrDistanceFieldGeoProc.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/effects/GrBitmapTextGeoProc.cpp
diff --git a/src/gpu/effects/GrBitmapTextGeoProc.cpp b/src/gpu/effects/GrBitmapTextGeoProc.cpp
index a0350e99f5e40ebb4248f001b0bb1e53f6079827..9496dbffc33540c3d64d35e1112a28d3d8a524ca 100644
--- a/src/gpu/effects/GrBitmapTextGeoProc.cpp
+++ b/src/gpu/effects/GrBitmapTextGeoProc.cpp
@@ -28,18 +28,19 @@ public:
// emit attributes
vsBuilder->emitAttributes(cte);
+ // 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);
+ SkScalar recipWidth = 1.0f / atlas->width();
+ SkScalar recipHeight = 1.0f / atlas->height();
+
GrGLVertToFrag v(kVec2f_GrSLType);
pb->addVarying("TextureCoords", &v);
- // this is only used with text, so our texture bounds always match the glyph atlas
- if (cte.maskFormat() == kA8_GrMaskFormat) {
- vsBuilder->codeAppendf("%s = vec2(" GR_FONT_ATLAS_A8_RECIP_WIDTH ", "
- GR_FONT_ATLAS_RECIP_HEIGHT ")*%s;", v.vsOut(),
- cte.inTextureCoords()->fName);
- } else {
- vsBuilder->codeAppendf("%s = vec2(" GR_FONT_ATLAS_RECIP_WIDTH ", "
- GR_FONT_ATLAS_RECIP_HEIGHT ")*%s;", v.vsOut(),
- cte.inTextureCoords()->fName);
- }
+ vsBuilder->codeAppendf("%s = vec2(%.*f, %.*f) * %s;", v.vsOut(),
+ SK_FLT_DECIMAL_DIG, recipWidth,
+ SK_FLT_DECIMAL_DIG, recipHeight,
+ cte.inTextureCoords()->fName);
// Setup pass through color
if (!cte.colorIgnored()) {
@@ -102,6 +103,13 @@ public:
key |= gp.colorIgnored() ? 0x2 : 0x0;
key |= gp.maskFormat() << 3;
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:
« no previous file with comments | « src/gpu/GrFontAtlasSizes.h ('k') | src/gpu/effects/GrDistanceFieldGeoProc.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698