Index: src/core/SkGlyphCache_Globals.h |
diff --git a/src/core/SkGlyphCache_Globals.h b/src/core/SkGlyphCache_Globals.h |
index e8f950f6114a4d6ddc0f3b7db5cd086021622c5c..8e0ceb55c4a0939bb3f151b89e03fa12cbc7b629 100644 |
--- a/src/core/SkGlyphCache_Globals.h |
+++ b/src/core/SkGlyphCache_Globals.h |
@@ -10,6 +10,7 @@ |
#include "SkGlyphCache.h" |
#include "SkMutex.h" |
+#include "SkSpinlock.h" |
#include "SkTLS.h" |
#ifndef SK_DEFAULT_FONT_CACHE_COUNT_LIMIT |
@@ -22,23 +23,14 @@ |
/////////////////////////////////////////////////////////////////////////////// |
-class SkMutex; |
- |
class SkGlyphCache_Globals { |
public: |
- enum UseMutex { |
- kNo_UseMutex, // thread-local cache |
- kYes_UseMutex // shared cache |
- }; |
- |
- SkGlyphCache_Globals(UseMutex um) { |
+ SkGlyphCache_Globals() { |
fHead = NULL; |
fTotalMemoryUsed = 0; |
fCacheSizeLimit = SK_DEFAULT_FONT_CACHE_LIMIT; |
fCacheCount = 0; |
fCacheCountLimit = SK_DEFAULT_FONT_CACHE_COUNT_LIMIT; |
- |
- fMutex = (kYes_UseMutex == um) ? SkNEW(SkMutex) : NULL; |
} |
~SkGlyphCache_Globals() { |
@@ -48,11 +40,9 @@ public: |
SkDELETE(cache); |
cache = next; |
} |
- |
- SkDELETE(fMutex); |
} |
- SkMutex* fMutex; |
+ SkSpinlock fLock; |
SkGlyphCache* internalGetHead() const { return fHead; } |
SkGlyphCache* internalGetTail() const; |
@@ -88,17 +78,6 @@ public: |
void internalDetachCache(SkGlyphCache*); |
void internalAttachCacheToHead(SkGlyphCache*); |
- // can return NULL |
- static SkGlyphCache_Globals* FindTLS() { |
- return (SkGlyphCache_Globals*)SkTLS::Find(CreateTLS); |
- } |
- |
- static SkGlyphCache_Globals& GetTLS() { |
- return *(SkGlyphCache_Globals*)SkTLS::Get(CreateTLS, DeleteTLS); |
- } |
- |
- static void DeleteTLS() { SkTLS::Delete(CreateTLS); } |
- |
private: |
SkGlyphCache* fHead; |
size_t fTotalMemoryUsed; |
@@ -110,14 +89,6 @@ private: |
// and attempt to purge caches to match. |
// Returns number of bytes freed. |
size_t internalPurge(size_t minBytesNeeded = 0); |
- |
- static void* CreateTLS() { |
- return SkNEW_ARGS(SkGlyphCache_Globals, (kNo_UseMutex)); |
- } |
- |
- static void DeleteTLS(void* ptr) { |
- SkDELETE((SkGlyphCache_Globals*)ptr); |
- } |
}; |
#endif |