Revert "Make SkRemoteGlyphCache tests use private glyph cache"

This reverts commit 3e36ce6e660ad585c58c5cc5591f23a46fcab767.

Reason for revert: Too much verification

Original change's description:
> Make SkRemoteGlyphCache tests use private glyph cache
> 
> Change-Id: If6aa189f3badc7558ab8ecf71ee3d704b275b20f
> Reviewed-on: https://skia-review.googlesource.com/136225
> Commit-Queue: Herb Derby <herb@google.com>
> Reviewed-by: Mike Klein <mtklein@google.com>

TBR=mtklein@google.com,herb@google.com

Change-Id: Ia0c096abd0ab651bc7c907f0595af4f07c88fb5e
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://skia-review.googlesource.com/136478
Reviewed-by: Herb Derby <herb@google.com>
Commit-Queue: Herb Derby <herb@google.com>
diff --git a/src/core/SkRemoteGlyphCache.cpp b/src/core/SkRemoteGlyphCache.cpp
index 10b1b41..fa47670 100644
--- a/src/core/SkRemoteGlyphCache.cpp
+++ b/src/core/SkRemoteGlyphCache.cpp
@@ -734,11 +734,8 @@
     sk_sp<DiscardableHandleManager> fManager;
 };
 
-SkStrikeClient::SkStrikeClient(sk_sp<DiscardableHandleManager> discardableManager,
-                               bool isLogging,
-                               SkStrikeCache* strikeCache)
+SkStrikeClient::SkStrikeClient(sk_sp<DiscardableHandleManager> discardableManager, bool isLogging)
         : fDiscardableHandleManager(std::move(discardableManager))
-        , fStrikeCache{strikeCache ? strikeCache : SkStrikeCache::GetGlobalStrikeCache()}
         , fIsLogging{isLogging} {}
 
 SkStrikeClient::~SkStrikeClient() = default;
@@ -795,19 +792,18 @@
         SkAutoDescriptor ad;
         auto* client_desc = auto_descriptor_from_desc(sourceAd.getDesc(), tf->uniqueID(), &ad);
 
-        auto strike = fStrikeCache->findStrikeExclusive(*client_desc);
+        auto strike = SkStrikeCache::FindStrikeExclusive(*client_desc);
         if (strike == nullptr) {
             // Note that we don't need to deserialize the effects since we won't be generating any
             // glyphs here anyway, and the desc is still correct since it includes the serialized
             // effects.
             SkScalerContextEffects effects;
             auto scaler = SkStrikeCache::CreateScalerContext(*client_desc, effects, *tf);
-            strike = fStrikeCache->createStrikeExclusive(
+            strike = SkStrikeCache::CreateStrikeExclusive(
                     *client_desc, std::move(scaler), &fontMetrics,
                     skstd::make_unique<DiscardableStrikePinner>(spec.discardableHandleId,
                                                                 fDiscardableHandleManager));
-            auto proxyContext = static_cast<SkScalerContextProxy*>(strike->getScalerContext());
-            proxyContext->initCache(strike.get(), fStrikeCache);
+            static_cast<SkScalerContextProxy*>(strike->getScalerContext())->initCache(strike.get());
         }
 
         size_t glyphImagesCount = 0u;
@@ -869,7 +865,7 @@
     WireTypeface wire;
     if (len != sizeof(wire)) return nullptr;
     memcpy(&wire, buf, sizeof(wire));
-    return this->addTypeface(wire);
+    return addTypeface(wire);
 }
 
 sk_sp<SkTypeface> SkStrikeClient::addTypeface(const WireTypeface& wire) {
diff --git a/src/core/SkRemoteGlyphCache.h b/src/core/SkRemoteGlyphCache.h
index f09228f..ac13920 100644
--- a/src/core/SkRemoteGlyphCache.h
+++ b/src/core/SkRemoteGlyphCache.h
@@ -20,6 +20,7 @@
 #include "SkMakeUnique.h"
 #include "SkNoDrawCanvas.h"
 #include "SkRefCnt.h"
+#include "SkRemoteGlyphCache.h"
 #include "SkSerialProcs.h"
 #include "SkTypeface.h"
 
@@ -29,7 +30,6 @@
 struct SkPackedGlyphID;
 enum SkScalerContextFlags : uint32_t;
 class SkScalerContextRecDescriptor;
-class SkStrikeCache;
 class SkTextBlobRunIterator;
 class SkTypefaceProxy;
 struct WireTypeface;
@@ -212,9 +212,7 @@
         virtual void notifyCacheMiss(CacheMissType) {}
     };
 
