From 840c66c58a149842f2416959f8e8118e9a86b56e Mon Sep 17 00:00:00 2001 From: Herb Derby Date: Mon, 16 Apr 2018 16:42:08 -0400 Subject: [PATCH] Rename SkGlyphCacheGlobals to SkStrikeCache Change-Id: I7773c1fff309bf9416f16fe9908191eeba94eb99 Reviewed-on: https://skia-review.googlesource.com/121356 Reviewed-by: Ben Wagner Commit-Queue: Herb Derby --- bench/SkGlyphCacheBench.cpp | 2 +- gn/core.gni | 2 +- src/core/SkGlyphCache.cpp | 45 ++++++++++--------- src/core/SkGlyphCache.h | 6 +-- ...SkGlyphCache_Globals.h => SkStrikeCache.h} | 13 +++--- 5 files changed, 34 insertions(+), 34 deletions(-) rename src/core/{SkGlyphCache_Globals.h => SkStrikeCache.h} (92%) diff --git a/bench/SkGlyphCacheBench.cpp b/bench/SkGlyphCacheBench.cpp index 0cd3ab433f..0333bfe38e 100644 --- a/bench/SkGlyphCacheBench.cpp +++ b/bench/SkGlyphCacheBench.cpp @@ -10,7 +10,7 @@ #include "Benchmark.h" #include "SkCanvas.h" -#include "SkGlyphCache_Globals.h" +#include "SkStrikeCache.h" #include "SkGraphics.h" #include "SkTaskGroup.h" #include "SkTypeface.h" diff --git a/gn/core.gni b/gn/core.gni index 6f019f3f4d..620aa23b05 100644 --- a/gn/core.gni +++ b/gn/core.gni @@ -159,7 +159,6 @@ skia_core_sources = [ "$_src/core/SkGlyph.cpp", "$_src/core/SkGlyphCache.cpp", "$_src/core/SkGlyphCache.h", - "$_src/core/SkGlyphCache_Globals.h", "$_src/core/SkGpuBlurUtils.h", "$_src/core/SkGpuBlurUtils.cpp", "$_src/core/SkGraphics.cpp", @@ -295,6 +294,7 @@ skia_core_sources = [ "$_src/core/SkSpriteBlitter.h", "$_src/core/SkStream.cpp", "$_src/core/SkStreamPriv.h", + "$_src/core/SkStrikeCache.h", "$_src/core/SkString.cpp", "$_src/core/SkStringUtils.cpp", "$_src/core/SkStroke.h", diff --git a/src/core/SkGlyphCache.cpp b/src/core/SkGlyphCache.cpp index 057f4d731e..11b9728b77 100644 --- a/src/core/SkGlyphCache.cpp +++ b/src/core/SkGlyphCache.cpp @@ -8,6 +8,7 @@ #include "SkGlyphCache.h" #include "SkGraphics.h" +#include "SkMutex.h" #include "SkOnce.h" #include "SkPaintPriv.h" #include "SkPath.h" @@ -24,11 +25,11 @@ const char gGlyphCacheDumpName[] = "skia/sk_glyph_cache"; } // namespace // Returns the shared globals -static SkGlyphCache_Globals& get_globals() { +static SkStrikeCache& get_globals() { static SkOnce once; - static SkGlyphCache_Globals* globals; + static SkStrikeCache* globals; - once([]{ globals = new SkGlyphCache_Globals; }); + once([]{ globals = new SkStrikeCache; }); return *globals; } @@ -414,22 +415,22 @@ void SkGlyphCache::dump() const { /////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////// -size_t SkGlyphCache_Globals::getTotalMemoryUsed() const { +size_t SkStrikeCache::getTotalMemoryUsed() const { SkAutoExclusive ac(fLock); return fTotalMemoryUsed; } -int SkGlyphCache_Globals::getCacheCountUsed() const { +int SkStrikeCache::getCacheCountUsed() const { SkAutoExclusive ac(fLock); return fCacheCount; } -int SkGlyphCache_Globals::getCacheCountLimit() const { +int SkStrikeCache::getCacheCountLimit() const { SkAutoExclusive ac(fLock); return fCacheCountLimit; } -size_t SkGlyphCache_Globals::setCacheSizeLimit(size_t newLimit) { +size_t SkStrikeCache::setCacheSizeLimit(size_t newLimit) { static const size_t minLimit = 256 * 1024; if (newLimit < minLimit) { newLimit = minLimit; @@ -443,12 +444,12 @@ size_t SkGlyphCache_Globals::setCacheSizeLimit(size_t newLimit) { return prevLimit; } -size_t SkGlyphCache_Globals::getCacheSizeLimit() const { +size_t SkStrikeCache::getCacheSizeLimit() const { SkAutoExclusive ac(fLock); return fCacheSizeLimit; } -int SkGlyphCache_Globals::setCacheCountLimit(int newCount) { +int SkStrikeCache::setCacheCountLimit(int newCount) { if (newCount < 0) { newCount = 0; } @@ -461,12 +462,12 @@ int SkGlyphCache_Globals::setCacheCountLimit(int newCount) { return prevCount; } -int SkGlyphCache_Globals::getCachePointSizeLimit() const { +int SkStrikeCache::getCachePointSizeLimit() const { SkAutoExclusive ac(fLock); return fPointSizeLimit; } -int SkGlyphCache_Globals::setCachePointSizeLimit(int newLimit) { +int SkStrikeCache::setCachePointSizeLimit(int newLimit) { if (newLimit < 0) { newLimit = 0; } @@ -478,13 +479,13 @@ int SkGlyphCache_Globals::setCachePointSizeLimit(int newLimit) { return prevLimit; } -void SkGlyphCache_Globals::purgeAll() { +void SkStrikeCache::purgeAll() { SkAutoExclusive ac(fLock); this->internalPurge(fTotalMemoryUsed); } SkExclusiveStrikePtr SkGlyphCache::FindStrikeExclusive(const SkDescriptor& desc) { - SkGlyphCache_Globals& globals = get_globals(); + SkStrikeCache& globals = get_globals(); SkGlyphCache* cache; SkAutoExclusive ac(globals.fLock); @@ -559,7 +560,7 @@ SkExclusiveStrikePtr SkGlyphCache::CreateStrikeExclusive( } void SkGlyphCache::ForEachStrike(std::function visitor) { - SkGlyphCache_Globals& globals = get_globals(); + SkStrikeCache& globals = get_globals(); SkAutoExclusive ac(globals.fLock); SkGlyphCache* cache; @@ -632,7 +633,7 @@ void SkGlyphCache::DumpMemoryStatistics(SkTraceMemoryDump* dump) { /////////////////////////////////////////////////////////////////////////////// -SkGlyphCache_Globals::~SkGlyphCache_Globals() { +SkStrikeCache::~SkStrikeCache() { SkGlyphCache* cache = fHead; while (cache) { SkGlyphCache* next = cache->fNext; @@ -641,7 +642,7 @@ SkGlyphCache_Globals::~SkGlyphCache_Globals() { } } -void SkGlyphCache_Globals::AttachCache(SkGlyphCache* cache) { +void SkStrikeCache::AttachCache(SkGlyphCache* cache) { if (cache == nullptr) { return; } @@ -651,7 +652,7 @@ void SkGlyphCache_Globals::AttachCache(SkGlyphCache* cache) { } -void SkGlyphCache_Globals::attachCacheToHead(SkGlyphCache* cache) { +void SkStrikeCache::attachCacheToHead(SkGlyphCache* cache) { SkAutoExclusive ac(fLock); this->validate(); @@ -661,7 +662,7 @@ void SkGlyphCache_Globals::attachCacheToHead(SkGlyphCache* cache) { this->internalPurge(); } -SkGlyphCache* SkGlyphCache_Globals::internalGetTail() const { +SkGlyphCache* SkStrikeCache::internalGetTail() const { SkGlyphCache* cache = fHead; if (cache) { while (cache->fNext) { @@ -671,7 +672,7 @@ SkGlyphCache* SkGlyphCache_Globals::internalGetTail() const { return cache; } -size_t SkGlyphCache_Globals::internalPurge(size_t minBytesNeeded) { +size_t SkStrikeCache::internalPurge(size_t minBytesNeeded) { this->validate(); size_t bytesNeeded = 0; @@ -725,7 +726,7 @@ size_t SkGlyphCache_Globals::internalPurge(size_t minBytesNeeded) { return bytesFreed; } -void SkGlyphCache_Globals::internalAttachCacheToHead(SkGlyphCache* cache) { +void SkStrikeCache::internalAttachCacheToHead(SkGlyphCache* cache) { SkASSERT(nullptr == cache->fPrev && nullptr == cache->fNext); if (fHead) { fHead->fPrev = cache; @@ -737,7 +738,7 @@ void SkGlyphCache_Globals::internalAttachCacheToHead(SkGlyphCache* cache) { fTotalMemoryUsed += cache->fMemoryUsed; } -void SkGlyphCache_Globals::internalDetachCache(SkGlyphCache* cache) { +void SkStrikeCache::internalDetachCache(SkGlyphCache* cache) { SkASSERT(fCacheCount > 0); fCacheCount -= 1; fTotalMemoryUsed -= cache->fMemoryUsed; @@ -770,7 +771,7 @@ void SkGlyphCache::validate() const { #endif } -void SkGlyphCache_Globals::validate() const { +void SkStrikeCache::validate() const { size_t computedBytes = 0; int computedCount = 0; diff --git a/src/core/SkGlyphCache.h b/src/core/SkGlyphCache.h index 8bb10bb55f..3143656659 100644 --- a/src/core/SkGlyphCache.h +++ b/src/core/SkGlyphCache.h @@ -10,7 +10,7 @@ #include "SkArenaAlloc.h" #include "SkDescriptor.h" #include "SkGlyph.h" -#include "SkGlyphCache_Globals.h" +#include "SkStrikeCache.h" #include "SkPaint.h" #include "SkTHash.h" #include "SkScalerContext.h" @@ -22,7 +22,7 @@ class SkTraceMemoryDump; class SkGlyphCache; using SkExclusiveStrikePtr = std::unique_ptr< SkGlyphCache, - SkFunctionWrapper>; + SkFunctionWrapper>; /** \class SkGlyphCache @@ -191,7 +191,7 @@ public: }; private: - friend class SkGlyphCache_Globals; + friend class SkStrikeCache; enum MetricsType { kNothing_MetricsType, diff --git a/src/core/SkGlyphCache_Globals.h b/src/core/SkStrikeCache.h similarity index 92% rename from src/core/SkGlyphCache_Globals.h rename to src/core/SkStrikeCache.h index de37bbb7e8..5efbdc9f01 100644 --- a/src/core/SkGlyphCache_Globals.h +++ b/src/core/SkStrikeCache.h @@ -5,10 +5,9 @@ * found in the LICENSE file. */ -#ifndef SkGlyphCache_Globals_DEFINED -#define SkGlyphCache_Globals_DEFINED +#ifndef SkStrikeCache_DEFINED +#define SkStrikeCache_DEFINED -#include "SkMutex.h" #include "SkSpinlock.h" class SkGlyphCache; @@ -27,9 +26,9 @@ class SkGlyphCache; /////////////////////////////////////////////////////////////////////////////// -class SkGlyphCache_Globals { +class SkStrikeCache { public: - SkGlyphCache_Globals() { + SkStrikeCache() { fHead = nullptr; fTotalMemoryUsed = 0; fCacheSizeLimit = SK_DEFAULT_FONT_CACHE_LIMIT; @@ -38,7 +37,7 @@ public: fPointSizeLimit = SK_DEFAULT_FONT_CACHE_POINT_SIZE_LIMIT; } - ~SkGlyphCache_Globals(); + ~SkStrikeCache(); static void AttachCache(SkGlyphCache* cache); @@ -88,4 +87,4 @@ private: size_t internalPurge(size_t minBytesNeeded = 0); }; -#endif +#endif // SkStrikeCache_DEFINED