aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--src/core/SkRemoteGlyphCache.cpp14
-rw-r--r--src/core/SkRemoteGlyphCache.h11
-rw-r--r--src/core/SkStrikeCache.cpp129
-rw-r--r--src/core/SkStrikeCache.h19
-rw-r--r--src/core/SkTypeface_remote.cpp7
-rw-r--r--src/core/SkTypeface_remote.h4
-rw-r--r--tests/SkRemoteGlyphCacheTest.cpp25
7 files changed, 78 insertions, 131 deletions
diff --git a/src/core/SkRemoteGlyphCache.cpp b/src/core/SkRemoteGlyphCache.cpp
index 10b1b41cbd..fa4767069f 100644
--- a/src/core/SkRemoteGlyphCache.cpp
+++ b/src/core/SkRemoteGlyphCache.cpp
@@ -734,11 +734,8 @@ private:
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 @@ bool SkStrikeClient::readStrikeData(const volatile void* memory, size_t memorySi
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 @@ sk_sp<SkTypeface> SkStrikeClient::deserializeTypeface(const void* buf, size_t le
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 f09228fd1e..ac13920772 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 @@ class SkGlyphCache;
struct SkPackedGlyphID;
enum SkScalerContextFlags : uint32_t;
class SkScalerContextRecDescriptor;
-class SkStrikeCache;
class SkTextBlobRunIterator;
class SkTypefaceProxy;
struct WireTypeface;
@@ -212,9 +212,7 @@ public:
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 @@ public:
// 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 @@ private:
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 5f3a46bd42..fef46fd36d 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 @@ struct SkStrikeCache::Node {
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 @@ bool operator == (decltype(nullptr), const SkStrikeCache::ExclusiveStrikePtr& rh
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 @@ SkStrikeCache::~SkStrikeCache() {
}
}
+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 @@ std::unique_ptr<SkScalerContext> SkStrikeCache::CreateScalerContext(
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,22 +162,16 @@ SkExclusiveStrikePtr SkStrikeCache::FindOrCreateStrikeExclusive(const SkPaint& p
}
void SkStrikeCache::PurgeAll() {
- GetGlobalStrikeCache()->purgeAll();
+ get_globals().purgeAll();
}
void SkStrikeCache::Validate() {
#ifdef SK_DEBUG
- GetGlobalStrikeCache()->validate();
-#endif
-}
+ auto visitor = [](const SkGlyphCache& cache) { cache.forceValidate(); };
-#ifdef SK_DEBUG
-void SkStrikeCache::validate() const {
- SkAutoExclusive ac(fLock);
- this->internalValidate();
-}
+ get_globals().forEachStrike(visitor);
#endif
-
+}
void SkStrikeCache::Dump() {
SkDebugf("GlyphCache [ used budget ]\n");
@@ -200,7 +190,7 @@ void SkStrikeCache::Dump() {
counter += 1;
};
- GetGlobalStrikeCache()->forEachStrike(visitor);
+ get_globals().forEachStrike(visitor);
}
namespace {
@@ -244,7 +234,7 @@ void SkStrikeCache::DumpMemoryStatistics(SkTraceMemoryDump* dump) {
dump->setMemoryBacking(dumpName.c_str(), "malloc", nullptr);
};
- GetGlobalStrikeCache()->forEachStrike(visitor);
+ get_globals().forEachStrike(visitor);
}
@@ -254,7 +244,7 @@ void SkStrikeCache::attachNode(Node* node) {
}
SkAutoExclusive ac(fLock);
- this->internalValidate();
+ this->validate();
node->fCache.validate();
this->internalAttachToHead(node);
@@ -268,11 +258,11 @@ SkExclusiveStrikePtr SkStrikeCache::findStrikeExclusive(const SkDescriptor& desc
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 @@ SkExclusiveStrikePtr SkStrikeCache::CreateStrikeExclusive(
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 @@ SkExclusiveStrikePtr SkStrikeCache::createStrikeExclusive(
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 @@ int SkStrikeCache::setCachePointSizeLimit(int newLimit) {
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 @@ size_t SkStrikeCache::internalPurge(size_t minBytesNeeded) {
node = prev;
}
- this->internalValidate();
+ this->validate();
#ifdef SPEW_PURGE_STATUS
if (countFreed) {
@@ -554,13 +534,12 @@ void SkStrikeCache::internalDetachCache(Node* node) {
}
#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 @@ void SkStrikeCache::internalValidate() const {
////////////////////////////////////////////////////////////////////////////////////////////////////
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 a2b3a8a19d..05e3aa4025 100644
--- a/src/core/SkStrikeCache.h
+++ b/src/core/SkStrikeCache.h
@@ -47,7 +47,7 @@ public:
class ExclusiveStrikePtr {
public:
- explicit ExclusiveStrikePtr(Node*, SkStrikeCache*);
+ explicit ExclusiveStrikePtr(Node*);
ExclusiveStrikePtr();
ExclusiveStrikePtr(const ExclusiveStrikePtr&) = delete;
ExclusiveStrikePtr& operator = (const ExclusiveStrikePtr&) = delete;
@@ -65,10 +65,8 @@ public:
private:
Node* fNode;
- SkStrikeCache* fStrikeCache;
};
- static SkStrikeCache* GetGlobalStrikeCache();
static ExclusiveStrikePtr FindStrikeExclusive(const SkDescriptor&);
@@ -113,17 +111,6 @@ public:
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 @@ public:
#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 bc6376d8fe..4b10f1e96f 100644
--- a/src/core/SkTypeface_remote.cpp
+++ b/src/core/SkTypeface_remote.cpp
@@ -19,12 +19,11 @@ SkScalerContextProxy::SkScalerContextProxy(sk_sp<SkTypeface> tf,
: 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 @@ void SkScalerContextProxy::generateMetrics(SkGlyph* glyph) {
}
// 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 @@ bool SkScalerContextProxy::generatePath(SkGlyphID glyphID, SkPath* path) {
// 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 f4d3f73e2b..88628d13b4 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 @@ public:
const SkDescriptor* desc,
sk_sp<SkStrikeClient::DiscardableHandleManager> manager);
- void initCache(SkGlyphCache*, SkStrikeCache*);
+ void initCache(SkGlyphCache*);
protected:
unsigned generateGlyphCount() override;
@@ -42,7 +41,6 @@ protected:
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 6dc79a7dd5..8bdfb7af69 100644
--- a/tests/SkRemoteGlyphCacheTest.cpp
+++ b/tests/SkRemoteGlyphCacheTest.cpp
@@ -428,8 +428,6 @@ DEF_TEST(SkRemoteGlyphCache_SearchOfDesperation, reporter) {
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 @@ DEF_TEST(SkRemoteGlyphCache_SearchOfDesperation, reporter) {
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 @@ DEF_TEST(SkRemoteGlyphCache_SearchOfDesperation, reporter) {
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 @@ DEF_TEST(SkRemoteGlyphCache_SearchOfDesperation, reporter) {
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 @@ DEF_TEST(SkRemoteGlyphCache_SearchOfDesperation, reporter) {
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 @@ DEF_TEST(SkRemoteGlyphCache_ReWriteGlyph, reporter) {
uint32_t realMask;
uint32_t fakeMask;
- SkStrikeCache strikeCache;
-
{
SkAutoDescriptor ad;
SkScalerContextRec rec;
@@ -562,7 +557,7 @@ DEF_TEST(SkRemoteGlyphCache_ReWriteGlyph, reporter) {
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 @@ DEF_TEST(SkRemoteGlyphCache_ReWriteGlyph, reporter) {
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 @@ DEF_TEST(SkRemoteGlyphCache_ReWriteGlyph, reporter) {
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);