diff --git a/src/gpu/text/GrTextBlob.cpp b/src/gpu/text/GrTextBlob.cpp index 73eb4fbb28..836a7b6b0d 100644 --- a/src/gpu/text/GrTextBlob.cpp +++ b/src/gpu/text/GrTextBlob.cpp @@ -65,9 +65,6 @@ struct ARGB3DVertex { AtlasPt atlasPos; }; -template -using UP = std::unique_ptr; - GrAtlasTextOp::MaskType op_mask_type(GrMaskFormat grMaskFormat) { switch (grMaskFormat) { case kA8_GrMaskFormat: return GrAtlasTextOp::MaskType::kGrayscaleCoverage; @@ -186,11 +183,11 @@ public: GrAtlasSubRun* testingOnly_atlasSubRun() override; - static UP Make(const SkZip& drawables, - bool isAntiAliased, - const SkStrikeSpec& strikeSpec, - const GrTextBlob& blob, - GrSubRunAllocator* alloc); + static GrSubRunOwner Make(const SkZip& drawables, + bool isAntiAliased, + const SkStrikeSpec& strikeSpec, + const GrTextBlob& blob, + GrSubRunAllocator* alloc); private: struct PathGlyph { @@ -274,12 +271,11 @@ bool PathSubRun::canReuse(const SkPaint& paint, const SkMatrix& drawMatrix) cons return true; } -auto PathSubRun::Make( - const SkZip& drawables, - bool isAntiAliased, - const SkStrikeSpec& strikeSpec, - const GrTextBlob& blob, - GrSubRunAllocator* alloc) -> UP { +GrSubRunOwner PathSubRun::Make(const SkZip& drawables, + bool isAntiAliased, + const SkStrikeSpec& strikeSpec, + const GrTextBlob& blob, + GrSubRunAllocator* alloc) { auto pathData = alloc->makeUniqueArray( drawables.size(), [&](int i){ @@ -448,11 +444,11 @@ public: GlyphVector glyphs, bool glyphsOutOfBounds); - static UP Make(const SkZip& drawables, - const SkStrikeSpec& strikeSpec, - GrMaskFormat format, - GrTextBlob* blob, - GrSubRunAllocator* alloc); + static GrSubRunOwner Make(const SkZip& drawables, + const SkStrikeSpec& strikeSpec, + GrMaskFormat format, + GrTextBlob* blob, + GrSubRunAllocator* alloc); void draw(const GrClip* clip, const SkMatrixProvider& viewMatrix, @@ -510,11 +506,11 @@ DirectMaskSubRun::DirectMaskSubRun(GrMaskFormat format, , fSomeGlyphsExcluded{glyphsOutOfBounds} , fGlyphs{glyphs} {} -UP DirectMaskSubRun::Make(const SkZip& drawables, - const SkStrikeSpec& strikeSpec, - GrMaskFormat format, - GrTextBlob* blob, - GrSubRunAllocator* alloc) { +GrSubRunOwner DirectMaskSubRun::Make(const SkZip& drawables, + const SkStrikeSpec& strikeSpec, + GrMaskFormat format, + GrTextBlob* blob, + GrSubRunAllocator* alloc) { DevicePosition* glyphLeftTop = alloc->makePODArray(drawables.size()); GlyphVector::Variant* glyphIDs = alloc->makePODArray(drawables.size()); @@ -834,11 +830,11 @@ public: SkSpan vertexData, GlyphVector glyphs); - static UP Make(const SkZip& drawables, - const SkStrikeSpec& strikeSpec, - GrMaskFormat format, - GrTextBlob* blob, - GrSubRunAllocator* alloc); + static GrSubRunOwner Make(const SkZip& drawables, + const SkStrikeSpec& strikeSpec, + GrMaskFormat format, + GrTextBlob* blob, + GrSubRunAllocator* alloc); void draw(const GrClip* clip, const SkMatrixProvider& viewMatrix, @@ -894,11 +890,11 @@ TransformedMaskSubRun::TransformedMaskSubRun(GrMaskFormat format, , fVertexData{vertexData} , fGlyphs{glyphs} { } -UP TransformedMaskSubRun::Make(const SkZip& drawables, - const SkStrikeSpec& strikeSpec, - GrMaskFormat format, - GrTextBlob* blob, - GrSubRunAllocator* alloc) { +GrSubRunOwner TransformedMaskSubRun::Make(const SkZip& drawables, + const SkStrikeSpec& strikeSpec, + GrMaskFormat format, + GrTextBlob* blob, + GrSubRunAllocator* alloc) { SkRect bounds = SkRectPriv::MakeLargestInverted(); SkScalar strikeToSource = strikeSpec.strikeToSourceRatio(); @@ -1084,11 +1080,11 @@ public: bool useLCDText, bool antiAliased); - static UP Make(const SkZip& drawables, - const SkFont& runFont, - const SkStrikeSpec& strikeSpec, - GrTextBlob* blob, - GrSubRunAllocator* alloc); + static GrSubRunOwner Make(const SkZip& drawables, + const SkFont& runFont, + const SkStrikeSpec& strikeSpec, + GrTextBlob* blob, + GrSubRunAllocator* alloc); void draw(const GrClip* clip, const SkMatrixProvider& viewMatrix, @@ -1157,13 +1153,11 @@ bool has_some_antialiasing(const SkFont& font ) { || edging == SkFont::Edging::kSubpixelAntiAlias; } -UP SDFTSubRun::Make( - const SkZip& drawables, - const SkFont& runFont, - const SkStrikeSpec& strikeSpec, - GrTextBlob* blob, - GrSubRunAllocator* alloc) { - +GrSubRunOwner SDFTSubRun::Make(const SkZip& drawables, + const SkFont& runFont, + const SkStrikeSpec& strikeSpec, + GrTextBlob* blob, + GrSubRunAllocator* alloc) { SkRect bounds = SkRectPriv::MakeLargestInverted(); auto mapper = [&, strikeToSource=strikeSpec.strikeToSourceRatio()](const auto& d) { auto& [variant, pos] = d; @@ -1554,7 +1548,7 @@ void GrTextBlob::addMultiMaskFormat( if (drawables.empty()) { return; } auto addSameFormat = [&](const SkZip& drawable, GrMaskFormat format) { - UP subRun = addSingle(drawable, strikeSpec, format, this, &fAlloc); + GrSubRunOwner subRun = addSingle(drawable, strikeSpec, format, this, &fAlloc); if (subRun != nullptr) { fSubRunList.append(std::move(subRun)); } else { diff --git a/src/gpu/text/GrTextBlob.h b/src/gpu/text/GrTextBlob.h index 3abccfda20..7f37441654 100644 --- a/src/gpu/text/GrTextBlob.h +++ b/src/gpu/text/GrTextBlob.h @@ -290,6 +290,8 @@ public: // * TransformedMaskSubRun - handle large bitmap/argb glyphs that need to be scaled to the screen. // * SDFTSubRun - use signed distance fields to draw largish glyphs to the screen. // * GrAtlasSubRun - this is an abstract class used for atlas drawing. +class GrSubRun; +using GrSubRunOwner = std::unique_ptr; class GrSubRun { public: virtual ~GrSubRun() = default; @@ -308,7 +310,7 @@ public: // * Don't use this API. It is only to support testing. virtual GrAtlasSubRun* testingOnly_atlasSubRun() = 0; - std::unique_ptr fNext; + GrSubRunOwner fNext; }; struct GrSubRunList { @@ -330,8 +332,8 @@ struct GrSubRunList { GrSubRun* fPtr; }; - void append(std::unique_ptr subRun) { - std::unique_ptr* newTail = &subRun->fNext; + void append(GrSubRunOwner subRun) { + GrSubRunOwner* newTail = &subRun->fNext; *fTail = std::move(subRun); fTail = newTail; } @@ -342,8 +344,8 @@ struct GrSubRunList { Iterator end() const { return Iterator{nullptr}; } GrSubRun& front() const {return *fHead; } - std::unique_ptr fHead{nullptr}; - std::unique_ptr* fTail{&fHead}; + GrSubRunOwner fHead{nullptr}; + GrSubRunOwner* fTail{&fHead}; }; // A GrTextBlob contains a fully processed SkTextBlob, suitable for nearly immediate drawing