-    SkStrikeClient(sk_sp<DiscardableHandleManager>,
-                   bool isLogging = true,
-                   SkStrikeCache* strikeCache = nullptr);
+    SkStrikeClient(sk_sp<DiscardableHandleManager>, bool isLogging = true);
     ~SkStrikeClient();
 
     // Deserializes the typeface previously serialized using the SkStrikeServer. Returns null if the
@@ -225,9 +223,7 @@
     // from a server when serializing the ops must be deserialized before the op
     // is rasterized.
     // Returns false if the data is invalid.
-    bool readStrikeData(
-            const volatile void* memory,
-            size_t memorySize);
+    bool readStrikeData(const volatile void* memory, size_t memorySize);
 
 private:
     class DiscardableStrikePinner;
@@ -236,7 +232,6 @@
 
     SkTHashMap<SkFontID, sk_sp<SkTypeface>> fRemoteFontIdToTypeface;
     sk_sp<DiscardableHandleManager> fDiscardableHandleManager;
-    SkStrikeCache* const fStrikeCache;
     const bool fIsLogging;
 };
 
diff --git a/src/core/SkStrikeCache.cpp b/src/core/SkStrikeCache.cpp
index 5f3a46b..fef46fd 100644
--- a/src/core/SkStrikeCache.cpp
+++ b/src/core/SkStrikeCache.cpp
@@ -19,6 +19,15 @@
 #include "SkTypefaceCache.h"
 #include "SkPaintPriv.h"
 
