diff options
author | Robert Phillips <robertphillips@google.com> | 2017-08-24 11:32:33 -0400 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2017-08-24 16:09:16 +0000 |
commit | e84c087e621978e6d298b8ca950521601a0366cb (patch) | |
tree | cf343efbabc5ce70a157632df3006b80b9c9dcf8 /src/gpu/text | |
parent | f3c99eecc07a0ac64dc8e796c05fa6df71ea1119 (diff) |
Switch atlas clients over to using absolute texture coordinates
This is a prerequisite for being able to resize the atlas with impunity.
Change-Id: I509816c8d6f38fbc92fa39aeab303b42ab09f58b
Reviewed-on: https://skia-review.googlesource.com/37560
Reviewed-by: Robert Phillips <robertphillips@google.com>
Commit-Queue: Robert Phillips <robertphillips@google.com>
Diffstat (limited to 'src/gpu/text')
-rw-r--r-- | src/gpu/text/GrAtlasTextBlob_regenInOp.cpp | 38 |
1 files changed, 10 insertions, 28 deletions
diff --git a/src/gpu/text/GrAtlasTextBlob_regenInOp.cpp b/src/gpu/text/GrAtlasTextBlob_regenInOp.cpp index 3150988fdb..96f0080ec2 100644 --- a/src/gpu/text/GrAtlasTextBlob_regenInOp.cpp +++ b/src/gpu/text/GrAtlasTextBlob_regenInOp.cpp @@ -21,9 +21,8 @@ template <bool regenPos, bool regenCol, bool regenTexCoords> inline void regen_vertices(intptr_t vertex, const GrGlyph* glyph, size_t vertexStride, bool useDistanceFields, SkScalar transX, SkScalar transY, - int32_t log2Width, int32_t log2Height, GrColor color) { - int u0, v0, u1, v1; + uint16_t u0, v0, u1, v1; if (regenTexCoords) { SkASSERT(glyph); int width = glyph->fBounds.width(); @@ -40,20 +39,6 @@ inline void regen_vertices(intptr_t vertex, const GrGlyph* glyph, size_t vertexS u1 = u0 + width; v1 = v0 + height; } - - // normalize - u0 *= 65535; - u0 >>= log2Width; - u1 *= 65535; - u1 >>= log2Width; - v0 *= 65535; - v0 >>= log2Height; - v1 *= 65535; - v1 >>= log2Height; - SkASSERT(u0 >= 0 && u0 <= 65535); - SkASSERT(u1 >= 0 && u1 <= 65535); - SkASSERT(v0 >= 0 && v0 <= 65535); - SkASSERT(v1 >= 0 && v1 <= 65535); } // This is a bit wonky, but sometimes we have LCD text, in which case we won't have color @@ -75,8 +60,8 @@ inline void regen_vertices(intptr_t vertex, const GrGlyph* glyph, size_t vertexS if (regenTexCoords) { uint16_t* textureCoords = reinterpret_cast<uint16_t*>(vertex + texCoordOffset); - textureCoords[0] = (uint16_t) u0; - textureCoords[1] = (uint16_t) v0; + textureCoords[0] = u0; + textureCoords[1] = v0; } vertex += vertexStride; @@ -94,8 +79,8 @@ inline void regen_vertices(intptr_t vertex, const GrGlyph* glyph, size_t vertexS if (regenTexCoords) { uint16_t* textureCoords = reinterpret_cast<uint16_t*>(vertex + texCoordOffset); - textureCoords[0] = (uint16_t)u0; - textureCoords[1] = (uint16_t)v1; + textureCoords[0] = u0; + textureCoords[1] = v1; } vertex += vertexStride; @@ -113,8 +98,8 @@ inline void regen_vertices(intptr_t vertex, const GrGlyph* glyph, size_t vertexS if (regenTexCoords) { uint16_t* textureCoords = reinterpret_cast<uint16_t*>(vertex + texCoordOffset); - textureCoords[0] = (uint16_t)u1; - textureCoords[1] = (uint16_t)v1; + textureCoords[0] = u1; + textureCoords[1] = v1; } vertex += vertexStride; @@ -132,8 +117,8 @@ inline void regen_vertices(intptr_t vertex, const GrGlyph* glyph, size_t vertexS if (regenTexCoords) { uint16_t* textureCoords = reinterpret_cast<uint16_t*>(vertex + texCoordOffset); - textureCoords[0] = (uint16_t)u1; - textureCoords[1] = (uint16_t)v0; + textureCoords[0] = u1; + textureCoords[1] = v0; } } @@ -170,7 +155,6 @@ void GrAtlasTextBlob::regenInOp(GrDrawOp::Target* target, GrAtlasGlyphCache* fon bool brokenRun = false; for (int glyphIdx = 0; glyphIdx < glyphCount; glyphIdx++) { GrGlyph* glyph = nullptr; - int log2Width = 0, log2Height = 0; if (regenTexCoords) { size_t glyphOffset = glyphIdx + info->glyphStartIndex(); @@ -197,8 +181,6 @@ void GrAtlasTextBlob::regenInOp(GrDrawOp::Target* target, GrAtlasGlyphCache* fon } fontCache->addGlyphToBulkAndSetUseToken(info->bulkUseToken(), glyph, target->nextDrawToken()); - log2Width = fontCache->log2Width(info->maskFormat()); - log2Height = fontCache->log2Height(info->maskFormat()); } intptr_t vertex = reinterpret_cast<intptr_t>(fVertices); @@ -206,7 +188,7 @@ void GrAtlasTextBlob::regenInOp(GrDrawOp::Target* target, GrAtlasGlyphCache* fon vertex += vertexStride * glyphIdx * GrAtlasTextOp::kVerticesPerGlyph; regen_vertices<regenPos, regenCol, regenTexCoords>(vertex, glyph, vertexStride, info->drawAsDistanceFields(), transX, - transY, log2Width, log2Height, color); + transY, color); helper->incGlyphCount(); } |