Use uint16s for texture coordinates when rendering text.
Allows us to push more vertices into a given vertex buffer, with
a slight performance improvement.
Committed: https://skia.googlesource.com/skia/+/059034d252007d0dd86fff5ffdbb53cbcb10d34b
Review URL: https://codereview.chromium.org/917373002
diff --git a/src/gpu/effects/GrBitmapTextGeoProc.cpp b/src/gpu/effects/GrBitmapTextGeoProc.cpp
index 2487b65..54e8891 100644
--- a/src/gpu/effects/GrBitmapTextGeoProc.cpp
+++ b/src/gpu/effects/GrBitmapTextGeoProc.cpp
@@ -6,6 +6,7 @@
*/
#include "GrBitmapTextGeoProc.h"
+#include "GrFontAtlasSizes.h"
#include "GrInvariantOutput.h"
#include "GrTexture.h"
#include "gl/GrGLProcessor.h"
@@ -37,7 +38,10 @@
GrGLVertToFrag v(kVec2f_GrSLType);
pb->addVarying("TextureCoords", &v);
- vsBuilder->codeAppendf("%s = %s;", v.vsOut(), cte.inTextureCoords()->fName);
+ // this is only used with text, so our texture bounds always match the glyph atlas
+ vsBuilder->codeAppendf("%s = vec2(" GR_FONT_ATLAS_RECIP_WIDTH ", "
+ GR_FONT_ATLAS_RECIP_HEIGHT ")*%s;", v.vsOut(),
+ cte.inTextureCoords()->fName);
// Setup pass through color
this->setupColorPassThrough(pb, local.fInputColorType, args.fOutputColor, cte.inColor(),
@@ -122,7 +126,7 @@
this->setHasVertexColor();
}
fInTextureCoords = &this->addVertexAttrib(Attribute("inTextureCoords",
- kVec2f_GrVertexAttribType));
+ kVec2s_GrVertexAttribType));
this->addTextureAccess(&fTextureAccess);
}