From c5eb5c7127b2a4d7e33220e55ba1c1659b604341 Mon Sep 17 00:00:00 2001 From: Herb Derby Date: Wed, 20 May 2020 11:27:50 -0400 Subject: [PATCH] Cleanup text vertex structs * Rename SDFT3DVertex->Mask3DVertex * Add ctor to ARGB to make construction interface the same as Mask ctor. Change-Id: I28560fce0423b11d7dac6e3a4c798ffd0f088794 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/291076 Reviewed-by: Robert Phillips Commit-Queue: Herb Derby --- src/gpu/text/GrTextBlob.cpp | 18 +++++++++--------- src/gpu/text/GrTextBlob.h | 16 +++++++++++----- 2 files changed, 20 insertions(+), 14 deletions(-) diff --git a/src/gpu/text/GrTextBlob.cpp b/src/gpu/text/GrTextBlob.cpp index d4eaa8a071..737bea301a 100644 --- a/src/gpu/text/GrTextBlob.cpp +++ b/src/gpu/text/GrTextBlob.cpp @@ -152,13 +152,13 @@ size_t GrTextBlob::SubRun::vertexStride() const { return GetVertexStride(this->maskFormat(), this->hasW()); } size_t GrTextBlob::SubRun::colorOffset() const { - return this->hasW() ? offsetof(SDFT3DVertex, color) : offsetof(Mask2DVertex, color); + return this->hasW() ? offsetof(Mask3DVertex, color) : offsetof(Mask2DVertex, color); } size_t GrTextBlob::SubRun::texCoordOffset() const { switch (fMaskFormat) { case kA8_GrMaskFormat: - return this->hasW() ? offsetof(SDFT3DVertex, atlasPos) + return this->hasW() ? offsetof(Mask3DVertex, atlasPos) : offsetof(Mask2DVertex, atlasPos); case kARGB_GrMaskFormat: return this->hasW() ? offsetof(ARGB3DVertex, atlasPos) @@ -338,20 +338,20 @@ sk_sp GrTextBlob::Make(const SkGlyphRunList& glyphRunList, static_assert(alignof(ARGB2DVertex) <= alignof(Mask2DVertex)); size_t quadSize = sizeof(Mask2DVertex) * kVerticesPerGlyph; if (drawMatrix.hasPerspective() || forceWForDistanceFields) { - static_assert(sizeof(ARGB3DVertex) <= sizeof(SDFT3DVertex)); - static_assert(alignof(ARGB3DVertex) <= alignof(SDFT3DVertex)); - quadSize = sizeof(SDFT3DVertex) * kVerticesPerGlyph; + static_assert(sizeof(ARGB3DVertex) <= sizeof(Mask3DVertex)); + static_assert(alignof(ARGB3DVertex) <= alignof(Mask3DVertex)); + quadSize = sizeof(Mask3DVertex) * kVerticesPerGlyph; } // We can use the alignment of SDFT3DVertex as a proxy for all Vertex alignments. - static_assert(alignof(SDFT3DVertex) >= alignof(Mask2DVertex)); + static_assert(alignof(Mask3DVertex) >= alignof(Mask2DVertex)); // Assume there is no padding needed between glyph pointers and vertices. - static_assert(alignof(GrGlyph*) >= alignof(SDFT3DVertex)); + static_assert(alignof(GrGlyph*) >= alignof(Mask3DVertex)); // In the arena, the layout is GrGlyph*... | SDFT3DVertex... | SubRun, so there is no padding // between GrGlyph* and SDFT3DVertex, but padding is needed between the Mask2DVertex array // and the SubRun. - size_t vertexToSubRunPadding = alignof(SDFT3DVertex) - alignof(SubRun); + size_t vertexToSubRunPadding = alignof(Mask3DVertex) - alignof(SubRun); size_t arenaSize = sizeof(GrGlyph*) * glyphRunList.totalGlyphCount() + quadSize * glyphRunList.totalGlyphCount() @@ -401,7 +401,7 @@ void GrTextBlob::setMinAndMaxScale(SkScalar scaledMin, SkScalar scaledMax) { size_t GrTextBlob::GetVertexStride(GrMaskFormat maskFormat, bool hasWCoord) { switch (maskFormat) { case kA8_GrMaskFormat: - return hasWCoord ? sizeof(SDFT3DVertex) : sizeof(Mask2DVertex); + return hasWCoord ? sizeof(Mask3DVertex) : sizeof(Mask2DVertex); case kARGB_GrMaskFormat: return hasWCoord ? sizeof(ARGB3DVertex) : sizeof(ARGB2DVertex); default: diff --git a/src/gpu/text/GrTextBlob.h b/src/gpu/text/GrTextBlob.h index 71f860f37e..f5d6108108 100644 --- a/src/gpu/text/GrTextBlob.h +++ b/src/gpu/text/GrTextBlob.h @@ -137,27 +137,33 @@ public: const SkMatrixProvider& deviceMatrix, SkPoint drawOrigin); + struct AtlasPt { + uint16_t u; + uint16_t v; + }; // Normal text mask, SDFT, or color. struct Mask2DVertex { SkPoint devicePos; GrColor color; - SkIPoint16 atlasPos; + AtlasPt atlasPos; }; struct ARGB2DVertex { + ARGB2DVertex(SkPoint d, GrColor, AtlasPt a) : devicePos{d}, atlasPos{a} {} SkPoint devicePos; - SkIPoint16 atlasPos; + AtlasPt atlasPos; }; // Perspective SDFT or SDFT forced to 3D or perspective color. - struct SDFT3DVertex { + struct Mask3DVertex { SkPoint3 devicePos; GrColor color; - SkIPoint16 atlasPos; + AtlasPt atlasPos; }; struct ARGB3DVertex { + ARGB3DVertex(SkPoint3 d, GrColor, AtlasPt a) : devicePos{d}, atlasPos{a} {} SkPoint3 devicePos; - SkIPoint16 atlasPos; + AtlasPt atlasPos; }; static const int kVerticesPerGlyph = 4;