+// Returns the shared globals
+static SkStrikeCache& get_globals() {
+    static SkOnce once;
+    static SkStrikeCache* globals;
+
+    once([]{ globals = new SkStrikeCache; });
+    return *globals;
+}
+
 struct SkStrikeCache::Node {
     Node(const SkDescriptor& desc,
         std::unique_ptr<SkScalerContext> scaler,
@@ -33,35 +42,23 @@
     std::unique_ptr<SkStrikePinner> fPinner;
 };
 
-SkStrikeCache::ExclusiveStrikePtr::ExclusiveStrikePtr(
-        SkStrikeCache::Node* node, SkStrikeCache* strikeCache)
-        : fNode{node}
-        , fStrikeCache{strikeCache} {}
-SkStrikeCache::ExclusiveStrikePtr::ExclusiveStrikePtr()
-        : fNode{nullptr}
-        , fStrikeCache{nullptr} {}
+SkStrikeCache::ExclusiveStrikePtr::ExclusiveStrikePtr(SkStrikeCache::Node* node) : fNode{node} {}
+SkStrikeCache::ExclusiveStrikePtr::ExclusiveStrikePtr() : fNode{nullptr} {}
 SkStrikeCache::ExclusiveStrikePtr::ExclusiveStrikePtr(ExclusiveStrikePtr&& o)
-    : fNode{o.fNode}, fStrikeCache{o.fStrikeCache} {
+    : fNode{o.fNode} {
     o.fNode = nullptr;
-    o.fStrikeCache = nullptr;
 }
 
 SkStrikeCache::ExclusiveStrikePtr&
 SkStrikeCache::ExclusiveStrikePtr::operator = (ExclusiveStrikePtr&& o) {
-    if (fNode != nullptr) {
-        fStrikeCache->attachNode(fNode);
-    }
+    Attach(fNode);
     fNode = o.fNode;
-    fStrikeCache = o.fStrikeCache;
     o.fNode = nullptr;
-    o.fStrikeCache = nullptr;
     return *this;
 }
 
 SkStrikeCache::ExclusiveStrikePtr::~ExclusiveStrikePtr() {
-    if (fNode != nullptr) {
-        fStrikeCache->attachNode(fNode);
-    }
+    SkStrikeCache::Attach(fNode);
 }
 SkGlyphCache* SkStrikeCache::ExclusiveStrikePtr::get() const {
     return &fNode->fCache;
@@ -87,14 +84,6 @@
     return nullptr == rhs.fNode;
 }
 
-SkStrikeCache* SkStrikeCache::GetGlobalStrikeCache() {
-    static SkOnce once;
-    static SkStrikeCache* globals;
-
-    once([]{ globals = new SkStrikeCache; });
-    return globals;
-}
-
 SkStrikeCache::~SkStrikeCache() {
     Node* node = fHead;
     while (node) {
@@ -104,9 +93,22 @@
     }
 }
 
+void SkStrikeCache::Attach(Node* node) {
+    get_globals().attachNode(node);
+}
 
 SkExclusiveStrikePtr SkStrikeCache::FindStrikeExclusive(const SkDescriptor& desc) {
-    return GetGlobalStrikeCache()->findStrikeExclusive(desc);
+    return get_globals().findStrikeExclusive(desc);
+}
+
+bool SkStrikeCache::DesperationSearchForImage(const SkDescriptor& desc, SkGlyph* glyph,
+                                              SkGlyphCache* targetCache) {
+    return get_globals().desperationSearchForImage(desc, glyph, targetCache);
+}
+
+bool SkStrikeCache::DesperationSearchForPath(
+        const SkDescriptor& desc, SkGlyphID glyphID, SkPath* path) {
+    return get_globals().desperationSearchForPath(desc, glyphID, path);
 }
 
 std::unique_ptr<SkScalerContext> SkStrikeCache::CreateScalerContext(
@@ -129,16 +131,10 @@
 SkExclusiveStrikePtr SkStrikeCache::FindOrCreateStrikeExclusive(
         const SkDescriptor& desc, const SkScalerContextEffects& effects, const SkTypeface& typeface)
 {
-    return GetGlobalStrikeCache()->findOrCreateStrikeExclusive(desc, effects, typeface);
-}
-
-SkExclusiveStrikePtr SkStrikeCache::findOrCreateStrikeExclusive(
-        const SkDescriptor& desc, const SkScalerContextEffects& effects, const SkTypeface& typeface)
-{
-    auto cache = this->findStrikeExclusive(desc);
+    auto cache = FindStrikeExclusive(desc);
     if (cache == nullptr) {
         auto scaler = CreateScalerContext(desc, effects, typeface);
-        cache = this->createStrikeExclusive(desc, std::move(scaler));
+        cache = CreateStrikeExclusive(desc, std::move(scaler));
     }
     return cache;
 }
@@ -166,23 +162,17 @@
 }
 
 void SkStrikeCache::PurgeAll() {
-    GetGlobalStrikeCache()->purgeAll();
+    get_globals().purgeAll();
 }
 
 void SkStrikeCache::Validate() {
 #ifdef SK_DEBUG
-    GetGlobalStrikeCache()->validate();
+    auto visitor = [](const SkGlyphCache& cache) { cache.forceValidate(); };
+
+    get_globals().forEachStrike(visitor);
 #endif
 }
 
-#ifdef SK_DEBUG
-void SkStrikeCache::validate() const {
-    SkAutoExclusive ac(fLock);
-    this->internalValidate();
-}
-#endif
-
-
 void SkStrikeCache::Dump() {
     SkDebugf("GlyphCache [     used    budget ]\n");
     SkDebugf("    bytes  [ %8zu  %8zu ]\n",
@@ -200,7 +190,7 @@
         counter += 1;
     };
 
-    GetGlobalStrikeCache()->forEachStrike(visitor);
+    get_globals().forEachStrike(visitor);
 }
 
 namespace {
@@ -244,7 +234,7 @@
         dump->setMemoryBacking(dumpName.c_str(), "malloc", nullptr);
     };
 
-    GetGlobalStrikeCache()->forEachStrike(visitor);
+    get_globals().forEachStrike(visitor);
 }
 
 
@@ -254,7 +244,7 @@
     }
     SkAutoExclusive ac(fLock);
 
