diff options
-rw-r--r-- | src/core/SkStrikeCache.cpp | 22 | ||||
-rw-r--r-- | src/core/SkStrikeCache.h | 9 | ||||
-rw-r--r-- | tests/SkRemoteGlyphCacheTest.cpp | 10 |
3 files changed, 24 insertions, 17 deletions
diff --git a/src/core/SkStrikeCache.cpp b/src/core/SkStrikeCache.cpp index 817d00b2e3..bac48d8230 100644 --- a/src/core/SkStrikeCache.cpp +++ b/src/core/SkStrikeCache.cpp @@ -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; diff --git a/src/core/SkStrikeCache.h b/src/core/SkStrikeCache.h index 7b600181d2..22f1daf9fb 100644 --- a/src/core/SkStrikeCache.h +++ b/src/core/SkStrikeCache.h @@ -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: diff --git a/tests/SkRemoteGlyphCacheTest.cpp b/tests/SkRemoteGlyphCacheTest.cpp index 8bdfb7af69..828ca031c0 100644 --- a/tests/SkRemoteGlyphCacheTest.cpp +++ b/tests/SkRemoteGlyphCacheTest.cpp @@ -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(); |