OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2006 The Android Open Source Project | 2 * Copyright 2006 The Android Open Source Project |
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 #include "SkGlyphCache.h" | 8 #include "SkGlyphCache.h" |
9 #include "SkGlyphCache_Globals.h" | 9 #include "SkGlyphCache_Globals.h" |
10 #include "SkGraphics.h" | 10 #include "SkGraphics.h" |
11 #include "SkOncePtr.h" | 11 #include "SkOnce.h" |
12 #include "SkPath.h" | 12 #include "SkPath.h" |
13 #include "SkTemplates.h" | 13 #include "SkTemplates.h" |
14 #include "SkTraceMemoryDump.h" | 14 #include "SkTraceMemoryDump.h" |
15 #include "SkTypeface.h" | 15 #include "SkTypeface.h" |
16 | 16 |
17 #include <cctype> | 17 #include <cctype> |
18 | 18 |
19 //#define SPEW_PURGE_STATUS | 19 //#define SPEW_PURGE_STATUS |
20 | 20 |
21 namespace { | 21 namespace { |
22 const char gGlyphCacheDumpName[] = "skia/sk_glyph_cache"; | 22 const char gGlyphCacheDumpName[] = "skia/sk_glyph_cache"; |
23 } // namespace | 23 } // namespace |
24 | 24 |
25 // Returns the shared globals | 25 // Returns the shared globals |
26 SK_DECLARE_STATIC_ONCE_PTR(SkGlyphCache_Globals, globals); | |
27 static SkGlyphCache_Globals& get_globals() { | 26 static SkGlyphCache_Globals& get_globals() { |
28 return *globals.get([]{ return new SkGlyphCache_Globals; }); | 27 static SkOnce once; |
| 28 static SkGlyphCache_Globals* globals; |
| 29 |
| 30 once([]{ globals = new SkGlyphCache_Globals; }); |
| 31 return *globals; |
29 } | 32 } |
30 | 33 |
31 /////////////////////////////////////////////////////////////////////////////// | 34 /////////////////////////////////////////////////////////////////////////////// |
32 | 35 |
33 // so we don't grow our arrays a lot | 36 // so we don't grow our arrays a lot |
34 #define kMinGlyphCount 16 | 37 #define kMinGlyphCount 16 |
35 #define kMinGlyphImageSize (16*2) | 38 #define kMinGlyphImageSize (16*2) |
36 #define kMinAllocAmount ((sizeof(SkGlyph) + kMinGlyphImageSize) * kMinGlyphC
ount) | 39 #define kMinAllocAmount ((sizeof(SkGlyph) + kMinGlyphImageSize) * kMinGlyphC
ount) |
37 | 40 |
38 SkGlyphCache::SkGlyphCache(SkTypeface* typeface, const SkDescriptor* desc, SkSca
lerContext* ctx) | 41 SkGlyphCache::SkGlyphCache(SkTypeface* typeface, const SkDescriptor* desc, SkSca
lerContext* ctx) |
(...skipping 775 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
814 } | 817 } |
815 | 818 |
816 void SkGraphics::PurgeFontCache() { | 819 void SkGraphics::PurgeFontCache() { |
817 get_globals().purgeAll(); | 820 get_globals().purgeAll(); |
818 SkTypefaceCache::PurgeAll(); | 821 SkTypefaceCache::PurgeAll(); |
819 } | 822 } |
820 | 823 |
821 // TODO(herb): clean up TLS apis. | 824 // TODO(herb): clean up TLS apis. |
822 size_t SkGraphics::GetTLSFontCacheLimit() { return 0; } | 825 size_t SkGraphics::GetTLSFontCacheLimit() { return 0; } |
823 void SkGraphics::SetTLSFontCacheLimit(size_t bytes) { } | 826 void SkGraphics::SetTLSFontCacheLimit(size_t bytes) { } |
OLD | NEW |