From c113e9e23d76a463743d6e5372284fb84b58fd8c Mon Sep 17 00:00:00 2001 From: Herb Derby Date: Thu, 21 Jun 2018 14:06:30 -0400 Subject: 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 Reviewed-by: Mike Klein --- src/core/SkStrikeCache.cpp | 22 ++++++++++++++-------- src/core/SkStrikeCache.h | 9 +++++---- 2 files changed, 19 insertions(+), 12 deletions(-) (limited to 'src') 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: -- cgit v1.2.3