diff options
author | Robert Phillips <robertphillips@google.com> | 2017-08-25 08:45:21 -0400 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2017-08-25 15:19:27 +0000 |
commit | 8296e752fa1803dcb8cf97d6ab10bb4f5f5f51f0 (patch) | |
tree | 7251f087721b2578152647b1c9e17d7dbf581dbc /src/gpu/text | |
parent | c8323aa51ab27259076532ba081d2ed5c26aedfc (diff) |
Switch atlas clients over to using absolute texture coordinates (take 2)
This is a prerequisite for being able to resize the atlas with impunity.
Change-Id: Iccc9c7ced43f38a7d8483a7bd12a458d59a3453a
Reviewed-on: https://skia-review.googlesource.com/38362
Reviewed-by: Jim Van Verth <jvanverth@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(); } |