Make SkStrikeCache::Validate call non global version

Change Validate to ValidateGlyphCacheDataSize. Make it call a
non-global version.

BUG=skia:8091

Change-Id: Iec31a06569a0ab1ec318e693e699a808eb9ad247
Reviewed-on: https://skia-review.googlesource.com/136638
Commit-Queue: Herb Derby <herb@google.com>
Reviewed-by: Mike Klein <mtklein@google.com>
This commit is contained in:
Herb Derby 2018-06-21 14:06:30 -04:00 committed by Skia Commit-Bot
parent 09f92b94f5
commit c113e9e23d
3 changed files with 24 additions and 17 deletions

View File

@ -181,14 +181,6 @@ void SkStrikeCache::PurgeAll() {
GlobalStrikeCache()->purgeAll();
}
void SkStrikeCache::Validate() {
#ifdef SK_DEBUG
auto visitor = [](const SkGlyphCache& cache) { cache.forceValidate(); };
GlobalStrikeCache()->forEachStrike(visitor);
#endif
}
void SkStrikeCache::Dump() {
SkDebugf("GlyphCache [ used budget ]\n");
SkDebugf(" bytes [ %8zu %8zu ]\n",
@ -559,6 +551,20 @@ void SkStrikeCache::internalDetachCache(Node* node) {
node->fPrev = node->fNext = nullptr;
}
void SkStrikeCache::ValidateGlyphCacheDataSize() {
#ifdef SK_DEBUG
GlobalStrikeCache()->validateGlyphCacheDataSize();
#endif
}
#ifdef SK_DEBUG
void SkStrikeCache::validateGlyphCacheDataSize() const {
this->forEachStrike(
[](const SkGlyphCache& cache) { cache.forceValidate();
});
}
#endif
#ifdef SK_DEBUG
void SkStrikeCache::validate() const {
size_t computedBytes = 0;

View File

@ -121,7 +121,7 @@ public:
const SkDescriptor&, const SkScalerContextEffects&, const SkTypeface&);
static void PurgeAll();
static void Validate();
static void ValidateGlyphCacheDataSize();
static void Dump();
// Dump memory usage statistics of all the attaches caches in the process using the
@ -131,9 +131,6 @@ public:
// call when a glyphcache is available for caching (i.e. not in use)
void attachNode(Node* node);
void purgeAll(); // does not change budget
int getCacheCountLimit() const;
@ -148,9 +145,13 @@ public:
int setCachePointSizeLimit(int limit);
#ifdef SK_DEBUG
// A simple accounting of what each glyph cache reports and the strike cache total.
void validate() const;
// Make sure that each glyph cache's memory tracking and actual memory used are in sync.
void validateGlyphCacheDataSize() const;
#else
void validate() const {}
void validateGlyphCacheDataSize() const {}
#endif
private:

View File

@ -287,7 +287,7 @@ DEF_TEST(SkRemoteGlyphCache_ClientMemoryAccounting, reporter) {
// Client.
REPORTER_ASSERT(reporter,
client.readStrikeData(serverStrikeData.data(), serverStrikeData.size()));
SkStrikeCache::Validate();
SkStrikeCache::ValidateGlyphCacheDataSize();
// Must unlock everything on termination, otherwise valgrind complains about memory leaks.
discardableManager->unlockAndDeleteAll();
@ -326,7 +326,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(SkRemoteGlyphCache_DrawTextAsPath, reporter,
SkBitmap actual = RasterBlob(clientBlob, 10, 10, paint, ctxInfo.grContext());
COMPARE_BLOBS(expected, actual, reporter);
REPORTER_ASSERT(reporter, !discardableManager->hasCacheMiss());
SkStrikeCache::Validate();
SkStrikeCache::ValidateGlyphCacheDataSize();
// Must unlock everything on termination, otherwise valgrind complains about memory leaks.
discardableManager->unlockAndDeleteAll();
@ -373,7 +373,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(SkRemoteGlyphCache_DrawTextAsDFT, reporter, c
SkBitmap actual = RasterBlob(clientBlob, 10, 10, paint, ctxInfo.grContext(), &matrix);
COMPARE_BLOBS(expected, actual, reporter);
REPORTER_ASSERT(reporter, !discardableManager->hasCacheMiss());
SkStrikeCache::Validate();
SkStrikeCache::ValidateGlyphCacheDataSize();
// Must unlock everything on termination, otherwise valgrind complains about memory leaks.
discardableManager->unlockAndDeleteAll();
@ -504,7 +504,7 @@ DEF_TEST(SkRemoteGlyphCache_SearchOfDesperation, reporter) {
REPORTER_ASSERT(reporter, discardableManager->cacheMissCount(i) == 0);
}
}
SkStrikeCache::Validate();
SkStrikeCache::ValidateGlyphCacheDataSize();
// Must unlock everything on termination, otherwise valgrind complains about memory leaks.
discardableManager->unlockAndDeleteAll();
@ -605,7 +605,7 @@ DEF_TEST(SkRemoteGlyphCache_ReWriteGlyph, reporter) {
memcmp(glyph->fImage, glyphImage, glyph->computeImageSize()) == 0);
}
SkStrikeCache::Validate();
SkStrikeCache::ValidateGlyphCacheDataSize();
// Must unlock everything on termination, otherwise valgrind complains about memory leaks.
discardableManager->unlockAndDeleteAll();