Use descriptor instead of cache for GrStrikeCache lookup
Change-Id: Ia8e82344d3d8b394a6d9cc14d56dcf0addeff96c
Reviewed-on: https://skia-review.googlesource.com/c/191220
Commit-Queue: Herb Derby <herb@google.com>
Commit-Queue: Mike Klein <mtklein@google.com>
Auto-Submit: Herb Derby <herb@google.com>
Reviewed-by: Mike Klein <mtklein@google.com>
diff --git a/src/core/SkGlyphRunPainter.cpp b/src/core/SkGlyphRunPainter.cpp
index 03346e1..651b74d 100644
--- a/src/core/SkGlyphRunPainter.cpp
+++ b/src/core/SkGlyphRunPainter.cpp
@@ -697,7 +697,7 @@
auto subRun = fRun->initARGBFallback();
SkExclusiveStrikePtr fallbackCache = SkStrikeCache::FindOrCreateStrikeExclusive(
fallbackFont, fallbackPaint, fProps, fScalerContextFlags, glyphCacheMatrix);
- sk_sp<GrTextStrike> strike = fGrStrikeCache->getStrike(fallbackCache.get());
+ sk_sp<GrTextStrike> strike = fGrStrikeCache->getStrike(fallbackCache->getDescriptor());
fRun->setupFont(fallbackPaint, fallbackFont, fallbackCache->getDescriptor());
SkASSERT(strike != nullptr);
@@ -762,7 +762,7 @@
{
SkExclusiveStrikePtr cache =SkStrikeCache::FindOrCreateStrikeExclusive(
distanceFieldFont, distanceFieldPaint, props, flags, SkMatrix::I());
- sk_sp<GrTextStrike> currStrike = glyphCache->getStrike(cache.get());
+ sk_sp<GrTextStrike> currStrike = glyphCache->getStrike(cache->getDescriptor());
run->setupFont(distanceFieldPaint, distanceFieldFont, cache->getDescriptor());
auto perEmpty = [](const SkGlyph&, SkPoint) {};
@@ -835,7 +835,7 @@
auto processMasks =
[run, cache{cache.get()}, glyphCache]
(SkSpan<const SkGlyphRunListPainter::GlyphAndPos> masks) {
- sk_sp<GrTextStrike> currStrike = glyphCache->getStrike(cache);
+ sk_sp<GrTextStrike> 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 0874ffc..15fc9c3 100644
--- a/src/gpu/text/GrStrikeCache.h
+++ b/src/gpu/text/GrStrikeCache.h
@@ -112,10 +112,10 @@
// 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<GrTextStrike> getStrike(const SkStrike* cache) {
- sk_sp<GrTextStrike> strike = sk_ref_sp(fCache.find(cache->getDescriptor()));
+ sk_sp<GrTextStrike> getStrike(const SkDescriptor& desc) {
+ sk_sp<GrTextStrike> strike = sk_ref_sp(fCache.find(desc));
if (!strike) {
- strike = this->generateStrike(cache);
+ strike = this->generateStrike(desc);
}
return strike;
}
@@ -127,9 +127,9 @@
static void HandleEviction(GrDrawOpAtlas::AtlasID, void*);
private:
- sk_sp<GrTextStrike> generateStrike(const SkStrike* cache) {
+ sk_sp<GrTextStrike> generateStrike(const SkDescriptor& desc) {
// 'fCache' get the construction ref
- sk_sp<GrTextStrike> strike = sk_ref_sp(new GrTextStrike(cache->getDescriptor()));
+ sk_sp<GrTextStrike> 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 77d2b8d..1b2b117 100644
--- a/src/gpu/text/GrTextBlobVertexRegenerator.cpp
+++ b/src/gpu/text/GrTextBlobVertexRegenerator.cpp
@@ -176,7 +176,7 @@
}
if (regenGlyphs) {
- strike = fGlyphCache->getStrike(fLazyCache->get());
+ strike = fGlyphCache->getStrike((*fLazyCache)->getDescriptor());
} else {
strike = fSubRun->refStrike();
}