Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(304)

Unified Diff: src/core/SkGlyphCache_Globals.h

Issue 1210143004: SkGlyphCache_Globals: SkMutex -> SkSpinlock (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: address more comments Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/core/SkGlyphCache.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
« no previous file with comments | « src/core/SkGlyphCache.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698