| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2011 Google Inc. | 2 * Copyright 2011 Google Inc. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
| 6 */ | 6 */ |
| 7 | 7 |
| 8 | 8 |
| 9 | 9 |
| 10 #include "SkTypefaceCache.h" | 10 #include "SkTypefaceCache.h" |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 57 SkTypefaceCache& SkTypefaceCache::Get() { | 57 SkTypefaceCache& SkTypefaceCache::Get() { |
| 58 static SkTypefaceCache gCache; | 58 static SkTypefaceCache gCache; |
| 59 return gCache; | 59 return gCache; |
| 60 } | 60 } |
| 61 | 61 |
| 62 SkFontID SkTypefaceCache::NewFontID() { | 62 SkFontID SkTypefaceCache::NewFontID() { |
| 63 static int32_t gFontID; | 63 static int32_t gFontID; |
| 64 return sk_atomic_inc(&gFontID) + 1; | 64 return sk_atomic_inc(&gFontID) + 1; |
| 65 } | 65 } |
| 66 | 66 |
| 67 static SkMutex gMutex; | 67 SK_DECLARE_STATIC_MUTEX(gMutex); |
| 68 | 68 |
| 69 void SkTypefaceCache::Add(SkTypeface* face) { | 69 void SkTypefaceCache::Add(SkTypeface* face) { |
| 70 SkAutoMutexAcquire ama(gMutex); | 70 SkAutoMutexAcquire ama(gMutex); |
| 71 Get().add(face); | 71 Get().add(face); |
| 72 } | 72 } |
| 73 | 73 |
| 74 SkTypeface* SkTypefaceCache::FindByProcAndRef(FindProc proc, void* ctx) { | 74 SkTypeface* SkTypefaceCache::FindByProcAndRef(FindProc proc, void* ctx) { |
| 75 SkAutoMutexAcquire ama(gMutex); | 75 SkAutoMutexAcquire ama(gMutex); |
| 76 return Get().findByProcAndRef(proc, ctx); | 76 return Get().findByProcAndRef(proc, ctx); |
| 77 } | 77 } |
| (...skipping 15 matching lines...) Expand all Loading... |
| 93 face, id, s.weight(), s.width(), s.slant(), face->getRefCnt(), n.c_
str()); | 93 face, id, s.weight(), s.width(), s.slant(), face->getRefCnt(), n.c_
str()); |
| 94 return false; | 94 return false; |
| 95 } | 95 } |
| 96 #endif | 96 #endif |
| 97 | 97 |
| 98 void SkTypefaceCache::Dump() { | 98 void SkTypefaceCache::Dump() { |
| 99 #ifdef SK_DEBUG | 99 #ifdef SK_DEBUG |
| 100 (void)Get().findByProcAndRef(DumpProc, nullptr); | 100 (void)Get().findByProcAndRef(DumpProc, nullptr); |
| 101 #endif | 101 #endif |
| 102 } | 102 } |
| OLD | NEW |