-    this->internalValidate();
+    this->validate();
     node->fCache.validate();
 
     this->internalAttachToHead(node);
@@ -268,11 +258,11 @@
     for (node = internalGetHead(); node != nullptr; node = node->fNext) {
         if (node->fCache.getDescriptor() == desc) {
             this->internalDetachCache(node);
-            return SkExclusiveStrikePtr(node, this);
+            return SkExclusiveStrikePtr(node);
         }
     }
 
-    return SkExclusiveStrikePtr();
+    return SkExclusiveStrikePtr(nullptr);
 }
 
 static bool loose_compare(const SkDescriptor& lhs, const SkDescriptor& rhs) {
@@ -364,16 +354,6 @@
         SkPaint::FontMetrics* maybeMetrics,
         std::unique_ptr<SkStrikePinner> pinner)
 {
-    return GetGlobalStrikeCache()->createStrikeExclusive(
-            desc, std::move(scaler), maybeMetrics, std::move(pinner));
-}
-
-SkExclusiveStrikePtr SkStrikeCache::createStrikeExclusive(
-        const SkDescriptor& desc,
-        std::unique_ptr<SkScalerContext> scaler,
-        SkPaint::FontMetrics* maybeMetrics,
-        std::unique_ptr<SkStrikePinner> pinner)
-{
     SkPaint::FontMetrics fontMetrics;
     if (maybeMetrics != nullptr) {
         fontMetrics = *maybeMetrics;
@@ -381,9 +361,7 @@
         scaler->getFontMetrics(&fontMetrics);
     }
 
-    return SkExclusiveStrikePtr(
-            new Node(desc, std::move(scaler), fontMetrics, std::move(pinner)),
-            this);
+    return SkExclusiveStrikePtr(new Node(desc, std::move(scaler), fontMetrics, std::move(pinner)));
 }
 
 void SkStrikeCache::purgeAll() {
@@ -458,13 +436,15 @@
 void SkStrikeCache::forEachStrike(std::function<void(const SkGlyphCache&)> visitor) const {
     SkAutoExclusive ac(fLock);
 
+    this->validate();
+
     for (Node* node = this->internalGetHead(); node != nullptr; node = node->fNext) {
         visitor(node->fCache);
     }
 }
 
 size_t SkStrikeCache::internalPurge(size_t minBytesNeeded) {
-    this->internalValidate();
+    this->validate();
 
     size_t bytesNeeded = 0;
     if (fTotalMemoryUsed > fCacheSizeLimit) {
@@ -507,7 +487,7 @@
         node = prev;
     }
 
-    this->internalValidate();
+    this->validate();
 
 #ifdef SPEW_PURGE_STATUS
     if (countFreed) {
@@ -554,13 +534,12 @@
 }
 
 #ifdef SK_DEBUG
-void SkStrikeCache::internalValidate() const {
+void SkStrikeCache::validate() const {
     size_t computedBytes = 0;
     int computedCount = 0;
 
     const Node* node = fHead;
     while (node != nullptr) {
-        node->fCache.forceValidate();
         computedBytes += node->fCache.getMemoryUsed();
         computedCount += 1;
         node = node->fNext;
@@ -576,38 +555,38 @@
 ////////////////////////////////////////////////////////////////////////////////////////////////////
 
 size_t SkGraphics::GetFontCacheLimit() {
-    return SkStrikeCache::GetGlobalStrikeCache()->getCacheSizeLimit();
+    return get_globals().getCacheSizeLimit();
 }
 
 size_t SkGraphics::SetFontCacheLimit(size_t bytes) {
-    return SkStrikeCache::GetGlobalStrikeCache()->setCacheSizeLimit(bytes);
+    return get_globals().setCacheSizeLimit(bytes);
 }
 
 size_t SkGraphics::GetFontCacheUsed() {
-    return SkStrikeCache::GetGlobalStrikeCache()->getTotalMemoryUsed();
+    return get_globals().getTotalMemoryUsed();
 }
 
 int SkGraphics::GetFontCacheCountLimit() {
-    return SkStrikeCache::GetGlobalStrikeCache()->getCacheCountLimit();
+    return get_globals().getCacheCountLimit();
 }
 
 int SkGraphics::SetFontCacheCountLimit(int count) {
-    return SkStrikeCache::GetGlobalStrikeCache()->setCacheCountLimit(count);
+    return get_globals().setCacheCountLimit(count);
 }
 
 int SkGraphics::GetFontCacheCountUsed() {
-    return SkStrikeCache::GetGlobalStrikeCache()->getCacheCountUsed();
+    return get_globals().getCacheCountUsed();
 }
 
 int SkGraphics::GetFontCachePointSizeLimit() {
-    return SkStrikeCache::GetGlobalStrikeCache()->getCachePointSizeLimit();
+    return get_globals().getCachePointSizeLimit();
 }
 
 int SkGraphics::SetFontCachePointSizeLimit(int limit) {
-    return SkStrikeCache::GetGlobalStrikeCache()->setCachePointSizeLimit(limit);
+    return get_globals().setCachePointSizeLimit(limit);
 }
 
 void SkGraphics::PurgeFontCache() {
-    SkStrikeCache::GetGlobalStrikeCache()->purgeAll();
+    get_globals().purgeAll();
     SkTypefaceCache::PurgeAll();
 }
diff --git a/src/core/SkStrikeCache.h b/src/core/SkStrikeCache.h
index a2b3a8a..05e3aa4 100644
--- a/src/core/SkStrikeCache.h
+++ b/src/core/SkStrikeCache.h
@@ -47,7 +47,7 @@
 
     class ExclusiveStrikePtr {
     public:
-        explicit ExclusiveStrikePtr(Node*, SkStrikeCache*);
+        explicit ExclusiveStrikePtr(Node*);
         ExclusiveStrikePtr();
         ExclusiveStrikePtr(const ExclusiveStrikePtr&) = delete;
         ExclusiveStrikePtr& operator = (const ExclusiveStrikePtr&) = delete;
@@ -65,10 +65,8 @@
 
     private:
         Node* fNode;
-        SkStrikeCache* fStrikeCache;
     };
 
-    static SkStrikeCache* GetGlobalStrikeCache();
 
     static ExclusiveStrikePtr FindStrikeExclusive(const SkDescriptor&);
 
@@ -113,17 +111,6 @@
     void attachNode(Node* node);
     ExclusiveStrikePtr findStrikeExclusive(const SkDescriptor&);
 
-    ExclusiveStrikePtr findOrCreateStrikeExclusive(
-            const SkDescriptor& desc,
-            const SkScalerContextEffects& effects,
-            const SkTypeface& typeface);
-
-    ExclusiveStrikePtr createStrikeExclusive(
-            const SkDescriptor& desc,
-            std::unique_ptr<SkScalerContext> scaler,
-            SkPaint::FontMetrics* maybeMetrics = nullptr,
-            std::unique_ptr<SkStrikePinner> = nullptr);
-
     // Routines to find suitable data when working in a remote cache situation. These are
     // suitable as substitutes for similar calls in SkScalerContext.
     bool desperationSearchForImage(const SkDescriptor& desc,
@@ -146,13 +133,13 @@
 
 #ifdef SK_DEBUG
     void validate() const;
-    void internalValidate() const;
 #else
     void validate() const {}
-    void internalValidate() const {}
 #endif
 
 private:
+    static void Attach(Node* node);
+
     // The following methods can only be called when mutex is already held.
     Node* internalGetHead() const { return fHead; }
     Node* internalGetTail() const { return fTail; }
diff --git a/src/core/SkTypeface_remote.cpp b/src/core/SkTypeface_remote.cpp
index bc6376d..4b10f1e 100644
--- a/src/core/SkTypeface_remote.cpp
+++ b/src/core/SkTypeface_remote.cpp
@@ -19,12 +19,11 @@
         : SkScalerContext{std::move(tf), effects, desc}
         , fDiscardableManager{std::move(manager)} {}
 
-void SkScalerContextProxy::initCache(SkGlyphCache* cache, SkStrikeCache* strikeCache) {
+void SkScalerContextProxy::initCache(SkGlyphCache* cache) {
     SkASSERT(fCache == nullptr);
     SkASSERT(cache != nullptr);
 
     fCache = cache;
-    fStrikeCache = strikeCache;
 }
 
 unsigned SkScalerContextProxy::generateGlyphCount()  {
@@ -58,7 +57,7 @@
         }
 
         // Now check other caches for a desc mismatch.
-        if (fStrikeCache->desperationSearchForImage(fCache->getDescriptor(), glyph, fCache)) {
+        if (SkStrikeCache::DesperationSearchForImage(fCache->getDescriptor(), glyph, fCache)) {
             fDiscardableManager->notifyCacheMiss(
                     SkStrikeClient::CacheMissType::kGlyphMetricsFallback);
             return;
@@ -89,7 +88,7 @@
     // Since the scaler context is being called, we don't have the needed data. Try to find a
     // fallback before failing.
     auto desc = SkScalerContext::DescriptorGivenRecAndEffects(this->getRec(), this->getEffects());
-    bool foundPath = fStrikeCache->desperationSearchForPath(*desc, glyphID, path);
+    bool foundPath = SkStrikeCache::DesperationSearchForPath(*desc, glyphID, path);
     fDiscardableManager->notifyCacheMiss(foundPath
                                                  ? SkStrikeClient::CacheMissType::kGlyphPathFallback
                                                  : SkStrikeClient::CacheMissType::kGlyphPath);
diff --git a/src/core/SkTypeface_remote.h b/src/core/SkTypeface_remote.h
index f4d3f73..88628d1 100644
--- a/src/core/SkTypeface_remote.h
+++ b/src/core/SkTypeface_remote.h
@@ -18,7 +18,6 @@
 #include "SkTypeface.h"
 
 class SkTypefaceProxy;
-class SkStrikeCache;
 
 class SkScalerContextProxy : public SkScalerContext {
 public:
@@ -27,7 +26,7 @@
                          const SkDescriptor* desc,
                          sk_sp<SkStrikeClient::DiscardableHandleManager> manager);
 
-    void initCache(SkGlyphCache*, SkStrikeCache*);
+    void initCache(SkGlyphCache*);
 
 protected:
     unsigned generateGlyphCount() override;
@@ -42,7 +41,6 @@
 private:
     sk_sp<SkStrikeClient::DiscardableHandleManager> fDiscardableManager;
     SkGlyphCache* fCache = nullptr;
-    SkStrikeCache* fStrikeCache = nullptr;
     typedef SkScalerContext INHERITED;
 };
 
diff --git a/tests/SkRemoteGlyphCacheTest.cpp b/tests/SkRemoteGlyphCacheTest.cpp
index 6dc79a7..8bdfb7a 100644
--- a/tests/SkRemoteGlyphCacheTest.cpp
+++ b/tests/SkRemoteGlyphCacheTest.cpp
@@ -428,8 +428,6 @@
     auto lostGlyphID = SkPackedGlyphID(1, SK_FixedHalf, SK_FixedHalf);
     const uint8_t glyphImage[] = {0xFF, 0xFF};
 
-    SkStrikeCache strikeCache;
-
     // Build a fallback cache.
     {
         SkAutoDescriptor ad;
@@ -439,7 +437,7 @@
         SkScalerContext::MakeRecAndEffects(paint, nullptr, nullptr, flags, &rec, &effects, false);
         auto desc = SkScalerContext::AutoDescriptorGivenRecAndEffects(rec, effects, &ad);
 
-        auto fallbackCache = strikeCache.findOrCreateStrikeExclusive(*desc, effects, *clientTf);
+        auto fallbackCache = SkStrikeCache::FindOrCreateStrikeExclusive(*desc, effects, *clientTf);
         auto glyph = fallbackCache->getRawGlyphByID(lostGlyphID);
         glyph->fMaskFormat = SkMask::kA8_Format;
         glyph->fHeight = 1;
@@ -456,7 +454,7 @@
         SkScalerContextFlags flags = SkScalerContextFlags::kFakeGammaAndBoostContrast;
         SkScalerContext::MakeRecAndEffects(paint, nullptr, nullptr, flags, &rec, &effects, false);
         auto desc = SkScalerContext::AutoDescriptorGivenRecAndEffects(rec, effects, &ad);
-        auto testCache = strikeCache.findStrikeExclusive(*desc);
+        auto testCache = SkStrikeCache::FindStrikeExclusive(*desc);
         REPORTER_ASSERT(reporter, !(testCache == nullptr));
     }
 
@@ -468,12 +466,11 @@
     SkScalerContextFlags flags = SkScalerContextFlags::kNone;
     SkScalerContext::MakeRecAndEffects(paint, nullptr, nullptr, flags, &rec, &effects, false);
     auto desc = SkScalerContext::AutoDescriptorGivenRecAndEffects(rec, effects, &ad);
-    testCache = strikeCache.findStrikeExclusive(*desc);
+    testCache = SkStrikeCache::FindStrikeExclusive(*desc);
     REPORTER_ASSERT(reporter, testCache == nullptr);
-    testCache = strikeCache.createStrikeExclusive(*desc,
+    testCache = SkStrikeCache::CreateStrikeExclusive(*desc,
                                                      clientTf->createScalerContext(effects, desc));
-    auto scalerProxy = static_cast<SkScalerContextProxy*>(testCache->getScalerContext());
-    scalerProxy->initCache(testCache.get(), &strikeCache);
+    static_cast<SkScalerContextProxy*>(testCache->getScalerContext())->initCache(testCache.get());
 
     // Look for the lost glyph.
     {
@@ -507,7 +504,7 @@
             REPORTER_ASSERT(reporter, discardableManager->cacheMissCount(i) == 0);
         }
     }
-    strikeCache.internalValidate();
+    SkStrikeCache::Validate();
 
     // Must unlock everything on termination, otherwise valgrind complains about memory leaks.
     discardableManager->unlockAndDeleteAll();
@@ -533,8 +530,6 @@
     uint32_t realMask;
     uint32_t fakeMask;
 
-    SkStrikeCache strikeCache;
-
     {
         SkAutoDescriptor ad;
         SkScalerContextRec rec;
@@ -562,7 +557,7 @@
         SkScalerContext::MakeRecAndEffects(paint, nullptr, nullptr, flags, &rec, &effects, false);
         auto desc = SkScalerContext::AutoDescriptorGivenRecAndEffects(rec, effects, &ad);
 
-        auto fallbackCache = strikeCache.findOrCreateStrikeExclusive(*desc, effects, *clientTf);
+        auto fallbackCache = SkStrikeCache::FindOrCreateStrikeExclusive(*desc, effects, *clientTf);
         auto glyph = fallbackCache->getRawGlyphByID(lostGlyphID);
         fakeMask = (realMask == SkMask::kA8_Format) ? SkMask::kBW_Format : SkMask::kA8_Format;
         glyph->fMaskFormat = fakeMask;
@@ -584,9 +579,7 @@
         std::vector<uint8_t> serverStrikeData;
         server.writeStrikeData(&serverStrikeData);
         REPORTER_ASSERT(reporter,
-                        client.readStrikeData(
-                                serverStrikeData.data(),
-                                serverStrikeData.size()));
+                        client.readStrikeData(serverStrikeData.data(), serverStrikeData.size()));
     }
 
     {
@@ -598,7 +591,7 @@
         SkScalerContext::MakeRecAndEffects(paint, nullptr, nullptr, flags, &rec, &effects, false);
         auto desc = SkScalerContext::AutoDescriptorGivenRecAndEffects(rec, effects, &ad);
 
-        auto fallbackCache = strikeCache.findStrikeExclusive(*desc);
+        auto fallbackCache = SkStrikeCache::FindStrikeExclusive(*desc);
         REPORTER_ASSERT(reporter, fallbackCache.get() != nullptr);
         auto glyph = fallbackCache->getRawGlyphByID(lostGlyphID);
         REPORTER_ASSERT(reporter, glyph->fMaskFormat == fakeMask);