Use SkAutoTExclusive in SkGlyphCache.
This replaces the local AutoAcquire class. Review URL: https://codereview.chromium.org/1424563002
This commit is contained in:
parent
9003d1e738
commit
043a75e234
@ -293,14 +293,7 @@ void SkGlyphCache::invokeAndRemoveAuxProcs() {
|
|||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
typedef SkAutoTExclusive<SkSpinlock> Exclusive;
|
||||||
class AutoAcquire {
|
|
||||||
public:
|
|
||||||
AutoAcquire(SkSpinlock& lock) : fLock(lock) { fLock.acquire(); }
|
|
||||||
~AutoAcquire() { fLock.release(); }
|
|
||||||
private:
|
|
||||||
SkSpinlock& fLock;
|
|
||||||
};
|
|
||||||
|
|
||||||
size_t SkGlyphCache_Globals::setCacheSizeLimit(size_t newLimit) {
|
size_t SkGlyphCache_Globals::setCacheSizeLimit(size_t newLimit) {
|
||||||
static const size_t minLimit = 256 * 1024;
|
static const size_t minLimit = 256 * 1024;
|
||||||
@ -308,7 +301,7 @@ size_t SkGlyphCache_Globals::setCacheSizeLimit(size_t newLimit) {
|
|||||||
newLimit = minLimit;
|
newLimit = minLimit;
|
||||||
}
|
}
|
||||||
|
|
||||||
AutoAcquire ac(fLock);
|
Exclusive ac(fLock);
|
||||||
|
|
||||||
size_t prevLimit = fCacheSizeLimit;
|
size_t prevLimit = fCacheSizeLimit;
|
||||||
fCacheSizeLimit = newLimit;
|
fCacheSizeLimit = newLimit;
|
||||||
@ -321,7 +314,7 @@ int SkGlyphCache_Globals::setCacheCountLimit(int newCount) {
|
|||||||
newCount = 0;
|
newCount = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
AutoAcquire ac(fLock);
|
Exclusive ac(fLock);
|
||||||
|
|
||||||
int prevCount = fCacheCountLimit;
|
int prevCount = fCacheCountLimit;
|
||||||
fCacheCountLimit = newCount;
|
fCacheCountLimit = newCount;
|
||||||
@ -330,7 +323,7 @@ int SkGlyphCache_Globals::setCacheCountLimit(int newCount) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void SkGlyphCache_Globals::purgeAll() {
|
void SkGlyphCache_Globals::purgeAll() {
|
||||||
AutoAcquire ac(fLock);
|
Exclusive ac(fLock);
|
||||||
this->internalPurge(fTotalMemoryUsed);
|
this->internalPurge(fTotalMemoryUsed);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -353,7 +346,7 @@ SkGlyphCache* SkGlyphCache::VisitCache(SkTypeface* typeface,
|
|||||||
SkGlyphCache* cache;
|
SkGlyphCache* cache;
|
||||||
|
|
||||||
{
|
{
|
||||||
AutoAcquire ac(globals.fLock);
|
Exclusive ac(globals.fLock);
|
||||||
|
|
||||||
globals.validate();
|
globals.validate();
|
||||||
|
|
||||||
@ -466,7 +459,7 @@ void SkGlyphCache::DumpMemoryStatistics(SkTraceMemoryDump* dump) {
|
|||||||
|
|
||||||
void SkGlyphCache::VisitAll(Visitor visitor, void* context) {
|
void SkGlyphCache::VisitAll(Visitor visitor, void* context) {
|
||||||
SkGlyphCache_Globals& globals = get_globals();
|
SkGlyphCache_Globals& globals = get_globals();
|
||||||
AutoAcquire ac(globals.fLock);
|
Exclusive ac(globals.fLock);
|
||||||
SkGlyphCache* cache;
|
SkGlyphCache* cache;
|
||||||
|
|
||||||
globals.validate();
|
globals.validate();
|
||||||
@ -479,7 +472,7 @@ void SkGlyphCache::VisitAll(Visitor visitor, void* context) {
|
|||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
void SkGlyphCache_Globals::attachCacheToHead(SkGlyphCache* cache) {
|
void SkGlyphCache_Globals::attachCacheToHead(SkGlyphCache* cache) {
|
||||||
AutoAcquire ac(fLock);
|
Exclusive ac(fLock);
|
||||||
|
|
||||||
this->validate();
|
this->validate();
|
||||||
cache->validate();
|
cache->validate();
|
||||||
|
Loading…
Reference in New Issue
Block a user