From 30595ea7c7825fb170d546cf77602e37b2ec8bd6 Mon Sep 17 00:00:00 2001 From: Herb Derby Date: Mon, 11 Feb 2019 11:25:55 -0500 Subject: [PATCH] Use descriptor instead of cache for GrStrikeCache lookup Change-Id: Ia8e82344d3d8b394a6d9cc14d56dcf0addeff96c Reviewed-on: https://skia-review.googlesource.com/c/191220 Commit-Queue: Herb Derby Commit-Queue: Mike Klein Auto-Submit: Herb Derby Reviewed-by: Mike Klein --- src/core/SkGlyphRunPainter.cpp | 6 +++--- src/gpu/text/GrStrikeCache.h | 10 +++++----- src/gpu/text/GrTextBlobVertexRegenerator.cpp | 2 +- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/core/SkGlyphRunPainter.cpp b/src/core/SkGlyphRunPainter.cpp index 03346e1e15..651b74d963 100644 --- a/src/core/SkGlyphRunPainter.cpp +++ b/src/core/SkGlyphRunPainter.cpp @@ -697,7 +697,7 @@ void GrTextBlob::generateFromGlyphRunList(GrStrikeCache* glyphCache, auto subRun = fRun->initARGBFallback(); SkExclusiveStrikePtr fallbackCache = SkStrikeCache::FindOrCreateStrikeExclusive( fallbackFont, fallbackPaint, fProps, fScalerContextFlags, glyphCacheMatrix); - sk_sp strike = fGrStrikeCache->getStrike(fallbackCache.get()); + sk_sp strike = fGrStrikeCache->getStrike(fallbackCache->getDescriptor()); fRun->setupFont(fallbackPaint, fallbackFont, fallbackCache->getDescriptor()); SkASSERT(strike != nullptr); @@ -762,7 +762,7 @@ void GrTextBlob::generateFromGlyphRunList(GrStrikeCache* glyphCache, { SkExclusiveStrikePtr cache =SkStrikeCache::FindOrCreateStrikeExclusive( distanceFieldFont, distanceFieldPaint, props, flags, SkMatrix::I()); - sk_sp currStrike = glyphCache->getStrike(cache.get()); + sk_sp currStrike = glyphCache->getStrike(cache->getDescriptor()); run->setupFont(distanceFieldPaint, distanceFieldFont, cache->getDescriptor()); auto perEmpty = [](const SkGlyph&, SkPoint) {}; @@ -835,7 +835,7 @@ void GrTextBlob::generateFromGlyphRunList(GrStrikeCache* glyphCache, auto processMasks = [run, cache{cache.get()}, glyphCache] (SkSpan masks) { - sk_sp currStrike = glyphCache->getStrike(cache); + sk_sp currStrike = glyphCache->getStrike(cache->getDescriptor()); for (const auto& mask : masks) { SkPoint pt{SkScalarFloorToScalar(mask.position.fX), SkScalarFloorToScalar(mask.position.fY)}; diff --git a/src/gpu/text/GrStrikeCache.h b/src/gpu/text/GrStrikeCache.h index 0874ffc50b..15fc9c3920 100644 --- a/src/gpu/text/GrStrikeCache.h +++ b/src/gpu/text/GrStrikeCache.h @@ -112,10 +112,10 @@ public: // another client of the cache may cause the strike to be purged while it is still reffed. // Therefore, the caller must check GrTextStrike::isAbandoned() if there are other // interactions with the cache since the strike was received. - sk_sp getStrike(const SkStrike* cache) { - sk_sp strike = sk_ref_sp(fCache.find(cache->getDescriptor())); + sk_sp getStrike(const SkDescriptor& desc) { + sk_sp strike = sk_ref_sp(fCache.find(desc)); if (!strike) { - strike = this->generateStrike(cache); + strike = this->generateStrike(desc); } return strike; } @@ -127,9 +127,9 @@ public: static void HandleEviction(GrDrawOpAtlas::AtlasID, void*); private: - sk_sp generateStrike(const SkStrike* cache) { + sk_sp generateStrike(const SkDescriptor& desc) { // 'fCache' get the construction ref - sk_sp strike = sk_ref_sp(new GrTextStrike(cache->getDescriptor())); + sk_sp strike = sk_ref_sp(new GrTextStrike(desc)); fCache.add(strike.get()); return strike; } diff --git a/src/gpu/text/GrTextBlobVertexRegenerator.cpp b/src/gpu/text/GrTextBlobVertexRegenerator.cpp index 77d2b8ded7..1b2b11739c 100644 --- a/src/gpu/text/GrTextBlobVertexRegenerator.cpp +++ b/src/gpu/text/GrTextBlobVertexRegenerator.cpp @@ -176,7 +176,7 @@ bool GrTextBlob::VertexRegenerator::doRegen(GrTextBlob::VertexRegenerator::Resul } if (regenGlyphs) { - strike = fGlyphCache->getStrike(fLazyCache->get()); + strike = fGlyphCache->getStrike((*fLazyCache)->getDescriptor()); } else { strike = fSubRun->refStrike(); }