diff options
author | 2018-01-25 16:26:25 -0500 | |
---|---|---|
committer | 2018-01-26 13:54:54 +0000 | |
commit | fc4f768e5aaf8efdd112f38295a35de83a0f9a55 (patch) | |
tree | 64571d9e826dd917299fd4973111732dd76ddcb1 /src/gpu/text | |
parent | fc807c885b3cce6252cc1d057098d96f8e14eadc (diff) |
Use int when possible to calculate atlas indices in shaders.
On certain iOS devices half has a mantissa of only 10 bits, which is not
enough to perform the floating point trickery to get the lower bits
out of the "texture coordinates". Instead we use int if available, and
float if not available.
Also re-enables multitexturing for iOS and adds a sample which
stresses the issue, and a version of fontcache that tests multitexturing.
Bug: skia:7285
Change-Id: Ia541b6a418c1860c941071750ceb26459eb846ea
Reviewed-on: https://skia-review.googlesource.com/99800
Reviewed-by: Brian Salomon <bsalomon@google.com>
Reviewed-by: Robert Phillips <robertphillips@google.com>
Commit-Queue: Jim Van Verth <jvanverth@google.com>
Diffstat (limited to 'src/gpu/text')
-rw-r--r-- | src/gpu/text/GrAtlasTextBlobVertexRegenerator.cpp | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/src/gpu/text/GrAtlasTextBlobVertexRegenerator.cpp b/src/gpu/text/GrAtlasTextBlobVertexRegenerator.cpp index 1ae2c79fd4..384596ddb6 100644 --- a/src/gpu/text/GrAtlasTextBlobVertexRegenerator.cpp +++ b/src/gpu/text/GrAtlasTextBlobVertexRegenerator.cpp @@ -38,6 +38,11 @@ inline void regen_vertices(char* vertex, const GrGlyph* glyph, size_t vertexStri bool useDistanceFields, SkScalar transX, SkScalar transY, GrColor color) { uint16_t u0, v0, u1, v1; +#ifdef DISPLAY_PAGE_INDEX + // Enable this to visualize the page from which each glyph is being drawn. + // Green Red Magenta Cyan -> 0 1 2 3; Black -> error + SkColor hackColor; +#endif if (regenTexCoords) { SkASSERT(glyph); int width = glyph->fBounds.width(); @@ -67,6 +72,25 @@ inline void regen_vertices(char* vertex, const GrGlyph* glyph, size_t vertexStri u1 |= uBit; v1 <<= 1; v1 |= vBit; +#ifdef DISPLAY_PAGE_INDEX + switch (pageIndex) { + case 0: + hackColor = SK_ColorGREEN; + break; + case 1: + hackColor = SK_ColorRED; + break; + case 2: + hackColor = SK_ColorMAGENTA; + break; + case 3: + hackColor = SK_ColorCYAN; + break; + default: + hackColor = SK_ColorBLACK; + break; + } +#endif } // This is a bit wonky, but sometimes we have LCD text, in which case we won't have color @@ -90,6 +114,10 @@ inline void regen_vertices(char* vertex, const GrGlyph* glyph, size_t vertexStri uint16_t* textureCoords = reinterpret_cast<uint16_t*>(vertex + texCoordOffset); textureCoords[0] = u0; textureCoords[1] = v0; +#ifdef DISPLAY_PAGE_INDEX + SkColor* vcolor = reinterpret_cast<SkColor*>(vertex + colorOffset); + *vcolor = hackColor; +#endif } vertex += vertexStride; @@ -109,6 +137,10 @@ inline void regen_vertices(char* vertex, const GrGlyph* glyph, size_t vertexStri uint16_t* textureCoords = reinterpret_cast<uint16_t*>(vertex + texCoordOffset); textureCoords[0] = u0; textureCoords[1] = v1; +#ifdef DISPLAY_PAGE_INDEX + SkColor* vcolor = reinterpret_cast<SkColor*>(vertex + colorOffset); + *vcolor = hackColor; +#endif } vertex += vertexStride; @@ -128,6 +160,10 @@ inline void regen_vertices(char* vertex, const GrGlyph* glyph, size_t vertexStri uint16_t* textureCoords = reinterpret_cast<uint16_t*>(vertex + texCoordOffset); textureCoords[0] = u1; textureCoords[1] = v0; +#ifdef DISPLAY_PAGE_INDEX + SkColor* vcolor = reinterpret_cast<SkColor*>(vertex + colorOffset); + *vcolor = hackColor; +#endif } vertex += vertexStride; @@ -147,6 +183,10 @@ inline void regen_vertices(char* vertex, const GrGlyph* glyph, size_t vertexStri uint16_t* textureCoords = reinterpret_cast<uint16_t*>(vertex + texCoordOffset); textureCoords[0] = u1; textureCoords[1] = v1; +#ifdef DISPLAY_PAGE_INDEX + SkColor* vcolor = reinterpret_cast<SkColor*>(vertex + colorOffset); + *vcolor = hackColor; +#endif } } |