OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2006 The Android Open Source Project | 3 * Copyright 2006 The Android Open Source Project |
4 * | 4 * |
5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
7 */ | 7 */ |
8 | 8 |
9 | 9 |
10 #include "SkGlyphCache.h" | 10 #include "SkGlyphCache.h" |
11 #include "SkGlyphCache_Globals.h" | 11 #include "SkGlyphCache_Globals.h" |
12 #include "SkDistanceFieldGen.h" | 12 #include "SkDistanceFieldGen.h" |
13 #include "SkGraphics.h" | 13 #include "SkGraphics.h" |
14 #include "SkPaint.h" | 14 #include "SkPaint.h" |
15 #include "SkPath.h" | 15 #include "SkPath.h" |
16 #include "SkTemplates.h" | 16 #include "SkTemplates.h" |
17 #include "SkTLS.h" | 17 #include "SkTLS.h" |
18 #include "SkTypeface.h" | 18 #include "SkTypeface.h" |
19 | 19 |
20 //#define SPEW_PURGE_STATUS | 20 //#define SPEW_PURGE_STATUS |
21 //#define RECORD_HASH_EFFICIENCY | 21 //#define RECORD_HASH_EFFICIENCY |
22 | 22 |
23 bool gSkSuppressFontCachePurgeSpew; | 23 bool gSkSuppressFontCachePurgeSpew; |
24 | 24 |
| 25 static void create_globals(SkGlyphCache_Globals** globals) { |
| 26 *globals = SkNEW_ARGS(SkGlyphCache_Globals, (SkGlyphCache_Globals::kYes_UseM
utex)); |
| 27 } |
| 28 |
25 // Returns the shared globals | 29 // Returns the shared globals |
26 static SkGlyphCache_Globals& getSharedGlobals() { | 30 static SkGlyphCache_Globals& getSharedGlobals() { |
27 // we leak this, so we don't incur any shutdown cost of the destructor | 31 // we leak this, so we don't incur any shutdown cost of the destructor |
28 static SkGlyphCache_Globals* gGlobals = SkNEW_ARGS(SkGlyphCache_Globals, | 32 static SkGlyphCache_Globals* gGlobals = NULL; |
29 (SkGlyphCache_Globals::kY
es_UseMutex)); | 33 SK_DECLARE_STATIC_ONCE(once); |
| 34 SkOnce(&once, create_globals, &gGlobals); |
| 35 SkASSERT(NULL != gGlobals); |
30 return *gGlobals; | 36 return *gGlobals; |
31 } | 37 } |
32 | 38 |
33 // Returns the TLS globals (if set), or the shared globals | 39 // Returns the TLS globals (if set), or the shared globals |
34 static SkGlyphCache_Globals& getGlobals() { | 40 static SkGlyphCache_Globals& getGlobals() { |
35 SkGlyphCache_Globals* tls = SkGlyphCache_Globals::FindTLS(); | 41 SkGlyphCache_Globals* tls = SkGlyphCache_Globals::FindTLS(); |
36 return tls ? *tls : getSharedGlobals(); | 42 return tls ? *tls : getSharedGlobals(); |
37 } | 43 } |
38 | 44 |
39 /////////////////////////////////////////////////////////////////////////////// | 45 /////////////////////////////////////////////////////////////////////////////// |
(...skipping 712 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
752 return tls ? tls->getCacheSizeLimit() : 0; | 758 return tls ? tls->getCacheSizeLimit() : 0; |
753 } | 759 } |
754 | 760 |
755 void SkGraphics::SetTLSFontCacheLimit(size_t bytes) { | 761 void SkGraphics::SetTLSFontCacheLimit(size_t bytes) { |
756 if (0 == bytes) { | 762 if (0 == bytes) { |
757 SkGlyphCache_Globals::DeleteTLS(); | 763 SkGlyphCache_Globals::DeleteTLS(); |
758 } else { | 764 } else { |
759 SkGlyphCache_Globals::GetTLS().setCacheSizeLimit(bytes); | 765 SkGlyphCache_Globals::GetTLS().setCacheSizeLimit(bytes); |
760 } | 766 } |
761 } | 767 } |
OLD | NEW |