update size GrTextBlob size calculation
Update calculating GrTextBlob size to reflect different VertexData sizes.
Change-Id: I8127c5ec5b6fdc3c7722cacd316cade5e467b4b9
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/307220
Reviewed-by: Robert Phillips <robertphillips@google.com>
Commit-Queue: Herb Derby <herb@google.com>
diff --git a/src/gpu/text/GrTextBlob.cpp b/src/gpu/text/GrTextBlob.cpp
index fb7f59b..4768b7c 100644
--- a/src/gpu/text/GrTextBlob.cpp
+++ b/src/gpu/text/GrTextBlob.cpp
@@ -904,12 +904,21 @@
sk_sp<GrTextBlob> GrTextBlob::Make(const SkGlyphRunList& glyphRunList, const SkMatrix& drawMatrix) {
// The difference in alignment from the storage of VertexData to SubRun;
- using AllSubRuns = std::aligned_union_t<1, GrSDFTSubRun, GrDirectMaskSubRun, GrPathSubRun>;
- constexpr size_t alignDiff = alignof(AllSubRuns) - alignof(GrSDFTSubRun::VertexData);
+ using AllSubRuns = std::aligned_union_t<1,
+ GrDirectMaskSubRun,
+ GrTransformedMaskSubRun,
+ GrSDFTSubRun,
+ GrPathSubRun>;
+
+ using AllVertexData = std::aligned_union<1,
+ GrDirectMaskSubRun::VertexData,
+ GrTransformedMaskSubRun::VertexData,
+ GrSDFTSubRun::VertexData>;
+ constexpr size_t alignDiff = alignof(AllSubRuns) - alignof(AllVertexData);
constexpr size_t vertexDataToSubRunPadding = alignDiff > 0 ? alignDiff : 0;
size_t totalGlyphCount = glyphRunList.totalGlyphCount();
size_t arenaSize =
- totalGlyphCount * sizeof(GrSDFTSubRun::VertexData)
+ totalGlyphCount * sizeof(AllVertexData)
+ GrGlyphVector::GlyphVectorSize(totalGlyphCount)
+ glyphRunList.runCount() * (sizeof(AllSubRuns) + vertexDataToSubRunPadding)
+ 32; // Misc arena overhead.
diff --git a/src/gpu/text/GrTextBlob.h b/src/gpu/text/GrTextBlob.h
index 05f65cf..4f2a966 100644
--- a/src/gpu/text/GrTextBlob.h
+++ b/src/gpu/text/GrTextBlob.h
@@ -246,11 +246,6 @@
int begin, int end, GrMeshDrawOp::Target* target) const = 0;
protected:
- using VertexData = std::tuple<
- SkPoint, // glyph position.
- GrIRect16 // glyph bounding rectangle.
- >;
-
struct AtlasPt {
uint16_t u;
uint16_t v;
@@ -315,6 +310,11 @@
// -- GrDirectMaskSubRun ---------------------------------------------------------------------------
class GrDirectMaskSubRun final : public GrAtlasSubRun {
public:
+ using VertexData = std::tuple<
+ SkPoint, // glyph position.
+ GrIRect16 // glyph bounding rectangle.
+ >;
+
GrDirectMaskSubRun(GrMaskFormat format,
GrTextBlob* blob,
const SkRect& bounds,