From 038c608a8658cb6413981b7d3c9368e8245b6384 Mon Sep 17 00:00:00 2001 From: Robert Phillips Date: Wed, 21 Feb 2018 12:31:17 -0500 Subject: Remove back pointer to GrAtlasGlyphCache from GrAtlasTextStrike This is calved off from https://skia-review.googlesource.com/c/skia/+/108001 (Fission GrAtlasGlyphCache in two) In the DDL world, the GrAtlasTextStrikes can outlive their generating GrAtlasGlyphCache. Change-Id: I52b01d3934b0651a58a59b12dcc4c98ffbb891a9 Reviewed-on: https://skia-review.googlesource.com/109061 Reviewed-by: Jim Van Verth Commit-Queue: Robert Phillips --- src/gpu/text/GrAtlasGlyphCache.cpp | 6 +++--- src/gpu/text/GrAtlasGlyphCache.h | 8 +++----- src/gpu/text/GrAtlasTextBlobVertexRegenerator.cpp | 2 +- 3 files changed, 7 insertions(+), 9 deletions(-) diff --git a/src/gpu/text/GrAtlasGlyphCache.cpp b/src/gpu/text/GrAtlasGlyphCache.cpp index c36ad8798d..fb52250781 100644 --- a/src/gpu/text/GrAtlasGlyphCache.cpp +++ b/src/gpu/text/GrAtlasGlyphCache.cpp @@ -399,10 +399,9 @@ static bool get_packed_glyph_df_image(SkGlyphCache* cache, const SkGlyph& glyph, atlas and a position within that texture. */ -GrAtlasTextStrike::GrAtlasTextStrike(GrAtlasGlyphCache* owner, const SkDescriptor& key) +GrAtlasTextStrike::GrAtlasTextStrike(const SkDescriptor& key) : fFontScalerKey(key) , fPool(9/*start allocations at 512 bytes*/) - , fAtlasGlyphCache(owner) // no need to ref, it won't go away before we do , fAtlasedGlyphs(0) , fIsAbandoned(false) {} @@ -447,6 +446,7 @@ void GrAtlasTextStrike::removeID(GrDrawOpAtlas::AtlasID id) { } bool GrAtlasTextStrike::addGlyphToAtlas(GrDeferredUploadTarget* target, + GrAtlasGlyphCache* atlasGlyphCache, GrGlyph* glyph, SkGlyphCache* cache, GrMaskFormat expectedMaskFormat) { @@ -473,7 +473,7 @@ bool GrAtlasTextStrike::addGlyphToAtlas(GrDeferredUploadTarget* target, } } - bool success = fAtlasGlyphCache->addToAtlas(this, &glyph->fID, target, expectedMaskFormat, + bool success = atlasGlyphCache->addToAtlas(this, &glyph->fID, target, expectedMaskFormat, glyph->width(), glyph->height(), storage.get(), &glyph->fAtlasLocation); if (success) { diff --git a/src/gpu/text/GrAtlasGlyphCache.h b/src/gpu/text/GrAtlasGlyphCache.h index aa337c43f5..6175342c26 100644 --- a/src/gpu/text/GrAtlasGlyphCache.h +++ b/src/gpu/text/GrAtlasGlyphCache.h @@ -28,8 +28,7 @@ class GrGpu; */ class GrAtlasTextStrike : public SkNVRefCnt { public: - /** Owner is the cache that owns this strike. */ - GrAtlasTextStrike(GrAtlasGlyphCache* owner, const SkDescriptor& fontScalerKey); + GrAtlasTextStrike(const SkDescriptor& fontScalerKey); ~GrAtlasTextStrike(); inline GrGlyph* getGlyph(const SkGlyph& skGlyph, GrGlyph::PackedID packed, @@ -65,7 +64,7 @@ public: // happen. // TODO we can handle some of these cases if we really want to, but the long term solution is to // get the actual glyph image itself when we get the glyph metrics. - bool addGlyphToAtlas(GrDeferredUploadTarget*, GrGlyph*, SkGlyphCache*, + bool addGlyphToAtlas(GrDeferredUploadTarget*, GrAtlasGlyphCache*, GrGlyph*, SkGlyphCache*, GrMaskFormat expectedMaskFormat); // testing @@ -88,7 +87,6 @@ private: SkAutoDescriptor fFontScalerKey; SkArenaAlloc fPool{512}; - GrAtlasGlyphCache* fAtlasGlyphCache; int fAtlasedGlyphs; bool fIsAbandoned; @@ -246,7 +244,7 @@ private: bool initAtlas(GrMaskFormat); GrAtlasTextStrike* generateStrike(const SkGlyphCache* cache) { - GrAtlasTextStrike* strike = new GrAtlasTextStrike(this, cache->getDescriptor()); + GrAtlasTextStrike* strike = new GrAtlasTextStrike(cache->getDescriptor()); fCache.add(strike); return strike; } diff --git a/src/gpu/text/GrAtlasTextBlobVertexRegenerator.cpp b/src/gpu/text/GrAtlasTextBlobVertexRegenerator.cpp index 384596ddb6..1a9c3d73e4 100644 --- a/src/gpu/text/GrAtlasTextBlobVertexRegenerator.cpp +++ b/src/gpu/text/GrAtlasTextBlobVertexRegenerator.cpp @@ -274,7 +274,7 @@ Regenerator::Result Regenerator::doRegen() { SkASSERT(glyph && glyph->fMaskFormat == fSubRun->maskFormat()); if (!fGlyphCache->hasGlyph(glyph) && - !strike->addGlyphToAtlas(fUploadTarget, glyph, fLazyCache->get(), + !strike->addGlyphToAtlas(fUploadTarget, fGlyphCache, glyph, fLazyCache->get(), fSubRun->maskFormat())) { fBrokenRun = glyphIdx > 0; result.fFinished = false; -- cgit v1.2.3